[jboss-cvs] JBoss Messaging SVN: r3653 - in trunk: src/main/org/jboss/messaging/core and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Jan 31 05:48:18 EST 2008


Author: ataylor
Date: 2008-01-31 05:48:18 -0500 (Thu, 31 Jan 2008)
New Revision: 3653

Removed:
   trunk/docs/examples/embedded/src/org/jboss/example/embedded/MessagingServerFactory.java
Modified:
   trunk/docs/examples/embedded/src/org/jboss/example/embedded/EmbeddedExample.java
   trunk/src/main/org/jboss/messaging/core/Configuration.java
   trunk/src/main/org/jboss/messaging/core/impl/server/MessagingServerImpl.java
Log:
added a constructor to MessagingServerImpl to allow a RemotingCOnfiguration to be passed in. This will pass the lifecycle of the RemotingService to the MessagingServer

Modified: trunk/docs/examples/embedded/src/org/jboss/example/embedded/EmbeddedExample.java
===================================================================
--- trunk/docs/examples/embedded/src/org/jboss/example/embedded/EmbeddedExample.java	2008-01-31 10:33:38 UTC (rev 3652)
+++ trunk/docs/examples/embedded/src/org/jboss/example/embedded/EmbeddedExample.java	2008-01-31 10:48:18 UTC (rev 3653)
@@ -36,6 +36,7 @@
 import org.jboss.messaging.core.MessagingServer;
 import org.jboss.messaging.core.impl.DestinationImpl;
 import org.jboss.messaging.core.impl.MessageImpl;
+import org.jboss.messaging.core.impl.server.MessagingServerImpl;
 import org.jboss.messaging.core.remoting.RemotingConfiguration;
 
 /**
@@ -46,7 +47,7 @@
    public static void main(String args[]) throws Exception
    {
       RemotingConfiguration remotingConf = new RemotingConfiguration(TCP, "localhost", 5400);
-      MessagingServer messagingServer = MessagingServerFactory.createMessagingServer(remotingConf);
+      MessagingServer messagingServer = new MessagingServerImpl(remotingConf);
       messagingServer.start();
       messagingServer.createQueue("Queue1");
       ClientConnectionFactory cf = new ClientConnectionFactoryImpl(remotingConf);
@@ -64,6 +65,6 @@
       System.out.println("m = " + new String(m.getPayload()));
       clientConnection.close();
 
-      MessagingServerFactory.stop(messagingServer);
+      messagingServer.stop();
    }
 }

Deleted: trunk/docs/examples/embedded/src/org/jboss/example/embedded/MessagingServerFactory.java
===================================================================
--- trunk/docs/examples/embedded/src/org/jboss/example/embedded/MessagingServerFactory.java	2008-01-31 10:33:38 UTC (rev 3652)
+++ trunk/docs/examples/embedded/src/org/jboss/example/embedded/MessagingServerFactory.java	2008-01-31 10:48:18 UTC (rev 3653)
@@ -1,57 +0,0 @@
-/*
-   * JBoss, Home of Professional Open Source
-   * Copyright 2005, JBoss Inc., and individual contributors as indicated
-   * by the @authors tag. See the copyright.txt in the distribution for a
-   * full listing of individual contributors.
-   *
-   * This is free software; you can redistribute it and/or modify it
-   * under the terms of the GNU Lesser General Public License as
-   * published by the Free Software Foundation; either version 2.1 of
-   * the License, or (at your option) any later version.
-   *
-   * This software is distributed in the hope that it will be useful,
-   * but WITHOUT ANY WARRANTY; without even the implied warranty of
-   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-   * Lesser General Public License for more details.
-   *
-   * You should have received a copy of the GNU Lesser General Public
-   * License along with this software; if not, write to the Free
-   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-   */
-package org.jboss.example.embedded;
-
-import org.jboss.jms.server.plugin.contract.JMSUserManager;
-import org.jboss.jms.server.security.NullAuthenticationManager;
-import org.jboss.messaging.core.Configuration;
-import org.jboss.messaging.core.MessagingServer;
-import org.jboss.messaging.core.impl.bdbje.BDBJEEnvironment;
-import org.jboss.messaging.core.impl.bdbje.BDBJEPersistenceManager;
-import org.jboss.messaging.core.impl.bdbje.integration.RealBDBJEEnvironment;
-import org.jboss.messaging.core.impl.server.MessagingServerImpl;
-import org.jboss.messaging.core.remoting.RemotingConfiguration;
-import org.jboss.messaging.core.remoting.impl.mina.MinaService;
-
-/**
- * @author <a href="ataylor at redhat.com">Andy Taylor</a>
- */
-public class MessagingServerFactory
-{   
-   public static MessagingServer createMessagingServer(RemotingConfiguration remotingConf) throws Exception
-   {
-      MinaService minaService = new MinaService(remotingConf);
-      minaService.start();
-      MessagingServerImpl messagingServer = new MessagingServerImpl();
-      messagingServer.setRemotingService(minaService);
-
-   
-      return messagingServer;
-   }
-   
-   public static void stop(MessagingServer server) throws Exception
-   {
-      server.stop();
-      server.getRemotingService().stop();
-      server.getPersistenceManager().stop();
-   }
-}

