Update of /cvsroot/commonjava/commonjava-projects/commonjava-enterprise-services/projects/jms-manager/src/main/java/org/commonjava/j2ee/services
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10019/projects/jms-manager/src/main/java/org/commonjava/j2ee/services
Added Files:
JMSManager.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: JMSManager.java ---
/* Created on Mar 22, 2004 */
package org.commonjava.j2ee.services;
import javax.jms.Queue;
import javax.jms.QueueConnectionFactory;
import javax.naming.NamingException;
import javax.rmi.PortableRemoteObject;
import org.commonjava.config.snapin.SnapInLoaderException;
/**
* @author jdcasey
*/
public final class JMSManager extends AbstractManager{
public static final String STANDARD_JMS_JNDI_CONFIG_NAME = "jms";
/**
*
*/
public JMSManager() {
setJndiConfigName(STANDARD_JMS_JNDI_CONFIG_NAME);
}
public JMSManager(ServiceLocator locator){
super(locator);
setJndiConfigName(STANDARD_JMS_JNDI_CONFIG_NAME);
}
public Queue getQueue(String jndiName) throws NamingException, SnapInLoaderException
{
Object result = getLocator().lookup(getJndiConfigName(), jndiName);
// shouldn't have to do this, but just in case...
if(result != null && !Queue.class.isInstance(result)){
result = PortableRemoteObject.narrow(result, Queue.class);
}
return (Queue)result;
}
public QueueConnectionFactory getQueueConnectionFactory(String jndiName)
throws NamingException, SnapInLoaderException
{
Object result = getLocator().lookup(getJndiConfigName(), jndiName);
// shouldn't have to do this, but just in case...
if(result != null && !QueueConnectionFactory.class.isInstance(result)){
result = PortableRemoteObject.narrow(result, QueueConnectionFactory.class);
}
return (QueueConnectionFactory)result;
}
}
|