KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > mq > il > jvm > JVMServerILService


1 /*
2  * JBoss, Home of Professional Open Source
3  * Copyright 2005, JBoss Inc., and individual contributors as indicated
4  * by the @authors tag. See the copyright.txt in the distribution for a
5  * full listing of individual contributors.
6  *
7  * This is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU Lesser General Public License as
9  * published by the Free Software Foundation; either version 2.1 of
10  * the License, or (at your option) any later version.
11  *
12  * This software is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this software; if not, write to the Free
19  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21  */

22 package org.jboss.mq.il.jvm;
23
24 import java.util.Properties JavaDoc;
25
26 import javax.naming.InitialContext JavaDoc;
27
28 import org.jboss.mq.GenericConnectionFactory;
29 import org.jboss.mq.il.ServerIL;
30 import org.jboss.mq.il.ServerILFactory;
31
32 /**
33  * Implements the ServerILJMXService which is used to manage the JVM IL.
34  *
35  * @author Hiram Chirino (Cojonudo14@hotmail.com)
36  * @author David Maplesden (David.Maplesden@orion.co.nz)
37  * @created August 16, 2001
38  * @version $Revision: 45305 $
39  *
40  * @jmx:mbean extends="org.jboss.mq.il.ServerILJMXServiceMBean"
41  */

42 public class JVMServerILService extends org.jboss.mq.il.ServerILJMXService implements JVMServerILServiceMBean
43 {
44
45    /**
46     * Gives this JMX service a name.
47     *
48     * @return The Name value
49     */

50    public String JavaDoc getName()
51    {
52       return "JBossMQ-JVMServerIL";
53    }
54
55    /**
56     * Used to construct the GenericConnectionFactory (bindJNDIReferences()
57     * builds it)
58     *
59     * @return The ServerIL value
60     * @returns ServerIL the instance of this IL
61     */

62    public ServerIL getServerIL()
63    {
64       return new JVMServerIL(getJMSServer());
65    }
66
67    /**
68     * Used to construct the GenericConnectionFactory (bindJNDIReferences()
69     * builds it) Sets up the connection properties need by a client to use this
70     * IL
71     *
72     * @return The ClientConnectionProperties value
73     */

74    public java.util.Properties JavaDoc getClientConnectionProperties()
75    {
76       Properties JavaDoc rc = super.getClientConnectionProperties();
77       rc.setProperty(ServerILFactory.CLIENT_IL_SERVICE_KEY, "org.jboss.mq.il.jvm.JVMClientILService");
78       rc.setProperty(ServerILFactory.SERVER_IL_FACTORY_KEY, "org.jboss.mq.il.jvm.JVMServerILFactory");
79       return rc;
80    }
81
82    /**
83     * Starts this IL, and binds it to JNDI
84     *
85     * @exception Exception Description of Exception
86     */

87    public void startService() throws Exception JavaDoc
88    {
89       super.startService();
90       bindJNDIReferences();
91    }
92
93    /**
94     * Stops this IL, and unbinds it from JNDI
95     */

96    public void stopService()
97    {
98       try
99       {
100          unbindJNDIReferences();
101       }
102       catch (Exception JavaDoc e)
103       {
104          log.error("Problem stopping JVMServerILService", e);
105       }
106    }
107
108    /**
109     * Binds the connection factories for this IL
110     *
111     * @throws javax.naming.NamingException it cannot be unbound
112     */

113    public void bindJNDIReferences() throws javax.naming.NamingException JavaDoc
114    {
115
116       GenericConnectionFactory gcf = new GenericConnectionFactory(getServerIL(), getClientConnectionProperties());
117       org.jboss.mq.SpyConnectionFactory scf = new org.jboss.mq.SpyConnectionFactory(gcf);
118       org.jboss.mq.SpyXAConnectionFactory sxacf = new org.jboss.mq.SpyXAConnectionFactory(gcf);
119
120       // Get an InitialContext
121
InitialContext JavaDoc ctx = getInitialContext();
122       org.jboss.naming.NonSerializableFactory.rebind(ctx, getConnectionFactoryJNDIRef(), scf);
123       org.jboss.naming.NonSerializableFactory.rebind(ctx, getXAConnectionFactoryJNDIRef(), sxacf);
124
125    }
126 }
127
Popular Tags