[CJ-dev] commonjava-projects/commonjava-enterprise-services/projects/service-manager/src/main/java/o
Brought to you by:
johnqueso
From: John C. <joh...@co...> - 2004-04-08 15:32:45
|
Update of /cvsroot/commonjava/commonjava-projects/commonjava-enterprise-services/projects/service-manager/src/main/java/org/commonjava/j2ee/services In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1684/projects/service-manager/src/main/java/org/commonjava/j2ee/services Modified Files: ServiceManager.java Added Files: DefaultServiceManager.java Log Message: refactored to provide an interface and default impl for each manager type, instead of merely a manager concrete impl. This will allow for easier mocking. --- NEW FILE: DefaultServiceManager.java --- /* Created on Mar 22, 2004 */ package org.commonjava.j2ee.services; import javax.naming.NamingException; import javax.rmi.PortableRemoteObject; import org.commonjava.config.snapin.SnapInLoaderException; import org.commonjava.j2ee.services.ServiceLocator; /** * @author jdcasey */ public final class DefaultServiceManager extends AbstractManager implements ServiceManager{ /** * */ public DefaultServiceManager() { setJndiConfigName(STANDARD_SVC_JNDI_CONFIG_NAME); } public DefaultServiceManager(ServiceLocator locator){ super(locator); setJndiConfigName(STANDARD_SVC_JNDI_CONFIG_NAME); } /** Retrieve the JNDI configuration for Service lookups, then lookup the specified * jndi binding and return a service object, cast to the specified class. * @param jndiName The JNDI binding * @param castTo The class to cast the lookup result to. */ public Object getService(String jndiName, Class castTo) throws NamingException, SnapInLoaderException { Object result = getLocator().lookup(getJndiConfigName(), jndiName); if(result != null && !castTo.isInstance(result)){ result = PortableRemoteObject.narrow(result, castTo); } return result; } } Index: ServiceManager.java =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-enterprise-services/projects/service-manager/src/main/java/org/commonjava/j2ee/services/ServiceManager.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- ServiceManager.java 23 Mar 2004 14:58:58 -0000 1.1 +++ ServiceManager.java 8 Apr 2004 15:19:35 -0000 1.2 @@ -1,45 +1,27 @@ -/* Created on Mar 22, 2004 */ +/* + * Created on Apr 8, 2004 + * + */ package org.commonjava.j2ee.services; import javax.naming.NamingException; -import javax.rmi.PortableRemoteObject; import org.commonjava.config.snapin.SnapInLoaderException; -import org.commonjava.j2ee.services.ServiceLocator; -/** - * @author jdcasey +//TODO: Add JavaDoc to ServiceManager in commonjava-enterprise-services! +/** + * + * @ + * */ -public final class ServiceManager extends AbstractManager{ - +public interface ServiceManager { public static final String STANDARD_SVC_JNDI_CONFIG_NAME = "services"; - - /** - * - */ - public ServiceManager() { - setJndiConfigName(STANDARD_SVC_JNDI_CONFIG_NAME); - } - - public ServiceManager(ServiceLocator locator){ - super(locator); - setJndiConfigName(STANDARD_SVC_JNDI_CONFIG_NAME); - } /** Retrieve the JNDI configuration for Service lookups, then lookup the specified * jndi binding and return a service object, cast to the specified class. * @param jndiName The JNDI binding * @param castTo The class to cast the lookup result to. */ - public Object getService(String jndiName, Class castTo) - throws NamingException, SnapInLoaderException - { - Object result = getLocator().lookup(getJndiConfigName(), jndiName); - if(result != null && !castTo.isInstance(result)){ - result = PortableRemoteObject.narrow(result, castTo); - } - - return result; - } - -} + public abstract Object getService(String jndiName, Class castTo) + throws NamingException, SnapInLoaderException; +} \ No newline at end of file |