All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.dynamicextensionsalfresco.policy.DefaultBehaviourProxyFactory Maven / Gradle / Ivy

Go to download

Adds an OSGi container to alfresco repository supporting dynamic code reloading, classpath isolation and a bunch of other useful features

There is a newer version: 3.1.0
Show newest version
package com.github.dynamicextensionsalfresco.policy;

import java.util.ArrayList;

import com.github.dynamicextensionsalfresco.metrics.Timer;
import org.alfresco.repo.policy.Behaviour;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextClosedEvent;
/**
 * Created by jasper on 19/07/17.
 */
public class DefaultBehaviourProxyFactory  implements BehaviourProxyFactory, ApplicationListener {
    private Logger logger = LoggerFactory.getLogger(DefaultBehaviourProxyFactory.class);

    @Autowired
    protected Timer timer;

    private ArrayList behaviourProxies = new ArrayList();

    @Override
    public BehaviourProxy createBehaviourProxy(Behaviour behaviour) {
        logger.debug("Creating BehaviourProxy for "+behaviour.getClass().getName()+"${} instance.");
        BehaviourProxy behaviourProxy = new BehaviourProxy(behaviour, timer);
        behaviourProxies.add(behaviourProxy);
        return behaviourProxy;
    }

    /* Callback operations */

    public void  onApplicationEvent( ContextClosedEvent event) {
        releaseBehaviourReferences();
    }

    /* Utility operations */

    protected void releaseBehaviourReferences() {
        for (BehaviourProxy behaviourProxy: behaviourProxies) {
            logger.debug("Releasing reference from BehaviourProxy to "+behaviourProxy.toString()+" instance." );
            behaviourProxy.release();
        }
        behaviourProxies.clear();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy