com.github.dynamicextensionsalfresco.policy.ProxyPolicyComponentFactoryBean Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of annotations-runtime Show documentation
Show all versions of annotations-runtime Show documentation
Adds an OSGi container to alfresco repository supporting dynamic code reloading, classpath isolation and a bunch of other useful features
package com.github.dynamicextensionsalfresco.policy;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;
import org.alfresco.repo.policy.PolicyComponent;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.annotation.Required;
/**
* {@link FactoryBean} for creating proxy {@link PolicyComponent}s.
*
* @author Laurens Fridael
*
*/
public class ProxyPolicyComponentFactoryBean implements FactoryBean {
/* Dependencies */
private PolicyComponent policyComponent;
private BehaviourProxyFactory behaviourProxyFactory;
/* State */
private PolicyComponent proxyPolicyComponent;
/* Operations */
@Override
public Class extends PolicyComponent> getObjectType() {
return PolicyComponent.class;
}
@Override
public boolean isSingleton() {
return true;
}
@Override
public PolicyComponent getObject() {
if (proxyPolicyComponent == null) {
proxyPolicyComponent = createProxyPolicyComponent();
}
return proxyPolicyComponent;
}
/* Utility operations */
protected PolicyComponent createProxyPolicyComponent() {
final InvocationHandler handler = new ProxyPolicyComponentInvocationHandler(getPolicyComponent(),
getBehaviourProxyFactory());
return (PolicyComponent) Proxy.newProxyInstance(getClass().getClassLoader(),
new Class>[] { PolicyComponent.class }, handler);
}
/* Dependencies */
@Required
public void setPolicyComponent(final PolicyComponent policyComponent) {
this.policyComponent = policyComponent;
}
protected PolicyComponent getPolicyComponent() {
return policyComponent;
}
@Required
public void setBehaviourProxyFactory(final BehaviourProxyFactory behaviourProxyFactory) {
this.behaviourProxyFactory = behaviourProxyFactory;
}
protected BehaviourProxyFactory getBehaviourProxyFactory() {
return behaviourProxyFactory;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy