[jboss-cvs] JBoss Messaging SVN: r4507 - in trunk: src/config and 21 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Jun 17 16:01:27 EDT 2008
Author: timfox
Date: 2008-06-17 16:01:27 -0400 (Tue, 17 Jun 2008)
New Revision: 4507
Added:
trunk/src/main/org/jboss/messaging/core/server/MessagingService.java
trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServiceImpl.java
Modified:
trunk/examples/messaging/src/org/jboss/messaging/example/SimpleExample.java
trunk/src/config/jbm-standalone-beans.xml
trunk/src/main/org/jboss/messaging/core/deployers/impl/SecurityManagerDeployer.java
trunk/src/main/org/jboss/messaging/core/deployers/impl/XmlDeployer.java
trunk/src/main/org/jboss/messaging/core/journal/PreparedTransactionInfo.java
trunk/src/main/org/jboss/messaging/core/journal/impl/JournalImpl.java
trunk/src/main/org/jboss/messaging/core/memory/impl/SimpleMemoryManager.java
trunk/src/main/org/jboss/messaging/core/persistence/impl/journal/JournalStorageManager.java
trunk/src/main/org/jboss/messaging/core/persistence/impl/nullpm/NullStorageManager.java
trunk/src/main/org/jboss/messaging/core/postoffice/impl/PostOfficeImpl.java
trunk/src/main/org/jboss/messaging/core/remoting/impl/RemotingServiceImpl.java
trunk/src/main/org/jboss/messaging/core/server/MessagingComponent.java
trunk/src/main/org/jboss/messaging/core/server/MessagingServer.java
trunk/src/main/org/jboss/messaging/core/server/ServerConnection.java
trunk/src/main/org/jboss/messaging/core/server/impl/ConnectionManagerImpl.java
trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java
trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerPacketHandler.java
trunk/src/main/org/jboss/messaging/core/server/impl/ServerConnectionImpl.java
trunk/src/main/org/jboss/messaging/core/server/impl/ServerSessionPacketHandler.java
trunk/src/main/org/jboss/messaging/jms/server/JMSServerManager.java
trunk/tests/src/org/jboss/messaging/tests/integration/CoreClientTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/impl/ClientCrashTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/impl/ClientExitTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/impl/PacketFilterTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/mina/ClientPingTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/ssl/CoreClientOverSSLTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/jms/server/impl/JMSServerManagerimplTest.java
trunk/tests/src/org/jboss/messaging/tests/performance/persistence/fakes/FakePostOffice.java
trunk/tests/src/org/jboss/messaging/tests/performance/persistence/impl/StorageManagerTimingTest.java
trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/ConnectionManagerTest.java
trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/INVMServerTest.java
trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/network/ClientNetworkFailureTest.java
trunk/tests/src/org/jboss/messaging/tests/unit/jms/misc/ManifestTest.java
Log:
Some refactoring around MessagingServer
Modified: trunk/examples/messaging/src/org/jboss/messaging/example/SimpleExample.java
===================================================================
--- trunk/examples/messaging/src/org/jboss/messaging/example/SimpleExample.java 2008-06-17 16:15:35 UTC (rev 4506)
+++ trunk/examples/messaging/src/org/jboss/messaging/example/SimpleExample.java 2008-06-17 20:01:27 UTC (rev 4507)
@@ -42,8 +42,9 @@
import org.jboss.messaging.core.security.CheckType;
import org.jboss.messaging.core.security.JBMSecurityManager;
import org.jboss.messaging.core.security.Role;
-import org.jboss.messaging.core.server.MessagingServer;
+import org.jboss.messaging.core.server.MessagingService;
import org.jboss.messaging.core.server.impl.MessagingServerImpl;
+import org.jboss.messaging.core.server.impl.MessagingServiceImpl;
import org.jboss.messaging.jms.client.JBossTextMessage;
import org.jboss.messaging.util.SimpleString;
@@ -56,7 +57,7 @@
{
public static void main(final String[] args) throws Exception
{
- MessagingServer messagingServer = null;
+ MessagingService messagingService = null;
ClientConnection clientConnection = null;
try
@@ -65,28 +66,14 @@
ConfigurationImpl configuration = new ConfigurationImpl();
configuration.setTransport(TransportType.TCP);
configuration.setHost("localhost");
- messagingServer = new MessagingServerImpl(configuration);
- //lets use our own security manager, we could use the default if needed but we would need to make sure that
- // jbm-security.xml and queues.xml are in the classpath
- messagingServer.setSecurityManager(new JBMSecurityManager()
- {
- public boolean validateUser(String user, String password)
- {
- return true;
- }
-
- public boolean validateUserAndRole(String user, String password, Set<Role> roles, CheckType checkType)
- {
- return true;
- }
- });
+ messagingService = MessagingServiceImpl.newNullStorageMessagingServer(configuration);
//start the server
- messagingServer.start();
+ messagingService.start();
//add a new binding
SimpleString atestq = new SimpleString("atestq");
- messagingServer.getPostOffice().addBinding(atestq, atestq, null, false, false);
+ messagingService.getServer().getPostOffice().addBinding(atestq, atestq, null, false, false);
//then we create a client as normal
Location location = new LocationImpl(TransportType.TCP, "localhost", 5400);
@@ -122,11 +109,11 @@
//
}
}
- if (messagingServer != null && messagingServer.isStarted())
+ if (messagingService != null && messagingService.isStarted())
{
try
{
- messagingServer.stop();
+ messagingService.stop();
}
catch (Exception e1)
{
Modified: trunk/src/config/jbm-standalone-beans.xml
===================================================================
--- trunk/src/config/jbm-standalone-beans.xml 2008-06-17 16:15:35 UTC (rev 4506)
+++ trunk/src/config/jbm-standalone-beans.xml 2008-06-17 20:01:27 UTC (rev 4507)
@@ -80,7 +80,7 @@
</parameter>
</constructor>
</bean>
-
+
<bean name="JMSServerManager" class="org.jboss.messaging.jms.server.impl.JMSServerManagerImpl">
<annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.messaging:service=JMSServerManager",exposedInterface=org.jboss.messaging.jms.server.JMSServerManager.class)</annotation>
<property name="messagingServerManagement">
Modified: trunk/src/main/org/jboss/messaging/core/deployers/impl/SecurityManagerDeployer.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/deployers/impl/SecurityManagerDeployer.java 2008-06-17 16:15:35 UTC (rev 4506)
+++ trunk/src/main/org/jboss/messaging/core/deployers/impl/SecurityManagerDeployer.java 2008-06-17 20:01:27 UTC (rev 4507)
@@ -27,13 +27,16 @@
import org.w3c.dom.NodeList;
/**
+ *
+ * TODO should rename this to security deployer rather than security manager deployer since doesn't deploy
+ * security managers
+ *
* deployer for adding security loaded from the file "jbm-security.xml"
* @author <a href="ataylor at redhat.com">Andy Taylor</a>
*/
public class SecurityManagerDeployer extends XmlDeployer
{
private JBMUpdateableSecurityManager jbmSecurityManager;
- private DeploymentManager deploymentManager;
private static final String PASSWORD_ATTRIBUTE = "password";
private static final String ROLES_NODE = "role";
private static final String ROLE_ATTR_NAME = "name";
Modified: trunk/src/main/org/jboss/messaging/core/deployers/impl/XmlDeployer.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/deployers/impl/XmlDeployer.java 2008-06-17 16:15:35 UTC (rev 4506)
+++ trunk/src/main/org/jboss/messaging/core/deployers/impl/XmlDeployer.java 2008-06-17 20:01:27 UTC (rev 4507)
@@ -46,11 +46,12 @@
private static Logger log = Logger.getLogger(XmlDeployer.class);
protected static final String NAME_ATTR = "name";
- private HashMap<URL, HashMap<String, Node>> configuration = new HashMap<URL, HashMap<String, Node>>();
+ private final HashMap<URL, HashMap<String, Node>> configuration = new HashMap<URL, HashMap<String, Node>>();
+ private final DeploymentManager deploymentManager;
+
+ private volatile boolean started;
- protected DeploymentManager deploymentManager;
-
public XmlDeployer(final DeploymentManager deploymentManager)
{
this.deploymentManager = deploymentManager;
@@ -195,6 +196,8 @@
public void start() throws Exception
{
deploymentManager.registerDeployer(this);
+
+ started = true;
}
//undeploy everything
@@ -216,7 +219,14 @@
}
}
deploymentManager.unregisterDeployer(this);
+
+ started = false;
}
+
+ public boolean isStarted()
+ {
+ return started;
+ }
/**
* the names of the elements to deploy
Modified: trunk/src/main/org/jboss/messaging/core/journal/PreparedTransactionInfo.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/journal/PreparedTransactionInfo.java 2008-06-17 16:15:35 UTC (rev 4506)
+++ trunk/src/main/org/jboss/messaging/core/journal/PreparedTransactionInfo.java 2008-06-17 20:01:27 UTC (rev 4507)
@@ -1,3 +1,4 @@
+
package org.jboss.messaging.core.journal;
import java.util.ArrayList;
Modified: trunk/src/main/org/jboss/messaging/core/journal/impl/JournalImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/journal/impl/JournalImpl.java 2008-06-17 16:15:35 UTC (rev 4506)
+++ trunk/src/main/org/jboss/messaging/core/journal/impl/JournalImpl.java 2008-06-17 20:01:27 UTC (rev 4507)
@@ -1354,6 +1354,11 @@
// MessagingComponent implementation ---------------------------------------------------
+ public synchronized boolean isStarted()
+ {
+ return state != STATE_STOPPED;
+ }
+
public synchronized void start()
{
if (state != STATE_STOPPED)
Modified: trunk/src/main/org/jboss/messaging/core/memory/impl/SimpleMemoryManager.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/memory/impl/SimpleMemoryManager.java 2008-06-17 16:15:35 UTC (rev 4506)
+++ trunk/src/main/org/jboss/messaging/core/memory/impl/SimpleMemoryManager.java 2008-06-17 20:01:27 UTC (rev 4507)
@@ -111,6 +111,11 @@
}
}
+ public synchronized boolean isStarted()
+ {
+ return started;
+ }
+
private class MemoryRunnable implements Runnable
{
public void run()
Modified: trunk/src/main/org/jboss/messaging/core/persistence/impl/journal/JournalStorageManager.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/persistence/impl/journal/JournalStorageManager.java 2008-06-17 16:15:35 UTC (rev 4506)
+++ trunk/src/main/org/jboss/messaging/core/persistence/impl/journal/JournalStorageManager.java 2008-06-17 20:01:27 UTC (rev 4507)
@@ -552,6 +552,11 @@
started = false;
}
+ public synchronized boolean isStarted()
+ {
+ return started;
+ }
+
// Private ----------------------------------------------------------------------------------
private byte[] ackBytes(final long queueID, final long messageID)
Modified: trunk/src/main/org/jboss/messaging/core/persistence/impl/nullpm/NullStorageManager.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/persistence/impl/nullpm/NullStorageManager.java 2008-06-17 16:15:35 UTC (rev 4506)
+++ trunk/src/main/org/jboss/messaging/core/persistence/impl/nullpm/NullStorageManager.java 2008-06-17 20:01:27 UTC (rev 4507)
@@ -149,5 +149,10 @@
started = false;
}
+
+ public synchronized boolean isStarted()
+ {
+ return started;
+ }
}
Modified: trunk/src/main/org/jboss/messaging/core/postoffice/impl/PostOfficeImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/postoffice/impl/PostOfficeImpl.java 2008-06-17 16:15:35 UTC (rev 4506)
+++ trunk/src/main/org/jboss/messaging/core/postoffice/impl/PostOfficeImpl.java 2008-06-17 20:01:27 UTC (rev 4507)
@@ -73,6 +73,8 @@
private final boolean checkAllowable;
private final StorageManager storageManager;
+
+ private volatile boolean started;
public PostOfficeImpl(final StorageManager storageManager,
final QueueFactory queueFactory, final boolean checkAllowable)
@@ -89,6 +91,8 @@
public void start() throws Exception
{
loadBindings();
+
+ started = true;
}
public void stop() throws Exception
@@ -96,8 +100,15 @@
mappings.clear();
destinations.clear();
+
+ started = false;
}
+ public boolean isStarted()
+ {
+ return started;
+ }
+
// PostOffice implementation -----------------------------------------------
public boolean addDestination(final SimpleString address, final boolean temporary) throws Exception
Modified: trunk/src/main/org/jboss/messaging/core/remoting/impl/RemotingServiceImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/impl/RemotingServiceImpl.java 2008-06-17 16:15:35 UTC (rev 4506)
+++ trunk/src/main/org/jboss/messaging/core/remoting/impl/RemotingServiceImpl.java 2008-06-17 20:01:27 UTC (rev 4507)
@@ -35,7 +35,7 @@
// Attributes ----------------------------------------------------
- private boolean started = false;
+ private volatile boolean started = false;
private Configuration config;
@@ -133,6 +133,11 @@
started = false;
}
+
+ public boolean isStarted()
+ {
+ return started;
+ }
public PacketDispatcher getDispatcher()
{
Modified: trunk/src/main/org/jboss/messaging/core/server/MessagingComponent.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/MessagingComponent.java 2008-06-17 16:15:35 UTC (rev 4506)
+++ trunk/src/main/org/jboss/messaging/core/server/MessagingComponent.java 2008-06-17 20:01:27 UTC (rev 4507)
@@ -35,4 +35,6 @@
void start() throws Exception;
void stop() throws Exception;
+
+ boolean isStarted();
}
Modified: trunk/src/main/org/jboss/messaging/core/server/MessagingServer.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/MessagingServer.java 2008-06-17 16:15:35 UTC (rev 4506)
+++ trunk/src/main/org/jboss/messaging/core/server/MessagingServer.java 2008-06-17 20:01:27 UTC (rev 4507)
@@ -52,6 +52,12 @@
*/
public interface MessagingServer extends MessagingComponent
{
+ //The pluggable components
+
+ void setConfiguration(Configuration configuration);
+
+ Configuration getConfiguration();
+
void setRemotingService(RemotingService remotingService);
RemotingService getRemotingService();
@@ -64,18 +70,11 @@
void setSecurityManager(JBMSecurityManager securityManager);
- void setPostOffice(PostOffice postOffice);
+
+ //Access to hard wired components
PostOffice getPostOffice();
- void setConfiguration(Configuration configuration);
-
- Configuration getConfiguration();
-
- Version getVersion();
-
- boolean isStarted();
-
ConnectionManager getConnectionManager();
HierarchicalRepository<Set<Role>> getSecurityRepository();
@@ -87,10 +86,17 @@
ExecutorFactory getExecutorFactory();
ResourceManager getResourceManager();
+
+ Version getVersion();
+ //Operations
+
CreateConnectionResponse createConnection(String username, String password,
- long remotingClientSessionID, String clientAddress,
- int incrementVersion,
+ long remotingClientSessionID,
+ int incrementingVersion,
PacketReturner sender) throws Exception;
+
+ boolean isStarted();
+
}
Added: trunk/src/main/org/jboss/messaging/core/server/MessagingService.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/MessagingService.java (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/server/MessagingService.java 2008-06-17 20:01:27 UTC (rev 4507)
@@ -0,0 +1,38 @@
+/*
+ * 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.messaging.core.server;
+
+/**
+ *
+ * MessagingServiceImpl is a convenience class typically used when you are embedding JBM into your own application
+ * It provides various convenient static methods for creating different kinds of Messaging servers
+ * And has convenience start and stop methods that handle starting stopping of the dependent components.
+ * This would not normally be used when using JBM inside a dependency injection framework such as Spring
+ * or JBoss MC, since that would be handle dependency injection in that case
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
+ */
+public interface MessagingService extends MessagingComponent
+{
+ public MessagingServer getServer();
+}
Modified: trunk/src/main/org/jboss/messaging/core/server/ServerConnection.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/ServerConnection.java 2008-06-17 16:15:35 UTC (rev 4506)
+++ trunk/src/main/org/jboss/messaging/core/server/ServerConnection.java 2008-06-17 20:01:27 UTC (rev 4507)
@@ -21,11 +21,8 @@
*/
package org.jboss.messaging.core.server;
-import java.util.Collection;
-
import org.jboss.messaging.core.remoting.PacketReturner;
import org.jboss.messaging.core.remoting.impl.wireformat.ConnectionCreateSessionResponseMessage;
-import org.jboss.messaging.core.security.SecurityStore;
import org.jboss.messaging.util.SimpleString;
/**
@@ -43,7 +40,7 @@
MessagingServer getServer();
ConnectionCreateSessionResponseMessage createSession(boolean xa, boolean autoCommitSends, boolean autoCommitAcks,
- PacketReturner sender) throws Exception;
+ PacketReturner returner) throws Exception;
void start() throws Exception;
@@ -67,13 +64,5 @@
boolean isStarted();
- long getCreatedTime();
-
- String getClientAddress();
-
- long getCreated();
-
- long getRemotingClientSessionID();
-
- Collection<ServerSession> getSessions();
+ long getClientSessionID();
}
Modified: trunk/src/main/org/jboss/messaging/core/server/impl/ConnectionManagerImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/ConnectionManagerImpl.java 2008-06-17 16:15:35 UTC (rev 4506)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/ConnectionManagerImpl.java 2008-06-17 20:01:27 UTC (rev 4507)
@@ -25,7 +25,6 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.Map.Entry;
import org.jboss.messaging.core.client.RemotingSessionListener;
import org.jboss.messaging.core.exception.MessagingException;
@@ -64,7 +63,7 @@
// ConnectionManager implementation -------------------------------------------------------------
public synchronized void registerConnection(long remotingClientSessionID,
- ServerConnection endpoint)
+ ServerConnection endpoint)
{
List<ServerConnection> connectionEndpoints = endpoints.get(remotingClientSessionID);
@@ -170,33 +169,33 @@
}
}
- dump();
+ //dump();
}
- private void dump()
- {
- if (log.isDebugEnabled())
- {
- StringBuffer buff = new StringBuffer("*********** Dumping connections\n");
- buff.append("remoting session ID -----> server connection endpoints:\n");
- if (endpoints.size() == 0)
- {
- buff.append(" No registered endpoints\n");
- }
- for (Entry<Long, List<ServerConnection>> entry : endpoints.entrySet())
- {
- List<ServerConnection> connectionEndpoints = entry.getValue();
- buff.append(" " + entry.getKey() + "----->\n");
- for (ServerConnection sce : connectionEndpoints)
- {
- buff.append(" " + sce + " (" + System.identityHashCode(sce) + ") " + sce.getClientAddress() + "\n");
- }
- }
- buff.append("*** Dumped connections");
-
- log.debug(buff);
- }
- }
+// private void dump()
+// {
+// if (log.isDebugEnabled())
+// {
+// StringBuffer buff = new StringBuffer("*********** Dumping connections\n");
+// buff.append("remoting session ID -----> server connection endpoints:\n");
+// if (endpoints.size() == 0)
+// {
+// buff.append(" No registered endpoints\n");
+// }
+// for (Entry<Long, List<ServerConnection>> entry : endpoints.entrySet())
+// {
+// List<ServerConnection> connectionEndpoints = entry.getValue();
+// buff.append(" " + entry.getKey() + "----->\n");
+// for (ServerConnection sce : connectionEndpoints)
+// {
+// buff.append(" " + sce + " (" + System.identityHashCode(sce) + ") " + sce.getClientAddress() + "\n");
+// }
+// }
+// buff.append("*** Dumped connections");
+//
+// log.debug(buff);
+// }
+// }
// Inner classes --------------------------------------------------------------------------------
Modified: trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java 2008-06-17 16:15:35 UTC (rev 4506)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java 2008-06-17 20:01:27 UTC (rev 4507)
@@ -21,27 +21,29 @@
*/
package org.jboss.messaging.core.server.impl;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ScheduledThreadPoolExecutor;
+import java.util.concurrent.ThreadFactory;
+
import org.jboss.messaging.core.client.RemotingSessionListener;
import org.jboss.messaging.core.config.Configuration;
-import org.jboss.messaging.core.config.impl.ConfigurationImpl;
import org.jboss.messaging.core.exception.MessagingException;
import org.jboss.messaging.core.logging.Logger;
-import org.jboss.messaging.core.memory.MemoryManager;
-import org.jboss.messaging.core.memory.impl.SimpleMemoryManager;
import org.jboss.messaging.core.persistence.StorageManager;
-import org.jboss.messaging.core.persistence.impl.nullpm.NullStorageManager;
import org.jboss.messaging.core.postoffice.PostOffice;
import org.jboss.messaging.core.postoffice.impl.PostOfficeImpl;
import org.jboss.messaging.core.remoting.ConnectorRegistryFactory;
import org.jboss.messaging.core.remoting.Interceptor;
import org.jboss.messaging.core.remoting.PacketReturner;
import org.jboss.messaging.core.remoting.RemotingService;
-import org.jboss.messaging.core.remoting.impl.RemotingServiceImpl;
import org.jboss.messaging.core.remoting.impl.wireformat.CreateConnectionResponse;
import org.jboss.messaging.core.security.JBMSecurityManager;
import org.jboss.messaging.core.security.Role;
import org.jboss.messaging.core.security.SecurityStore;
-import org.jboss.messaging.core.security.impl.JBMSecurityManagerImpl;
import org.jboss.messaging.core.security.impl.SecurityStoreImpl;
import org.jboss.messaging.core.server.ConnectionManager;
import org.jboss.messaging.core.server.MessagingServer;
@@ -57,18 +59,11 @@
import org.jboss.messaging.util.OrderedExecutorFactory;
import org.jboss.messaging.util.VersionLoader;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.concurrent.*;
-
/**
- * A Messaging Server
- *
- * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
+ * The messaging server implementation
+ *
* @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @author <a href="mailto:juha at jboss.org">Juha Lindfors</a>
- * @author <a href="mailto:aslak at conduct.no">Aslak Knutsen</a>
* @author <a href="mailto:ataylor at redhat.com>Andy Taylor</a>
* @version <tt>$Revision: 3543 $</tt>
* <p/>
@@ -92,96 +87,104 @@
private SecurityStore securityStore;
private ConnectionManager connectionManager;
- private RemotingSessionListener sessionListener;
- private MemoryManager memoryManager = new SimpleMemoryManager();
+ private RemotingSessionListener sessionListener;
+ private HierarchicalRepository<QueueSettings> queueSettingsRepository;
+ private ScheduledExecutorService scheduledExecutor;
+ private QueueFactory queueFactory;
private PostOffice postOffice;
- private ExecutorFactory executorFactory;
private ExecutorService threadPool;
- private HierarchicalRepository<Set<Role>> securityRepository = new HierarchicalObjectRepository<Set<Role>>();
- private HierarchicalRepository<QueueSettings> queueSettingsRepository = new HierarchicalObjectRepository<QueueSettings>();
- private QueueFactory queueFactory;
- private ResourceManager resourceManager = new ResourceManagerImpl(0);
- private ScheduledExecutorService scheduledExecutor;
+ private ExecutorFactory executorFactory;
+ private HierarchicalRepository<Set<Role>> securityRepository;
+ private ResourceManager resourceManager;
private MessagingServerPacketHandler serverPacketHandler;
// plugins
- private StorageManager storageManager = new NullStorageManager();
+ private StorageManager storageManager;
private RemotingService remotingService;
- private JBMSecurityManager securityManager = new JBMSecurityManagerImpl(true);
- private boolean createTransport = false;
+ private JBMSecurityManager securityManager;
private Configuration configuration;
-
-
+
// Constructors ---------------------------------------------------------------------------------
- /**
- * typically called by the MC framework or embedded if the user want to create and start their own RemotingService
- */
public MessagingServerImpl()
{
//We need to hard code the version information into a source file
version = VersionLoader.load();
-
- //Default config
- configuration = new ConfigurationImpl();
}
-
- /**
- * called when the usewr wants the MessagingServer to handle the creation of the RemotingTransport
- *
- * @param configuration the configuration
- */
- public MessagingServerImpl(final Configuration configuration)
- {
- version = VersionLoader.load();
-
- this.configuration = configuration;
- createTransport = true;
- remotingService = new RemotingServiceImpl(configuration);
- }
// lifecycle methods ----------------------------------------------------------------
public synchronized void start() throws Exception
{
- log.debug("starting MessagingServer");
-
if (started)
{
return;
}
- log.debug(this + " starting");
+ /*
+ The following components are pluggable on the messaging server:
+ Configuration, StorageManager, RemotingService and SecurityManager
+ They must already be injected by the time the messaging server starts
+ It's up to the user to make sure the pluggable components are started - there
+ lifecycle will not be controlled here
+ */
+
+ //We make sure the pluggable components have been injected
+ if (configuration == null)
+ {
+ throw new IllegalStateException("Must inject Configuration before starting MessagingServer");
+ }
+
+ if (storageManager == null)
+ {
+ throw new IllegalStateException("Must inject StorageManager before starting MessagingServer");
+ }
+
+ if (remotingService == null)
+ {
+ throw new IllegalStateException("Must inject RemotingService before starting MessagingServer");
+ }
+
+ if (securityManager == null)
+ {
+ throw new IllegalStateException("Must inject SecurityManager before starting MessagingServer");
+ }
+
+ if (!storageManager.isStarted())
+ {
+ throw new IllegalStateException("StorageManager must be started before MessagingServer is started");
+ }
+
+ if (!remotingService.isStarted())
+ {
+ throw new IllegalStateException("RemotingService must be started before MessagingServer is started");
+ }
+
+ //The rest of the components are not pluggable and created and started here
- // Create the wired components
-
securityStore = new SecurityStoreImpl(configuration.getSecurityInvalidationInterval(), configuration.isSecurityEnabled());
- securityRepository.setDefault(new HashSet<Role>());
- securityStore.setSecurityRepository(securityRepository);
- securityStore.setSecurityManager(securityManager);
- queueSettingsRepository.setDefault(new QueueSettings());
- scheduledExecutor = new ScheduledThreadPoolExecutor(configuration.getScheduledThreadPoolMaxSize(), new JBMThreadFactory("JBM-scheduled-threads"));
- queueFactory = new QueueFactoryImpl(scheduledExecutor, queueSettingsRepository);
ConnectionManagerImpl cm = new ConnectionManagerImpl();
this.connectionManager = cm;
- this.sessionListener = cm;
- memoryManager = new SimpleMemoryManager();
+ this.sessionListener = cm;
+ queueSettingsRepository = new HierarchicalObjectRepository<QueueSettings>();
+ queueSettingsRepository.setDefault(new QueueSettings());
+ scheduledExecutor = new ScheduledThreadPoolExecutor(configuration.getScheduledThreadPoolMaxSize(), new JBMThreadFactory("JBM-scheduled-threads"));
+ queueFactory = new QueueFactoryImpl(scheduledExecutor, queueSettingsRepository);
postOffice = new PostOfficeImpl(storageManager, queueFactory, configuration.isRequireDestinations());
threadPool = Executors.newFixedThreadPool(configuration.getThreadPoolMaxSize(), new JBMThreadFactory("JBM-session-threads"));
- executorFactory = new OrderedExecutorFactory(threadPool);
-
- if (createTransport)
- {
- remotingService.start();
- }
- // Start the wired components
- remotingService.addRemotingSessionListener(sessionListener);
- memoryManager.start();
+ executorFactory = new OrderedExecutorFactory(threadPool);
+ securityRepository = new HierarchicalObjectRepository<Set<Role>>();
+ securityRepository.setDefault(new HashSet<Role>());
+ securityStore.setSecurityRepository(securityRepository);
+ securityStore.setSecurityManager(securityManager);
+
+ scheduledExecutor = new ScheduledThreadPoolExecutor(configuration.getScheduledThreadPoolMaxSize(), new JBMThreadFactory("JBM-scheduled-threads"));
+ resourceManager = new ResourceManagerImpl(0);
+ remotingService.addRemotingSessionListener(sessionListener);
postOffice.start();
- serverPacketHandler = new MessagingServerPacketHandler(this);
- getRemotingService().getDispatcher().register(serverPacketHandler);
+ serverPacketHandler = new MessagingServerPacketHandler(this);
ClassLoader loader = Thread.currentThread().getContextClassLoader();
for (String interceptorClass : configuration.getInterceptorClassNames())
{
@@ -195,8 +198,9 @@
log.warn("Error instantiating interceptor \"" + interceptorClass + "\"", e);
}
}
-
+ //Register the handler as the last thing - since after that users will be able to connect
started = true;
+ getRemotingService().getDispatcher().register(serverPacketHandler);
}
public synchronized void stop() throws Exception
@@ -205,28 +209,27 @@
{
return;
}
-
- log.info(this + " is Stopping. NOTE! Stopping the server peer cleanly will NOT cause failover to occur");
-
- started = false;
-
- // Stop the wired components
+
+ getRemotingService().getDispatcher().unregister(serverPacketHandler.getID());
remotingService.removeRemotingSessionListener(sessionListener);
+
+ securityStore = null;
connectionManager = null;
- memoryManager.stop();
- memoryManager = null;
+ sessionListener = null;
postOffice.stop();
postOffice = null;
- scheduledExecutor.shutdown();
- scheduledExecutor = null;
threadPool.shutdown();
- threadPool = null;
executorFactory = null;
- if (createTransport)
- {
- remotingService.stop();
- }
+ securityRepository = null;
+ securityStore = null;
+ queueSettingsRepository = null;
+ scheduledExecutor.shutdown();
+ queueFactory = null;
+ resourceManager = null;
+ serverPacketHandler = null;
ConnectorRegistryFactory.getRegistry().clear();
+
+ started = false;
}
// MessagingServer implementation -----------------------------------------------------------
@@ -312,14 +315,12 @@
}
public CreateConnectionResponse createConnection(final String username, final String password,
- final long remotingClientSessionID, final String clientAddress,
- final int incrementVersion,
+ final long remotingClientSessionID,
+ final int incrementingVersion,
final PacketReturner sender)
throws Exception
{
- log.trace("creating a new connection for user " + username);
-
- if (version.getIncrementingVersion() < incrementVersion)
+ if (version.getIncrementingVersion() < incrementingVersion)
{
throw new MessagingException(MessagingException.INCOMPATIBLE_CLIENT_SERVER_VERSIONS,
"client not compatible with version: " + version.getFullVersion());
@@ -333,7 +334,9 @@
final ServerConnection connection =
new ServerConnectionImpl(this, username, password,
- sender.getSessionID(), clientAddress);
+ sender.getSessionID());
+
+ connectionManager.registerConnection(sender.getSessionID(), connection);
remotingService.getDispatcher().register(new ServerConnectionPacketHandler(connection));
Modified: trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerPacketHandler.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerPacketHandler.java 2008-06-17 16:15:35 UTC (rev 4506)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerPacketHandler.java 2008-06-17 20:01:27 UTC (rev 4507)
@@ -74,8 +74,7 @@
CreateConnectionRequest request = (CreateConnectionRequest) packet;
CreateConnectionResponse createConnectionResponse = server.createConnection(request.getUsername(), request.getPassword(),
- request.getRemotingSessionID(),
- sender.getRemoteAddress(),
+ request.getRemotingSessionID(),
request.getVersion(),
sender);
response = createConnectionResponse;
Added: trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServiceImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServiceImpl.java (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServiceImpl.java 2008-06-17 20:01:27 UTC (rev 4507)
@@ -0,0 +1,105 @@
+/*
+ * 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.messaging.core.server.impl;
+
+import org.jboss.messaging.core.config.Configuration;
+import org.jboss.messaging.core.config.impl.ConfigurationImpl;
+import org.jboss.messaging.core.persistence.StorageManager;
+import org.jboss.messaging.core.persistence.impl.nullpm.NullStorageManager;
+import org.jboss.messaging.core.remoting.RemotingService;
+import org.jboss.messaging.core.remoting.impl.RemotingServiceImpl;
+import org.jboss.messaging.core.security.JBMSecurityManager;
+import org.jboss.messaging.core.security.impl.JBMSecurityManagerImpl;
+import org.jboss.messaging.core.server.MessagingServer;
+import org.jboss.messaging.core.server.MessagingService;
+
+/**
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
+ */
+public class MessagingServiceImpl implements MessagingService
+{
+ public static MessagingServiceImpl newNullStorageMessagingServer()
+ {
+ return newNullStorageMessagingServer(new ConfigurationImpl());
+ }
+
+ public static MessagingServiceImpl newNullStorageMessagingServer(final Configuration config)
+ {
+ StorageManager storageManager = new NullStorageManager();
+
+ RemotingService remotingService = new RemotingServiceImpl(config);
+
+ JBMSecurityManager securityManager = new JBMSecurityManagerImpl(true);
+
+ MessagingServer server = new MessagingServerImpl();
+
+ server.setConfiguration(config);
+
+ server.setStorageManager(storageManager);
+
+ server.setRemotingService(remotingService);
+
+ server.setSecurityManager(securityManager);
+
+ return new MessagingServiceImpl(server, storageManager, remotingService);
+ }
+
+ private final MessagingServer server;
+
+ private final StorageManager storageManager;
+
+ private final RemotingService remotingService;
+
+ public MessagingServiceImpl(final MessagingServer server, final StorageManager storageManager,
+ final RemotingService remotingService)
+ {
+ this.server = server;
+ this.storageManager = storageManager;
+ this.remotingService = remotingService;
+ }
+
+ public void start() throws Exception
+ {
+ storageManager.start();
+ remotingService.start();
+ server.start();
+ }
+
+ public void stop() throws Exception
+ {
+ remotingService.stop();
+ storageManager.stop();
+ server.stop();
+ }
+
+ public MessagingServer getServer()
+ {
+ return server;
+ }
+
+ public boolean isStarted()
+ {
+ return server.isStarted();
+ }
+}
Modified: trunk/src/main/org/jboss/messaging/core/server/impl/ServerConnectionImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/ServerConnectionImpl.java 2008-06-17 16:15:35 UTC (rev 4506)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/ServerConnectionImpl.java 2008-06-17 20:01:27 UTC (rev 4507)
@@ -21,7 +21,6 @@
*/
package org.jboss.messaging.core.server.impl;
-import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
@@ -30,6 +29,7 @@
import org.jboss.messaging.core.postoffice.PostOffice;
import org.jboss.messaging.core.remoting.PacketDispatcher;
import org.jboss.messaging.core.remoting.PacketReturner;
+import org.jboss.messaging.core.remoting.RemotingService;
import org.jboss.messaging.core.remoting.impl.wireformat.ConnectionCreateSessionResponseMessage;
import org.jboss.messaging.core.server.ConnectionManager;
import org.jboss.messaging.core.server.MessagingServer;
@@ -40,9 +40,7 @@
import org.jboss.messaging.util.SimpleString;
/**
- * Concrete implementation of ConnectionEndpoint.
- *
- * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
+ *
* @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
* @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
* @author <a href="ataylor at redhat.com">Andy Taylor</a>
@@ -68,10 +66,6 @@
private final long remotingClientSessionID;
- private final String clientAddress;
-
- private final long createdTime;
-
private final Set<ServerSession> sessions = new ConcurrentHashSet<ServerSession>();
private final Set<Queue> temporaryQueues = new ConcurrentHashSet<Queue>();
@@ -79,7 +73,7 @@
private final Set<SimpleString> temporaryDestinations = new ConcurrentHashSet<SimpleString>();
private final MessagingServer server;
-
+
private volatile boolean started;
//We cache some of the service locally
@@ -94,29 +88,24 @@
public ServerConnectionImpl(final MessagingServer server,
final String username, final String password,
- final long remotingClientSessionID,
- final String clientAddress)
+ final long remotingClientSessionID)
{
- this.id = server.getRemotingService().getDispatcher().generateID();
+ RemotingService rs = server.getRemotingService();
+ this.dispatcher = rs.getDispatcher();
+
+ this.id = dispatcher.generateID();
+
this.username = username;
this.password = password;
this.remotingClientSessionID = remotingClientSessionID;
- this.clientAddress = clientAddress;
-
started = false;
- createdTime = System.currentTimeMillis();
-
- server.getConnectionManager().registerConnection(remotingClientSessionID, this);
-
this.server = server;
- this.dispatcher = server.getRemotingService().getDispatcher();
-
this.postOffice = server.getPostOffice();
this.connectionManager = server.getConnectionManager();
@@ -136,10 +125,10 @@
public ConnectionCreateSessionResponseMessage createSession(final boolean xa, final boolean autoCommitSends,
final boolean autoCommitAcks,
- final PacketReturner sender) throws Exception
+ final PacketReturner returner) throws Exception
{
ServerSession session =
- new ServerSessionImpl(this, autoCommitSends, autoCommitAcks, xa, sender);
+ new ServerSessionImpl(this, autoCommitSends, autoCommitAcks, xa, returner);
sessions.add(session);
@@ -221,22 +210,36 @@
public void addTemporaryQueue(final Queue queue)
{
+ if (temporaryQueues.contains(queue))
+ {
+ throw new IllegalStateException("Connection already has temporary queue " + queue);
+ }
temporaryQueues.add(queue);
}
public void removeTemporaryQueue(final Queue queue)
{
- temporaryQueues.remove(queue);
+ if (!temporaryQueues.remove(queue))
+ {
+ throw new IllegalStateException("Cannot find temporary queue to remove " + queue);
+ }
}
public void addTemporaryDestination(final SimpleString address)
{
+ if (temporaryDestinations.contains(address))
+ {
+ throw new IllegalStateException("Connection already has temporary destination " + address);
+ }
temporaryDestinations.add(address);
}
public void removeTemporaryDestination(final SimpleString address)
{
- temporaryDestinations.remove(address);
+ if (!temporaryDestinations.remove(address))
+ {
+ throw new IllegalStateException("Cannot find temporary destination to remove " + address);
+ }
}
public boolean isStarted()
@@ -244,31 +247,26 @@
return started;
}
- public long getCreatedTime()
+ public long getClientSessionID()
{
- return createdTime;
+ return remotingClientSessionID;
}
-
- public String getClientAddress()
+
+ public Set<Queue> getTemporaryQueues()
{
- return clientAddress;
+ return new HashSet<Queue>(temporaryQueues);
}
-
- public long getCreated()
+
+ public Set<SimpleString> getTemporaryDestinations()
{
- return createdTime;
+ return new HashSet<SimpleString>(temporaryDestinations);
}
-
- public long getRemotingClientSessionID()
+
+ public Set<ServerSession> getSessions()
{
- return remotingClientSessionID;
+ return new HashSet<ServerSession>(sessions);
}
-
- public Collection<ServerSession> getSessions()
- {
- return sessions;
- }
-
+
// Public ---------------------------------------------------------------------------------------
public String toString()
Modified: trunk/src/main/org/jboss/messaging/core/server/impl/ServerSessionPacketHandler.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/ServerSessionPacketHandler.java 2008-06-17 16:15:35 UTC (rev 4506)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/ServerSessionPacketHandler.java 2008-06-17 20:01:27 UTC (rev 4507)
@@ -80,6 +80,18 @@
{
return session.getID();
}
+
+ public boolean equals(ServerSessionPacketHandler other)
+ {
+ if (other instanceof ServerSessionPacketHandler == false)
+ {
+ return false;
+ }
+
+ ServerSessionPacketHandler sother = (ServerSessionPacketHandler)other;
+
+ return sother.session.getID() == session.getID();
+ }
public Packet doHandle(final Packet packet, final PacketReturner sender) throws Exception
{
Modified: trunk/src/main/org/jboss/messaging/jms/server/JMSServerManager.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/server/JMSServerManager.java 2008-06-17 16:15:35 UTC (rev 4506)
+++ trunk/src/main/org/jboss/messaging/jms/server/JMSServerManager.java 2008-06-17 20:01:27 UTC (rev 4507)
@@ -2,11 +2,8 @@
import java.io.Serializable;
import java.util.List;
-import java.util.Set;
-import javax.jms.Message;
-
/**
* The JMS Management interface.
*
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/CoreClientTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/CoreClientTest.java 2008-06-17 16:15:35 UTC (rev 4506)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/CoreClientTest.java 2008-06-17 20:01:27 UTC (rev 4507)
@@ -1,17 +1,23 @@
package org.jboss.messaging.tests.integration;
-import java.util.concurrent.CountDownLatch;
-
import junit.framework.TestCase;
-import org.jboss.messaging.core.client.*;
+import org.jboss.messaging.core.client.ClientConnection;
+import org.jboss.messaging.core.client.ClientConnectionFactory;
+import org.jboss.messaging.core.client.ClientConsumer;
+import org.jboss.messaging.core.client.ClientMessage;
+import org.jboss.messaging.core.client.ClientProducer;
+import org.jboss.messaging.core.client.ClientSession;
+import org.jboss.messaging.core.client.ConnectionParams;
+import org.jboss.messaging.core.client.Location;
import org.jboss.messaging.core.client.impl.ClientConnectionFactoryImpl;
import org.jboss.messaging.core.client.impl.ClientMessageImpl;
+import org.jboss.messaging.core.client.impl.ConnectionParamsImpl;
import org.jboss.messaging.core.client.impl.LocationImpl;
-import org.jboss.messaging.core.client.impl.ConnectionParamsImpl;
import org.jboss.messaging.core.config.impl.ConfigurationImpl;
import org.jboss.messaging.core.remoting.TransportType;
-import org.jboss.messaging.core.server.impl.MessagingServerImpl;
+import org.jboss.messaging.core.server.MessagingService;
+import org.jboss.messaging.core.server.impl.MessagingServiceImpl;
import org.jboss.messaging.jms.client.JBossTextMessage;
import org.jboss.messaging.util.SimpleString;
@@ -23,7 +29,7 @@
// Attributes ----------------------------------------------------
private ConfigurationImpl conf;
- private MessagingServerImpl server;
+ private MessagingService messagingService;
// Static --------------------------------------------------------
@@ -40,14 +46,14 @@
conf.setSecurityEnabled(false);
conf.setTransport(TransportType.TCP);
conf.setHost("localhost");
- server = new MessagingServerImpl(conf);
- server.start();
+ messagingService = MessagingServiceImpl.newNullStorageMessagingServer(conf);
+ messagingService.start();
}
@Override
protected void tearDown() throws Exception
{
- server.stop();
+ messagingService.stop();
super.tearDown();
}
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/impl/ClientCrashTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/impl/ClientCrashTest.java 2008-06-17 16:15:35 UTC (rev 4506)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/impl/ClientCrashTest.java 2008-06-17 20:01:27 UTC (rev 4507)
@@ -21,18 +21,24 @@
*/
package org.jboss.messaging.tests.integration.core.remoting.impl;
+import static org.jboss.messaging.core.remoting.TransportType.TCP;
import junit.framework.TestCase;
-import org.jboss.messaging.core.client.*;
+
+import org.jboss.messaging.core.client.ClientConnection;
+import org.jboss.messaging.core.client.ClientConnectionFactory;
+import org.jboss.messaging.core.client.ClientConsumer;
+import org.jboss.messaging.core.client.ClientMessage;
+import org.jboss.messaging.core.client.ClientProducer;
+import org.jboss.messaging.core.client.ClientSession;
import org.jboss.messaging.core.client.impl.ClientConnectionFactoryImpl;
import org.jboss.messaging.core.client.impl.ClientMessageImpl;
import org.jboss.messaging.core.client.impl.LocationImpl;
import org.jboss.messaging.core.config.impl.ConfigurationImpl;
import org.jboss.messaging.core.logging.Logger;
import org.jboss.messaging.core.message.Message;
-import static org.jboss.messaging.core.remoting.TransportType.TCP;
import org.jboss.messaging.core.server.ConnectionManager;
-import org.jboss.messaging.core.server.MessagingServer;
-import org.jboss.messaging.core.server.impl.MessagingServerImpl;
+import org.jboss.messaging.core.server.MessagingService;
+import org.jboss.messaging.core.server.impl.MessagingServiceImpl;
import org.jboss.messaging.jms.client.JBossTextMessage;
import org.jboss.messaging.tests.unit.core.remoting.impl.ConfigurationHelper;
import org.jboss.messaging.tests.util.SpawnedVMSupport;
@@ -60,7 +66,7 @@
// Attributes ----------------------------------------------------
- private MessagingServer server;
+ private MessagingService messagingService;
private ClientConnectionFactory cf;
// Constructors --------------------------------------------------
@@ -158,8 +164,8 @@
config.getConnectionParams().setPingInterval(2000);
config.getConnectionParams().setPingTimeout(1000);
config.setSecurityEnabled(false);
- server = new MessagingServerImpl(config);
- server.start();
+ messagingService = MessagingServiceImpl.newNullStorageMessagingServer(config);
+ messagingService.start();
cf = new ClientConnectionFactoryImpl(new LocationImpl(TCP, "localhost", ConfigurationImpl.DEFAULT_PORT));
}
@@ -167,7 +173,7 @@
@Override
protected void tearDown() throws Exception
{
- server.stop();
+ messagingService.stop();
super.tearDown();
}
@@ -179,7 +185,7 @@
private void assertActiveConnections(int expectedActiveConnections)
throws Exception
{
- ConnectionManager cm = server.getConnectionManager();
+ ConnectionManager cm = messagingService.getServer().getConnectionManager();
assertEquals(expectedActiveConnections, cm.getActiveConnections().size());
}
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/impl/ClientExitTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/impl/ClientExitTest.java 2008-06-17 16:15:35 UTC (rev 4506)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/impl/ClientExitTest.java 2008-06-17 20:01:27 UTC (rev 4507)
@@ -21,7 +21,9 @@
*/
package org.jboss.messaging.tests.integration.core.remoting.impl;
+import static org.jboss.messaging.core.remoting.TransportType.TCP;
import junit.framework.TestCase;
+
import org.jboss.messaging.core.client.ClientConnection;
import org.jboss.messaging.core.client.ClientConnectionFactory;
import org.jboss.messaging.core.client.ClientConsumer;
@@ -31,9 +33,9 @@
import org.jboss.messaging.core.config.impl.ConfigurationImpl;
import org.jboss.messaging.core.logging.Logger;
import org.jboss.messaging.core.message.Message;
-import static org.jboss.messaging.core.remoting.TransportType.TCP;
-import org.jboss.messaging.core.server.MessagingServer;
+import org.jboss.messaging.core.server.MessagingService;
import org.jboss.messaging.core.server.impl.MessagingServerImpl;
+import org.jboss.messaging.core.server.impl.MessagingServiceImpl;
import org.jboss.messaging.tests.unit.core.remoting.impl.ConfigurationHelper;
import org.jboss.messaging.tests.util.SpawnedVMSupport;
import org.jboss.messaging.util.SimpleString;
@@ -64,7 +66,7 @@
// Attributes -----------------------------------------------------------------------------------
- private MessagingServer server;
+ private MessagingService messagingService;
private ClientConnection connection;
@@ -102,8 +104,8 @@
ConfigurationImpl config = ConfigurationHelper.newTCPConfiguration(
"localhost", ConfigurationImpl.DEFAULT_PORT);
config.setSecurityEnabled(false);
- server = new MessagingServerImpl(config);
- server.start();
+ messagingService = MessagingServiceImpl.newNullStorageMessagingServer(config);
+ messagingService.start();
ClientConnectionFactory cf = new ClientConnectionFactoryImpl(new LocationImpl(TCP, "localhost", ConfigurationImpl.DEFAULT_PORT));
connection = cf.createConnection(null, null);
@@ -119,7 +121,7 @@
consumer.close();
connection.close();
- server.stop();
+ messagingService.stop();
super.tearDown();
}
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/impl/PacketFilterTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/impl/PacketFilterTest.java 2008-06-17 16:15:35 UTC (rev 4506)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/impl/PacketFilterTest.java 2008-06-17 20:01:27 UTC (rev 4507)
@@ -7,8 +7,17 @@
package org.jboss.messaging.tests.integration.core.remoting.impl;
+import java.util.UUID;
+
import junit.framework.TestCase;
-import org.jboss.messaging.core.client.*;
+
+import org.jboss.messaging.core.client.ClientConnection;
+import org.jboss.messaging.core.client.ClientConnectionFactory;
+import org.jboss.messaging.core.client.ClientConsumer;
+import org.jboss.messaging.core.client.ClientMessage;
+import org.jboss.messaging.core.client.ClientProducer;
+import org.jboss.messaging.core.client.ClientSession;
+import org.jboss.messaging.core.client.Location;
import org.jboss.messaging.core.client.impl.ClientConnectionFactoryImpl;
import org.jboss.messaging.core.client.impl.ClientMessageImpl;
import org.jboss.messaging.core.client.impl.LocationImpl;
@@ -16,17 +25,16 @@
import org.jboss.messaging.core.logging.Logger;
import org.jboss.messaging.core.message.Message;
import org.jboss.messaging.core.remoting.TransportType;
-import org.jboss.messaging.core.server.impl.MessagingServerImpl;
+import org.jboss.messaging.core.server.MessagingService;
+import org.jboss.messaging.core.server.impl.MessagingServiceImpl;
import org.jboss.messaging.jms.client.JBossTextMessage;
import org.jboss.messaging.util.SimpleString;
-import java.util.UUID;
-
public class PacketFilterTest extends TestCase
{
Logger log = Logger.getLogger(PacketFilterTest.class);
- private MessagingServerImpl server;
+ private MessagingService messagingService;
private static final SimpleString QUEUE1 = new SimpleString("queue1");
@@ -42,16 +50,16 @@
config.setTransport(TransportType.TCP);
config.setHost("localhost");
config.setSecurityEnabled(false);
- server = new MessagingServerImpl(config);
- server.start();
+ messagingService = MessagingServiceImpl.newNullStorageMessagingServer(config);
+ messagingService.start();
}
protected void tearDown() throws Exception
{
- if(server != null)
+ if (messagingService != null)
{
- server.stop();
- server = null;
+ messagingService.stop();
+ messagingService = null;
}
}
@@ -69,7 +77,7 @@
// Deploy using the API
interceptorA = new DummyInterceptor();
- server.getRemotingService().addInterceptor(interceptorA);
+ messagingService.getServer().getRemotingService().addInterceptor(interceptorA);
interceptorA.sendException=true;
@@ -97,7 +105,7 @@
interceptorA.clearCounter();
DummyInterceptorB.clearCounter();
interceptorB = new DummyInterceptorB();
- server.getRemotingService().addInterceptor(interceptorB);
+ messagingService.getServer().getRemotingService().addInterceptor(interceptorB);
conn = cf.createConnection();
conn.createClientSession(false, true, true, -1, false, false);
conn.close();
@@ -109,7 +117,7 @@
interceptorA.clearCounter();
DummyInterceptorB.clearCounter();
- server.getRemotingService().removeInterceptor(interceptorA);
+ messagingService.getServer().getRemotingService().removeInterceptor(interceptorA);
conn = cf.createConnection();
conn.createClientSession(false, true, true, -1, false, false);
@@ -121,7 +129,7 @@
log.info("Undeploying server");
- server.getRemotingService().removeInterceptor(interceptorB);
+ messagingService.getServer().getRemotingService().removeInterceptor(interceptorB);
interceptorB = null;
interceptorA.clearCounter();
DummyInterceptorB.clearCounter();
@@ -144,11 +152,11 @@
}
if (interceptorA != null)
{
- server.getRemotingService().removeInterceptor(interceptorA);
+ messagingService.getServer().getRemotingService().removeInterceptor(interceptorA);
}
if (interceptorB != null)
{
- try{server.getRemotingService().removeInterceptor(interceptorB);} catch (Exception ignored){}
+ try{messagingService.getServer().getRemotingService().removeInterceptor(interceptorB);} catch (Exception ignored){}
}
}
}
@@ -163,8 +171,8 @@
{
interceptor = new DummyInterceptor();
- server.getRemotingService().addInterceptor(interceptor);
- server.getPostOffice().addBinding(QUEUE1, QUEUE1, null, false, false);
+ messagingService.getServer().getRemotingService().addInterceptor(interceptor);
+ messagingService.getServer().getPostOffice().addBinding(QUEUE1, QUEUE1, null, false, false);
interceptor.sendException=false;
@@ -208,7 +216,7 @@
{
if (interceptor != null)
{
- server.getRemotingService().removeInterceptor(interceptor);
+ messagingService.getServer().getRemotingService().removeInterceptor(interceptor);
}
}
catch (Exception ignored)
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/mina/ClientPingTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/mina/ClientPingTest.java 2008-06-17 16:15:35 UTC (rev 4506)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/mina/ClientPingTest.java 2008-06-17 20:01:27 UTC (rev 4507)
@@ -6,7 +6,15 @@
*/
package org.jboss.messaging.tests.integration.core.remoting.mina;
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
+import static org.jboss.messaging.core.remoting.TransportType.TCP;
+import static org.jboss.messaging.tests.util.RandomUtil.randomLong;
+
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.atomic.AtomicLong;
+
import junit.framework.TestCase;
+
import org.jboss.messaging.core.client.ConnectionParams;
import org.jboss.messaging.core.client.RemotingSessionListener;
import org.jboss.messaging.core.client.impl.ConnectionParamsImpl;
@@ -17,19 +25,14 @@
import org.jboss.messaging.core.remoting.PacketHandler;
import org.jboss.messaging.core.remoting.PacketReturner;
import org.jboss.messaging.core.remoting.RemotingSession;
-import static org.jboss.messaging.core.remoting.TransportType.TCP;
import org.jboss.messaging.core.remoting.impl.PacketDispatcherImpl;
import org.jboss.messaging.core.remoting.impl.mina.MinaConnector;
import org.jboss.messaging.core.remoting.impl.wireformat.Pong;
-import org.jboss.messaging.core.server.MessagingServer;
+import org.jboss.messaging.core.server.MessagingService;
import org.jboss.messaging.core.server.impl.MessagingServerImpl;
+import org.jboss.messaging.core.server.impl.MessagingServiceImpl;
import org.jboss.messaging.tests.unit.core.remoting.impl.ConfigurationHelper;
-import static org.jboss.messaging.tests.util.RandomUtil.randomLong;
-import java.util.concurrent.CountDownLatch;
-import static java.util.concurrent.TimeUnit.MILLISECONDS;
-import java.util.concurrent.atomic.AtomicLong;
-
/**
* @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
* @version <tt>$Revision$</tt>
@@ -40,7 +43,7 @@
// Attributes ----------------------------------------------------
- private MessagingServer messagingServer;
+ private MessagingService messagingService;
// Static --------------------------------------------------------
@@ -54,14 +57,14 @@
ConfigurationImpl config = ConfigurationHelper.newTCPConfiguration("localhost", TestSupport.PORT);
config.getConnectionParams().setPingInterval(TestSupport.PING_INTERVAL);
config.getConnectionParams().setPingTimeout(TestSupport.PING_TIMEOUT);
- messagingServer = new MessagingServerImpl(config);
- messagingServer.start();
+ messagingService = MessagingServiceImpl.newNullStorageMessagingServer(config);
+ messagingService.start();
}
@Override
protected void tearDown() throws Exception
{
- messagingServer.stop();
+ messagingService.stop();
}
public void testKeepAliveWithClientOK() throws Exception
@@ -75,7 +78,7 @@
latch.countDown();
}
};
- messagingServer.getRemotingService().addRemotingSessionListener(listener);
+ messagingService.getServer().getRemotingService().addRemotingSessionListener(listener);
ConnectionParams connectionParams = new ConnectionParamsImpl();
connectionParams.setPingInterval(TestSupport.PING_INTERVAL);
connectionParams.setPingTimeout(TestSupport.PING_TIMEOUT);
@@ -86,7 +89,7 @@
+ TestSupport.PING_TIMEOUT + 2000, MILLISECONDS);
assertFalse(firedKeepAliveNotification);
- messagingServer.getRemotingService().removeRemotingSessionListener(listener);
+ messagingService.getServer().getRemotingService().removeRemotingSessionListener(listener);
//connector.disconnect();
// verify(factory);
@@ -106,7 +109,7 @@
latch.countDown();
}
};
- messagingServer.getRemotingService().addRemotingSessionListener(listener);
+ messagingService.getServer().getRemotingService().addRemotingSessionListener(listener);
ConnectionParams connectionParams = new ConnectionParamsImpl();
connectionParams.setPingInterval(TestSupport.PING_INTERVAL);
connectionParams.setPingTimeout(TestSupport.PING_TIMEOUT);
@@ -124,7 +127,7 @@
assertNotNull(clientSessionIDNotResponding[0]);
//assertEquals(clientSessionID, clientSessionIDNotResponding[0]);
- messagingServer.getRemotingService().removeRemotingSessionListener(listener);
+ messagingService.getServer().getRemotingService().removeRemotingSessionListener(listener);
connector.disconnect();
}
@@ -184,14 +187,14 @@
latch.countDown();
}
};
- messagingServer.getRemotingService().addRemotingSessionListener(listener);
+ messagingService.getServer().getRemotingService().addRemotingSessionListener(listener);
boolean firedKeepAliveNotification = latch.await(TestSupport.PING_INTERVAL
+ TestSupport.PING_TIMEOUT + 2000, MILLISECONDS);
assertTrue("notification has not been received", firedKeepAliveNotification);
//assertEquals(clientSessionID, clientSessionIDNotResponding.longValue());
- messagingServer.getRemotingService().removeRemotingSessionListener(listener);
+ messagingService.getServer().getRemotingService().removeRemotingSessionListener(listener);
connector.disconnect();
}
@@ -221,7 +224,7 @@
};
//assign this after we have connected to replace the pong handler
PacketHandler notRespondingPacketHandler = new NotRespondingPacketHandler();
- messagingServer.getRemotingService().addRemotingSessionListener(listener);
+ messagingService.getServer().getRemotingService().addRemotingSessionListener(listener);
ConnectionParams connectionParams = new ConnectionParamsImpl();
connectionParams.setPingInterval(TestSupport.PING_INTERVAL);
connectionParams.setPingTimeout(TestSupport.PING_TIMEOUT);
@@ -244,7 +247,7 @@
//assertEquals(clientSessionIDNotResponding, sessionIDNotResponding.longValue());
assertNotSame(clientSessionIDResponding, sessionIDNotResponding.longValue());
- messagingServer.getRemotingService().removeRemotingSessionListener(listener);
+ messagingService.getServer().getRemotingService().removeRemotingSessionListener(listener);
connectorNotResponding.disconnect();
connectorResponding.disconnect();
}
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/ssl/CoreClientOverSSLTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/ssl/CoreClientOverSSLTest.java 2008-06-17 16:15:35 UTC (rev 4506)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/ssl/CoreClientOverSSLTest.java 2008-06-17 20:01:27 UTC (rev 4507)
@@ -21,21 +21,25 @@
*/
package org.jboss.messaging.tests.integration.core.remoting.ssl;
+import static java.lang.Boolean.FALSE;
import junit.framework.TestCase;
-import org.jboss.messaging.core.client.*;
+
+import org.jboss.messaging.core.client.ClientConnection;
+import org.jboss.messaging.core.client.ClientConnectionFactory;
+import org.jboss.messaging.core.client.ClientConsumer;
+import org.jboss.messaging.core.client.ClientSession;
+import org.jboss.messaging.core.client.ConnectionParams;
import org.jboss.messaging.core.client.impl.ClientConnectionFactoryImpl;
import org.jboss.messaging.core.client.impl.ConnectionParamsImpl;
import org.jboss.messaging.core.config.impl.ConfigurationImpl;
import org.jboss.messaging.core.logging.Logger;
import org.jboss.messaging.core.message.Message;
-import org.jboss.messaging.core.server.MessagingServer;
-import org.jboss.messaging.core.server.impl.MessagingServerImpl;
+import org.jboss.messaging.core.server.MessagingService;
+import org.jboss.messaging.core.server.impl.MessagingServiceImpl;
import org.jboss.messaging.tests.unit.core.remoting.impl.ConfigurationHelper;
import org.jboss.messaging.tests.util.SpawnedVMSupport;
import org.jboss.messaging.util.SimpleString;
-import static java.lang.Boolean.FALSE;
-
/**
* @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
*
@@ -57,7 +61,7 @@
// Attributes ----------------------------------------------------
- private MessagingServer server;
+ private MessagingService messagingService;
private ClientConnection connection;
@@ -125,8 +129,8 @@
config.setTrustStorePath("messaging.truststore");
config.setTrustStorePassword("secureexample");
- server = new MessagingServerImpl(config);
- server.start();
+ messagingService = MessagingServiceImpl.newNullStorageMessagingServer(config);
+ messagingService.start();
ConnectionParams connectionParams = new ConnectionParamsImpl();
connectionParams.setSSLEnabled(true);
connectionParams.setKeyStorePath("messaging.keystore");
@@ -147,7 +151,7 @@
consumer.close();
connection.close();
- server.stop();
+ messagingService.stop();
super.tearDown();
}
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/jms/server/impl/JMSServerManagerimplTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/jms/server/impl/JMSServerManagerimplTest.java 2008-06-17 16:15:35 UTC (rev 4506)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/jms/server/impl/JMSServerManagerimplTest.java 2008-06-17 20:01:27 UTC (rev 4507)
@@ -35,8 +35,8 @@
import org.jboss.messaging.core.config.impl.ConfigurationImpl;
import org.jboss.messaging.core.management.impl.MessagingServerManagementImpl;
-import org.jboss.messaging.core.server.MessagingServer;
-import org.jboss.messaging.core.server.impl.MessagingServerImpl;
+import org.jboss.messaging.core.server.MessagingService;
+import org.jboss.messaging.core.server.impl.MessagingServiceImpl;
import org.jboss.messaging.jms.client.JBossConnectionFactory;
import org.jboss.messaging.jms.server.impl.JMSServerManagerImpl;
@@ -48,7 +48,7 @@
{
private JMSServerManagerImpl jmsServerManager;
private InitialContext initialContext;
- private MessagingServer messagingServer;
+ private MessagingService messagingService;
protected void setUp() throws Exception
{
@@ -57,10 +57,10 @@
ConfigurationImpl conf = new ConfigurationImpl();
conf.getConnectionParams().setInVMOptimisationEnabled(true);
conf.setTransport(INVM);
- messagingServer = new MessagingServerImpl(conf);
- messagingServer.start();
+ messagingService = MessagingServiceImpl.newNullStorageMessagingServer(conf);
+ messagingService.start();
jmsServerManager.setMessagingServerManagement(messagingServerManagement);
- messagingServerManagement.setMessagingServer(messagingServer);
+ messagingServerManagement.setMessagingServer(messagingService.getServer());
Hashtable env = new Hashtable();
env.put("java.naming.factory.initial",
"org.jboss.messaging.tests.util.InVMSingleInitialContextFactory");
@@ -71,9 +71,9 @@
protected void tearDown() throws Exception
{
//InVMInitialContextFactory.reset();
- messagingServer.stop();
+ messagingService.stop();
jmsServerManager = null;
- messagingServer = null;
+ messagingService = null;
}
public void testIsStarted()
Modified: trunk/tests/src/org/jboss/messaging/tests/performance/persistence/fakes/FakePostOffice.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/performance/persistence/fakes/FakePostOffice.java 2008-06-17 16:15:35 UTC (rev 4506)
+++ trunk/tests/src/org/jboss/messaging/tests/performance/persistence/fakes/FakePostOffice.java 2008-06-17 20:01:27 UTC (rev 4507)
@@ -1,3 +1,24 @@
+/*
+ * 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.messaging.tests.performance.persistence.fakes;
import java.util.List;
@@ -16,19 +37,23 @@
import org.jboss.messaging.util.ConcurrentHashSet;
import org.jboss.messaging.util.SimpleString;
-
-
-/** Maybe this Fake should be moved to postoffice.fakes, but since this
- * Fake only has the basic needed for StorageManagerTest, I have left it here for now */
+/**
+ *
+ * A FakePostOffice
+ *
+ * @author <a href="mailto:clebert.suconic at jboss.com">Clebert Suconic</a>
+ *
+ */
public class FakePostOffice implements PostOffice
{
-
- ConcurrentHashMap<SimpleString, Binding> bindings = new ConcurrentHashMap<SimpleString, Binding>();
+ private ConcurrentHashMap<SimpleString, Binding> bindings = new ConcurrentHashMap<SimpleString, Binding>();
- QueueFactory queueFactory = new FakeQueueFactory();
+ private QueueFactory queueFactory = new FakeQueueFactory();
- ConcurrentHashSet<SimpleString> addresses = new ConcurrentHashSet<SimpleString>();
+ private ConcurrentHashSet<SimpleString> addresses = new ConcurrentHashSet<SimpleString>();
+ private volatile boolean started;
+
public Binding addBinding(SimpleString address, SimpleString queueName,
Filter filter, boolean durable, boolean temporary) throws Exception
{
@@ -89,15 +114,18 @@
public void start() throws Exception
{
- // TODO Auto-generated method stub
-
+ started = true;
}
public void stop() throws Exception
{
- // TODO Auto-generated method stub
-
+ started = false;
}
+
+ public boolean isStarted()
+ {
+ return started;
+ }
public List<org.jboss.messaging.core.server.MessageReference> route(
ServerMessage message) throws Exception
Modified: trunk/tests/src/org/jboss/messaging/tests/performance/persistence/impl/StorageManagerTimingTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/performance/persistence/impl/StorageManagerTimingTest.java 2008-06-17 16:15:35 UTC (rev 4506)
+++ trunk/tests/src/org/jboss/messaging/tests/performance/persistence/impl/StorageManagerTimingTest.java 2008-06-17 20:01:27 UTC (rev 4507)
@@ -29,7 +29,6 @@
import org.jboss.messaging.core.asyncio.impl.AsynchronousFileImpl;
import org.jboss.messaging.core.config.impl.FileConfiguration;
import org.jboss.messaging.core.logging.Logger;
-import org.jboss.messaging.core.message.impl.MessageImpl;
import org.jboss.messaging.core.persistence.impl.journal.JournalStorageManager;
import org.jboss.messaging.core.remoting.impl.mina.IoBufferWrapper;
import org.jboss.messaging.core.server.JournalType;
@@ -41,7 +40,6 @@
public class StorageManagerTimingTest extends UnitTestCase
{
-
private static final Logger log = Logger.getLogger(StorageManagerTimingTest.class);
protected void tearDown() throws Exception
@@ -50,7 +48,6 @@
assertEquals(0, AsynchronousFileImpl.getTotalMaxIO());
}
-
public void testAIO() throws Exception
{
// just to do some initial loading.. ignore this rate
@@ -107,8 +104,7 @@
rates = internalTestStorage(JournalType.NIO, 5000, 1, 5);
printRates("Rate of NIO, 5000 inserts / commit on every insert", rates);
-
-
+
}
public double[] internalTestStorage(final JournalType journalType,
@@ -216,8 +212,7 @@
try
{
LocalThread[] threads = new LocalThread[numberOfThreads];
-
-
+
for (int i = 0; i < numberOfThreads; i++)
{
threads[i] = new LocalThread(i);
@@ -256,12 +251,12 @@
}
}
-
private void printRates(String msg, double rate)
{
printRates(msg, new double[] { rate });
}
+
private void printRates(String msg, double[] rates)
{
double rate = 0;
@@ -283,6 +278,4 @@
log.info( " Total rate : = " + totalRate + " inserts/sec (including commits)");
log.info("*************************************************************************");
}
-
-
}
Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/ConnectionManagerTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/ConnectionManagerTest.java 2008-06-17 16:15:35 UTC (rev 4506)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/ConnectionManagerTest.java 2008-06-17 20:01:27 UTC (rev 4507)
@@ -22,19 +22,19 @@
package org.jboss.messaging.tests.unit.core.remoting.impl;
-import org.jboss.messaging.core.remoting.TransportType;
-import org.jboss.messaging.core.server.ConnectionManager;
-import org.jboss.messaging.core.server.impl.MessagingServerImpl;
-import static org.jboss.messaging.core.remoting.TransportType.INVM;
-import org.jboss.messaging.core.client.ClientConnectionFactory;
+import junit.framework.TestCase;
+
import org.jboss.messaging.core.client.ClientConnection;
+import org.jboss.messaging.core.client.ClientConnectionFactory;
import org.jboss.messaging.core.client.impl.ClientConnectionFactoryImpl;
import org.jboss.messaging.core.client.impl.LocationImpl;
-import org.jboss.messaging.core.config.Configuration;
import org.jboss.messaging.core.config.impl.ConfigurationImpl;
+import org.jboss.messaging.core.remoting.TransportType;
+import org.jboss.messaging.core.server.ConnectionManager;
+import org.jboss.messaging.core.server.MessagingService;
+import org.jboss.messaging.core.server.impl.MessagingServerImpl;
+import org.jboss.messaging.core.server.impl.MessagingServiceImpl;
-import junit.framework.TestCase;
-
/**
* @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
*
@@ -48,7 +48,7 @@
// Static --------------------------------------------------------
// Attributes ----------------------------------------------------
- private MessagingServerImpl server;
+ private MessagingService messagingService;
// Constructors --------------------------------------------------
public ConnectionManagerTest(String name)
@@ -60,16 +60,16 @@
{
ConfigurationImpl config = new ConfigurationImpl();
config.setTransport(TransportType.INVM);
- server = new MessagingServerImpl(config);
- server.start();
+ messagingService = MessagingServiceImpl.newNullStorageMessagingServer(config);
+ messagingService.start();
}
protected void tearDown() throws Exception
{
- if(server != null)
+ if (messagingService != null)
{
- server.stop();
- server = null;
+ messagingService.stop();
+ messagingService = null;
}
}
@@ -107,8 +107,7 @@
private void assertActiveConnectionsOnTheServer(int expectedSize)
throws Exception
{
- ConnectionManager cm = server
- .getConnectionManager();
+ ConnectionManager cm = messagingService.getServer().getConnectionManager();
assertEquals(expectedSize, cm.getActiveConnections().size());
}
Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/INVMServerTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/INVMServerTest.java 2008-06-17 16:15:35 UTC (rev 4506)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/INVMServerTest.java 2008-06-17 20:01:27 UTC (rev 4507)
@@ -1,26 +1,24 @@
package org.jboss.messaging.tests.unit.core.remoting.impl;
-import org.jboss.messaging.core.client.ClientConnection;
+import junit.framework.TestCase;
+
import org.jboss.messaging.core.client.ClientConnectionFactory;
-import org.jboss.messaging.core.client.Location;
import org.jboss.messaging.core.client.impl.ClientConnectionFactoryImpl;
import org.jboss.messaging.core.client.impl.ClientConnectionInternal;
import org.jboss.messaging.core.client.impl.LocationImpl;
import org.jboss.messaging.core.config.impl.ConfigurationImpl;
import org.jboss.messaging.core.remoting.TransportType;
-import org.jboss.messaging.core.server.impl.MessagingServerImpl;
-import org.jboss.messaging.jms.client.JBossConnection;
+import org.jboss.messaging.core.server.MessagingService;
+import org.jboss.messaging.core.server.impl.MessagingServiceImpl;
-import junit.framework.TestCase;
-
public class INVMServerTest extends TestCase
{
// Constants -----------------------------------------------------
// Attributes ----------------------------------------------------
- private MessagingServerImpl server_1;
- private MessagingServerImpl server_2;
+ private MessagingService service_1;
+ private MessagingService service_2;
// Static --------------------------------------------------------
@@ -54,21 +52,21 @@
ConfigurationImpl config = new ConfigurationImpl();
config.setServerID(0);
config.setTransport(TransportType.INVM);
- server_1 = new MessagingServerImpl(config);
- server_1.start();
+ service_1 = MessagingServiceImpl.newNullStorageMessagingServer(config);
+ service_1.start();
config = new ConfigurationImpl();
config.setServerID(1);
config.setTransport(TransportType.INVM);
- server_2 = new MessagingServerImpl(config);
- server_2.start();
+ service_2 = MessagingServiceImpl.newNullStorageMessagingServer(config);
+ service_2.start();
}
@Override
protected void tearDown() throws Exception
{
- server_1.stop();
- server_2.stop();
+ service_1.stop();
+ service_2.stop();
super.tearDown();
}
Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/network/ClientNetworkFailureTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/network/ClientNetworkFailureTest.java 2008-06-17 16:15:35 UTC (rev 4506)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/network/ClientNetworkFailureTest.java 2008-06-17 20:01:27 UTC (rev 4507)
@@ -21,7 +21,17 @@
*/
package org.jboss.messaging.tests.unit.core.remoting.network;
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
+import static org.jboss.messaging.core.remoting.TransportType.TCP;
+import static org.jboss.messaging.tests.integration.core.remoting.mina.TestSupport.PING_INTERVAL;
+import static org.jboss.messaging.tests.integration.core.remoting.mina.TestSupport.PING_TIMEOUT;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.concurrent.CountDownLatch;
+
import junit.framework.TestCase;
+
import org.jboss.messaging.core.client.ClientConnection;
import org.jboss.messaging.core.client.ClientConnectionFactory;
import org.jboss.messaging.core.client.RemotingSessionListener;
@@ -32,20 +42,13 @@
import org.jboss.messaging.core.logging.Logger;
import org.jboss.messaging.core.remoting.Acceptor;
import org.jboss.messaging.core.remoting.TransportType;
-import static org.jboss.messaging.core.remoting.TransportType.TCP;
import org.jboss.messaging.core.remoting.impl.RemotingServiceImpl;
import org.jboss.messaging.core.remoting.impl.mina.MinaAcceptor;
import org.jboss.messaging.core.server.ConnectionManager;
-import org.jboss.messaging.core.server.MessagingServer;
+import org.jboss.messaging.core.server.MessagingService;
import org.jboss.messaging.core.server.impl.MessagingServerImpl;
-import static org.jboss.messaging.tests.integration.core.remoting.mina.TestSupport.PING_INTERVAL;
-import static org.jboss.messaging.tests.integration.core.remoting.mina.TestSupport.PING_TIMEOUT;
+import org.jboss.messaging.core.server.impl.MessagingServiceImpl;
-import java.io.IOException;
-import java.util.List;
-import java.util.concurrent.CountDownLatch;
-import static java.util.concurrent.TimeUnit.MILLISECONDS;
-
/**
* @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
* @version <tt>$Revision$</tt>
@@ -55,7 +58,7 @@
// Constants -----------------------------------------------------
Logger log = Logger.getLogger(ClientNetworkFailureTest.class);
- private MessagingServer server;
+ private MessagingService messagingService;
private RemotingServiceImpl minaService;
private NetworkFailureFilter networkFailureFilter;
@@ -81,9 +84,9 @@
newConfig.setTransport(TransportType.TCP);
newConfig.getConnectionParams().setPingInterval(PING_INTERVAL);
newConfig.getConnectionParams().setPingTimeout(PING_TIMEOUT);
- server = new MessagingServerImpl(newConfig);
- server.start();
- minaService = (RemotingServiceImpl) server.getRemotingService();
+ messagingService = MessagingServiceImpl.newNullStorageMessagingServer(newConfig);
+ messagingService.start();
+ minaService = (RemotingServiceImpl) messagingService.getServer().getRemotingService();
networkFailureFilter = new NetworkFailureFilter();
List<Acceptor> acceptor = minaService.getAcceptors();
MinaAcceptor minaAcceptor = (MinaAcceptor) acceptor.get(0);
@@ -97,8 +100,7 @@
protected void tearDown() throws Exception
{
assertActiveConnectionsOnTheServer(0);
- server.stop();
- //minaService.start();
+ messagingService.stop();
super.tearDown();
}
@@ -207,8 +209,7 @@
private void assertActiveConnectionsOnTheServer(int expectedSize)
throws Exception
{
- ConnectionManager cm = server
- .getConnectionManager();
+ ConnectionManager cm = messagingService.getServer().getConnectionManager();
assertEquals(expectedSize, cm.getActiveConnections().size());
}
}
Modified: trunk/tests/src/org/jboss/messaging/tests/unit/jms/misc/ManifestTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/jms/misc/ManifestTest.java 2008-06-17 16:15:35 UTC (rev 4506)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/jms/misc/ManifestTest.java 2008-06-17 20:01:27 UTC (rev 4507)
@@ -82,8 +82,7 @@
{
ConfigurationImpl config = new ConfigurationImpl();
config.setTransport(INVM);
- MessagingServer server = new MessagingServerImpl(config);
- //server.getVersion()
+ MessagingServer server = new MessagingServerImpl();
ConnectionMetaData meta = new JBossConnectionMetaData(server.getVersion());
More information about the jboss-cvs-commits
mailing list