While customizing alfresco we need serviceRegistry many times to get various service.
Lets make it utility and keep it singleton.
AlfrescoServiceRegistry.java
custom-context.xml
Lets make it utility and keep it singleton.
AlfrescoServiceRegistry.java
/** * Singleton service registry * @author ghanshyam */ public final class AlfrescoServiceRegistry { private static ServiceRegistry serviceRegistry; private AlfrescoServiceRegistry() { //private constructor } public static void setServiceRegistry(final ServiceRegistry serviceRegistry) { AlfrescoServiceRegistry.serviceRegistry = serviceRegistry; } public static ServiceRegistry getServiceRegistry() { return AlfrescoServiceRegistry.serviceRegistry; } }ServiceRegistryBean.java
public class ServiceRegistryBean { private ServiceRegistry serviceRegistry; public ServiceRegistry getServiceRegistry() { return serviceRegistry; } public void setServiceRegistry(ServiceRegistry serviceRegistry) { this.serviceRegistry = serviceRegistry; AlfrescoServiceRegistry.setServiceRegistry(this.serviceRegistry); } }
custom-context.xml
<bean id="AlfrescoServiceBean" class="com.poc.utility.ServiceRegistryBean">
<property name="serviceRegistry">
<ref bean="ServiceRegistry" />
</property>
</bean>
Thanks! Very usefull!
ReplyDelete