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-serv10019/projects/service-manager/src/main/java/org/commonjava/j2ee/services
Added Files:
ServiceManager.java
Log Message:
modified to make core, ejb, jms, jdbc, raw-service sub-projects, and to add JNDI name rewriting to the core ServiceLocator.
--- NEW FILE: ServiceManager.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 ServiceManager extends AbstractManager{
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;
}
}
|