com.kero.security.core.proxy.ProxyWrapperBase Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of Kero-Security Show documentation
Show all versions of Kero-Security Show documentation
Kero-Security is a library for statically controlling access to properties of objects / classes.
The newest version!
package com.kero.security.core.proxy;
import com.kero.security.core.config.PreparedAccessConfiguration;
import com.kero.security.core.proxy.exception.ProxyWrappingException;
public abstract class ProxyWrapperBase implements ProxyWrapper {
protected Class> targetClass;
private Class> proxyClass;
public ProxyWrapperBase(Class> targetClass) {
this.targetClass = targetClass;
}
@Override
public Object wrap(Object obj, PreparedAccessConfiguration pac) {
Class> proxyClass = getProxyClass();
try {
return proxyClass.getDeclaredConstructor(Object.class, PreparedAccessConfiguration.class).newInstance(obj, pac);
}
catch(Exception e) {
throw new ProxyWrappingException(e);
}
}
protected abstract Class> createProxyClass();
private Class> getProxyClass() {
if(this.proxyClass != null) return this.proxyClass;
this.proxyClass = createProxyClass();
return this.proxyClass;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy