KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > jms > client > jvm > JVMImplementation


1 /*
2  * JBoss, the OpenSource J2EE webOS
3  *
4  * Distributable under LGPL license.
5  * See terms of license at gnu.org.
6  */

7 package org.jboss.jms.client.jvm;
8
9 import javax.jms.JMSException JavaDoc;
10 import javax.naming.NamingException JavaDoc;
11 import javax.naming.Reference JavaDoc;
12 import javax.naming.StringRefAddr JavaDoc;
13
14 import org.jboss.aop.advice.Interceptor;
15 import org.jboss.jms.client.ConnectionDelegate;
16 import org.jboss.jms.client.ImplementationDelegate;
17 import org.jboss.jms.client.JBossConnectionFactory;
18 import org.jboss.jms.client.container.ClientContainerFactory;
19 import org.jboss.jms.client.container.FactoryInterceptor;
20 import org.jboss.jms.server.MessageBroker;
21 import org.jboss.jms.server.container.Client;
22 import org.jboss.jms.server.container.ServerConnectionInterceptor;
23 import org.jboss.jms.server.container.ServerContainerFactory;
24 import org.jboss.jms.server.container.ServerFactoryInterceptor;
25
26 /**
27  * The in jvm implementation
28  *
29  * @author <a HREF="mailto:adrian@jboss.org>Adrian Brock</a>
30  * @version $Revision: 1.3 $
31  */

32 public class JVMImplementation
33    implements ImplementationDelegate
34 {
35    // Constants -----------------------------------------------------
36

37    // Attributes ----------------------------------------------------
38

39    /** The message broker */
40    private MessageBroker broker;
41
42    // Static --------------------------------------------------------
43

44    // Constructors --------------------------------------------------
45

46    public JVMImplementation(MessageBroker broker)
47    {
48       this.broker = broker;
49    }
50
51    // Public --------------------------------------------------------
52

53    // ImplementationDelegate implementation -------------------------
54

55    public ConnectionDelegate createConnection(String JavaDoc userName, String JavaDoc password) throws JMSException JavaDoc
56    {
57       Client client = new Client(broker);
58       Interceptor[] serverInterceptors = new Interceptor[]
59       {
60          ServerFactoryInterceptor.singleton,
61          ServerConnectionInterceptor.singleton
62       };
63       ConnectionDelegate delegate = ServerContainerFactory.getConnectionContainer(this, serverInterceptors, client.getMetaData());
64
65       Interceptor[] clientInterceptors = new Interceptor[]
66       {
67          FactoryInterceptor.singleton
68       };
69       return ClientContainerFactory.getConnectionContainer(this, delegate, clientInterceptors, null);
70    }
71
72    public Reference JavaDoc getReference() throws NamingException JavaDoc
73    {
74       return new Reference JavaDoc
75       (
76          JBossConnectionFactory.class.getName(),
77          new StringRefAddr JavaDoc("dummy", "dummy"),
78          JVMImplementationFactory.class.getName(),
79          null
80       );
81    }
82
83    // Protected ------------------------------------------------------
84

85    // Package Private ------------------------------------------------
86

87    // Private --------------------------------------------------------
88

89    // Inner Classes --------------------------------------------------
90

91 }
92
Popular Tags