Modified: trunk/src/main/org/jboss/messaging/core/Configuration.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/Configuration.java	2008-01-31 10:33:38 UTC (rev 3652)
+++ trunk/src/main/org/jboss/messaging/core/Configuration.java	2008-01-31 10:48:18 UTC (rev 3653)
@@ -58,12 +58,12 @@
 
 
    private PropertyChangeSupport propertyChangeSupport;
-   protected Integer messagingServerID = -1;
+   protected Integer messagingServerID = 0;
    protected String _defaultQueueJNDIContext = "";
    protected String _defaultTopicJNDIContext = "";
    protected String _securityDomain;
    protected HashSet<Role> _securityConfig;
-   protected List<String> defaultInterceptors;
+   protected List<String> defaultInterceptors = new ArrayList<String>();
    protected String _defaultDLQ;
    // The default maximum number of delivery attempts before sending to DLQ - can be overridden on
    // the destination

Modified: trunk/src/main/org/jboss/messaging/core/impl/server/MessagingServerImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/impl/server/MessagingServerImpl.java	2008-01-31 10:33:38 UTC (rev 3652)
+++ trunk/src/main/org/jboss/messaging/core/impl/server/MessagingServerImpl.java	2008-01-31 10:48:18 UTC (rev 3653)
@@ -52,6 +52,7 @@
 import org.jboss.messaging.core.remoting.Interceptor;
 import org.jboss.messaging.core.remoting.impl.mina.MinaService;
 import org.jboss.messaging.core.remoting.RemotingService;
+import org.jboss.messaging.core.remoting.RemotingConfiguration;
 import org.jboss.messaging.deployers.queue.QueueSettingsDeployer;
 import org.jboss.messaging.deployers.security.SecurityDeployer;
 import org.jboss.messaging.util.ExceptionUtil;
@@ -110,6 +111,7 @@
    private JMSUserManager jmsUserManager = new NullUserManager();
 
    private RemotingService remotingService;
+   private boolean createTransport = false;
 
    private Configuration configuration = new Configuration();
    private HierarchicalRepository<HashSet<Role>> securityRepository = new HierarchicalObjectRepository<HashSet<Role>>();
@@ -117,7 +119,10 @@
    private QueueFactoryImpl queueFactory = new QueueFactoryImpl();
 
    // Constructors ---------------------------------------------------------------------------------
-   public MessagingServerImpl() throws Exception
+   /**
+    * typically called by the MC framework or embedded if the user want to create and start their own RemotingService
+    */
+   public MessagingServerImpl()
    {
       // Some wired components need to be started here
 
@@ -128,6 +133,16 @@
       started = false;
    }
 
+   /**
+    * called when the usewr wants the MessagingServer to handle the creation of the RemotingTransport
+    * @param remotingConfiguration the RemotingConfiguration
+    */
+   public MessagingServerImpl(RemotingConfiguration remotingConfiguration)
+   {
+      this();
+      createTransport = true;
+      remotingService = new MinaService(remotingConfiguration);
+   }
    // lifecycle methods ----------------------------------------------------------------
 
    public synchronized void start() throws Exception
@@ -174,6 +189,10 @@
          postOffice = new PostOfficeImpl(configuration.getMessagingServerID(),
                                          persistenceManager, queueFactory);
 
+         if(createTransport)
+         {
+            remotingService.start();
+         }
          // Start the wired components
          securityDeployer.start();
          queueSettingsDeployer.start();
@@ -232,7 +251,10 @@
          messageCounterManager = null;
          postOffice.stop();
          postOffice = null;
-
+         if(createTransport)
+         {
+            remotingService.stop();
+         }
          MessagingTimeoutFactory.instance.reset();
 
          log.info("JMS " + this + " stopped");




More information about the jboss-cvs-commits mailing list