package org.jboss.jms.client.jvm;
import javax.jms.JMSException;
import javax.naming.NamingException;
import javax.naming.Reference;
import javax.naming.StringRefAddr;
import org.jboss.aop.advice.Interceptor;
import org.jboss.jms.client.ConnectionDelegate;
import org.jboss.jms.client.ImplementationDelegate;
import org.jboss.jms.client.JBossConnectionFactory;
import org.jboss.jms.client.container.ClientContainerFactory;
import org.jboss.jms.client.container.FactoryInterceptor;
import org.jboss.jms.server.MessageBroker;
import org.jboss.jms.server.container.Client;
import org.jboss.jms.server.container.ServerConnectionInterceptor;
import org.jboss.jms.server.container.ServerContainerFactory;
import org.jboss.jms.server.container.ServerFactoryInterceptor;
public class JVMImplementation
implements ImplementationDelegate
{
private MessageBroker broker;
public JVMImplementation(MessageBroker broker)
{
this.broker = broker;
}
public ConnectionDelegate createConnection(String userName, String password) throws JMSException
{
Client client = new Client(broker);
Interceptor[] serverInterceptors = new Interceptor[]
{
ServerFactoryInterceptor.singleton,
ServerConnectionInterceptor.singleton
};
ConnectionDelegate delegate = ServerContainerFactory.getConnectionContainer(this, serverInterceptors, client.getMetaData());
Interceptor[] clientInterceptors = new Interceptor[]
{
FactoryInterceptor.singleton
};
return ClientContainerFactory.getConnectionContainer(this, delegate, clientInterceptors, null);
}
public Reference getReference() throws NamingException
{
return new Reference
(
JBossConnectionFactory.class.getName(),
new StringRefAddr("dummy", "dummy"),
JVMImplementationFactory.class.getName(),
null
);
}
}