Class ReloadableComponentProxy

  • All Implemented Interfaces:
    Serializable, org.springframework.aop.framework.Advised, org.springframework.aop.TargetClassAware, org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanClassLoaderAware, org.springframework.beans.factory.BeanFactoryAware, org.springframework.beans.factory.FactoryBean<Object>, org.springframework.beans.factory.InitializingBean

    public class ReloadableComponentProxy
    extends org.springframework.aop.framework.ProxyFactoryBean
    implements org.springframework.beans.factory.InitializingBean
    WARNING: Requires Spring 1.2.8 or newer libraries in the classpath
    Allows you to define a Sakai component in a webapp so it can be reloaded, this makes development easier since it does not require all of Sakai to be restarted and yet allows you to expose beans to the Sakai component manager
    WARNING: This is currently experimental as your bean will not be able to be found by the component manager while things are starting up (since your webapp will not have loaded up yet), it is basically only useful for development and some testing right now
    How to use:
    1) Create a bean for the service you want to proxy in your webapp application context (example: myLocalBean)
    2) Create a bean in your webapp like so: <bean class="org.sakaiproject.entitybroker.util.ReloadableComponentProxy"> <property name="proxyInterfaces" value="org.sakaiproject.myproject.MyService"/> <property name="sakaiComponentName" value="org.sakaiproject.myproject.MyService"/> <property name="localSakaiComponentBean" ref="myLocalBeanName"/> </bean>
    3) Put the interface for your service into shared (this has to be the same interface you are registering in proxyInterfaces)
    4) Use ComponentManager.get(Class) to load up the proxied bean in the service/thing that is using your service at the point where it is used (not in the init or it will fail): if (webappService == null) { webappService = (MyService) ComponentManager.get(MyService.class); } That's it. Good luck.
    Author:
    Steven Githens (sgithens@caret.cam.ac.uk), Aaron Zeckoski (aaron@caret.cam.ac.uk)
    See Also:
    Serialized Form
    • Field Summary

      • Fields inherited from class org.springframework.aop.framework.ProxyFactoryBean

        GLOBAL_SUFFIX, logger
      • Fields inherited from class org.springframework.aop.framework.AdvisedSupport

        EMPTY_TARGET_SOURCE
      • Fields inherited from interface org.springframework.beans.factory.FactoryBean

        OBJECT_TYPE_ATTRIBUTE
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void afterPropertiesSet()  
      void setLocalSakaiComponentBean​(Object localSakaiComponentBean)  
      void setSakaiComponentName​(String sakaiComponentName)  
      • Methods inherited from class org.springframework.aop.framework.ProxyFactoryBean

        adviceChanged, createCompositeInterface, getObject, getObjectType, getProxy, isSingleton, setAdvisorAdapterRegistry, setAutodetectInterfaces, setBeanClassLoader, setBeanFactory, setFrozen, setInterceptorNames, setProxyClassLoader, setProxyInterfaces, setSingleton, setTargetName
      • Methods inherited from class org.springframework.aop.framework.ProxyCreatorSupport

        addListener, createAopProxy, getAopProxyFactory, isActive, removeListener, setAopProxyFactory
      • Methods inherited from class org.springframework.aop.framework.AdvisedSupport

        addAdvice, addAdvice, addAdvisor, addAdvisor, addAdvisors, addAdvisors, addInterface, adviceIncluded, copyConfigurationFrom, copyConfigurationFrom, countAdvicesOfType, getAdvisorChainFactory, getAdvisorCount, getAdvisors, getAdvisorsInternal, getInterceptorsAndDynamicInterceptionAdvice, getProxiedInterfaces, getTargetClass, getTargetSource, indexOf, indexOf, isInterfaceProxied, isPreFiltered, removeAdvice, removeAdvisor, removeAdvisor, removeInterface, replaceAdvisor, setAdvisorChainFactory, setInterfaces, setPreFiltered, setTarget, setTargetClass, setTargetSource, toProxyConfigString, toString
      • Methods inherited from class org.springframework.aop.framework.ProxyConfig

        copyFrom, isExposeProxy, isFrozen, isOpaque, isOptimize, isProxyTargetClass, setExposeProxy, setOpaque, setOptimize, setProxyTargetClass
      • Methods inherited from interface org.springframework.aop.framework.Advised

        isExposeProxy, isFrozen, isProxyTargetClass, setExposeProxy
    • Constructor Detail

      • ReloadableComponentProxy

        public ReloadableComponentProxy()
    • Method Detail

      • setSakaiComponentName

        public void setSakaiComponentName​(String sakaiComponentName)
        Parameters:
        sakaiComponentName - (optional) the name to use for this bean in the component manager, if unset then this will use the name of the registered proxyInterface
      • setLocalSakaiComponentBean

        public void setLocalSakaiComponentBean​(Object localSakaiComponentBean)
        Parameters:
        localSakaiComponentBean - this is the bean which you want to expose via the proxy
      • afterPropertiesSet

        public void afterPropertiesSet()
                                throws Exception
        Specified by:
        afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
        Throws:
        Exception