User: dmaplesden
Date: 01/09/12 18:53:13
Modified: src/main/org/jboss/mq/server JMSServer.java
JBossMQService.java
Log:
Changed management of static instance of JMSServer to allow jbossmq to be undeployed
and redeployed correctly.
Revision Changes Path
1.7 +27 -7 jbossmq/src/main/org/jboss/mq/server/JMSServer.java
Index: JMSServer.java
===================================================================
RCS file: /cvsroot/jboss/jbossmq/src/main/org/jboss/mq/server/JMSServer.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- JMSServer.java 2001/09/01 03:01:00 1.6
+++ JMSServer.java 2001/09/13 01:53:13 1.7
@@ -37,15 +37,15 @@
* @author Norbert Lataille ([EMAIL PROTECTED])
* @author Hiram Chirino ([EMAIL PROTECTED])
* @author David Maplesden ([EMAIL PROTECTED])
- * @version $Revision: 1.6 $
+ * @version $Revision: 1.7 $
*/
public class JMSServer
{
public final static String JBOSS_VESION = "JBossMQ ver. 0.9b";
- //Implement Singleton design pattern for JVMIL to work correctly
+ //provide static reference to the server for JVMIL to work.
//It would be nice if there was another way of doing this.
- protected static JMSServer theInstance = new JMSServer();
+ protected static JMSServer theInstance = null;
static org.apache.log4j.Category cat =
org.apache.log4j.Category.getInstance(JMSServer.class);
@@ -95,9 +95,29 @@
}
/**
- * Gets the Instance attribute of the JMSServer class
+ * Creates a new instance of the JMSServer if one has not already been created.
+ */
+ public static void initServer()
+ {
+ if(JMSServer.theInstance == null)
+ {
+ JMSServer.theInstance = new JMSServer();
+ }
+ }
+
+ /**
+ * Destroys the current instance of the JMSServer if one exists.
+ */
+ public static void destroyServer()
+ {
+ JMSServer.theInstance = null;
+ }
+
+ /**
+ * Gets the Instance of the JMSServer. Will return null if called before the
+ * initServer method has been called.
*
- * @return The Instance value
+ * @return The instance value
*/
public static JMSServer getInstance()
{
@@ -308,7 +328,7 @@
synchronized (stateLock)
{
this.stopped = true;
- //Any work that needs doing should be done here
+ //Any cleanup work that needs doing should be done here
//At the moment there is nothing to do due to the fact that the individual
//parts of the JBossMQ (pm, ils etc) each have their own mbean service
@@ -316,7 +336,7 @@
//We could wait in here for the client consumers to finish delivering any
//messages they have, but it is not neccessary as the client acks will be
- //almost certainly be lost anyway.
+ //lost anyway.
this.alive = false;
}
}
1.7 +6 -8 jbossmq/src/main/org/jboss/mq/server/JBossMQService.java
Index: JBossMQService.java
===================================================================
RCS file: /cvsroot/jboss/jbossmq/src/main/org/jboss/mq/server/JBossMQService.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- JBossMQService.java 2001/09/11 18:38:18 1.6
+++ JBossMQService.java 2001/09/13 01:53:13 1.7
@@ -22,7 +22,7 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Juha Lindfors</a>
* @author <a href="[EMAIL PROTECTED]">Hiram Chirino</a>
* @see JBossMQ subproject
- * @version $Revision: 1.6 $
+ * @version $Revision: 1.7 $
*/
public class JBossMQService extends ServiceMBeanSupport implements
JBossMQServiceMBean
{
@@ -31,8 +31,6 @@
// Attributes ----------------------------------------------------
- private JMSServer jmsServer;
-
/**
* Gets the Name attribute of the JBossMQService object
*
@@ -50,7 +48,7 @@
*/
public JMSServer getJMSServer()
{
- return jmsServer;
+ return JMSServer.getInstance();
}
/**
@@ -403,21 +401,21 @@
protected void initService() throws Exception
{
- jmsServer = JMSServer.getInstance();
+ JMSServer.initServer();
}
protected void startService() throws Exception
{
- jmsServer.startServer();
+ JMSServer.getInstance().startServer();
}
protected void stopService()
{
- jmsServer.stopServer();
+ JMSServer.getInstance().stopServer();
}
protected void destroyService()
{
- jmsServer = null;
+ JMSServer.destroyServer();
}
}
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development