[jboss-cvs] JBoss Messaging SVN: r3612 - in trunk: docs/examples/bridge and 40 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Jan 22 10:47:51 EST 2008


Author: ataylor
Date: 2008-01-22 10:47:50 -0500 (Tue, 22 Jan 2008)
New Revision: 3612

Added:
   trunk/src/main/org/jboss/jms/jndi/
   trunk/src/main/org/jboss/jms/jndi/JNDIObjectDeployer.java
   trunk/src/main/org/jboss/messaging/core/QueueSettings.java
   trunk/src/main/org/jboss/messaging/deployers/
   trunk/src/main/org/jboss/messaging/deployers/Deployable.java
   trunk/src/main/org/jboss/messaging/deployers/Deployer.java
   trunk/src/main/org/jboss/messaging/deployers/DeploymentManager.java
   trunk/src/main/org/jboss/messaging/deployers/queue/
   trunk/src/main/org/jboss/messaging/deployers/queue/QueueSettingsDeployer.java
   trunk/src/main/org/jboss/messaging/deployers/security/
   trunk/src/main/org/jboss/messaging/deployers/security/SecurityDeployer.java
   trunk/src/main/org/jboss/messaging/util/HierarchicalObjectRepository.java
   trunk/src/main/org/jboss/messaging/util/HierarchicalRepository.java
   trunk/src/main/org/jboss/messaging/util/Match.java
   trunk/tests/src/org/jboss/jms/server/deployer/
   trunk/tests/src/org/jboss/jms/server/deployer/test/
   trunk/tests/src/org/jboss/jms/server/deployer/test/unit/
   trunk/tests/src/org/jboss/jms/server/deployer/test/unit/DeployerTest.java
   trunk/tests/src/org/jboss/jms/server/destination/
   trunk/tests/src/org/jboss/jms/server/destination/settings/
   trunk/tests/src/org/jboss/jms/server/destination/settings/test/
   trunk/tests/src/org/jboss/jms/server/destination/settings/test/unit/
   trunk/tests/src/org/jboss/jms/server/destination/settings/test/unit/QueueSettingsDeployerTest.java
   trunk/tests/src/org/jboss/jms/server/security/
   trunk/tests/src/org/jboss/jms/server/security/test/
   trunk/tests/src/org/jboss/jms/server/security/test/unit/
   trunk/tests/src/org/jboss/jms/server/security/test/unit/SecurityDeployerTest.java
   trunk/tests/src/org/jboss/jms/server/security/test/unit/SecurityRepositoryTest.java
Removed:
   trunk/src/main/org/jboss/jms/server/ConnectionFactoryManager.java
   trunk/src/main/org/jboss/jms/server/DestinationJNDIMapper.java
   trunk/src/main/org/jboss/jms/server/DestinationManager.java
   trunk/src/main/org/jboss/jms/server/connectionfactory/ConnectionFactoryDeployer.java
   trunk/src/main/org/jboss/jms/server/connectionfactory/ConnectionFactoryJNDIMapper.java
   trunk/src/main/org/jboss/jms/server/destination/
   trunk/src/main/org/jboss/jms/server/security/SecurityMetadata.java
Modified:
   trunk/build-messaging.xml
   trunk/docs/examples/bridge/build.xml
   trunk/docs/examples/distributed-queue/build.xml
   trunk/docs/examples/distributed-topic/build.xml
   trunk/docs/examples/ejb3mdb/build.xml
   trunk/docs/examples/queue-failover/build.xml
   trunk/docs/examples/queue/build.xml
   trunk/docs/examples/secure-socket/build.xml
   trunk/docs/examples/stateless-clustered/build.xml
   trunk/docs/examples/stateless/build.xml
   trunk/docs/examples/topic/build.xml
   trunk/messaging.iml
   trunk/messaging.ipr
   trunk/src/etc/server/default/deploy/jbm-beans.xml
   trunk/src/etc/server/default/deploy/jbm-configuration.xml
   trunk/src/main/org/jboss/jms/server/SecurityStore.java
   trunk/src/main/org/jboss/jms/server/connectionfactory/ConnectionFactory.java
   trunk/src/main/org/jboss/jms/server/container/SecurityAspect.java
   trunk/src/main/org/jboss/jms/server/endpoint/ServerConnectionFactoryEndpoint.java
   trunk/src/main/org/jboss/jms/server/endpoint/ServerSessionEndpoint.java
   trunk/src/main/org/jboss/jms/server/security/Role.java
   trunk/src/main/org/jboss/jms/server/security/SecurityMetadataStore.java
   trunk/src/main/org/jboss/messaging/core/MessagingServer.java
   trunk/src/main/org/jboss/messaging/core/MessagingServerManagement.java
   trunk/src/main/org/jboss/messaging/core/QueueFactory.java
   trunk/src/main/org/jboss/messaging/core/impl/QueueFactoryImpl.java
   trunk/src/main/org/jboss/messaging/core/impl/server/MessagingServerImpl.java
   trunk/src/main/org/jboss/messaging/core/impl/server/MessagingServerManagementImpl.java
   trunk/tests/src/org/jboss/test/messaging/JBMServerTestCase.java
   trunk/tests/src/org/jboss/test/messaging/tools/ServerManagement.java
   trunk/tests/src/org/jboss/test/messaging/tools/container/LocalTestServer.java
   trunk/tests/src/org/jboss/test/messaging/tools/container/Server.java
   trunk/util/release-admin.xml
Log:
removal of jndi and first pass of new configuration

Modified: trunk/build-messaging.xml
===================================================================
--- trunk/build-messaging.xml	2008-01-22 13:47:58 UTC (rev 3611)
+++ trunk/build-messaging.xml	2008-01-22 15:47:50 UTC (rev 3612)
@@ -305,6 +305,12 @@
     <target name="deploy" depends="jar, sar">
         <copy file="${build.lib}/jboss-${module.name}.jar"
             todir="${jboss.home}/server/${jboss.config}/lib"/>
+       <copy file="${source.etc}/server/default/deploy/jbm-configuration.xml"
+            todir="${jboss.home}/server/${jboss.config}/conf"/>
+       <copy file="${source.etc}/server/default/deploy/jbm-jndi.xml"
+            todir="${jboss.home}/server/${jboss.config}/conf"/>
+       <copy file="${source.etc}/server/default/deploy/queues.xml"
+            todir="${jboss.home}/server/${jboss.config}/conf"/>
        <!--<copy file="${build.lib}/jboss-${module.name}.sar"
             todir="${jboss.home}/server/${jboss.config}/deploy"/>-->
        <copy
@@ -355,7 +361,21 @@
 
    <target name="sar-structure" depends="jar-structure">
       <copy todir="${build.sar}/META-INF" file="${source.etc}/server/default/deploy/jbm-beans.xml"/>
-      <copy todir="${build.sar}" file="${source.etc}/server/default/deploy/jbm-configuration.xml"/>
+      <!--<copy todir="${build.sar}" file="${source.etc}/server/default/deploy/jbm-configuration.xml"/>-->
+            <copy todir="${build.sar}">
+         <fileset dir="${project.thirdparty}/apache-mina/lib">
+            <include name="mina-core.jar"/>
+         </fileset>
+         <fileset dir="${project.thirdparty}/slf4j/api/lib">
+            <include name="**.jar"/>
+         </fileset>
+         <fileset dir="${project.thirdparty}/slf4j/log4j/lib">
+            <include name="**.jar"/>
+         </fileset>
+         <fileset dir="${project.thirdparty}/jgroups/lib">
+            <include name="**.jar"/>
+         </fileset>
+      </copy>
    </target>
 
    <target name="embedded-structure" depends="jar-structure">
@@ -488,6 +508,8 @@
             <include name="org/jboss/messaging/util/**/*.class"/>
 	    <include name="org/jboss/messaging/core/impl/message/**/*.class"/>
             <include name="org/jboss/messaging/core/contract/**/*.class"/>
+            <include name="org/jboss/messaging/core/remoting/**/*.class"/>
+            <include name="org/jboss/messaging/core/**/*.class"/>
             <include name="org/jboss/jms/server/remoting/**/*.class"/>
          </fileset>
          <fileset dir="${build.etc}">

Modified: trunk/docs/examples/bridge/build.xml
===================================================================
--- trunk/docs/examples/bridge/build.xml	2008-01-22 13:47:58 UTC (rev 3611)
+++ trunk/docs/examples/bridge/build.xml	2008-01-22 15:47:50 UTC (rev 3612)
@@ -36,7 +36,9 @@
       <pathelement path="../common/output/classes"/>
       <pathelement path="./output/classes"/>
       <fileset file="${messaging.client.jar.path}/${messaging.client.jar.name}"/>
-      <fileset file="${jboss.home}/server/${jboss.configuration}/lib/jboss-remoting.jar"/>
+      <fileset dir="${jboss.home}/server/${jboss.configuration}/deploy/jboss-messaging.sar">
+         <include name="**/*.jar"/>
+      </fileset>
       <fileset file="${jboss.home}/client/jbossall-client.jar"/>
       <fileset file="${jboss.home}/server/${jboss.configuration}/lib/log4j.jar"/>
       <fileset file="${jboss.home}/server/${jboss.configuration}/lib/javassist.jar"/>

Modified: trunk/docs/examples/distributed-queue/build.xml
===================================================================
--- trunk/docs/examples/distributed-queue/build.xml	2008-01-22 13:47:58 UTC (rev 3611)
+++ trunk/docs/examples/distributed-queue/build.xml	2008-01-22 15:47:50 UTC (rev 3612)
@@ -37,7 +37,9 @@
       <pathelement path="../common/output/classes"/>
       <pathelement path="./output/classes"/>
       <fileset file="${messaging.client.jar.path}/${messaging.client.jar.name}"/>
-      <fileset file="${jboss.home}/server/${jboss.configuration0}/lib/jboss-remoting.jar"/>
+      <fileset dir="${jboss.home}/server/${jboss.configuration}/deploy/jboss-messaging.sar">
+         <include name="**/*.jar"/>
+      </fileset>
       <fileset file="${jboss.home}/client/jbossall-client.jar"/>
       <fileset file="${jboss.home}/server/${jboss.configuration0}/lib/log4j.jar"/>
       <fileset file="${jboss.home}/lib/javassist.jar"/>

Modified: trunk/docs/examples/distributed-topic/build.xml
===================================================================
--- trunk/docs/examples/distributed-topic/build.xml	2008-01-22 13:47:58 UTC (rev 3611)
+++ trunk/docs/examples/distributed-topic/build.xml	2008-01-22 15:47:50 UTC (rev 3612)
@@ -37,7 +37,9 @@
       <pathelement path="../common/output/classes"/>
       <pathelement path="./output/classes"/>
       <fileset file="${messaging.client.jar.path}/${messaging.client.jar.name}"/>
-      <fileset file="${jboss.home}/server/${jboss.configuration0}/lib/jboss-remoting.jar"/>
+      <fileset dir="${jboss.home}/server/${jboss.configuration}/deploy/jboss-messaging.sar">
+         <include name="**/*.jar"/>
+      </fileset>
       <fileset file="${jboss.home}/client/jbossall-client.jar"/>
       <fileset file="${jboss.home}/server/${jboss.configuration0}/lib/log4j.jar"/>
       <fileset file="${jboss.home}/lib/javassist.jar"/>

Modified: trunk/docs/examples/ejb3mdb/build.xml
===================================================================
--- trunk/docs/examples/ejb3mdb/build.xml	2008-01-22 13:47:58 UTC (rev 3611)
+++ trunk/docs/examples/ejb3mdb/build.xml	2008-01-22 15:47:50 UTC (rev 3612)
@@ -36,7 +36,9 @@
       <pathelement path="../common/output/classes"/>
       <pathelement path="./output/classes"/>
       <fileset file="${messaging.client.jar.path}/${messaging.client.jar.name}"/>
-      <fileset file="${jboss.home}/server/${jboss.configuration}/lib/jboss-remoting.jar"/>
+      <fileset dir="${jboss.home}/server/${jboss.configuration}/deploy/jboss-messaging.sar">
+         <include name="**/*.jar"/>
+      </fileset>
       <fileset file="${jboss.home}/client/jbossall-client.jar"/>
       <fileset file="${jboss.home}/server/${jboss.configuration}/lib/log4j.jar"/>
       <fileset file="${jboss.home}/lib/javassist.jar"/>

Modified: trunk/docs/examples/queue/build.xml
===================================================================
--- trunk/docs/examples/queue/build.xml	2008-01-22 13:47:58 UTC (rev 3611)
+++ trunk/docs/examples/queue/build.xml	2008-01-22 15:47:50 UTC (rev 3612)
@@ -35,7 +35,9 @@
       <pathelement path="../common/output/classes"/>
       <pathelement path="./output/classes"/>
       <fileset file="${messaging.client.jar.path}/${messaging.client.jar.name}"/>
-      <fileset file="${jboss.home}/server/${jboss.configuration}/lib/jboss-remoting.jar"/>
+      <fileset dir="${jboss.home}/server/${jboss.configuration}/deploy/messaging.sar">
+         <include name="**/*.jar"/>
+      </fileset>
       <fileset file="${jboss.home}/client/jbossall-client.jar"/>
       <fileset file="${jboss.home}/server/${jboss.configuration}/lib/log4j.jar"/>
       <fileset file="${jboss.home}/lib/javassist.jar"/>

Modified: trunk/docs/examples/queue-failover/build.xml
===================================================================
--- trunk/docs/examples/queue-failover/build.xml	2008-01-22 13:47:58 UTC (rev 3611)
+++ trunk/docs/examples/queue-failover/build.xml	2008-01-22 15:47:50 UTC (rev 3612)
@@ -35,7 +35,9 @@
       <pathelement path="../common/output/classes"/>
       <pathelement path="./output/classes"/>
       <fileset file="${messaging.client.jar.path}/${messaging.client.jar.name}"/>
-      <fileset file="${jboss.home}/server/${jboss.configuration0}/lib/jboss-remoting.jar"/>
+      <fileset dir="${jboss.home}/server/${jboss.configuration}/deploy/jboss-messaging.sar">
+         <include name="**/*.jar"/>
+      </fileset>
       <fileset file="${jboss.home}/client/jbossall-client.jar"/>
       <fileset file="${jboss.home}/server/${jboss.configuration0}/lib/log4j.jar"/>
       <fileset file="${jboss.home}/lib/javassist.jar"/>

Modified: trunk/docs/examples/secure-socket/build.xml
===================================================================
--- trunk/docs/examples/secure-socket/build.xml	2008-01-22 13:47:58 UTC (rev 3611)
+++ trunk/docs/examples/secure-socket/build.xml	2008-01-22 15:47:50 UTC (rev 3612)
@@ -36,7 +36,9 @@
       <pathelement path="../common/output/classes"/>
       <pathelement path="./output/classes"/>
       <fileset file="${messaging.client.jar.path}/${messaging.client.jar.name}"/>
-      <fileset file="${jboss.home}/server/${jboss.configuration}/lib/jboss-remoting.jar"/>
+      <fileset dir="${jboss.home}/server/${jboss.configuration}/deploy/jboss-messaging.sar">
+         <include name="**/*.jar"/>
+      </fileset>
       <fileset file="${jboss.home}/client/jbossall-client.jar"/>
       <fileset file="${jboss.home}/server/${jboss.configuration}/lib/log4j.jar"/>
       <fileset file="${jboss.home}/server/${jboss.configuration}/lib/javassist.jar"/>

Modified: trunk/docs/examples/stateless/build.xml
===================================================================
--- trunk/docs/examples/stateless/build.xml	2008-01-22 13:47:58 UTC (rev 3611)
+++ trunk/docs/examples/stateless/build.xml	2008-01-22 15:47:50 UTC (rev 3612)
@@ -35,7 +35,9 @@
       <pathelement path="../common/output/classes"/>
       <pathelement path="./output/classes"/>
       <fileset file="${messaging.client.jar.path}/${messaging.client.jar.name}"/>
-      <fileset file="${jboss.home}/server/${jboss.configuration}/lib/jboss-remoting.jar"/>
+      <fileset dir="${jboss.home}/server/${jboss.configuration}/deploy/jboss-messaging.sar">
+         <include name="**/*.jar"/>
+      </fileset>
       <fileset file="${jboss.home}/client/jbossall-client.jar"/>
       <fileset file="${jboss.home}/server/${jboss.configuration}/lib/log4j.jar"/>
       <fileset file="${jboss.home}/server/${jboss.configuration}/lib/javassist.jar"/>

Modified: trunk/docs/examples/stateless-clustered/build.xml
===================================================================
--- trunk/docs/examples/stateless-clustered/build.xml	2008-01-22 13:47:58 UTC (rev 3611)
+++ trunk/docs/examples/stateless-clustered/build.xml	2008-01-22 15:47:50 UTC (rev 3612)
@@ -35,7 +35,9 @@
       <pathelement path="../common/output/classes"/>
       <pathelement path="./output/classes"/>
       <fileset file="${messaging.client.jar.path}/${messaging.client.jar.name}"/>
-      <fileset file="${jboss.home}/server/${jboss.configuration}/lib/jboss-remoting.jar"/>
+      <fileset dir="${jboss.home}/server/${jboss.configuration}/deploy/jboss-messaging.sar">
+         <include name="**/*.jar"/>
+      </fileset>
       <fileset file="${jboss.home}/client/jbossall-client.jar"/>
       <fileset file="${jboss.home}/server/${jboss.configuration}/lib/log4j.jar"/>
       <fileset file="${jboss.home}/server/${jboss.configuration}/lib/javassist.jar"/>

Modified: trunk/docs/examples/topic/build.xml
===================================================================
--- trunk/docs/examples/topic/build.xml	2008-01-22 13:47:58 UTC (rev 3611)
+++ trunk/docs/examples/topic/build.xml	2008-01-22 15:47:50 UTC (rev 3612)
@@ -35,7 +35,9 @@
       <pathelement path="../common/output"/>
       <pathelement path="./output"/>
       <fileset file="${messaging.client.jar.path}/${messaging.client.jar.name}"/>
-      <fileset file="${jboss.home}/server/${jboss.configuration}/lib/jboss-remoting.jar"/>
+      <fileset dir="${jboss.home}/server/${jboss.configuration}/deploy/jboss-messaging.sar">
+         <include name="**/*.jar"/>
+      </fileset>
       <fileset file="${jboss.home}/client/jbossall-client.jar"/>
       <fileset file="${jboss.home}/server/${jboss.configuration}/lib/log4j.jar"/>
       <fileset file="${jboss.home}/lib/javassist.jar"/>

Modified: trunk/messaging.iml
===================================================================
--- trunk/messaging.iml	2008-01-22 13:47:58 UTC (rev 3611)
+++ trunk/messaging.iml	2008-01-22 15:47:50 UTC (rev 3612)
@@ -1,132 +1,169 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<module relativePaths="true" type="JAVA_MODULE" version="4">
-  <component name="NewModuleRootManager" inherit-compiler-output="false">
-    <output url="file://$MODULE_DIR$/output/classes" />
-    <exclude-output />
-    <content url="file://$MODULE_DIR$">
-      <sourceFolder url="file://$MODULE_DIR$/docs/examples/common/src" isTestSource="false" />
-      <sourceFolder url="file://$MODULE_DIR$/docs/examples/distributed-queue/src" isTestSource="false" />
-      <sourceFolder url="file://$MODULE_DIR$/docs/examples/distributed-topic/src" isTestSource="false" />
-      <sourceFolder url="file://$MODULE_DIR$/docs/examples/http/src" isTestSource="false" />
-      <sourceFolder url="file://$MODULE_DIR$/docs/examples/mdb/src" isTestSource="false" />
-      <sourceFolder url="file://$MODULE_DIR$/docs/examples/queue-failover/src" isTestSource="false" />
-      <sourceFolder url="file://$MODULE_DIR$/docs/examples/queue/src" isTestSource="false" />
-      <sourceFolder url="file://$MODULE_DIR$/docs/examples/secure-socket/src" isTestSource="false" />
-      <sourceFolder url="file://$MODULE_DIR$/docs/examples/stateless/src" isTestSource="false" />
-      <sourceFolder url="file://$MODULE_DIR$/docs/examples/topic/src" isTestSource="false" />
-      <sourceFolder url="file://$MODULE_DIR$/output/gen-parsers" isTestSource="false" />
-      <sourceFolder url="file://$MODULE_DIR$/perf/src" isTestSource="false" />
-      <sourceFolder url="file://$MODULE_DIR$/perf/tests" isTestSource="false" />
-      <sourceFolder url="file://$MODULE_DIR$/src/main" isTestSource="false" />
-      <sourceFolder url="file://$MODULE_DIR$/src/test" isTestSource="false" />
-      <sourceFolder url="file://$MODULE_DIR$/tests/src" isTestSource="true" />
-      <excludeFolder url="file://$MODULE_DIR$/classes" />
-      <excludeFolder url="file://$MODULE_DIR$/docs/examples/bridge/output" />
-      <excludeFolder url="file://$MODULE_DIR$/docs/examples/common/output" />
-      <excludeFolder url="file://$MODULE_DIR$/docs/examples/distributed-queue/output" />
-      <excludeFolder url="file://$MODULE_DIR$/docs/examples/distributed-topic/output" />
-      <excludeFolder url="file://$MODULE_DIR$/docs/examples/ejb3mdb/output" />
-      <excludeFolder url="file://$MODULE_DIR$/docs/examples/http/output" />
-      <excludeFolder url="file://$MODULE_DIR$/docs/examples/output" />
-      <excludeFolder url="file://$MODULE_DIR$/docs/examples/queue-failover/output" />
-      <excludeFolder url="file://$MODULE_DIR$/docs/examples/queue/output" />
-      <excludeFolder url="file://$MODULE_DIR$/docs/examples/stateless/output" />
-      <excludeFolder url="file://$MODULE_DIR$/docs/examples/topic/output" />
-      <excludeFolder url="file://$MODULE_DIR$/docs/examples/web-service/output" />
-      <excludeFolder url="file://$MODULE_DIR$/output" />
-      <excludeFolder url="file://$MODULE_DIR$/output/classes" />
-      <excludeFolder url="file://$MODULE_DIR$/output/etc" />
-      <excludeFolder url="file://$MODULE_DIR$/output/jar" />
-      <excludeFolder url="file://$MODULE_DIR$/output/lib" />
-      <excludeFolder url="file://$MODULE_DIR$/output/scoped-sar" />
-      <excludeFolder url="file://$MODULE_DIR$/release" />
-      <excludeFolder url="file://$MODULE_DIR$/tests/ObjectStore" />
-      <excludeFolder url="file://$MODULE_DIR$/tests/lib/jdbc-drivers" />
-      <excludeFolder url="file://$MODULE_DIR$/tests/output" />
-    </content>
-    <orderEntry type="jdk" jdkName="1.5" jdkType="JavaSDK" />
-    <orderEntry type="sourceFolder" forTests="false" />
-    <orderEntry type="library" name="aop 5.0" level="project" />
-    <orderEntry type="library" name="microcontainer" level="project" />
-    <orderEntry type="library" name="deploy" level="project" />
-    <orderEntry type="library" name="concurrent" level="project" />
-    <orderEntry type="library" name="hsqldb" level="project" />
-    <orderEntry type="library" name="javassist" level="project" />
-    <orderEntry type="library" name="jboss-serialization" level="project" />
-    <orderEntry type="library" name="jgroups" level="project" />
-    <orderEntry type="library" name="junit" level="project" />
-    <orderEntry type="library" name="jbossas" level="project" />
-    <orderEntry type="library" name="jboss-ts" level="project" />
-    <orderEntry type="library" name="jboss-profiler-leaksfinder" level="project" />
-    <orderEntry type="library" name="ant-junit" level="project" />
-    <orderEntry type="library" name="apache" level="project" />
-    <orderEntry type="library" name="jdbc-drivers" level="project" />
-    <orderEntry type="library" name="dom4j" level="project" />
-    <orderEntry type="module-library">
-      <library>
-        <CLASSES>
-          <root url="jar://$MODULE_DIR$/thirdparty/trove/lib/trove.jar!/" />
-        </CLASSES>
-        <JAVADOC />
-        <SOURCES />
-      </library>
-    </orderEntry>
-    <orderEntry type="module-library">
-      <library>
-        <CLASSES>
-          <root url="file://$MODULE_DIR$/output/etc" />
-        </CLASSES>
-        <JAVADOC />
-        <SOURCES />
-      </library>
-    </orderEntry>
-    <orderEntry type="module-library">
-      <library>
-        <CLASSES>
-          <root url="jar://$MODULE_DIR$/thirdparty/jboss/jboss-security-spi/lib/jboss-security-spi.jar!/" />
-        </CLASSES>
-        <JAVADOC />
-        <SOURCES />
-      </library>
-    </orderEntry>
-    <orderEntry type="module-library">
-      <library>
-        <CLASSES>
-          <root url="jar://$MODULE_DIR$/thirdparty/jboss/jboss-jaspi-api/lib/jboss-jaspi-api.jar!/" />
-        </CLASSES>
-        <JAVADOC />
-        <SOURCES />
-      </library>
-    </orderEntry>
-    <orderEntry type="module-library">
-      <library>
-        <CLASSES>
-          <root url="jar://$MODULE_DIR$/thirdparty/jboss/jnpserver/lib/jnpserver.jar!/" />
-        </CLASSES>
-        <JAVADOC />
-        <SOURCES>
-          <root url="jar://$MODULE_DIR$/thirdparty/jboss/jnpserver/lib/jnpserver-sources.jar!/" />
-        </SOURCES>
-      </library>
-    </orderEntry>
-    <orderEntry type="module-library">
-      <library>
-        <CLASSES>
-          <root url="jar://$MODULE_DIR$/thirdparty/jboss/jboss-javaee/lib/jboss-javaee.jar!/" />
-        </CLASSES>
-        <JAVADOC />
-        <SOURCES />
-      </library>
-    </orderEntry>
-    <orderEntry type="library" name="mina" level="project" />
-    <orderEntry type="library" name="bdb" level="project" />
-    <orderEntry type="library" name="easymock" level="project" />
-    <orderEntry type="library" name="test-etc" level="project" />
-    <orderEntryProperties />
-  </component>
-  <component name="VcsManagerConfiguration">
-    <option name="ACTIVE_VCS_NAME" value="svn" />
-    <option name="USE_PROJECT_VCS" value="false" />
-  </component>
-</module>
-
+<?xml version="1.0" encoding="UTF-8"?>
+<module version="4" relativePaths="true" type="JAVA_MODULE">
+  <component name="ModuleRootManager" />
+  <component name="NewModuleRootManager" inherit-compiler-output="false">
+    <output url="file://$MODULE_DIR$/output/classes" />
+    <exclude-output />
+    <content url="file://$MODULE_DIR$">
+      <sourceFolder url="file://$MODULE_DIR$/docs/examples/common/src" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/docs/examples/distributed-queue/src" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/docs/examples/distributed-topic/src" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/docs/examples/http/src" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/docs/examples/mdb/src" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/docs/examples/queue-failover/src" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/docs/examples/queue/src" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/docs/examples/secure-socket/src" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/docs/examples/stateless/src" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/docs/examples/topic/src" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/output/gen-parsers" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/perf/src" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/perf/tests" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/main" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/test" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/tests/src" isTestSource="true" />
+      <excludeFolder url="file://$MODULE_DIR$/classes" />
+      <excludeFolder url="file://$MODULE_DIR$/docs/examples/bridge/output" />
+      <excludeFolder url="file://$MODULE_DIR$/docs/examples/common/output" />
+      <excludeFolder url="file://$MODULE_DIR$/docs/examples/distributed-queue/output" />
+      <excludeFolder url="file://$MODULE_DIR$/docs/examples/distributed-topic/output" />
+      <excludeFolder url="file://$MODULE_DIR$/docs/examples/ejb3mdb/output" />
+      <excludeFolder url="file://$MODULE_DIR$/docs/examples/http/output" />
+      <excludeFolder url="file://$MODULE_DIR$/docs/examples/output" />
+      <excludeFolder url="file://$MODULE_DIR$/docs/examples/queue-failover/output" />
+      <excludeFolder url="file://$MODULE_DIR$/docs/examples/queue/output" />
+      <excludeFolder url="file://$MODULE_DIR$/docs/examples/stateless/output" />
+      <excludeFolder url="file://$MODULE_DIR$/docs/examples/topic/output" />
+      <excludeFolder url="file://$MODULE_DIR$/docs/examples/web-service/output" />
+      <excludeFolder url="file://$MODULE_DIR$/output" />
+      <excludeFolder url="file://$MODULE_DIR$/output/classes" />
+      <excludeFolder url="file://$MODULE_DIR$/output/etc" />
+      <excludeFolder url="file://$MODULE_DIR$/output/jar" />
+      <excludeFolder url="file://$MODULE_DIR$/output/lib" />
+      <excludeFolder url="file://$MODULE_DIR$/output/scoped-sar" />
+      <excludeFolder url="file://$MODULE_DIR$/release" />
+      <excludeFolder url="file://$MODULE_DIR$/tests/ObjectStore" />
+      <excludeFolder url="file://$MODULE_DIR$/tests/lib/jdbc-drivers" />
+      <excludeFolder url="file://$MODULE_DIR$/tests/output" />
+    </content>
+    <orderEntry type="jdk" jdkName="1.5" jdkType="JavaSDK" />
+    <orderEntry type="sourceFolder" forTests="false" />
+    <orderEntry type="library" name="aop 5.0" level="project" />
+    <orderEntry type="library" name="microcontainer" level="project" />
+    <orderEntry type="library" name="concurrent" level="project" />
+    <orderEntry type="library" name="hsqldb" level="project" />
+    <orderEntry type="library" name="javassist" level="project" />
+    <orderEntry type="library" name="jboss-serialization" level="project" />
+    <orderEntry type="library" name="jgroups" level="project" />
+    <orderEntry type="library" name="junit" level="project" />
+    <orderEntry type="library" name="jboss-ts" level="project" />
+    <orderEntry type="library" name="jboss-profiler-leaksfinder" level="project" />
+    <orderEntry type="library" name="ant-junit" level="project" />
+    <orderEntry type="library" name="ant 1.7" level="application" />
+    <orderEntry type="library" name="apache" level="project" />
+    <orderEntry type="library" name="jdbc-drivers" level="project" />
+    <orderEntry type="library" name="dom4j" level="project" />
+    <orderEntry type="module-library">
+      <library>
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/thirdparty/trove/lib/trove.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library>
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../Desktop/jboss-common-core.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library>
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../devtools/jboss-5.0.0.Beta2/lib/jboss-container.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library>
+        <CLASSES>
+          <root url="file://$MODULE_DIR$/output/etc" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library>
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/thirdparty/jboss/jboss-security-spi/lib/jboss-security-spi.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library>
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/thirdparty/jboss/jboss-jaspi-api/lib/jboss-jaspi-api.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library>
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/tests/lib/jdbc-drivers/mysql-connector-java-5.0.7-bin.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library>
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/thirdparty/jboss/jnpserver/lib/jnpserver.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/thirdparty/jboss/jnpserver/lib/jnpserver-sources.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library>
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/thirdparty/jboss/jboss-javaee/lib/jboss-javaee.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="library" name="jboss" level="project" />
+    <orderEntry type="library" name="mina" level="project" />
+    <orderEntry type="library" name="easymock" level="project" />
+    <orderEntry type="library" name="bdb" level="project" />
+    <orderEntry type="library" name="test-etc" level="project" />
+    <orderEntry type="module-library">
+      <library>
+        <CLASSES>
+          <root url="file://$MODULE_DIR$/src/etc/server/default/deploy" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntryProperties />
+  </component>
+  <component name="VcsManagerConfiguration">
+    <option name="ACTIVE_VCS_NAME" value="svn" />
+    <option name="USE_PROJECT_VCS" value="false" />
+  </component>
+</module>
+

Modified: trunk/messaging.ipr
===================================================================
--- trunk/messaging.ipr	2008-01-22 13:47:58 UTC (rev 3611)
+++ trunk/messaging.ipr	2008-01-22 15:47:50 UTC (rev 3612)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<project relativePaths="false" version="4">
+<project version="4" relativePaths="false">
   <component name="AntConfiguration">
     <defaultAnt bundledAnt="true" />
     <buildFile url="file://$PROJECT_DIR$/tests/build.xml">
@@ -157,12 +157,11 @@
       <entry name="?*.tld" />
     </wildcardResourcePatterns>
   </component>
+  <component name="DataSourceManagerImpl" />
   <component name="DependenciesAnalyzeManager">
     <option name="myForwardDirection" value="false" />
   </component>
-  <component name="DependencyValidationManager">
-    <option name="SKIP_IMPORT_STATEMENTS" value="false" />
-  </component>
+  <component name="DependencyValidationManager" />
   <component name="EclipseCompilerSettings">
     <option name="DEBUGGING_INFO" value="true" />
     <option name="GENERATE_NO_WARNINGS" value="true" />
@@ -178,13 +177,14 @@
     <option name="MAXIMUM_HEAP_SIZE" value="128" />
   </component>
   <component name="EntryPointsManager">
-    <entry_points version="2.0" />
+    <entry_points />
   </component>
   <component name="ExportToHTMLSettings">
     <option name="PRINT_LINE_NUMBERS" value="false" />
     <option name="OPEN_IN_BROWSER" value="false" />
     <option name="OUTPUT_DIRECTORY" />
   </component>
+  <component name="GUI Designer component loader factory" />
   <component name="IdProvider" IDEtalkID="6A074DEDEA8BB8F84C6214EB1D2AF8C8" />
   <component name="InspectionProjectProfileManager">
     <option name="PROJECT_PROFILE" value="Project Default" />
@@ -194,10 +194,84 @@
       <profile version="1.0" is_locked="false">
         <option name="myName" value="Project Default" />
         <option name="myLocal" value="false" />
+        <used_levels>
+          <error>
+            <option name="myName" value="ERROR" />
+            <option name="myVal" value="400" />
+          </error>
+          <warning>
+            <option name="myName" value="WARNING" />
+            <option name="myVal" value="300" />
+          </warning>
+          <information>
+            <option name="myName" value="INFO" />
+            <option name="myVal" value="200" />
+          </information>
+          <server>
+            <option name="myName" value="SERVER PROBLEM" />
+            <option name="myVal" value="100" />
+          </server>
+        </used_levels>
       </profile>
     </profiles>
-    <list size="0" />
   </component>
+  <component name="IntelliJadProjectConfigComponent">
+    <config>
+      <pl type="string">_lcl</pl>
+      <v type="boolean">false</v>
+      <nonlb type="boolean">false</nonlb>
+      <decompile-to-memory type="boolean">true</decompile-to-memory>
+      <clear-and-close-console-on-success type="boolean">false</clear-and-close-console-on-success>
+      <af type="boolean">false</af>
+      <a type="boolean">false</a>
+      <d type="string" />
+      <noctor type="boolean">false</noctor>
+      <sort type="boolean">false</sort>
+      <ff type="boolean">false</ff>
+      <pe type="string">_ex</pe>
+      <s type="string">java</s>
+      <noclass type="boolean">false</noclass>
+      <use-project-specific-settings type="boolean">false</use-project-specific-settings>
+      <pc type="string">_cls</pc>
+      <stat type="boolean">false</stat>
+      <always-exclude-recursively type="boolean">false</always-exclude-recursively>
+      <reformat-according-to-style type="boolean">false</reformat-according-to-style>
+      <pm type="string">_mth</pm>
+      <t type="boolean">false</t>
+      <decompile-on-navigation type="string">Always</decompile-on-navigation>
+      <nl type="boolean">false</nl>
+      <clear type="boolean">false</clear>
+      <pv type="integer">3</pv>
+      <nocast type="boolean">false</nocast>
+      <noconv type="boolean">false</noconv>
+      <nodos type="boolean">false</nodos>
+      <dis type="boolean">false</dis>
+      <space type="boolean">false</space>
+      <pf type="string">_fld</pf>
+      <pa type="string" />
+      <create-output-directory type="boolean">false</create-output-directory>
+      <o type="boolean">false</o>
+      <safe type="boolean">false</safe>
+      <indentation type="integer">4</indentation>
+      <lnc type="boolean">false</lnc>
+      <nolvt type="boolean">false</nolvt>
+      <lradix type="integer">10</lradix>
+      <pp type="string">_prm</pp>
+      <nofd type="boolean">false</nofd>
+      <f type="boolean">false</f>
+      <radix type="integer">10</radix>
+      <noinner type="boolean">false</noinner>
+      <i type="boolean">false</i>
+      <jad-path type="string" />
+      <l type="integer">64</l>
+      <nocode type="boolean">false</nocode>
+      <read-only type="boolean">false</read-only>
+      <dead type="boolean">false</dead>
+      <r type="boolean">false</r>
+      <exclusion-table-model type="table-model" model-class="net.stevechaloner.intellijad.config.ExclusionTableModel" content-types="string,boolean,boolean" />
+      <b type="boolean">false</b>
+    </config>
+  </component>
   <component name="JavacSettings">
     <option name="DEBUGGING_INFO" value="true" />
     <option name="GENERATE_NO_WARNINGS" value="false" />
@@ -364,6 +438,7 @@
     </modules>
   </component>
   <component name="ProjectRootManager" version="2" assert-keyword="true" jdk-15="true" project-jdk-name="1.5" project-jdk-type="JavaSDK" />
+  <component name="ProjectRunConfigurationManager" />
   <component name="ResourceManagerContainer">
     <option name="myResourceBundles">
       <value>
@@ -378,10 +453,12 @@
     <option name="GENERATE_IIOP_STUBS" value="false" />
     <option name="ADDITIONAL_OPTIONS_STRING" value="" />
   </component>
+  <component name="StarteamVcsAdapter" />
   <component name="VcsDirectoryMappings">
     <mapping directory="" vcs="" />
     <mapping directory="$PROJECT_DIR$" vcs="svn" />
   </component>
+  <component name="VssVcs" />
   <component name="WebServicesPlugin" addRequiredLibraries="true" />
   <component name="com.intellij.jsf.UserDefinedFacesConfigs">
     <option name="USER_DEFINED_CONFIGS">
@@ -435,14 +512,6 @@
       <JAVADOC />
       <SOURCES />
     </library>
-    <library name="jbossas">
-      <CLASSES>
-        <root url="jar://$PROJECT_DIR$/thirdparty/jboss/jbossxb/lib/jboss-xml-binding.jar!/" />
-        <root url="jar://$PROJECT_DIR$/lib/jbossall-client.jar!/" />
-      </CLASSES>
-      <JAVADOC />
-      <SOURCES />
-    </library>
     <library name="jboss-ts">
       <CLASSES>
         <root url="jar://$PROJECT_DIR$/thirdparty/jboss/jbossts14/lib/jbossjta-integration.jar!/" />
@@ -465,8 +534,7 @@
     </library>
     <library name="ant-junit">
       <CLASSES>
-        <root url="jar:///usr/share/apache-ant-1.7.0/lib/ant.jar!/" />
-        <root url="jar:///usr/share/apache-ant-1.7.0/lib/ant-junit.jar!/" />
+        <root url="jar://$PROJECT_DIR$/thirdparty/junit/lib/junit.jar!/" />
       </CLASSES>
       <JAVADOC />
       <SOURCES />
@@ -508,7 +576,7 @@
     </library>
     <library name="jdbc-drivers">
       <CLASSES>
-        <root url="jar://$PROJECT_DIR$/tests/lib/jdbc-drivers/mysql-driver-3.0.17.GA.jar!/" />
+        <root url="jar://$PROJECT_DIR$/tests/lib/jdbc-drivers/mysql-connector-java-5.0.7-bin.jar!/" />
       </CLASSES>
       <JAVADOC />
       <SOURCES />
@@ -597,8 +665,36 @@
         <root url="jar://$PROJECT_DIR$/tests/lib/easymock.jar!/" />
       </CLASSES>
       <JAVADOC />
+      <SOURCES>
+        <root url="intellijad://intellijad" />
+      </SOURCES>
+    </library>
+    <library name="jboss">
+      <CLASSES>
+        <root url="jar://$PROJECT_DIR$/thirdparty/jboss/jboss-common-logging-spi/lib/jboss-common-logging-spi.jar!/" />
+        <root url="jar://$PROJECT_DIR$/thirdparty/jboss/jboss-common-logging-spi/lib/jboss-common-logging-spi-jdk14.jar!/" />
+        <root url="jar://$PROJECT_DIR$/thirdparty/jboss/integration/lib/jboss-classloading-spi.jar!/" />
+        <root url="jar://$PROJECT_DIR$/thirdparty/jboss/integration/lib/jboss-transaction-spi.jar!/" />
+        <root url="jar://$PROJECT_DIR$/thirdparty/jboss/integration/lib/jboss-corba-ots-spi.jar!/" />
+        <root url="jar://$PROJECT_DIR$/thirdparty/jboss/integration/lib/jboss-integration.jar!/" />
+        <root url="jar://$PROJECT_DIR$/thirdparty/jboss/jboss-security-spi/lib/jboss-security-spi.jar!/" />
+        <root url="jar://$PROJECT_DIR$/thirdparty/jboss/jbosssx-client/lib/jbosssx-client.jar!/" />
+        <root url="jar://$PROJECT_DIR$/thirdparty/jboss/remoting/lib/jboss-remoting.jar!/" />
+        <root url="jar://$PROJECT_DIR$/thirdparty/jboss/jbossxb/lib/jboss-xml-binding.jar!/" />
+        <root url="jar://$PROJECT_DIR$/thirdparty/jboss/common-core/lib/jboss-common-core.jar!/" />
+        <root url="jar://$PROJECT_DIR$/thirdparty/jboss/common/lib/jboss-common.jar!/" />
+        <root url="jar://$PROJECT_DIR$/thirdparty/jboss/common/lib/jboss-common-client.jar!/" />
+        <root url="jar://$PROJECT_DIR$/thirdparty/jboss/common/lib/namespace.jar!/" />
+      </CLASSES>
+      <JAVADOC />
       <SOURCES />
     </library>
   </component>
+  <component name="uidesigner-configuration">
+    <option name="INSTRUMENT_CLASSES" value="true" />
+    <option name="COPY_FORMS_RUNTIME_TO_OUTPUT" value="true" />
+    <option name="DEFAULT_LAYOUT_MANAGER" value="GridLayoutManager" />
+  </component>
+  <UsedPathMacros />
 </project>
 

Modified: trunk/src/etc/server/default/deploy/jbm-beans.xml
===================================================================
--- trunk/src/etc/server/default/deploy/jbm-beans.xml	2008-01-22 13:47:58 UTC (rev 3611)
+++ trunk/src/etc/server/default/deploy/jbm-beans.xml	2008-01-22 15:47:50 UTC (rev 3612)
@@ -75,6 +75,16 @@
                <value>INSERT INTO JBM_USER (USER_ID,PASSWD,CLIENTID) VALUES ('dilbert','dogbert','dilbert-id')
                </value>
             </entry>
+            <entry>
+               <key>POPULATE.TABLES.2</key>
+               <value>INSERT INTO JBM_USER (USER_ID,PASSWD,CLIENTID) VALUES ('guest','guest')
+               </value>
+            </entry>
+            <entry>
+               <key>POPULATE.TABLES.3</key>
+               <value>INSERT INTO JBM_ROLE (ROLE_ID, USER_ID) VALUES ('guest','guest')
+               </value>
+            </entry>
          </map>
       </property>
    </bean>
@@ -102,6 +112,10 @@
       </property>
    </bean> 
    
-      
+   <bean name="JNDIObjectDeployer" class="org.jboss.jms.jndi.JNDIObjectDeployer">
+      <property name="messagingServer">
+         <inject bean="MessagingServer"/>
+      </property>
+   </bean>
  
 </deployment>
\ No newline at end of file

Modified: trunk/src/etc/server/default/deploy/jbm-configuration.xml
===================================================================
--- trunk/src/etc/server/default/deploy/jbm-configuration.xml	2008-01-22 13:47:58 UTC (rev 3611)
+++ trunk/src/etc/server/default/deploy/jbm-configuration.xml	2008-01-22 15:47:50 UTC (rev 3612)
@@ -2,25 +2,8 @@
    <configuration>
       <!-- The unique id of the server peer - in a cluster each node MUST have a unique value - must be an integer -->
       <server-peer-id>0</server-peer-id>
-      <!-- The default JNDI context to use for queues when they are deployed without specifying one -->
-      <default-queue-jndi-context>/queue</default-queue-jndi-context>
-      <!-- The default JNDI context to use for topics when they are deployed without specifying one -->
-      <default-topic-jndi-context>/topic</default-topic-jndi-context>
       <!-- The JAAS security domain to use for JBoss Messaging -->
       <security-domain>java:/jaas/messaging</security-domain>
-      <!-- The default security configuration to apply to destinations - this can be overridden on a per destination basis -->
-      <default-security-config>
-         <role name="guest" read="true" write="true" create="true"/>
-      </default-security-config>
-      <!-- The default Dead Letter Queue (DLQ) to use for destinations. This can be overridden on a per destinatin basis -->
-      <default-dlq>DLQ</default-dlq>
-      <!-- The default maximum number of times to attempt delivery of a message before sending to the DLQ (if configured).
-This can be overridden on a per destinatin basis -->
-      <default-max-delivery-attempts>10</default-max-delivery-attempts>
-      <!-- The default Expiry Queue to use for destinations. This can be overridden on a per destinatin basis -->
-      <default-expiry-queue>ExpiryQueue</default-expiry-queue>
-      <!-- The default redelivery delay to impose. This can be overridden on a per destination basis -->
-      <default-redelivery-delay>0</default-redelivery-delay>
       <!-- The periodicity of the message counter manager enquiring on queues for statistics -->
       <message-counter-sample-period>5000</message-counter-sample-period>
       <!-- The maximum amount of time for a client to wait for failover to start on the server side after
@@ -79,153 +62,4 @@
 
    </configuration>
 
-   <factories>
-
-      <!-- The default connection factory does not support automatic failover or load balancing-
-           this is so we can maintain compatiblity with applications written for JBoss MQ which use this
-           connection factory.
-      -->
-      <factory name="ConnectionFactory">
-         <jndi-bindings>
-            <binding>/ConnectionFactory</binding>
-            <binding>/XAConnectionFactory</binding>
-            <binding>java:/ConnectionFactory</binding>
-            <binding>java:/XAConnectionFactory</binding>
-         </jndi-bindings>
-      </factory>
-
-      <factory name="ClusteredConnectionFactory">
-         <jndi-bindings>
-            <binding>/ClusteredConnectionFactory</binding>
-            <binding>/ClusteredXAConnectionFactory</binding>
-            <binding>java:/ClusteredConnectionFactory</binding>
-            <binding>java:/ClusteredXAConnectionFactory</binding>
-         </jndi-bindings>
-         <supports-failover>true</supports-failover>
-         <supports-load-balancing>true</supports-load-balancing>
-      </factory>
-
-      <factory name="jboss.messaging.connectionfactory:service=ClusterPullConnectionFactory">
-         <supports-failover>true</supports-failover>
-         <supports-load-balancing>true</supports-load-balancing>
-      </factory>
-      <!-- An example connection factory with all attributes shown  -->
-
-      <factory name="jboss.messaging.connectionfactory:service=MyExampleConnectionFactory">
-         <!-- You can specify the default Client ID to use for connections created using this factory -->
-         <client-id>MyClientID</client-id>
-         <!-- PrefetchSize determines the approximate maximum number of messages the client consumer will buffer locally -->
-         <prefetch-size>150</prefetch-size>
-         <!-- Paging params to be used for temporary queues -->
-         <default-temp-queue-full-size>200000</default-temp-queue-full-size>
-         <default-temp-queue-page-size>2000</default-temp-queue-page-size>
-         <default-temp-queue-down-cache-size>2000</default-temp-queue-down-cache-size>
-         <!-- The batch size to use when using the DUPS_OK_ACKNOWLEDGE acknowledgement mode -->
-         <dups-ok-batch-size>5000</dups-ok-batch-size>
-         <!-- Does this connection factory support automatic failover? -->
-         <supports-failover>false</supports-failover>
-         <!-- Does this connection factory support automatic client side load balancing? -->
-         <supports-load-balancing>false</supports-load-balancing>
-         <!-- The class name of the factory used to create the load balancing policy to use on the client side -->
-         <load-balancing-factory>org.jboss.jms.client.plugin.RoundRobinLoadBalancingFactory</load-balancing-factory>
-         <!-- Whether we should be strict TCK compliant, i.e. how we deal with foreign messages, defaults to false-->
-         <strict-tck>true</strict-tck>
-         <!-- Disable JBoss Remoting Connector sanity checks - There is rarely a good reason to set this to true -->
-         <disable-remoting-checks>false</disable-remoting-checks>
-         <!-- The connection factory will be bound in the following places in JNDI -->
-         <jndi-bindings>
-            <binding>/acme/MyExampleConnectionFactory</binding>
-            <binding>/acme/MyExampleConnectionFactoryDupe</binding>
-            <binding>java:/xyz/CF1</binding>
-            <binding>java:/connectionfactories/acme/connection_factory</binding>
-         </jndi-bindings>
-      </factory>
-
-   </factories>
-
-   <destinations>
-      <!--
-         The Default Dead Letter Queue. This destination is a dependency of an EJB MDB container.
-      -->
-      <queue name="DLQ"/>
-      <!--
-         The Default Expiry Queue.
-      -->
-      <queue name="ExpiryQueue"/>
-      <!--
-           Example destinations.
-      -->
-      <topic name="testTopic">
-         <security>
-            <role name="guest" read="true" write="true"/>
-            <role name="publisher" read="true" write="true" create="false"/>
-            <role name="durpublisher" read="true" write="true" create="true"/>
-         </security>
-      </topic>
-
-      <topic name="securedTopic">
-         <security>
-            <role name="publisher" read="true" write="true" create="false"/>
-         </security>
-      </topic>
-
-      <topic name="testDurableTopic">
-         <security>
-            <role name="guest" read="true" write="true"/>
-            <role name="publisher" read="true" write="true" create="false"/>
-            <role name="durpublisher" read="true" write="true" create="true"/>
-         </security>
-      </topic>
-
-      <queue name="testQueue">
-         <security>
-            <role name="guest" read="true" write="true"/>
-            <role name="publisher" read="true" write="true" create="false"/>
-            <role name="noacc" read="false" write="false" create="false"/>
-         </security>
-      </queue>
-
-      <queue name="A"/>
-      <queue name="B"/>
-      <queue name="C"/>
-      <queue name="D"/>
-      <queue name="ex"/>
-
-      <!-- It's possible for indiviual queues and topics to use a specific queue for
-  an expiry or DLQ -->
-
-      <queue name="PrivateDLQ"/>
-      <queue name="PrivateExpiryQueue"/>
-      <queue name="QueueWithOwnDLQAndExpiryQueue">
-         <dlq>PrivateDLQ</dlq>
-         <expiry-queue>PrivateExpiryQueue</expiry-queue>
-      </queue>
-
-      <topic name="TopicWithOwnDLQAndExpiryQueue">
-         <dlq>PrivateDLQ</dlq>
-         <expiry-queue>PrivateExpiryQueue</expiry-queue>
-      </topic>
-
-      <!-- Queues and Topics can also specify their own redelivery delay -->
-      <queue name="QueueWithOwnRedeliveryDelay">
-         <redelivery-delay>5000</redelivery-delay>
-      </queue>
-
-      <topic name="TopicWithOwnRedeliveryDelay">
-         <redelivery-delay>5000</redelivery-delay>
-      </topic>
-
-      <!--
-           Example clustered destinations.
-      -->
-      <queue name="testDistributedQueue">
-         <clustered>true</clustered>
-      </queue>
-
-      <topic name="testDistributedTopic">
-         <clustered>true</clustered>
-      </topic>
-
-   </destinations>
-
 </deployment>
\ No newline at end of file

Added: trunk/src/main/org/jboss/jms/jndi/JNDIObjectDeployer.java
===================================================================
--- trunk/src/main/org/jboss/jms/jndi/JNDIObjectDeployer.java	                        (rev 0)
+++ trunk/src/main/org/jboss/jms/jndi/JNDIObjectDeployer.java	2008-01-22 15:47:50 UTC (rev 3612)
@@ -0,0 +1,320 @@
+/*
+   * 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.jms.jndi;
+
+import org.jboss.jms.client.JBossConnectionFactory;
+import org.jboss.jms.client.impl.ClientConnectionFactoryImpl;
+import org.jboss.jms.destination.JBossQueue;
+import org.jboss.jms.destination.JBossTopic;
+import org.jboss.jms.server.connectionfactory.ConnectionFactory;
+import org.jboss.jms.server.endpoint.ServerConnectionFactoryEndpoint;
+import org.jboss.logging.Logger;
+import org.jboss.messaging.core.MessagingServer;
+import org.jboss.messaging.core.remoting.ServerLocator;
+import org.jboss.messaging.deployers.Deployer;
+import org.jboss.messaging.deployers.DeploymentManager;
+import org.jboss.messaging.util.JNDIUtil;
+import org.jboss.messaging.util.Version;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import javax.jms.InvalidDestinationException;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NameNotFoundException;
+import javax.naming.NamingException;
+
+/**
+ * A Deployer used to create and add to JNDI queues, topics and connection factories. Typically this would only be used
+ * in an app server env.
+ *
+ * @author <a href="ataylor at redhat.com">Andy Taylor</a>
+ */
+public class JNDIObjectDeployer extends Deployer
+{
+   Logger log = Logger.getLogger(JNDIObjectDeployer.class);
+
+   /**
+    * the initial context to bind to
+    */
+   InitialContext initialContext;
+
+   /**
+    * The messagingserver used for creating the objects
+    */
+   MessagingServer messagingServer;
+
+   private static final String CLIENTID_ELEMENT = "client-id";
+   private static final String PREFETECH_SIZE_ELEMENT = "prefetch-size";
+   private static final String DEF_TEMP_Q_FULL_SIZE = "default-temp-queue-full-size";
+   private static final String DEF_TEMP_Q_PAGE_SIZE_SIZE = "default-temp-queue-page-size";
+   private static final String DEF_TEMP_Q_DOWN_CACHE_SIZE = "default-temp-queue-down-cache-size";
+   private static final String DUPS_OK_BATCH_SIZE = "dups-ok-batch-size";
+   private static final String SUPPORTS_FAILOVER = "supports-failover";
+   private static final String SUPPORTS_LOAD_BALANCING = "supports-load-balancing";
+   private static final String LOAD_BALANCING_FACTORY = "load-balancing-factory";
+   private static final String STRICT_TCK = "strict-tck";
+   private static final String DISABLE_REMOTING_CHECKS = "disable-remoting-checks";
+   private static final String ENTRY_NODE_NAME = "entry";
+   private static final String CONNECTION_FACTORY_NODE_NAME = "connection-factory";
+   private static final String QUEUE_NODE_NAME = "queue";
+   private static final String TOPIC_NODE_NAME = "topic";
+
+   public void setMessagingServer(MessagingServer messagingServer)
+   {
+      this.messagingServer = messagingServer;
+   }
+
+   /**
+    * lifecycle method
+    */
+   public void start()
+   {
+      try
+      {
+         initialContext = new InitialContext();
+      }
+      catch (NamingException e)
+      {
+         log.error("Unable to create Initial Context", e);
+      }
+      try
+      {
+         DeploymentManager.getInstance().registerDeployable(this);
+      }
+      catch (Exception e)
+      {
+         log.error(new StringBuilder("Unable to get Deployment Manager: ").append(e));
+      }
+   }
+
+   /**
+    * lifecycle method
+    */
+   public void stop()
+   {
+
+   }
+
+   /**
+    * the names of the elements to deploy
+    * @return the names of the elements todeploy
+    */
+   public String[] getElementTagName()
+   {
+      return new String[]{QUEUE_NODE_NAME, TOPIC_NODE_NAME, CONNECTION_FACTORY_NODE_NAME};
+   }
+
+   /**
+    * deploy an element
+    * @param node the element to deploy
+    * @throws Exception .
+    */
+   public void deploy(Node node) throws Exception
+   {
+      Object objectToBind = getObjectToBind(node);
+      NodeList children = node.getChildNodes();
+      for (int i = 0; i < children.getLength(); i++)
+      {
+         Node child = children.item(i);
+
+         if (ENTRY_NODE_NAME.equalsIgnoreCase(children.item(i).getNodeName()))
+         {
+
+            String jndiName = child.getAttributes().getNamedItem("name").getNodeValue();
+            String parentContext;
+            String jndiNameInContext;
+            int sepIndex = jndiName.lastIndexOf('/');
+            if (sepIndex == -1)
+            {
+               parentContext = "";
+            }
+            else
+            {
+               parentContext = jndiName.substring(0, sepIndex);
+            }
+            jndiNameInContext = jndiName.substring(sepIndex + 1);
+            try
+            {
+               initialContext.lookup(jndiName);
+               throw new InvalidDestinationException("Destination " + jndiName + " already exists");
+            }
+            catch (NameNotFoundException e)
+            {
+               // OK
+            }
+
+            Context c = JNDIUtil.createContext(initialContext, parentContext);
+
+            c.rebind(jndiNameInContext, objectToBind);
+         }
+      }
+   }
+
+   /**
+    * creates the object to bind, this will either be a JBossConnectionFActory, JBossQueue or JBossTopic
+    * @param node the config
+    * @return the object to bind
+    * @throws Exception .
+    */
+   private Object getObjectToBind(Node node) throws Exception
+   {
+      if (node.getNodeName().equals(CONNECTION_FACTORY_NODE_NAME))
+      {
+         ConnectionFactory connectionFactory = createConnectionFactory(node);
+         ServerLocator serverLocator = messagingServer.getMinaService().getLocator();
+
+         log.info("Server locator is " + serverLocator);
+         log.info(this + " started");
+         // See http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4076040#4076040
+         final String id = connectionFactory.getName();
+
+         Version version = messagingServer.getVersion();
+
+         ServerConnectionFactoryEndpoint endpoint =
+                 new ServerConnectionFactoryEndpoint(connectionFactory.getName(), id, messagingServer, connectionFactory.getClientID(),
+                         connectionFactory.getPrefetchSize(),
+                         connectionFactory.getDefaultTempQueueFullSize(),
+                         connectionFactory.getDefaultTempQueuePageSize(),
+                         connectionFactory.getDefaultTempQueueDownCacheSize(),
+                         connectionFactory.getDupsOKBatchSize());
+
+         //The server peer strict setting overrides the connection factory
+         boolean useStrict = messagingServer.getConfiguration().isStrictTck() || connectionFactory.isStrictTck();
+
+         ClientConnectionFactoryImpl delegate =
+                 new ClientConnectionFactoryImpl(connectionFactory.getName(), id, messagingServer.getConfiguration().getMessagingServerID(),
+                         serverLocator.getURI(), version, false, useStrict);
+
+         log.debug(this + " created local delegate " + delegate);
+
+         // Registering with the dispatcher should always be the last thing otherwise a client could
+         // use a partially initialised object
+
+         messagingServer.getMinaService().getDispatcher().register(endpoint.newHandler());
+         return new JBossConnectionFactory(delegate);
+      }
+      else if (node.getNodeName().equals(QUEUE_NODE_NAME))
+      {
+         String queueName = node.getAttributes().getNamedItem(getKeyAttribute()).getNodeValue();
+         messagingServer.createQueue(queueName);
+         return new JBossQueue(queueName);
+
+      }
+      else if (node.equals(TOPIC_NODE_NAME))
+      {
+         String topicName = node.getAttributes().getNamedItem(getKeyAttribute()).getNodeValue();
+         messagingServer.createTopic(topicName);
+         return new JBossTopic(topicName);
+
+      }
+      return null;
+   }
+
+   /**
+    * undeploys an element
+    * @param node the element to undeploy
+    * @throws Exception .
+    */
+   public void undeploy(Node node) throws Exception
+   {
+      System.out.println("JNDIObjectDeployer.undeploy");
+   }
+
+   /**
+    * The name of the configuration file name to look for for deployment
+    *
+    * @return The name of the config file
+    */
+   public String getConfigFileName()
+   {
+      return "jbm-jndi.xml";
+   }
+
+   /**
+    * creates a connection factory
+    * @param node the config
+    * @return a ConnectionFactory
+    * @throws Exception .
+    */
+   private ConnectionFactory createConnectionFactory(Node node) throws Exception
+   {
+      String clientId = null;
+      String name = node.getAttributes().getNamedItem(getKeyAttribute()).getNodeValue();
+      ConnectionFactory connectionFactory = new ConnectionFactory(clientId);
+      connectionFactory.setName(name);
+
+      NodeList attributes = node.getChildNodes();
+      for (int j = 0; j < attributes.getLength(); j++)
+      {
+         if (CLIENTID_ELEMENT.equalsIgnoreCase(attributes.item(j).getNodeName()))
+         {
+            clientId = attributes.item(j).getTextContent();
+            connectionFactory.setClientID(clientId);
+         }
+
+         if (PREFETECH_SIZE_ELEMENT.equalsIgnoreCase(attributes.item(j).getNodeName()))
+         {
+            connectionFactory.setPrefetchSize(Integer.parseInt(attributes.item(j).getTextContent().trim()));
+         }
+         if (DEF_TEMP_Q_FULL_SIZE.equalsIgnoreCase(attributes.item(j).getNodeName()))
+         {
+            connectionFactory.setDefaultTempQueueFullSize(Integer.parseInt(attributes.item(j).getTextContent().trim()));
+         }
+         if (DEF_TEMP_Q_PAGE_SIZE_SIZE.equalsIgnoreCase(attributes.item(j).getNodeName()))
+         {
+            connectionFactory.setDefaultTempQueuePageSize(Integer.parseInt(attributes.item(j).getTextContent().trim()));
+         }
+         if (DEF_TEMP_Q_DOWN_CACHE_SIZE.equalsIgnoreCase(attributes.item(j).getNodeName()))
+         {
+            connectionFactory.setDefaultTempQueueDownCacheSize(Integer.parseInt(attributes.item(j).getTextContent().trim()));
+         }
+         if (DUPS_OK_BATCH_SIZE.equalsIgnoreCase(attributes.item(j).getNodeName()))
+         {
+            connectionFactory.setDupsOKBatchSize(Integer.parseInt(attributes.item(j).getTextContent().trim()));
+         }
+         if (SUPPORTS_FAILOVER.equalsIgnoreCase(attributes.item(j).getNodeName()))
+         {
+            connectionFactory.setSupportsFailover(Boolean.parseBoolean(attributes.item(j).getTextContent().trim()));
+         }
+         if (SUPPORTS_LOAD_BALANCING.equalsIgnoreCase(attributes.item(j).getNodeName()))
+         {
+            connectionFactory.setSupportsLoadBalancing(Boolean.parseBoolean(attributes.item(j).getTextContent().trim()));
+         }
+         if (LOAD_BALANCING_FACTORY.equalsIgnoreCase(attributes.item(j).getNodeName()))
+         {
+            connectionFactory.setLoadBalancingFactory(attributes.item(j).getTextContent().trim());
+         }
+         if (STRICT_TCK.equalsIgnoreCase(attributes.item(j).getNodeName()))
+         {
+            connectionFactory.setStrictTck(Boolean.parseBoolean(attributes.item(j).getTextContent().trim()));
+         }
+         if (DISABLE_REMOTING_CHECKS.equalsIgnoreCase(attributes.item(j).getNodeName()))
+         {
+            connectionFactory.setDisableRemotingChecks(Boolean.parseBoolean(attributes.item(j).getTextContent().trim()));
+         }
+
+      }
+      return connectionFactory;
+   }
+
+}

Deleted: trunk/src/main/org/jboss/jms/server/ConnectionFactoryManager.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/ConnectionFactoryManager.java	2008-01-22 13:47:58 UTC (rev 3611)
+++ trunk/src/main/org/jboss/jms/server/ConnectionFactoryManager.java	2008-01-22 15:47:50 UTC (rev 3612)
@@ -1,56 +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.jms.server;
-
-import org.jboss.jms.client.plugin.LoadBalancingFactory;
-import org.jboss.messaging.core.MessagingComponent;
-
-import java.util.List;
-
-/**
- * @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="ataylor at redhat.com">Andy Taylor</a>
- * @version <tt>$Revision$</tt>
- * 
- * $Id$
- */
-public interface ConnectionFactoryManager extends MessagingComponent
-{
-   /**
-    * @param jndiBindings - if null, the connection factory will be created and registered with the
-    *        AOP subsystem, but not bound in JNDI.
-    */
-   void registerConnectionFactory(String uniqueName, String clientID,  List<String> jndiBindings,
-                                 String serverURI, boolean clientPing,
-                                 int prefetchSize,                           
-                                 int defaultTempQueueFullSize,
-                                 int defaultTempQueuePageSize,
-                                 int defaultTempQueueDownCacheSize,
-                                 int dupsOKBatchSize,
-                                 boolean supportsFailover,
-                                 boolean supportsLoadBalancing,
-                                 LoadBalancingFactory loadBalancingPolicy,
-                                 boolean strictTck) throws Exception;
-
-   void unregisterConnectionFactory(String uniqueName) throws Exception;
-}

Deleted: trunk/src/main/org/jboss/jms/server/DestinationJNDIMapper.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/DestinationJNDIMapper.java	2008-01-22 13:47:58 UTC (rev 3611)
+++ trunk/src/main/org/jboss/jms/server/DestinationJNDIMapper.java	2008-01-22 15:47:50 UTC (rev 3612)
@@ -1,200 +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.jms.server;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.jms.InvalidDestinationException;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NameNotFoundException;
-
-import org.jboss.jms.destination.JBossDestination;
-import org.jboss.jms.destination.JBossQueue;
-import org.jboss.jms.destination.JBossTopic;
-import org.jboss.jms.exception.MessagingJMSException;
-import org.jboss.messaging.util.Logger;
-import org.jboss.messaging.core.Destination;
-import org.jboss.messaging.core.DestinationType;
-import org.jboss.messaging.core.MessagingServer;
-import org.jboss.messaging.util.JNDIUtil;
-
-/**
- * Keeps track of destinations - including temporary destinations
- * Also manages the mapping of non temporary destinations to JNDI context
- *
- * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @version <tt>$Revision$</tt>
- *
- * $Id$
- */
-public class DestinationJNDIMapper implements DestinationManager
-{
-   // Constants -----------------------------------------------------
-
-   private static final Logger log = Logger.getLogger(DestinationJNDIMapper.class);
-   
-   // Static --------------------------------------------------------
-   
-   // Attributes ----------------------------------------------------
-
-   private Context initialContext;
-
-   // Map <name , destination holder>
-   private Map queueMap;
-   private Map topicMap;
-   
-   private MessagingServer messagingServer;
-         
-   // Constructors --------------------------------------------------
-
-   public DestinationJNDIMapper(MessagingServer messagingServer) throws Exception
-   {;
-      queueMap = new HashMap();
-      topicMap = new HashMap();
-      this.messagingServer = messagingServer;
-   }
-   
-   // DestinationManager implementation -----------------------------
-   
-   public synchronized void registerDestination(Destination destination, String jndiName) throws Exception
-   {          
-      if (!destination.isTemporary())
-      {
-         String parentContext;
-         String jndiNameInContext;
-            
-         if (jndiName == null)
-         {
-            parentContext = destination.getType() == DestinationType.QUEUE ?
-               messagingServer.getConfiguration().getDefaultQueueJNDIContext() : messagingServer.getConfiguration().getDefaultTopicJNDIContext();
-   
-            jndiNameInContext = destination.getName();
-            jndiName = parentContext + "/" + jndiNameInContext;
-         }
-         else
-         {
-            // TODO more solid parsing + test cases
-            int sepIndex = jndiName.lastIndexOf('/');
-            if (sepIndex == -1)
-            {
-               parentContext = "";
-            }
-            else
-            {
-               parentContext = jndiName.substring(0, sepIndex);
-            }
-            jndiNameInContext = jndiName.substring(sepIndex + 1);
-         }
-         
-         try
-         {
-            initialContext.lookup(jndiName);
-            throw new InvalidDestinationException("Destination " + destination.getName() + " already exists");
-         }
-         catch(NameNotFoundException e)
-         {
-            // OK
-         }      
-
-         Context c = JNDIUtil.createContext(initialContext, parentContext);         
-         
-         JBossDestination jbDest;
-         
-         if (destination.getType() == DestinationType.QUEUE)
-         {
-            jbDest = new JBossQueue(destination.getName());
-         }
-         else
-         {
-            jbDest = new JBossTopic(destination.getName());
-         }
-           
-         c.rebind(jndiNameInContext, jbDest);         
-      }
-             
-      log.debug((destination.getType() == DestinationType.QUEUE ? "queue" : "topic") + " " + destination.getName() + " registered ");
-      log.debug((destination.getType() == DestinationType.QUEUE ? "queue" : "topic") + " bound in JNDI as " + jndiName);
-   }
-
-   public synchronized void unregisterDestination(Destination destination, String jndiName) throws Exception
-   {      
-      initialContext.unbind(jndiName);      
-   
-      messagingServer.getSecurityManager().clearSecurityConfig(destination.getType() == DestinationType.QUEUE, destination.getName());
-            
-      log.debug("unregistered " + (destination.getType() == DestinationType.QUEUE ? "queue " : "topic ") + destination.getName());
-   }
-   
-  
-   // MessagingComponent implementation -----------------------------
-   
-   public void start() throws Exception
-   {
-      initialContext = new InitialContext();
-
-      // see if the default queue/topic contexts are there, and if they're not, create them
-      createContext(messagingServer.getConfiguration().getDefaultQueueJNDIContext());
-      createContext(messagingServer.getConfiguration().getDefaultTopicJNDIContext());
-   }
-
-   public void stop() throws Exception
-   {      
-      initialContext.unbind(messagingServer.getConfiguration().getDefaultQueueJNDIContext());
-      initialContext.unbind(messagingServer.getConfiguration().getDefaultTopicJNDIContext());
-
-      initialContext.close();
-   }
-  
-   // Public --------------------------------------------------------
-
-   // Package protected ---------------------------------------------
-  
-   // Protected -----------------------------------------------------
-
-   // Private -------------------------------------------------------
-
-   private void createContext(String contextName) throws Exception
-   {
-      Object context = null;
-      try
-      {
-         context = initialContext.lookup(contextName);
-
-         if (!(context instanceof Context))
-         {
-            throw new MessagingJMSException(contextName + " is already bound " +
-                                        " and is not a JNDI context!");
-         }
-      }
-      catch(NameNotFoundException e)
-      {
-         initialContext.createSubcontext(contextName);
-         log.debug(contextName + " subcontext created");
-      }
-   }
-
-   // Inner classes -------------------------------------------------
-   
-}

Deleted: trunk/src/main/org/jboss/jms/server/DestinationManager.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/DestinationManager.java	2008-01-22 13:47:58 UTC (rev 3611)
+++ trunk/src/main/org/jboss/jms/server/DestinationManager.java	2008-01-22 15:47:50 UTC (rev 3612)
@@ -1,39 +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.jms.server;
-
-import org.jboss.messaging.core.Destination;
-import org.jboss.messaging.core.MessagingComponent;
-
-/**
- * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @version <tt>$Revision$</tt>
- *
- * $Id$
- */
-public interface DestinationManager extends MessagingComponent
-{   
-   void registerDestination(Destination destination, String jndiName) throws Exception;
-
-   void unregisterDestination(Destination destination, String jndiName) throws Exception;
-}

Modified: trunk/src/main/org/jboss/jms/server/SecurityStore.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/SecurityStore.java	2008-01-22 13:47:58 UTC (rev 3611)
+++ trunk/src/main/org/jboss/jms/server/SecurityStore.java	2008-01-22 15:47:50 UTC (rev 3612)
@@ -23,12 +23,12 @@
 
 import org.jboss.jms.server.security.CheckType;
 import org.jboss.jms.server.security.Role;
-import org.jboss.jms.server.security.SecurityMetadata;
+import org.jboss.messaging.core.Destination;
+import org.jboss.messaging.util.HierarchicalRepository;
 
 import javax.jms.JMSSecurityException;
 import javax.security.auth.Subject;
 import java.util.HashSet;
-import java.util.Set;
 
 /**
  * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
@@ -39,15 +39,6 @@
 public interface SecurityStore
 {
    /**
-    * @return the security meta-data for the given destination.
-    */
-   SecurityMetadata getSecurityMetadata(boolean isQueue, String destName);
-
-   void setSecurityConfig(boolean isQueue, String destName, HashSet<Role> conf) throws Exception;
-   
-   void clearSecurityConfig(boolean isQueue, String name) throws Exception;
-
-   /**
     * Authenticate the specified user with the given password. Implementations are most likely to
     * delegates to a JBoss AuthenticationManager.
     *
@@ -67,5 +58,7 @@
     * @param rolePrincipals - The set of roles allowed to read/write/create the destination.
     * @return true if the subject is authorized, or false if not.
     */
-   boolean authorize(String user, Set rolePrincipals, CheckType checkType);  
+   boolean authorize(String user,  Destination destination, CheckType checkType);
+
+   void setSecurityRepository(HierarchicalRepository<HashSet<Role>> securityRepository);
 }

Modified: trunk/src/main/org/jboss/jms/server/connectionfactory/ConnectionFactory.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/connectionfactory/ConnectionFactory.java	2008-01-22 13:47:58 UTC (rev 3611)
+++ trunk/src/main/org/jboss/jms/server/connectionfactory/ConnectionFactory.java	2008-01-22 15:47:50 UTC (rev 3612)
@@ -6,18 +6,11 @@
  */
 package org.jboss.jms.server.connectionfactory;
 
-import java.util.List;
-import java.util.Map;
-
 import org.jboss.jms.client.plugin.LoadBalancingFactory;
-import org.jboss.jms.server.ConnectionFactoryManager;
-import org.jboss.jms.server.ConnectionManager;
 import org.jboss.messaging.util.Logger;
-import org.jboss.messaging.core.MessagingServer;
-import org.jboss.messaging.core.remoting.ServerLocator;
-import org.jboss.messaging.core.remoting.impl.mina.MinaService;
-import org.jboss.messaging.util.ExceptionUtil;
 
+import java.util.List;
+
 /**
  * A deployable JBoss Messaging connection factory.
  * 
@@ -62,14 +55,6 @@
    
    private int dupsOKBatchSize = 1000;
 
-   private MessagingServer messagingServer;
-   
-   private ConnectionFactoryManager connectionFactoryManager;
-   
-   private MinaService minaService;
-
-   private boolean started;
-
    private boolean strictTck;
    
    private boolean disableRemotingChecks;
@@ -92,67 +77,15 @@
 
    // ServiceMBeanSupport overrides ----------------------------------------------------------------
 
-   public synchronized void start() throws Exception
-   {
-      try
-      {
-         log.debug(this + " starting");
 
-         started = true;
-         
-         if (minaService == null)
-         {
-            throw new IllegalArgumentException("A MinaService must be specified for " +
-                                               "each Connection Factory");
-         }
-         
-         if (messagingServer == null)
-         {
-            throw new IllegalArgumentException("MessagingServer must be specified for " +
-                                               "each Connection Factory");
-         }
-      
-         ServerLocator serverLocator = minaService.getLocator();
+   // JMX managed attributes -----------------------------------------------------------------------
 
-         connectionFactoryManager = messagingServer.getConnectionFactoryManager();
 
-         // We use the MBean service name to uniquely identify the connection factory
-         
-         connectionFactoryManager.
-            registerConnectionFactory(getName(), clientID, jndiBindings,
-                                      serverLocator.getURI(), false, prefetchSize, 
-                                      defaultTempQueueFullSize, defaultTempQueuePageSize,                                      
-                                      defaultTempQueueDownCacheSize, dupsOKBatchSize, supportsFailover, supportsLoadBalancing,
-                                      loadBalancingFactory, strictTck);               
-      
-         log.info("Server locator is " + serverLocator);
-         log.info(this + " started");
-      }
-      catch (Throwable t)
-      {
-         throw ExceptionUtil.handleJMXInvocation(t, this + " startService");
-      } 
-   }
-   
-   public synchronized void stop() throws Exception
+   public void setClientID(String clientID)
    {
-      try
-      {
-         started = false;
-         
-         connectionFactoryManager.
-            unregisterConnectionFactory(getName());
-         
-         log.info(this + " undeployed");
-      }
-      catch (Throwable t)
-      {
-         throw ExceptionUtil.handleJMXInvocation(t, this + " startService");
-      } 
+      this.clientID = clientID;
    }
 
-   // JMX managed attributes -----------------------------------------------------------------------
-   
    public int getDefaultTempQueueFullSize()
    {
       return defaultTempQueueFullSize;
@@ -222,21 +155,6 @@
       return jndiBindings;
    }
 
-   public MessagingServer getMessagingServer()
-   {
-      return messagingServer;
-   }
-
-   public void setMessagingServer(MessagingServer messagingServer)
-   {
-      this.messagingServer = messagingServer;
-   }
-
-   public void setMinaService(MinaService service)
-   {
-      this.minaService = service;
-   }
-
    public boolean isSupportsFailover()
    {
       return supportsFailover;
@@ -244,11 +162,6 @@
    
    public void setSupportsFailover(boolean supportsFailover)
    {
-      if (started)
-      {
-         log.warn("supportsFailover can only be changed when connection factory is stopped");
-         return;
-      }
       this.supportsFailover = supportsFailover;
    }
    
@@ -259,11 +172,6 @@
    
    public void setSupportsLoadBalancing(boolean supportsLoadBalancing)
    {
-      if (started)
-      {
-         log.warn("supportsLoadBalancing can only be changed when connection factory is stopped");
-         return;
-      }
       this.supportsLoadBalancing = supportsLoadBalancing;
    }
 
@@ -274,11 +182,6 @@
 
    public void setLoadBalancingFactory(String factoryName) throws Exception
    {
-      if (started)
-      {
-         log.warn("Load balancing policy can only be changed when connection factory is stopped");
-         return;
-      }
       
       //We don't use Class.forName() since then it won't work with scoped deployments
       Class clz = Thread.currentThread().getContextClassLoader().loadClass(factoryName);
@@ -288,12 +191,6 @@
    
    public void setDupsOKBatchSize(int size) throws Exception
    {
-      if (started)
-      {
-         log.warn("DupsOKBatchSize can only be changed when connection factory is stopped");
-         return;
-      }
-
       this.dupsOKBatchSize = size;
    }
 
@@ -309,12 +206,6 @@
 
    public void setStrictTck(boolean strictTck)
    {
-      if (started)
-      {
-         log.warn("StrictTCK can only be changed when connection factory is stopped");
-         return;         
-      }
-      
    	this.strictTck = strictTck;
    }
    
@@ -325,12 +216,6 @@
    
    public void setDisableRemotingChecks(boolean disable)
    {
-      if (started)
-      {
-         log.warn("DisableRemotingChecks can only be changed when connection factory is stopped");
-         return;
-      }
-      
    	this.disableRemotingChecks = disable;
    }
 
@@ -354,30 +239,6 @@
 
    // Private --------------------------------------------------------------------------------------
 
-   private boolean checkParam(Map params, String key, String value)
-   {
-   	String val = (String)params.get(key);
-   	if (val == null)
-   	{
-   		log.error("Parameter " + key + " is not specified in the remoting congiguration");
-   		return false;
-   	}   	
-   	else if (!val.equals(value))
-   	{
-   		log.error("Parameter " + key + " has a different value ( " + val + ") to the default shipped with this version of " +
-   				    "JBM (" + value + "). " +
-   				    "There is rarely a valid reason to change this parameter value. " +
-   				    "If you are using ServiceBindingManager to supply the remoting configuration you should check " +
-   				    "that the parameter value specified there exactly matches the value in the configuration supplied with JBM. " +
-   				    "This connection factory will now not deploy. To override these checks set 'disableRemotingChecks' to " +
-   				    "true on the connection factory. Only do this if you are absolutely sure you know the consequences.");
-   		return false;
-   	}
-   	else
-   	{
-   		return true;
-   	}
-   }
    
    // Inner classes --------------------------------------------------------------------------------
 }

Deleted: trunk/src/main/org/jboss/jms/server/connectionfactory/ConnectionFactoryDeployer.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/connectionfactory/ConnectionFactoryDeployer.java	2008-01-22 13:47:58 UTC (rev 3611)
+++ trunk/src/main/org/jboss/jms/server/connectionfactory/ConnectionFactoryDeployer.java	2008-01-22 15:47:50 UTC (rev 3612)
@@ -1,173 +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.jms.server.connectionfactory;
-
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.jboss.messaging.core.MessagingServer;
-import org.jboss.messaging.core.remoting.impl.mina.MinaService;
-import org.jboss.messaging.util.XMLUtil;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
-
-/**
- * This class will deploy any Connection Factories configured in the jbm-configuration.xml file.
- *
- * @author <a href="ataylor at redhat.com">Andy Taylor</a>
- */
-public class ConnectionFactoryDeployer
-{
-   private static final String JBM_FACTORIES_XML = "jbm-configuration.xml";
-   private static final String FACTORY_ELEMENT = "factory";
-   private static final String NAME_ATTR = "name";
-   private static final String CLIENTID_ELEMENT = "client-id";
-   private static final String PREFETECH_SIZE_ELEMENT = "prefetch-size";
-   private static final String DEF_TEMP_Q_FULL_SIZE = "default-temp-queue-full-size";
-   private static final String DEF_TEMP_Q_PAGE_SIZE_SIZE = "default-temp-queue-page-size";
-   private static final String DEF_TEMP_Q_DOWN_CACHE_SIZE = "default-temp-queue-down-cache-size";
-   private static final String DUPS_OK_BATCH_SIZE = "dups-ok-batch-size";
-   private static final String SUPPORTS_FAILOVER = "supports-failover";
-   private static final String SUPPORTS_LOAD_BALANCING = "supports-load-balancing";
-   private static final String LOAD_BALANCING_FACTORY = "load-balancing-factory";
-   private static final String STRICT_TCK = "strict-tck";
-   private static final String DISABLE_REMOTING_CHECKS = "disable-remoting-checks";
-   private static final String JNDI_BINDINGS = "jndi-bindings";
-   private static final String BIDING = "binding";
-
-   private List<ConnectionFactory> connectionFactories = new ArrayList<ConnectionFactory>();
-   private MessagingServer messagingServer;
-   private MinaService minaService;
-//   private Connector connector;
-
-
-   public ConnectionFactoryDeployer(MessagingServer messagingServer, MinaService minaService)
-   {
-      this.messagingServer = messagingServer;
-      this.minaService = minaService;
-   }
-
-   /**
-    * lifecycle method that will deploy and undeploy connection factories
-    */
-   public void start() throws Exception
-   {
-      //find the config file
-      URL url = getClass().getClassLoader().getResource(JBM_FACTORIES_XML);
-      Element e = XMLUtil.urlToElement(url);
-      //lets get all the factories and create them
-      NodeList children = e.getElementsByTagName(FACTORY_ELEMENT);
-      for (int i = 0; i < children.getLength(); i++)
-      {
-         String clientId = null;
-         String name = children.item(i).getAttributes().getNamedItem(NAME_ATTR).getNodeValue();
-         ConnectionFactory connectionFactory = new ConnectionFactory(clientId);
-         connectionFactory.setName(name);
-         connectionFactories.add(connectionFactory);
-         NodeList attributes = children.item(i).getChildNodes();
-         for (int j = 0; j < attributes.getLength(); j++)
-         {
-            if (CLIENTID_ELEMENT.equalsIgnoreCase(attributes.item(j).getNodeName()))
-            {
-               clientId = attributes.item(j).getTextContent();
-            }
-
-            if (PREFETECH_SIZE_ELEMENT.equalsIgnoreCase(attributes.item(j).getNodeName()))
-            {
-               connectionFactory.setPrefetchSize(Integer.parseInt(attributes.item(j).getTextContent().trim()));
-            }
-            if (DEF_TEMP_Q_FULL_SIZE.equalsIgnoreCase(attributes.item(j).getNodeName()))
-            {
-               connectionFactory.setDefaultTempQueueFullSize(Integer.parseInt(attributes.item(j).getTextContent().trim()));
-            }
-            if (DEF_TEMP_Q_PAGE_SIZE_SIZE.equalsIgnoreCase(attributes.item(j).getNodeName()))
-            {
-               connectionFactory.setDefaultTempQueuePageSize(Integer.parseInt(attributes.item(j).getTextContent().trim()));
-            }
-            if (DEF_TEMP_Q_DOWN_CACHE_SIZE.equalsIgnoreCase(attributes.item(j).getNodeName()))
-            {
-               connectionFactory.setDefaultTempQueueDownCacheSize(Integer.parseInt(attributes.item(j).getTextContent().trim()));
-            }
-            if (DUPS_OK_BATCH_SIZE.equalsIgnoreCase(attributes.item(j).getNodeName()))
-            {
-               connectionFactory.setDupsOKBatchSize(Integer.parseInt(attributes.item(j).getTextContent().trim()));
-            }
-            if (SUPPORTS_FAILOVER.equalsIgnoreCase(attributes.item(j).getNodeName()))
-            {
-               connectionFactory.setSupportsFailover(Boolean.parseBoolean(attributes.item(j).getTextContent().trim()));
-            }
-            if (SUPPORTS_LOAD_BALANCING.equalsIgnoreCase(attributes.item(j).getNodeName()))
-            {
-               connectionFactory.setSupportsLoadBalancing(Boolean.parseBoolean(attributes.item(j).getTextContent().trim()));
-            }
-            if (LOAD_BALANCING_FACTORY.equalsIgnoreCase(attributes.item(j).getNodeName()))
-            {
-               connectionFactory.setLoadBalancingFactory(attributes.item(j).getTextContent().trim());
-            }
-            if (STRICT_TCK.equalsIgnoreCase(attributes.item(j).getNodeName()))
-            {
-               connectionFactory.setStrictTck(Boolean.parseBoolean(attributes.item(j).getTextContent().trim()));
-            }
-            if (DISABLE_REMOTING_CHECKS.equalsIgnoreCase(attributes.item(j).getNodeName()))
-            {
-               connectionFactory.setDisableRemotingChecks(Boolean.parseBoolean(attributes.item(j).getTextContent().trim()));
-            }
-            if (JNDI_BINDINGS.equalsIgnoreCase(attributes.item(j).getNodeName()))
-            {
-               connectionFactory.setJNDIBindings(getBindings(attributes.item(j).getChildNodes()));
-            }
-
-         }
-         connectionFactory.setMessagingServer(messagingServer);
-         connectionFactory.setMinaService(minaService);
-         connectionFactory.start();
-      }
-   }
-
-   private List<String> getBindings(NodeList childNodes)
-   {
-      List<String> bindings = new ArrayList<String>();
-      for (int i = 0; i < childNodes.getLength(); i++)
-      {
-         if (BIDING.equalsIgnoreCase(childNodes.item(i).getNodeName()))
-         {
-            bindings.add(childNodes.item(i).getTextContent().trim());
-         }
-      }
-      return bindings;
-   }
-
-   /**
-    * lifecycle method to stop factories
-    *
-    * @throws Exception
-    */
-   public void stop() throws Exception
-   {
-      for (ConnectionFactory connectionFactory : connectionFactories)
-      {
-         connectionFactory.stop();
-      }
-   }
-
-}

Deleted: trunk/src/main/org/jboss/jms/server/connectionfactory/ConnectionFactoryJNDIMapper.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/connectionfactory/ConnectionFactoryJNDIMapper.java	2008-01-22 13:47:58 UTC (rev 3611)
+++ trunk/src/main/org/jboss/jms/server/connectionfactory/ConnectionFactoryJNDIMapper.java	2008-01-22 15:47:50 UTC (rev 3612)
@@ -1,215 +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.jms.server.connectionfactory;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-
-import org.jboss.jms.client.JBossConnectionFactory;
-import org.jboss.jms.client.impl.ClientConnectionFactoryImpl;
-import org.jboss.jms.client.plugin.LoadBalancingFactory;
-import org.jboss.jms.server.ConnectionFactoryManager;
-import org.jboss.jms.server.endpoint.ServerConnectionFactoryEndpoint;
-import org.jboss.messaging.core.MessagingServer;
-import org.jboss.messaging.util.JNDIUtil;
-import org.jboss.messaging.util.Logger;
-import org.jboss.messaging.util.Version;
-
-/**
- * @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:clebert.suconic at jboss.com">Clebert Suconic</a>
- * @author <a href="ataylor at redhat.com">Andy Taylor</a>
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
- * @version <tt>$Revision$</tt>
- *
- * $Id$
- */
-public class ConnectionFactoryJNDIMapper implements ConnectionFactoryManager
-{
-   // Constants ------------------------------------------------------------------------------------
-
-   private static final Logger log = Logger.getLogger(ConnectionFactoryJNDIMapper.class);
-
-   // Static ---------------------------------------------------------------------------------------
-
-   private static boolean trace = log.isTraceEnabled();
-
-   // Attributes -----------------------------------------------------------------------------------
-
-   protected Context initialContext;
-   protected MessagingServer messagingServer;
-
-   // Map<uniqueName<String> - ServerConnectionFactoryEndpoint>
-   private Map endpoints;
-
-   // Constructors ---------------------------------------------------------------------------------
-
-   public ConnectionFactoryJNDIMapper(MessagingServer messagingServer) throws Exception
-   {
-      this.messagingServer = messagingServer;
-      endpoints = new HashMap();
-   }
-
-   // ConnectionFactoryManager implementation ------------------------------------------------------
-
-   /**
-    * @param loadBalancingFactory - ignored for non-clustered connection factories.
-    */
-   public synchronized void registerConnectionFactory(String uniqueName,
-                                                      String clientID,
-                                                      List<String> jndiBindings,
-                                                      String serverLocatorURI,
-                                                      boolean clientPing,
-                                                      int prefetchSize,                                                 
-                                                      int defaultTempQueueFullSize,
-                                                      int defaultTempQueuePageSize,
-                                                      int defaultTempQueueDownCacheSize,
-                                                      int dupsOKBatchSize,
-                                                      boolean supportsFailover,
-                                                      boolean supportsLoadBalancing,
-                                                      LoadBalancingFactory loadBalancingFactory,
-                                                      boolean strictTck)
-      throws Exception
-   {
-      log.debug(this + " registering connection factory '" + uniqueName + "', bindings: " + jndiBindings);
-
-      // Sanity check
-      if (endpoints.containsKey(uniqueName))
-      {
-         throw new IllegalArgumentException("There's already a connection factory " +
-                                            "registered with name " + uniqueName);
-      }
-
-      // See http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4076040#4076040
-      final String id = uniqueName;
-
-      Version version = messagingServer.getVersion();
-
-      ServerConnectionFactoryEndpoint endpoint =
-         new ServerConnectionFactoryEndpoint(uniqueName, id, messagingServer, clientID,
-                                             jndiBindings, prefetchSize,                                            
-                                             defaultTempQueueFullSize,
-                                             defaultTempQueuePageSize,
-                                             defaultTempQueueDownCacheSize,
-                                             dupsOKBatchSize);
-      endpoints.put(uniqueName, endpoint);
-
-      //The server peer strict setting overrides the connection factory
-      boolean useStrict = messagingServer.getConfiguration().isStrictTck() || strictTck;
-
-      ClientConnectionFactoryImpl delegate =
-         new ClientConnectionFactoryImpl(uniqueName, id, messagingServer.getConfiguration().getMessagingServerID(),
-                                             serverLocatorURI, version, clientPing, useStrict);
-
-      log.debug(this + " created local delegate " + delegate);
-
-      // Now bind it in JNDI
-      rebindConnectionFactory(initialContext, jndiBindings, delegate);
-
-      // Registering with the dispatcher should always be the last thing otherwise a client could
-      // use a partially initialised object
-           
-      messagingServer.getMinaService().getDispatcher().register(endpoint.newHandler());
-   }
-
-   public synchronized void unregisterConnectionFactory(String uniqueName)
-      throws Exception
-   {
-      log.trace("ConnectionFactory " + uniqueName + " being unregistered");
-      ServerConnectionFactoryEndpoint endpoint =
-         (ServerConnectionFactoryEndpoint)endpoints.remove(uniqueName);
-
-      if (endpoint == null)
-      {
-         throw new IllegalArgumentException("Cannot find endpoint with name " + uniqueName);
-      }
-
-      List<String> jndiBindings = endpoint.getJNDIBindings();
-
-      if (jndiBindings != null)
-      {
-         for(Iterator i = jndiBindings.iterator(); i.hasNext(); )
-         {
-            String jndiName = (String)i.next();
-            initialContext.unbind(jndiName);
-            log.debug(jndiName + " unregistered");
-         }
-      }     
-      
-      this.messagingServer.getMinaService().getDispatcher().unregister(endpoint.getID());
-   }
-
-   // MessagingComponent implementation ------------------------------------------------------------
-
-   public void start() throws Exception
-   {
-      initialContext = new InitialContext();
-
-      log.debug("started");
-   }
-
-   public void stop() throws Exception
-   {
-      initialContext.close();
-
-      log.debug("stopped");
-   }
-   
-   // Public ---------------------------------------------------------------------------------------
-
-   public String toString()
-   {
-      return "Server[" + messagingServer.getConfiguration().getMessagingServerID() + "].ConnFactoryJNDIMapper";
-   }
-
-   // Package protected ----------------------------------------------------------------------------
-
-   // Protected ------------------------------------------------------------------------------------
-
-   // Private --------------------------------------------------------------------------------------
-
-   private void rebindConnectionFactory(Context ic, List<String> jndiBindings,
-                                        ClientConnectionFactoryImpl delegate)
-      throws NamingException
-   {
-      JBossConnectionFactory cf = new JBossConnectionFactory(delegate);
-
-      if (jndiBindings != null)
-      {
-         for(Iterator i = jndiBindings.iterator(); i.hasNext(); )
-         {
-            String jndiName = (String)i.next();
-            log.debug(this + " rebinding " + cf + " as " + jndiName);
-            JNDIUtil.rebind(ic, jndiName, cf);
-         }
-      }
-   }
-
-   // Inner classes --------------------------------------------------------------------------------
-}

Modified: trunk/src/main/org/jboss/jms/server/container/SecurityAspect.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/container/SecurityAspect.java	2008-01-22 13:47:58 UTC (rev 3611)
+++ trunk/src/main/org/jboss/jms/server/container/SecurityAspect.java	2008-01-22 15:47:50 UTC (rev 3612)
@@ -21,32 +21,28 @@
   */
 package org.jboss.jms.server.container;
 
-import java.util.HashSet;
-import java.util.Set;
-
-import javax.jms.JMSSecurityException;
-
 import org.jboss.jms.server.SecurityStore;
 import org.jboss.jms.server.endpoint.ServerConnectionEndpoint;
 import org.jboss.jms.server.security.CheckType;
-import org.jboss.jms.server.security.SecurityMetadata;
-import org.jboss.messaging.util.Logger;
 import org.jboss.messaging.core.Destination;
-import org.jboss.messaging.core.DestinationType;
-import org.jboss.security.SimplePrincipal;
+import org.jboss.messaging.util.Logger;
 
+import javax.jms.JMSSecurityException;
+import java.util.HashSet;
+import java.util.Set;
+
 /**
  * This aspect enforces the JBossMessaging JMS security policy.
- * 
+ *
  * This aspect is PER_INSTANCE
- * 
+ *
  * For performance reasons we cache access rights in the interceptor for a maximum of
  * INVALIDATION_INTERVAL milliseconds.
  * This is because we don't want to do a full authentication and authorization on every send,
  * for example, since this will drastically reduce performance.
  * This means any changes to security data won't be reflected until INVALIDATION_INTERVAL
  * milliseconds later.
- * 
+ *
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
  * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
  * @version <tt>$Revision 1.1 $</tt>
@@ -60,56 +56,56 @@
    private static final Logger log = Logger.getLogger(SecurityAspect.class);
 
    // Static --------------------------------------------------------
-   
+
    // Attributes ----------------------------------------------------
-   
+
    private boolean trace = log.isTraceEnabled();
-   
+
    private Set<Destination> readCache;
-   
+
    private Set<Destination> writeCache;
-   
-   private Set<Destination> createCache;
-   
+
+   private Set createCache;
+
    //TODO Make this configurable
    private static final long INVALIDATION_INTERVAL = 15000;
-   
+
    private long lastCheck;
-      
+
    // Constructors --------------------------------------------------
-   
+
    // Public --------------------------------------------------------
    public SecurityAspect()
    {
-      readCache = new HashSet<Destination>();
-      
-      writeCache = new HashSet<Destination>();
-      
-      createCache = new HashSet<Destination>();
+      readCache = new HashSet();
+
+      writeCache = new HashSet();
+
+      createCache = new HashSet();
    }
-   
+
    // Package protected ---------------------------------------------
-   
+
    // Protected -----------------------------------------------------
-   
+
    // Private -------------------------------------------------------
-         
+
    public boolean checkCached(Destination dest, CheckType checkType)
    {
       long now = System.currentTimeMillis();
-      
+
       boolean granted = false;
-      
+
       if (now - lastCheck > INVALIDATION_INTERVAL)
       {
          readCache.clear();
-         
+
          writeCache.clear();
-         
-         createCache.clear();         
+
+         createCache.clear();
       }
       else
-      {         
+      {
          switch (checkType.type)
          {
             case CheckType.TYPE_READ:
@@ -133,12 +129,12 @@
             }
          }
       }
-      
+
       lastCheck = now;
-      
+
       return granted;
    }
-   
+
    public void check(Destination dest, CheckType checkType, ServerConnectionEndpoint conn)
       throws JMSSecurityException
    {
@@ -149,40 +145,28 @@
       }
 
       if (trace) { log.trace("checking access permissions to " + dest); }
-      
+
       if (checkCached(dest, checkType))
       {
          // OK
          return;
       }
 
-      
-      //FIXME - this check does not belong here
-      boolean isQueue = dest.getType() == DestinationType.QUEUE;
       String name = dest.getName();
 
       SecurityStore sm = conn.getSecurityManager();
-      SecurityMetadata securityMetadata = sm.getSecurityMetadata(isQueue, name);
 
-      if (securityMetadata == null)
-      {
-         throw new JMSSecurityException("No security configuration avaliable for " + name);
-      }
-
       // Authenticate. Successful autentication will place a new SubjectContext on thread local,
       // which will be used in the authorization process. However, we need to make sure we clean up
       // thread local immediately after we used the information, otherwise some other people
       // security my be screwed up, on account of thread local security stack being corrupted.
-      
+
       sm.authenticate(conn.getUsername(), conn.getPassword());
 
       // Authorize
-      Set<SimplePrincipal> principals = checkType == CheckType.READ ? securityMetadata.getReadPrincipals() :
-                       checkType == CheckType.WRITE ? securityMetadata.getWritePrincipals() :
-                       securityMetadata.getCreatePrincipals();
       try
       {
-         if (!sm.authorize(conn.getUsername(), principals, checkType))
+         if (!sm.authorize(conn.getUsername(), dest, checkType))
          {
             String msg = "User: " + conn.getUsername() +
                " is not authorized to " +

Modified: trunk/src/main/org/jboss/jms/server/endpoint/ServerConnectionFactoryEndpoint.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/endpoint/ServerConnectionFactoryEndpoint.java	2008-01-22 13:47:58 UTC (rev 3611)
+++ trunk/src/main/org/jboss/jms/server/endpoint/ServerConnectionFactoryEndpoint.java	2008-01-22 15:47:50 UTC (rev 3612)
@@ -21,30 +21,22 @@
   */
 package org.jboss.jms.server.endpoint;
 
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_UPDATECALLBACK;
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_CREATECONNECTION;
-
-import java.util.List;
-import java.util.Map;
-
-import javax.jms.JMSException;
-
-import org.jboss.jms.client.impl.ClientConnectionImpl;
 import org.jboss.jms.client.impl.ClientConnectionFactoryImpl;
+import org.jboss.jms.client.impl.ClientConnectionImpl;
 import org.jboss.jms.client.impl.CreateConnectionResult;
 import org.jboss.jms.exception.MessagingJMSException;
 import org.jboss.messaging.core.MessagingServer;
 import org.jboss.messaging.core.remoting.PacketHandler;
 import org.jboss.messaging.core.remoting.PacketSender;
-import org.jboss.messaging.core.remoting.wireformat.AbstractPacket;
-import org.jboss.messaging.core.remoting.wireformat.CreateConnectionRequest;
-import org.jboss.messaging.core.remoting.wireformat.CreateConnectionResponse;
-import org.jboss.messaging.core.remoting.wireformat.JMSExceptionMessage;
-import org.jboss.messaging.core.remoting.wireformat.PacketType;
-import org.jboss.messaging.core.remoting.wireformat.UpdateCallbackMessage;
+import org.jboss.messaging.core.remoting.wireformat.*;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_UPDATECALLBACK;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_CREATECONNECTION;
 import org.jboss.messaging.util.ExceptionUtil;
 import org.jboss.messaging.util.Logger;
 
+import javax.jms.JMSException;
+import java.util.Map;
+
 /**
  * Concrete implementation of ConnectionFactoryEndpoint
  *
@@ -73,8 +65,6 @@
 
    private String id;
 
-   private List<String> jndiBindings;
-
    private int prefetchSize;
 
    private int defaultTempQueueFullSize;
@@ -95,15 +85,9 @@
 
    
    // Constructors ---------------------------------------------------------------------------------
-
-   /**
-    * @param jndiBindings - names under which the corresponding JBossConnectionFactory is bound in
-    *        JNDI.
-    */
    public ServerConnectionFactoryEndpoint(String uniqueName, String id, MessagingServer messagingServer,
                                           String defaultClientID,
-                                          List<String> jndiBindings,
-                                          int preFetchSize,                                          
+                                          int preFetchSize,
                                           int defaultTempQueueFullSize,
                                           int defaultTempQueuePageSize,
                                           int defaultTempQueueDownCacheSize,
@@ -113,7 +97,6 @@
       this.messagingServer = messagingServer;
       this.clientID = defaultClientID;
       this.id = id;
-      this.jndiBindings = jndiBindings;
       this.prefetchSize = preFetchSize;
       this.defaultTempQueueFullSize = defaultTempQueueFullSize;
       this.defaultTempQueuePageSize = defaultTempQueuePageSize;
@@ -238,11 +221,6 @@
       return id;
    }
 
-   public List<String> getJNDIBindings()
-   {
-      return jndiBindings;
-   }
-
    public MessagingServer getMessagingServer()
    {
       return messagingServer;

Modified: trunk/src/main/org/jboss/jms/server/endpoint/ServerSessionEndpoint.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/endpoint/ServerSessionEndpoint.java	2008-01-22 13:47:58 UTC (rev 3611)
+++ trunk/src/main/org/jboss/jms/server/endpoint/ServerSessionEndpoint.java	2008-01-22 15:47:50 UTC (rev 3612)
@@ -21,104 +21,45 @@
   */
 package org.jboss.jms.server.endpoint;
 
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_ACKDELIVERIES;
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_ADDTEMPORARYDESTINATION;
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_CANCELDELIVERIES;
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_CANCELDELIVERY;
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_CLOSE;
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_DELETETEMPORARYDESTINATION;
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_SENDMESSAGE;
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_UNSUBSCRIBE;
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_ACKDELIVERY;
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_CLOSING;
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_CREATEBROWSER;
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_CREATECONSUMER;
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_CREATEDESTINATION;
-
-import java.lang.ref.WeakReference;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-
-import javax.jms.IllegalStateException;
-import javax.jms.InvalidDestinationException;
-import javax.jms.InvalidSelectorException;
-import javax.jms.JMSException;
-
+import EDU.oswego.cs.dl.util.concurrent.ConcurrentHashMap;
+import EDU.oswego.cs.dl.util.concurrent.LinkedQueue;
+import EDU.oswego.cs.dl.util.concurrent.QueuedExecutor;
+import EDU.oswego.cs.dl.util.concurrent.SynchronizedLong;
 import org.jboss.jms.client.api.ClientBrowser;
-import org.jboss.jms.client.impl.Ack;
-import org.jboss.jms.client.impl.AckImpl;
-import org.jboss.jms.client.impl.Cancel;
-import org.jboss.jms.client.impl.ClientBrowserImpl;
-import org.jboss.jms.client.impl.ClientConsumerImpl;
-import org.jboss.jms.client.impl.DeliveryInfo;
+import org.jboss.jms.client.impl.*;
 import org.jboss.jms.destination.JBossDestination;
 import org.jboss.jms.destination.JBossQueue;
 import org.jboss.jms.destination.JBossTopic;
 import org.jboss.jms.exception.MessagingJMSException;
-import org.jboss.jms.server.DestinationManager;
 import org.jboss.jms.server.container.SecurityAspect;
 import org.jboss.jms.server.security.CheckType;
-import org.jboss.messaging.core.Binding;
-import org.jboss.messaging.core.Condition;
-import org.jboss.messaging.core.Destination;
-import org.jboss.messaging.core.DestinationType;
-import org.jboss.messaging.core.Filter;
-import org.jboss.messaging.core.Message;
-import org.jboss.messaging.core.MessageReference;
-import org.jboss.messaging.core.MessagingServer;
-import org.jboss.messaging.core.PostOffice;
+import org.jboss.messaging.core.*;
 import org.jboss.messaging.core.Queue;
-import org.jboss.messaging.core.Transaction;
-import org.jboss.messaging.core.TransactionSynchronization;
 import org.jboss.messaging.core.impl.ConditionImpl;
 import org.jboss.messaging.core.impl.TransactionImpl;
 import org.jboss.messaging.core.impl.filter.FilterImpl;
 import org.jboss.messaging.core.remoting.PacketHandler;
 import org.jboss.messaging.core.remoting.PacketSender;
-import org.jboss.messaging.core.remoting.wireformat.AbstractPacket;
-import org.jboss.messaging.core.remoting.wireformat.AcknowledgeDeliveriesMessage;
-import org.jboss.messaging.core.remoting.wireformat.AcknowledgeDeliveryRequest;
-import org.jboss.messaging.core.remoting.wireformat.AcknowledgeDeliveryResponse;
-import org.jboss.messaging.core.remoting.wireformat.AddTemporaryDestinationMessage;
-import org.jboss.messaging.core.remoting.wireformat.CancelDeliveriesMessage;
-import org.jboss.messaging.core.remoting.wireformat.CancelDeliveryMessage;
-import org.jboss.messaging.core.remoting.wireformat.ClosingRequest;
-import org.jboss.messaging.core.remoting.wireformat.ClosingResponse;
-import org.jboss.messaging.core.remoting.wireformat.CreateBrowserRequest;
-import org.jboss.messaging.core.remoting.wireformat.CreateBrowserResponse;
-import org.jboss.messaging.core.remoting.wireformat.CreateConsumerRequest;
-import org.jboss.messaging.core.remoting.wireformat.CreateConsumerResponse;
-import org.jboss.messaging.core.remoting.wireformat.CreateDestinationRequest;
-import org.jboss.messaging.core.remoting.wireformat.CreateDestinationResponse;
-import org.jboss.messaging.core.remoting.wireformat.DeleteTemporaryDestinationMessage;
-import org.jboss.messaging.core.remoting.wireformat.DeliverMessage;
-import org.jboss.messaging.core.remoting.wireformat.JMSExceptionMessage;
-import org.jboss.messaging.core.remoting.wireformat.NullPacket;
-import org.jboss.messaging.core.remoting.wireformat.PacketType;
-import org.jboss.messaging.core.remoting.wireformat.SendMessage;
-import org.jboss.messaging.core.remoting.wireformat.UnsubscribeMessage;
+import org.jboss.messaging.core.remoting.wireformat.*;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.*;
 import org.jboss.messaging.util.ExceptionUtil;
 import org.jboss.messaging.util.Logger;
 import org.jboss.messaging.util.MessageQueueNameHelper;
 
-import EDU.oswego.cs.dl.util.concurrent.ConcurrentHashMap;
-import EDU.oswego.cs.dl.util.concurrent.LinkedQueue;
-import EDU.oswego.cs.dl.util.concurrent.QueuedExecutor;
-import EDU.oswego.cs.dl.util.concurrent.SynchronizedLong;
+import javax.jms.IllegalStateException;
+import javax.jms.InvalidDestinationException;
+import javax.jms.InvalidSelectorException;
+import javax.jms.JMSException;
+import java.lang.ref.WeakReference;
+import java.util.*;
 
 /**
  * Session implementation
- * 
+ *
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * 
+ *
  * Parts derived from JBM 1.x ServerSessionEndpoint by
- * 
+ *
  * @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:clebert.suconic at jboss.com">Clebert Suconic</a>
@@ -132,15 +73,15 @@
    // Constants ------------------------------------------------------------------------------------
 
    private static final Logger log = Logger.getLogger(ServerSessionEndpoint.class);
-   
+
    static final String DUR_SUB_STATE_CONSUMERS = "C";
-   
+
    static final String TEMP_QUEUE_MESSAGECOUNTER_PREFIX = "TempQueue.";
-   
+
    private static final long DELIVERY_WAIT_TIMEOUT = 5 * 1000;
-   
+
    private static final long CLOSE_WAIT_TIMEOUT = 5 * 1000;
-      
+
    // Static ---------------------------------------------------------------------------------------
 
    // Attributes -----------------------------------------------------------------------------------
@@ -154,13 +95,12 @@
    private volatile boolean closed;
 
    private ServerConnectionEndpoint connectionEndpoint;
-   
+
    private MessagingServer sp;
 
    private Map consumers;
    private Map browsers;
 
-   private DestinationManager dm;
    private PostOffice postOffice;
    private int nodeId;
    private int defaultMaxDeliveryAttempts;
@@ -169,21 +109,21 @@
    private Queue defaultExpiryQueue;
 
    private Object deliveryLock = new Object();
-      
+
    // Map <deliveryID, Delivery>
    private Map deliveries;
-   
+
    private SynchronizedLong deliveryIdSequence;
-   
-   //Temporary until we have our own NIO transport   
+
+   //Temporary until we have our own NIO transport
    QueuedExecutor executor = new QueuedExecutor(new LinkedQueue());
-   
+
    private LinkedQueue toDeliver = new LinkedQueue();
-   
+
    private boolean waitingToClose = false;
-   
+
    private Object waitLock = new Object();
-   
+
    // Constructors ---------------------------------------------------------------------------------
 
    ServerSessionEndpoint(String sessionID, ServerConnectionEndpoint connectionEndpoint) throws Exception
@@ -191,32 +131,30 @@
       this.id = sessionID;
 
       this.connectionEndpoint = connectionEndpoint;
-       
+
       sp = connectionEndpoint.getMessagingServer();
 
-      dm = sp.getDestinationManager();
-      
-      postOffice = sp.getPostOffice(); 
-      
+      postOffice = sp.getPostOffice();
+
       nodeId = sp.getConfiguration().getMessagingServerID();
-      
+
       consumers = new HashMap();
-      
+
 		browsers = new HashMap();
-      
+
       defaultDLQ = sp.getDefaultDLQInstance();
-      
+
       defaultExpiryQueue = sp.getDefaultExpiryQueueInstance();
-      
+
       defaultMaxDeliveryAttempts = sp.getConfiguration().getDefaultMaxDeliveryAttempts();
-      
+
       defaultRedeliveryDelay = sp.getConfiguration().getDefaultRedeliveryDelay();
-      
+
       deliveries = new ConcurrentHashMap();
-      
+
       deliveryIdSequence = new SynchronizedLong(0);
    }
-   
+
    // SessionDelegate implementation ---------------------------------------------------------------
 
 
@@ -239,12 +177,12 @@
                                                         String subscriptionName,
                                                         boolean isCC) throws JMSException
    {
-      
+
       checkSecurityCreateConsumerDelegate(destination, subscriptionName);
-      
+
       try
       {
-      	return createConsumerDelegateInternal(destination, filterString, noLocal, subscriptionName);      	
+      	return createConsumerDelegateInternal(destination, filterString, noLocal, subscriptionName);
       }
       catch (Throwable t)
       {
@@ -276,15 +214,15 @@
          {
             throw new IllegalStateException("Session is closed");
          }
-         
+
          //FIXME - this method should not exist on the server
-         
+
          Condition condition = new ConditionImpl(DestinationType.QUEUE, name);
-         
+
          if (!postOffice.containsCondition(condition))
          {
             throw new JMSException("There is no administratively defined queue with name:" + name);
-         }    
+         }
 
          return new JBossQueue(name);
       }
@@ -302,16 +240,16 @@
          {
             throw new IllegalStateException("Session is closed");
          }
-              
+
          //FIXME - this method should not exist on the server
-                  
+
          Condition condition = new ConditionImpl(DestinationType.TOPIC, name);
-         
+
          if (!postOffice.containsCondition(condition))
          {
             throw new JMSException("There is no administratively defined topic with name:" + name);
-         }        
-   
+         }
+
          return new JBossTopic(name);
       }
       catch (Throwable t)
@@ -319,15 +257,15 @@
          throw ExceptionUtil.handleJMSInvocation(t, this + " createTopic");
       }
    }
-   
+
    public void close() throws JMSException
    {
       try
       {
          localClose();
-         
+
          connectionEndpoint.removeSession(id);
-         
+
          connectionEndpoint.getMessagingServer().getMinaService().getDispatcher().unregister(id);
       }
       catch (Throwable t)
@@ -335,74 +273,74 @@
          throw ExceptionUtil.handleJMSInvocation(t, this + " close");
       }
    }
-      
+
    public long closing(long sequence) throws JMSException
    {
       if (trace) log.trace(this + " closing");
-      
+
       // Wait for last np message to arrive
-      
+
       if (sequence != 0)
       {
       	synchronized (waitLock)
-      	{      		
+      	{
       		long wait = CLOSE_WAIT_TIMEOUT;
-      		
+
 	      	while (sequence != expectedSequence && wait > 0)
 	      	{
-	      		long start = System.currentTimeMillis(); 
+	      		long start = System.currentTimeMillis();
 	      		try
 	      		{
 	      			waitLock.wait();
 	      		}
 	      		catch (InterruptedException e)
-	      		{	      			
+	      		{
 	      		}
 	      		wait -= (System.currentTimeMillis() - start);
 	      	}
-	      	
+
 	      	if (wait <= 0)
 	      	{
 	      		log.warn("Timed out waiting for last message");
 	      	}
-      	}      	
-      }      
-      
+      	}
+      }
+
       return -1;
    }
- 
+
    private volatile long expectedSequence = 0;
-   
+
    public void send(Message message) throws JMSException
    {
    	throw new IllegalStateException("Should not be handled on the server");
    }
-   
+
    public void send(Message message, long thisSequence) throws JMSException
    {
       try
-      {                
+      {
       	if (thisSequence != -1)
       	{
       		synchronized (waitLock)
-      		{	      		      	        
-   				connectionEndpoint.sendMessage(message); 
-   				
+      		{
+   				connectionEndpoint.sendMessage(message);
+
       			expectedSequence++;
-     			
+
 	      		waitLock.notify();
       		}
       	}
       	else
       	{
       		connectionEndpoint.sendMessage(message);
-      	}        
-      	
+      	}
+
       	if (message.isDurable())
       	{
       	   sp.getPersistenceManager().addMessage(message);
       	}
-      	
+
       	message.send();
       }
       catch (Throwable t)
@@ -410,33 +348,33 @@
          throw ExceptionUtil.handleJMSInvocation(t, this + " send");
       }
    }
-   
+
    public boolean acknowledgeDelivery(Ack ack) throws JMSException
    {
       try
       {
-         return acknowledgeDeliveryInternal(ack);   
+         return acknowledgeDeliveryInternal(ack);
       }
       catch (Throwable t)
       {
          JMSException e = ExceptionUtil.handleJMSInvocation(t, this + " acknowledgeDelivery");
-         
+
          throw e;
       }
-   }     
-         
+   }
+
    public void acknowledgeDeliveries(List acks) throws JMSException
-   {    
+   {
       if (trace) {log.trace(this + " acknowledges deliveries " + acks); }
-      
+
       try
       {
          Iterator iter = acks.iterator();
-         
+
          while (iter.hasNext())
          {
             Ack ack = (Ack)iter.next();
-            
+
             acknowledgeDeliveryInternal(ack);
          }
       }
@@ -445,47 +383,47 @@
          throw ExceptionUtil.handleJMSInvocation(t, this + " acknowledgeDeliveries");
       }
    }
-             
+
    public void cancelDelivery(Cancel cancel) throws JMSException
    {
       try
       {
          if (trace) {log.trace(this + " cancelDelivery " + cancel); }
-         
-         cancelDeliveryInternal(cancel);          
+
+         cancelDeliveryInternal(cancel);
       }
       catch (Throwable t)
       {
          throw ExceptionUtil.handleJMSInvocation(t, this + " acknowledgeDeliveries");
       }
-   }            
+   }
 
    public void cancelDeliveries(List cancels) throws JMSException
    {
       if (trace) {log.trace(this + " cancels deliveries " + cancels); }
-        
+
       try
       {
          // deliveries must be cancelled in reverse order
-                   
+
          for (int i = cancels.size() - 1; i >= 0; i--)
          {
-            Cancel cancel = (Cancel)cancels.get(i);       
-            
+            Cancel cancel = (Cancel)cancels.get(i);
+
             if (trace) { log.trace(this + " cancelling delivery " + cancel.getDeliveryId()); }
-                        
+
             cancelDeliveryInternal(cancel);
          }
-                 
+
          if (trace) { log.trace("Cancelled deliveries"); }
-         
+
       }
       catch (Throwable t)
       {
          throw ExceptionUtil.handleJMSInvocation(t, this + " cancelDeliveries");
       }
-   }         
-      
+   }
+
    public void addTemporaryDestination(Destination dest) throws JMSException
    {
       try
@@ -494,34 +432,34 @@
          {
             throw new IllegalStateException("Session is closed");
          }
-         
+
          if (!dest.isTemporary())
          {
             throw new InvalidDestinationException("Destination:" + dest + " is not a temporary destination");
          }
 
          connectionEndpoint.addTemporaryDestination(dest);
-         
+
          Condition condition = new ConditionImpl(dest.getType(), dest.getName());
-         
+
          postOffice.addCondition(condition);
-                        
+
          //FIXME - comparisons like this do not belong on the server side
          //They should be computed on the client side
          if (dest.getType() == DestinationType.QUEUE)
-         {                     
-            
+         {
+
             postOffice.addQueue(condition, dest.getName(), null,
                                 false, true, sp.getConfiguration().isClustered());
-                        
-         }         
+
+         }
       }
       catch (Throwable t)
       {
          throw ExceptionUtil.handleJMSInvocation(t, this + " addTemporaryDestination");
       }
    }
-   
+
    public void deleteTemporaryDestination(Destination dest) throws JMSException
    {
       try
@@ -530,66 +468,66 @@
          {
             throw new IllegalStateException("Session is closed");
          }
-   
+
          if (!dest.isTemporary())
          {
             throw new InvalidDestinationException("Destination:" + dest +
                                                   " is not a temporary destination");
          }
-         
+
          Condition condition = new ConditionImpl(dest.getType(), dest.getName());
-                       
+
          //FIXME - comparisons like this should be done on the jms client not here
          if (dest.getType() == DestinationType.QUEUE)
          {
             List<Binding> bindings = postOffice.getBindingsForQueueName(dest.getName());
-                     	
+
          	if (bindings.isEmpty())
          	{
          		throw new IllegalStateException("Cannot find binding for queue " + dest.getName());
          	}
-         	
+
          	Binding binding = bindings.get(0);
-         	
+
          	if (binding.getQueue().getConsumerCount() != 0)
          	{
          		throw new IllegalStateException("Cannot delete temporary queue if it has consumer(s)");
          	}
-         	
+
          	// temporary queues must be unbound on ALL nodes of the cluster
-         	
+
          	postOffice.removeQueue(condition, dest.getName(), sp.getConfiguration().isClustered());
          }
          else
          {
             //FIXME - this should be evaluated on the client side
-            
+
             List<Binding> bindings = postOffice.getBindingsForCondition(new ConditionImpl(dest.getType(), dest.getName()));
-            
+
             if (!bindings.isEmpty())
          	{
             	throw new IllegalStateException("Cannot delete temporary topic if it has consumer(s)");
          	}
-                        
+
             // There is no need to explicitly unbind the subscriptions for the temp topic, this is because we
             // will not get here unless there are no bindings.
             // Note that you cannot create surable subs on a temp topic
          }
-         
+
          postOffice.removeCondition(condition);
-         
-         connectionEndpoint.removeTemporaryDestination(dest);                                
+
+         connectionEndpoint.removeTemporaryDestination(dest);
       }
       catch (Throwable t)
       {
          throw ExceptionUtil.handleJMSInvocation(t, this + " deleteTemporaryDestination");
       }
    }
-   
+
    public void unsubscribe(String subscriptionName) throws JMSException
    {
       log.trace(this + " unsubscribing " + subscriptionName);
-      
+
       try
       {
          if (closed)
@@ -600,73 +538,73 @@
          {
             throw new InvalidDestinationException("Destination is null");
          }
-   
+
          String clientID = connectionEndpoint.getClientID();
-   
+
          if (clientID == null)
          {
             throw new JMSException("null clientID on connection");
          }
-         
+
          //FIXME - this should be done on the client side
-         
+
          String queueName = MessageQueueNameHelper.createSubscriptionName(clientID, subscriptionName);
-                  
+
          List<Binding> bindings = postOffice.getBindingsForQueueName(queueName);
-         
+
          if (bindings.isEmpty())
          {
             throw new InvalidDestinationException("Cannot find durable subscription with name " +
                                                   subscriptionName + " to unsubscribe");
          }
-         
-         Queue sub = bindings.get(0).getQueue(); 
-         
+
+         Queue sub = bindings.get(0).getQueue();
+
          //FIXME all this should be done on the jms client
-         
+
          // Section 6.11. JMS 1.1.
          // "It is erroneous for a client to delete a durable subscription while it has an active
          // TopicSubscriber for it or while a message received by it is part of a current
          // transaction or has not been acknowledged in the session."
-         
+
          if (sub.getConsumerCount() != 0)
          {
             throw new IllegalStateException("Cannot unsubscribe durable subscription " +
                                             subscriptionName + " since it has active subscribers");
          }
-         
+
          //Also if it is clustered we must disallow unsubscribing if it has active consumers on other nodes
 
          //TODO - reimplement this for JBM2
 //         if (sub.isClustered() && sp.getConfiguration().isClustered())
 //         {
 //         	Replicator rep = (Replicator)postOffice;
-//         	
+//
 //         	Map map = rep.get(sub.getName());
-//         	
+//
 //         	if (!map.isEmpty())
 //         	{
 //         		throw new IllegalStateException("Cannot unsubscribe durable subscription " +
 //                     subscriptionName + " since it has active subscribers on other nodes");
 //         	}
 //         }
-         
+
          //FIXME - again all this should be done on the client side jms client
-         
+
          Condition condition = bindings.get(0).getCondition();
-         
+
          postOffice.removeQueue(condition, sub.getName(), sub.isClustered() && sp.getConfiguration().isClustered());
-         
+
          sp.getPersistenceManager().deleteAllReferences(sub);
-         
+
          sub.removeAllReferences();
-         
+
          //TODO - message counters should be handled automatically by the destination
-         
+
 //         String counterName = ManagedDestination.SUBSCRIPTION_MESSAGECOUNTER_PREFIX + sub.getName();
-//         
+//
 //         MessageCounter counter = sp.getMessageCounterManager().unregisterMessageCounter(counterName);
-//         
+//
 //         if (counter == null)
 //         {
 //            throw new IllegalStateException("Cannot find counter to remove " + counterName);
@@ -687,9 +625,9 @@
    {
       throw new RuntimeException("information only available on client side");
    }
-   
+
    // Public ---------------------------------------------------------------------------------------
-   
+
    public ServerConnectionEndpoint getConnectionEndpoint()
    {
       return connectionEndpoint;
@@ -699,30 +637,30 @@
    {
       return "SessionEndpoint[" + id + "]";
    }
-   
+
    // Package protected ----------------------------------------------------------------------------
-   
+
    void expireDelivery(MessageReference ref, Queue expiryQueue) throws Exception
    {
       if (trace) { log.trace(this + " detected expired message " + ref); }
-      
+
       if (expiryQueue != null)
       {
          if (trace) { log.trace(this + " sending expired message to expiry queue " + expiryQueue); }
-         
+
          Message copy = makeCopyForDLQOrExpiry(true, ref);
-         
+
          moveInTransaction(copy, ref, expiryQueue, true);
       }
       else
       {
          log.warn("No expiry queue has been configured so removing expired " + ref);
-         
+
          //TODO - tidy up these references - ugly
          ref.acknowledge(this.getConnectionEndpoint().getMessagingServer().getPersistenceManager());
       }
    }
-      
+
    void removeBrowser(String browserId) throws Exception
    {
       synchronized (browsers)
@@ -744,52 +682,52 @@
          }
       }
    }
-    
+
    void localClose() throws Exception
    {
       if (closed)
       {
          throw new IllegalStateException("Session is already closed");
       }
-      
+
       if (trace) log.trace(this + " close()");
-            
+
       //We clone to avoid deadlock http://jira.jboss.org/jira/browse/JBMESSAGING-836
       Map consumersClone;
       synchronized (consumers)
       {
          consumersClone = new HashMap(consumers);
       }
-      
+
       for( Iterator i = consumersClone.values().iterator(); i.hasNext(); )
       {
          ((ServerConsumerEndpoint)i.next()).localClose();
-      }  
-      
+      }
+
       consumers.clear();
-      
-      
+
+
       //We clone to avoid deadlock http://jira.jboss.org/jira/browse/JBMESSAGING-836
       Map browsersClone;
       synchronized (browsers)
       {
          browsersClone = new HashMap(browsers);
       }
-      
+
       for( Iterator i = browsersClone.values().iterator(); i.hasNext(); )
       {
          ((ServerBrowserEndpoint)i.next()).localClose();
-      }  
-      
+      }
+
       browsers.clear();
-      
-      
+
+
       //Now cancel any remaining deliveries in reverse delivery order
       //Note we don't maintain order using a LinkedHashMap since then we lose
       //concurrency since we would have to lock it exclusively
-      
+
       List entries = new ArrayList(deliveries.entrySet());
-      
+
       //Sort them in reverse delivery id order
       Collections.sort(entries,
                        new Comparator()
@@ -801,26 +739,26 @@
                               Long id1 = (Long)entry1.getKey();
                               Long id2 = (Long)entry2.getKey();
                               return id2.compareTo(id1);
-                           } 
+                           }
                        });
 
       Iterator iter = entries.iterator();
-              
+
       if (trace) { log.trace(this + " cancelling " + entries.size() + " deliveries"); }
-      
+
       while (iter.hasNext())
       {
          Map.Entry entry = (Map.Entry)iter.next();
-         
+
          if (trace) { log.trace(this + " cancelling delivery with delivery id: " + entry.getKey()); }
-         
+
          DeliveryRecord rec = (DeliveryRecord)entry.getValue();
 
-         rec.ref.cancel(this.sp.getPersistenceManager());         
+         rec.ref.cancel(this.sp.getPersistenceManager());
       }
-      
+
       //Close down the executor
-      
+
       //Note we need to wait for ALL tasks to complete NOT just one otherwise we can end up with the following situation
       //prompter is queued and starts to execute
       //prompter almost finishes executing then a message is cancelled due to this session closing
@@ -830,45 +768,45 @@
       executor.shutdownAfterProcessingCurrentlyQueuedTasks();
 
       deliveries.clear();
-      
+
       sp.removeSession(id);
-            
+
       closed = true;
-   }            
-   
+   }
+
    void cancelDelivery(long deliveryId) throws Exception
    {
       DeliveryRecord rec = (DeliveryRecord)deliveries.remove(new Long(deliveryId));
-      
+
       if (rec == null)
       {
          throw new IllegalStateException("Cannot find delivery to cancel " + deliveryId);
       }
-      
+
       rec.ref.cancel(this.sp.getPersistenceManager());
-   }         
-      
+   }
+
    //TODO NOTE! This needs to be synchronized to prevent deliveries coming back
-   //out of order! There maybe some better way of doing this 
+   //out of order! There maybe some better way of doing this
    synchronized void handleDelivery(MessageReference ref, ServerConsumerEndpoint consumer) throws Exception
    {
    	 long deliveryId = -1;
-   	 
+
    	 DeliveryRecord rec = null;
-   	 
-   	 deliveryId = deliveryIdSequence.increment();   	 
-   	 
+
+   	 deliveryId = deliveryIdSequence.increment();
+
    	 if (trace) { log.trace("Delivery id is now " + deliveryId); }
-   	 
+
    	 //TODO can't we combine flags isRetainDeliveries and isReplicating - surely they're mutually exclusive?
        if (consumer.isRetainDeliveries())
-       {      	 
+       {
       	 // Add a delivery
 
       	 rec = new DeliveryRecord(ref, consumer, deliveryId);
-          
+
           deliveries.put(new Long(deliveryId), rec);
-          
+
           if (trace) { log.trace(this + " added delivery " + deliveryId + ": " + ref); }
        }
        else
@@ -877,9 +815,9 @@
        	try
        	{
        		//This basically just releases the memory reference
-       		
+
        		if (trace) { log.trace("Acknowledging delivery now"); }
-       		     		
+
        		ref.acknowledge(connectionEndpoint.getMessagingServer().getPersistenceManager());
        	}
        	catch (Throwable t)
@@ -887,36 +825,36 @@
        		log.error("Failed to acknowledge delivery", t);
        	}
        }
-       
 
-       performDelivery(ref, deliveryId, consumer); 	                             
+
+       performDelivery(ref, deliveryId, consumer);
    }
-   
+
    void performDelivery(MessageReference ref, long deliveryID, ServerConsumerEndpoint consumer)
    {
    	if (consumer == null)
    	{
    		if (trace) { log.trace(this + " consumer is null, cannot perform delivery"); }
-   		
+
    		return;
    	}
-      
+
       if (consumer.isDead())
       {
          //Ignore any responses that come back after consumer has died
          return;
       }
-   	
+
    	if (trace) { log.trace(this + " performing delivery for " + ref); }
-   	   	
+
       // We send the message to the client on the current thread. The message is written onto the
       // transport and then the thread returns immediately without waiting for a response.
 
    	DeliverMessage m = new DeliverMessage(ref.getMessage(), consumer.getID(), deliveryID, ref.getDeliveryCount());
    	m.setVersion(getConnectionEndpoint().getUsingVersion());
    	consumer.deliver(m);
-   	
-   	//TODO - what if we get an exception from MINA? 
+
+   	//TODO - what if we get an exception from MINA?
    	//Surely we need to do exception logic too???
 
 //      }
@@ -928,31 +866,31 @@
 //         // I need to do my own cleanup at ConnectionManager level.
 //
 //         log.trace(this + " failed to handle callback", t);
-//         
-//         //We stop the consumer - some time later the lease will expire and the connection will be closed        
+//
+//         //We stop the consumer - some time later the lease will expire and the connection will be closed
 //         //which will remove the consumer
-//         
+//
 //         consumer.setStarted(false);
-//         
+//
 //         consumer.setDead();
 //
 //         //** IMPORTANT NOTE! We must return the delivery NOT null. **
 //         //This is because if we return NULL then message will remain in the queue, but later
 //         //the connection checker will cleanup and close this consumer which will cancel all the deliveries in it
-//         //including this one, so the message will go back on the queue twice!         
+//         //including this one, so the message will go back on the queue twice!
 //      }
    }
-   
+
    List<MessageReference> acknowledgeTransactionally(List<Ack> acks, Transaction tx) throws Exception
    {
       if (trace) { log.trace(this + " acknowledging transactionally " + acks.size() + " messages for " + tx); }
-             
+
       List<MessageReference> refs = new ArrayList<MessageReference>();
-      
+
       for(Ack ack: acks)
       {
          long id = ack.getDeliveryID();
-         
+
          //TODO - do this more elegantly
          if (ack instanceof DeliveryInfo)
          {
@@ -963,24 +901,24 @@
          		continue;
          	}
          }
-         
+
          DeliveryRecord rec = (DeliveryRecord)deliveries.get(id);
-          
+
          DeliveryCallback cb = new DeliveryCallback(id);
-         
+
          tx.addSynchronization(cb);
-         
+
          refs.add(rec.ref);
-         
+
          if (rec.ref.getMessage().isDurable())
          {
             tx.setContainsPersistent(true);
          }
-      }  
-      
+      }
+
       return refs;
    }
-   
+
    /**
     * Starts this session's Consumers
     */
@@ -992,7 +930,7 @@
       {
          consumersClone = new HashMap(consumers);
       }
-      
+
       for(Iterator i = consumersClone.values().iterator(); i.hasNext(); )
       {
          ServerConsumerEndpoint sce = (ServerConsumerEndpoint)i.next();
@@ -1004,37 +942,37 @@
          {
             sce.stop();
          }
-      }      
-   } 
+      }
+   }
 
    void promptDelivery(final Queue queue)
    {
    	if (trace) { log.trace("Prompting delivery on " + queue); }
-   	
+
       try
       {
          //Prompting delivery must be asynchronous to avoid deadlock
          //but we cannot use one way invocations on cancelDelivery and
-         //cancelDeliveries because remoting one way invocations can 
+         //cancelDeliveries because remoting one way invocations can
          //overtake each other in flight - this problem will
          //go away when we have our own transport and our dedicated connection
          this.executor.execute(new Runnable() { public void run() { queue.deliver();} } );
-         
+
       }
       catch (Throwable t)
       {
          log.error("Failed to prompt delivery", t);
       }
    }
-   
+
    // Protected ------------------------------------------------------------------------------------
 
    // Private --------------------------------------------------------------------------------------
-   
+
    private void cancelDeliveryInternal(Cancel cancel) throws Exception
    {
       DeliveryRecord rec = (DeliveryRecord)deliveries.remove(cancel.getDeliveryId());
-      
+
       if (rec == null)
       {
          //The delivery might not be found, if the session is not replicated (i.e. auto_ack or dups_ok)
@@ -1045,59 +983,59 @@
       	}
       	return;
       }
-                 
-      MessageReference ref = rec.ref;      
-      
+
+      MessageReference ref = rec.ref;
+
       //Note we check the flag *and* evaluate again, this is because the server and client clocks may
       //be out of synch and don't want to send back to the client a message it thought it has sent to
-      //the expiry queue  
+      //the expiry queue
       boolean expired = cancel.isExpired() || ref.getMessage().isExpired();
-      
+
       //Note we check the flag *and* evaluate again, this is because the server value of maxDeliveries
       //might get changed after the client has sent the cancel - and we don't want to end up cancelling
       //back to the original queue
       boolean reachedMaxDeliveryAttempts =
          cancel.isReachedMaxDeliveryAttempts() || cancel.getDeliveryCount() >= rec.maxDeliveryAttempts;
-                    
+
       if (!expired && !reachedMaxDeliveryAttempts)
       {
          //Normal cancel back to the queue
-         
+
          ref.setDeliveryCount(cancel.getDeliveryCount());
-         
+
          //Do we need to set a redelivery delay?
-         
+
          if (rec.redeliveryDelay != 0)
          {
             ref.setScheduledDeliveryTime(System.currentTimeMillis() + rec.redeliveryDelay);
          }
-         
+
          if (trace) { log.trace("Cancelling delivery " + cancel.getDeliveryId()); }
-         
+
          ref.cancel(sp.getPersistenceManager());
-         
+
       }
       else
-      {                  
+      {
          if (expired)
          {
             //Sent to expiry queue
-            
+
             Message copy = makeCopyForDLQOrExpiry(true, ref);
-            
+
             moveInTransaction(copy, ref, rec.expiryQueue, false);
          }
          else
          {
             //Send to DLQ
-         	
+
             Message copy = makeCopyForDLQOrExpiry(false, ref);
-            
+
             moveInTransaction(copy, ref, rec.dlq, true);
          }
-      }      
-   }      
-   
+      }
+   }
+
    private Message makeCopyForDLQOrExpiry(boolean expiry, MessageReference ref) throws Exception
    {
       //We copy the message and send that to the dlq/expiry queue - this is because
@@ -1105,99 +1043,99 @@
       //which would barf - this might happen if the same message had been expire from multiple
       //subscriptions of a topic for example
       //We set headers that hold the original message destination, expiry time and original message id
-      
+
    	if (trace) { log.trace("Making copy of message for DLQ or expiry " + ref); }
-   	
+
       Message msg = ref.getMessage();
-      
+
       Message copy = msg.copy();
-      
+
       long newMessageId = sp.getPersistenceManager().generateMessageID();
-      
+
       copy.setMessageID(newMessageId);
-      
+
       //reset expiry
       copy.setExpiration(0);
-      
-      
-      //TODO 
-// http://jira.jboss.org/jira/browse/JBMESSAGING-1202      
+
+
+      //TODO
+// http://jira.jboss.org/jira/browse/JBMESSAGING-1202
 //      String origMessageId = msg.getJMSMessageID();
-//      
+//
 //      String origDest = msg.getJMSDestination().toString();
-//            
+//
 //      copy.setStringProperty(JBossMessage.JBOSS_MESSAGING_ORIG_MESSAGE_ID, origMessageId);
-//      
+//
 //      copy.setStringProperty(JBossMessage.JBOSS_MESSAGING_ORIG_DESTINATION, origDest);
-//      
+//
 //      if (expiry)
 //      {
 //         long actualExpiryTime = System.currentTimeMillis();
-//         
+//
 //         copy.setLongProperty(JBossMessage.JBOSS_MESSAGING_ACTUAL_EXPIRY_TIME, actualExpiryTime);
 //      }
-      
+
       return copy;
    }
-   
+
    private void moveInTransaction(Message msg, MessageReference ref, Queue queue, boolean dlq) throws Exception
    {
       List<Message> msgs = new ArrayList<Message>();
-      
+
       msgs.add(msg);
-      
+
       List<MessageReference> refs = new ArrayList<MessageReference>();
-      
+
       refs.add(ref);
-                  
+
       Transaction tx = new TransactionImpl(msgs, refs, msg.isDurable());
-      
+
       //FIXME - clear up these ugly refs to the pm
       tx.commit(getConnectionEndpoint().getMessagingServer().getPersistenceManager());
-      
+
 //      MessageReference ref = msg.createReference();
-//                    
+//
 //      try
-//      {               
+//      {
 //         if (queue != null)
-//         {          
+//         {
 //            queue.handle(null, ref, tx);
 //            del.acknowledge(tx);
 //         }
 //         else
 //         {
 //            log.warn("No " + (dlq ? "DLQ" : "expiry queue") + " has been specified so the message will be removed");
-//            
+//
 //            del.acknowledge(tx);
-//         }             
-//         
-//         tx.commit();         
+//         }
+//
+//         tx.commit();
 //      }
 //      catch (Throwable t)
 //      {
 //         tx.rollback();
 //         throw t;
-//      }       
+//      }
    }
-   
+
    private boolean acknowledgeDeliveryInternal(Ack ack) throws Exception
    {
       if (trace) { log.trace(this + " acknowledging delivery " + ack); }
 
       DeliveryRecord rec = (DeliveryRecord)deliveries.remove(ack.getDeliveryID());
-      
+
       if (rec != null)
       {
          rec.ref.acknowledge(this.sp.getPersistenceManager());
-         
+
          if (trace) { log.trace(this + " acknowledged delivery " + ack); }
-         
+
          return true;
       }
-      
-      return false;      
+
+      return false;
    }
-      
+
    private CreateConsumerResponse createConsumerDelegateInternal(Destination destination,
                                                                  String filterString,
                                                                  boolean noLocal,
@@ -1208,12 +1146,12 @@
       {
          throw new IllegalStateException("Session is closed");
       }
-      
+
       if ("".equals(filterString))
       {
          filterString = null;
       }
-      
+
       if (trace)
       {
          log.trace(this + " creating consumer for " + destination +
@@ -1223,12 +1161,12 @@
       }
 
       Condition condition = new ConditionImpl(destination.getType(), destination.getName());
-            
+
       if (!postOffice.containsCondition(condition))
       {
          throw new InvalidDestinationException("No such destination: " + destination.getName() + " has it been deployed?");
       }
-      
+
       if (destination.isTemporary())
       {
          // Can only create a consumer for a temporary destination on the same connection
@@ -1240,12 +1178,12 @@
             throw new IllegalStateException(msg);
          }
       }
-      
+
       String consumerID = UUID.randomUUID().toString();
-      
+
       // Always validate the filter first
       Filter filter = null;
-      
+
       if (filterString != null)
       {
          try
@@ -1257,22 +1195,22 @@
             throw new InvalidSelectorException("Invalid selector " + filterString);
          }
       }
-      
+
       Queue queue;
-      
+
       //FIXME - all this logic belongs on the jms client side
-      
+
       if (destination.getType() == DestinationType.TOPIC)
-      {         
+      {
          if (subscriptionName == null)
          {
             // non-durable subscription
             if (log.isTraceEnabled()) { log.trace(this + " creating new non-durable subscription on " + destination); }
-                    
+
             queue = postOffice.addQueue(condition, UUID.randomUUID().toString(), filter, false, false, false);
 
             //TODO - message counters should be applied by the queue configurator factory
-            
+
          }
          else
          {
@@ -1280,163 +1218,163 @@
             {
                throw new InvalidDestinationException("Cannot create a durable subscription on a temporary topic");
             }
-            
+
             // We have a durable subscription, look it up
             String clientID = connectionEndpoint.getClientID();
             if (clientID == null)
             {
                throw new JMSException("Cannot create durable subscriber without a valid client ID");
             }
-            
+
             // See if there any bindings with the same client_id.subscription_name name
-            
+
             String name = MessageQueueNameHelper.createSubscriptionName(clientID, subscriptionName);
-            
+
             List<Binding> bindings = postOffice.getBindingsForQueueName(name);
-            
+
             Binding binding = null;
-            
+
             if (!bindings.isEmpty())
             {
                binding = bindings.get(0);
             }
-            
+
             if (binding == null)
             {
                // Does not already exist
-               
+
                if (trace) { log.trace(this + " creating new durable subscription on " + destination); }
-                               
+
                queue = postOffice.addQueue(condition, name, filter, true, false,
                                            sp.getConfiguration().isClustered());
-                 
+
                //TODO message counters handled by queue configurator
-               
+
             }
             else
             {
                //Durable sub already exists
-            	
+
             	queue = binding.getQueue();
-            	
+
                if (trace) { log.trace(this + " subscription " + subscriptionName + " already exists"); }
-               
+
             	//Check if it is already has a subscriber
             	//We can't have more than one subscriber at a time on the durable sub
-               
+
                if (queue.getConsumerCount() > 0)
                {
                	throw new IllegalStateException("Cannot create a subscriber on the durable subscription since it already has subscriber(s)");
                }
-               
+
                //TODO - apply message counters on the queue configurator
-               
+
                // From javax.jms.Session Javadoc (and also JMS 1.1 6.11.1):
                // A client can change an existing durable subscription by creating a durable
                // TopicSubscriber with the same name and a new topic and/or message selector.
                // Changing a durable subscriber is equivalent to unsubscribing (deleting) the old
                // one and creating a new one.
-               
+
                String oldFilterString = queue.getFilter() != null ? queue.getFilter().getFilterString() : null;
-               
+
                boolean selectorChanged =
                   (filterString == null && oldFilterString != null) ||
                   (oldFilterString == null && filterString != null) ||
                   (oldFilterString != null && filterString != null &&
                            !oldFilterString.equals(filterString));
-               
+
                if (trace) { log.trace("selector " + (selectorChanged ? "has" : "has NOT") + " changed"); }
-               
+
                //FIXME - all this needs to be on the jms client
-               
+
                String oldTopicName = binding.getCondition().getKey();
-               
+
                boolean topicChanged = !oldTopicName.equals(destination.getName());
-               
+
                if (log.isTraceEnabled()) { log.trace("topic " + (topicChanged ? "has" : "has NOT") + " changed"); }
-               
+
                if (selectorChanged || topicChanged)
                {
                   if (trace) { log.trace("topic or selector changed so deleting old subscription"); }
-                  
+
                   // Unbind the durable subscription
-                  
+
                   // Durable subs must be unbound on ALL nodes of the cluster
-                  
+
                   postOffice.removeQueue(binding.getCondition(), queue.getName(), sp.getConfiguration().isClustered());
-                  
+
                   sp.getPersistenceManager().deleteAllReferences(queue);
-                  
+
                   queue.removeAllReferences();
-                  
+
                   queue = postOffice.addQueue(condition, name, filter, true, false, sp.getConfiguration().isClustered());
-                  
+
                }
-               
+
                //TODO counter creation is handled in the queue configurator
-               
+
             }
          }
       }
       else
       {
          // ClientConsumer on a jms queue
-         
+
       	List<Binding> bindings = postOffice.getBindingsForQueueName(destination.getName());
-         
+
          if (bindings.isEmpty())
          {
             throw new IllegalStateException("Cannot find queue: " + destination.getName());
          }
-         
+
          queue = bindings.get(0).getQueue();
       }
-         
+
       int prefetchSize = connectionEndpoint.getPrefetchSize();
-      
+
       Queue dlqToUse = queue.getDLQ() == null ? defaultDLQ : queue.getDLQ();
-      
+
       Queue expiryQueueToUse = queue.getExpiryQueue() == null ? defaultExpiryQueue : queue.getExpiryQueue();
-      
+
       int maxDeliveryAttemptsToUse = queue.getMaxDeliveryAttempts() == -1 ? defaultMaxDeliveryAttempts : queue.getMaxDeliveryAttempts();
-          
+
       long redeliveryDelayToUse = queue.getRedeliveryDelay() == -1 ? defaultRedeliveryDelay : queue.getRedeliveryDelay();
-      
+
       ServerConsumerEndpoint ep =
          new ServerConsumerEndpoint(sp, consumerID, queue,
                                     queue.getName(), this, filter, noLocal,
                                     destination, dlqToUse, expiryQueueToUse, redeliveryDelayToUse,
                                     maxDeliveryAttemptsToUse, prefetchSize);
-      
+
       //TODO implements this for JBM2
-      
+
 //      if (queue.isClustered() && sp.getConfiguration().isClustered() && jmsDestination.isTopic() && subscriptionName != null)
 //      {
 //      	//Clustered durable sub consumer created - we need to add this info in the replicator - it is needed by other nodes
-//      	
+//
 //      	//This is also used to prevent a possible race condition where a clustered durable sub is bound on all nodes
 //      	//but then unsubscribed before the bind is complete on all nodes, leaving it bound on some nodes and not on others
 //      	//The bind all is synchronous so by the time we add the x to the replicator we know it is bound on all nodes
 //      	//and same to unsubscribe
-//      	
+//
 //      	Replicator rep = (Replicator)postOffice;
-//      	
+//
 //      	rep.put(queue.getName(), DUR_SUB_STATE_CONSUMERS);
 //      }
       connectionEndpoint.getMessagingServer().getMinaService().getDispatcher().register(ep.newHandler());
-        
+
       CreateConsumerResponse response = new CreateConsumerResponse(consumerID, prefetchSize,
                                                                    maxDeliveryAttemptsToUse, redeliveryDelayToUse );
-      
+
       synchronized (consumers)
       {
          consumers.put(consumerID, ep);
       }
-         
+
       log.trace(this + " created and registered " + ep);
-      
+
       return response;
-   }   
+   }
 
    private ClientBrowser createBrowserDelegateInternal(Destination destination,
                                                          String selector) throws Exception
@@ -1452,16 +1390,16 @@
       }
 
       //FIXME - this belongs in JMS client - not here
-      
+
       if (destination.getType() == DestinationType.TOPIC)
       {
          throw new IllegalStateException("Cannot browse a topic");
       }
 
       Condition condition = new ConditionImpl(DestinationType.QUEUE, destination.getName());
-      
+
       List<Binding> bindings = this.postOffice.getBindingsForCondition(condition);
-      
+
       if (bindings.isEmpty())
       {
          throw new InvalidDestinationException("No such destination: " + destination);
@@ -1471,7 +1409,7 @@
          (selector == null ? "" : ", selector '" + selector + "'"));
 
       Binding binding = bindings.get(0);
-      
+
       String browserID = UUID.randomUUID().toString();
 
       ServerBrowserEndpoint ep = new ServerBrowserEndpoint(this, browserID, binding.getQueue(), selector);
@@ -1483,7 +1421,7 @@
       }
 
       connectionEndpoint.getMessagingServer().getMinaService().getDispatcher().register(ep.newHandler());
-      
+
       ClientBrowserImpl stub = new ClientBrowserImpl(browserID);
 
       log.trace(this + " created and registered " + ep);
@@ -1492,7 +1430,7 @@
    }
 
    // Inner classes --------------------------------------------------------------------------------
-   
+
    /*
     * Holds a record of a delivery - we need to store the consumer id as well
     * hence this class
@@ -1501,34 +1439,34 @@
     * when they were in transit.
     * In such a case we might otherwise end up with the consumer closing but not all it's deliveries being
     * cancelled, which would mean they wouldn't be cancelled until the session is closed which is too late
-    * 
+    *
     * We need to store various pieces of information, such as consumer id, dlq, expiry queue
     * since we need this at cancel time, but by then the actual consumer might have closed
     */
    private static class DeliveryRecord
    {
-   	// We need to cache the attributes here  since the consumer may get gc'd BEFORE the delivery is acked   	
-   	
+   	// We need to cache the attributes here  since the consumer may get gc'd BEFORE the delivery is acked
+
       MessageReference ref;
-        
+
       Queue dlq;
-      
+
       Queue expiryQueue;
-      
+
       long redeliveryDelay;
-      
+
       int maxDeliveryAttempts;
-      
+
       WeakReference consumerRef;
-      
+
       String queueName;
-      
+
       boolean replicating;
-      
+
       volatile boolean waitingForResponse;
-      
+
       long deliveryID;
-      
+
       ServerConsumerEndpoint getConsumer()
       {
       	if (consumerRef != null)
@@ -1540,63 +1478,63 @@
       		return null;
       	}
       }
-            
+
       private DeliveryRecord(MessageReference ref, Queue dlq, Queue expiryQueue, long redeliveryDelay, int maxDeliveryAttempts,
       		         String queueName, long deliveryID)
       {
       	this.ref = ref;
-      	
+
       	this.dlq = dlq;
-      	
+
       	this.expiryQueue = expiryQueue;
-      	
+
       	this.redeliveryDelay = redeliveryDelay;
-      	
+
       	this.maxDeliveryAttempts = maxDeliveryAttempts;
-      	
+
       	this.queueName = queueName;
-      	
+
       	this.deliveryID = deliveryID;
       }
-      
+
       DeliveryRecord(MessageReference ref, ServerConsumerEndpoint consumer, long deliveryID)
       {
       	this (ref, consumer.getDLQ(), consumer.getExpiryQueue(), consumer.getRedliveryDelay(), consumer.getMaxDeliveryAttempts(),
       			consumer.getQueueName(), deliveryID);
 
       	// We need to cache the attributes here  since the consumer may get gc'd BEFORE the delivery is acked
-         
-      	
+
+
          //We hold a WeakReference to the consumer - this is only needed when replicating - where we store the delivery then wait
          //for the response to come back from the replicant before actually performing delivery
          //We need a weak ref since when the consumer closes deliveries may still and remain and we don't want that to prevent
          //the consumer being gc'd
-      	
+
       	//FIXME - do we still need this??
          this.consumerRef = new WeakReference(consumer);
-      }            
-      
+      }
+
    	public String toString()
    	{
    		return "DeliveryRecord " + System.identityHashCode(this) + " ref: " + ref + " queueName: " + queueName;
    	}
    }
-   
+
    /**
-    * 
+    *
     * The purpose of this class is to remove deliveries from the delivery list on commit
     * Each transaction has once instance of this per SCE
     *
     */
    private class DeliveryCallback implements TransactionSynchronization
-   { 
+   {
       private long deliveryId;
-      
+
       DeliveryCallback(long deliveryId)
       {
          this.deliveryId = deliveryId;
       }
-      
+
       public void afterCommit() throws Exception
       {
          deliveries.remove(deliveryId);
@@ -1615,8 +1553,8 @@
       }
 
       public void beforeRollback() throws Exception
-      {       
-      }   
+      {
+      }
    }
 
    public PacketHandler newHandler()

Modified: trunk/src/main/org/jboss/jms/server/security/Role.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/security/Role.java	2008-01-22 13:47:58 UTC (rev 3611)
+++ trunk/src/main/org/jboss/jms/server/security/Role.java	2008-01-22 15:47:50 UTC (rev 3612)
@@ -29,14 +29,18 @@
  */
 public class Role implements Serializable
 {
-    String name;
+   public static final String WRITE_NAME="write";
+   public static final String READ_NAME="read";
+   public static final String CREATE_NAME="create";
+   String name;
     private boolean read = false;
     private boolean write = false;
     private boolean create = false;
 
 
-    public Role()
+    public Role(String name)
     {
+       this.name = name;
     }
 
     public Role(String name, boolean read, boolean write, boolean create)
@@ -88,9 +92,38 @@
         this.create = create;
     }
 
+   public boolean isCheckType(CheckType checkType)
+   {
+      return checkType.equals(CheckType.TYPE_READ) ? read : checkType.equals(CheckType.TYPE_WRITE) ? write : create;
+   }
     public String toString()
     {
         return "Role {name=" + name + ";read=" + read + ";write=" + write + ";create=" + create + "}";
     }
 
+
+   public boolean equals(Object o)
+   {
+      if (this == o) return true;
+      if (o == null || getClass() != o.getClass()) return false;
+
+      Role role = (Role) o;
+
+      if (create != role.create) return false;
+      if (read != role.read) return false;
+      if (write != role.write) return false;
+      if (!name.equals(role.name)) return false;
+
+      return true;
+   }
+
+   public int hashCode()
+   {
+      int result;
+      result = name.hashCode();
+      result = 31 * result + (read ? 1 : 0);
+      result = 31 * result + (write ? 1 : 0);
+      result = 31 * result + (create ? 1 : 0);
+      return result;
+   }
 }

Deleted: trunk/src/main/org/jboss/jms/server/security/SecurityMetadata.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/security/SecurityMetadata.java	2008-01-22 13:47:58 UTC (rev 3611)
+++ trunk/src/main/org/jboss/jms/server/security/SecurityMetadata.java	2008-01-22 15:47:50 UTC (rev 3612)
@@ -1,125 +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.jms.server.security;
-
-import org.jboss.messaging.util.Logger;
-import org.jboss.security.SimplePrincipal;
-
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * SecurityMetadata.java
- * <p/>
- * <p/>
- * Created: Tue Feb 26 15:02:29 2002
- *
- * @author Peter
- * @author <a href="ataylor at redhat.com">Andy Taylor</a>
- */
-
-public class SecurityMetadata
-{
-    static Role DEFAULT_ROLE = new Role("guest", true, true, true);
-
-    HashSet<Role> roles = new HashSet<Role>();
-    HashSet<SimplePrincipal> read = new HashSet<SimplePrincipal>();
-    HashSet<SimplePrincipal> write = new HashSet<SimplePrincipal>();
-    HashSet<SimplePrincipal> create = new HashSet<SimplePrincipal>();
-    static Logger log = Logger.getLogger(SecurityMetadata.class);
-
-    /**
-     * create with default roles
-     */
-    public SecurityMetadata()
-    {
-        addRole(DEFAULT_ROLE);
-    }
-
-    /**
-     * create with roles provided
-     * @param roles
-     * @throws Exception
-     */
-    public SecurityMetadata(HashSet<Role> roles)
-    {
-        setRoles(roles);
-    }
-
-    public void addRole(String name, boolean read, boolean write, boolean create)
-    {
-        Role r = new Role(name, read, write, create);
-        addRole(r);
-    }
-
-    public void addRole(Role r)
-    {
-        if (log.isTraceEnabled())
-            log.trace("Adding role: " + r.toString());
-
-        roles.add(r);
-        SimplePrincipal p = new SimplePrincipal(r.name);
-        if (r.isRead())
-            read.add(p);
-        if (r.isWrite())
-            write.add(p);
-        if (r.isCreate())
-            create.add(p);
-    }
-
-    public Set<SimplePrincipal> getReadPrincipals()
-    {
-        return read;
-    }
-
-    public Set<SimplePrincipal> getWritePrincipals()
-    {
-        return write;
-    }
-
-    public Set<SimplePrincipal> getCreatePrincipals()
-    {
-        return create;
-    }
-
-
-    public HashSet<Role> getRoles()
-    {
-        return roles;
-    }
-
-    public void setRoles(HashSet< Role> roles)
-    {
-        this.roles = roles;
-        for (Role role : roles)
-        {
-            SimplePrincipal p = new SimplePrincipal(role.name);
-            if (role.isRead())
-                read.add(p);
-            if (role.isWrite())
-                write.add(p);
-            if (role.isCreate())
-                create.add(p);
-        }
-    }
-
-} // SecurityMetadata

Modified: trunk/src/main/org/jboss/jms/server/security/SecurityMetadataStore.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/security/SecurityMetadataStore.java	2008-01-22 13:47:58 UTC (rev 3611)
+++ trunk/src/main/org/jboss/jms/server/security/SecurityMetadataStore.java	2008-01-22 15:47:50 UTC (rev 3612)
@@ -21,27 +21,25 @@
   */
 package org.jboss.jms.server.security;
 
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.security.Principal;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import javax.jms.JMSSecurityException;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import javax.security.auth.Subject;
-
 import org.jboss.jms.server.SecurityStore;
-import org.jboss.messaging.util.Logger;
+import org.jboss.messaging.core.Destination;
+import org.jboss.messaging.core.DestinationType;
 import org.jboss.messaging.core.MessagingServer;
+import org.jboss.messaging.util.HierarchicalRepository;
+import org.jboss.messaging.util.Logger;
 import org.jboss.security.AuthenticationManager;
 import org.jboss.security.RealmMapping;
 import org.jboss.security.SimplePrincipal;
 import org.jboss.security.SubjectSecurityManager;
 
+import javax.jms.JMSSecurityException;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.security.auth.Subject;
+import java.security.Principal;
+import java.util.HashSet;
+import java.util.Set;
+
 /**
  * A security metadate store for JMS. Stores security information for destinations and delegates
  * authentication and authorization to a JaasSecurityManager.
@@ -58,19 +56,17 @@
 public class SecurityMetadataStore implements SecurityStore
 {
    // Constants -----------------------------------------------------
-   
+
    private static final Logger log = Logger.getLogger(SecurityMetadataStore.class);
 
    public static final String SUCKER_USER = "JBM.SUCKER";
-   
+
    public static final String DEFAULT_SUCKER_USER_PASSWORD = "CHANGE ME!!";
-   
+
    // Attributes ----------------------------------------------------
-   
+
    private boolean trace = log.isTraceEnabled();
-   
-   private Map<String, SecurityMetadata> queueSecurityConf;
-   private Map<String, SecurityMetadata> topicSecurityConf;
+   HierarchicalRepository<HashSet<Role>> securityRepository;
 
    private AuthenticationManager authenticationManager;
    private RealmMapping realmMapping;
@@ -80,122 +76,21 @@
    private MessagingServer messagingServer;
 
    // Static --------------------------------------------------------
-   
+
    // Constructors --------------------------------------------------
 
    public SecurityMetadataStore(MessagingServer messagingServer)
    {
       this.messagingServer = messagingServer;
-      queueSecurityConf = new HashMap<String, SecurityMetadata>();
-      topicSecurityConf = new HashMap<String, SecurityMetadata>();
-      //add a property change listener then we can update the default security config
-      messagingServer.getConfiguration().addPropertyChangeListener(new PropertyChangeListener()
-         {
-            public void propertyChange(PropertyChangeEvent evt)
-            {
-               if(evt.getPropertyName().equals("securityConfig"))
-               {
-                  HashSet<Role> roles = (HashSet<Role>) evt.getNewValue();
-                  for (String key : queueSecurityConf.keySet())
-                  {
-                     if(evt.getNewValue() != null)
-                        queueSecurityConf.put(key, new SecurityMetadata(roles));
-                     else
-                        queueSecurityConf.put(key, new SecurityMetadata());
-                  }
-                  for (String key : topicSecurityConf.keySet())
-                  {
-                     if(evt.getNewValue() != null)
-                        topicSecurityConf.put(key, new SecurityMetadata(roles));
-                     else
-                        topicSecurityConf.put(key, new SecurityMetadata());
-                  }
-               }
-            }
-         });
    }
 
    // SecurityManager implementation --------------------------------
 
-   public SecurityMetadata getSecurityMetadata(boolean isQueue, String destName)
-   {
-      SecurityMetadata m = (isQueue ? queueSecurityConf.get(destName) : topicSecurityConf.get(destName));
 
-      if (m == null)
-      {
-         // No SecurityMetadata was configured for the destination, apply the default
-         m = getDefaultSecurityConfig(destName);
-
-      }
-      return m;
-   }
-
-   private SecurityMetadata getDefaultSecurityConfig(String destName)
-   {
-      SecurityMetadata m;
-      if (messagingServer.getConfiguration().getSecurityConfig() != null)
-      {
-         log.debug("No SecurityMetadadata was available for " + destName + ", using default security config");
-         try
-         {
-            m = new SecurityMetadata(messagingServer.getConfiguration().getSecurityConfig());
-         }
-         catch (Exception e)
-         {
-            log.warn("Unable to apply default security for destName, using guest " + destName, e);
-            m = new SecurityMetadata();
-         }
-      }
-      else
-      {
-         // default to guest
-         log.warn("No SecurityMetadadata was available for " + destName + ", adding guest");
-         m = new SecurityMetadata();
-      }
-      return m;
-   }
-
-   public void setSecurityConfig(boolean isQueue, String destName, HashSet<Role> conf) throws Exception
-   {
-      if (trace) { log.trace("adding security configuration for " + (isQueue ? "queue " : "topic ") + destName); }
-      
-      if (conf == null)
-      {
-      	clearSecurityConfig(isQueue, destName);
-      }
-      else
-      {	
-	      SecurityMetadata m = new SecurityMetadata(conf);
-	
-	      if (isQueue)
-	      {
-	         queueSecurityConf.put(destName, m);
-	      }
-	      else
-	      {
-	         topicSecurityConf.put(destName, m);
-	      }
-      }
-   }
-
-   public void clearSecurityConfig(boolean isQueue, String name) throws Exception
-   {
-      if (trace) { log.trace("clearing security configuration for " + (isQueue ? "queue " : "topic ") + name); }
-
-      if (isQueue)
-      {
-         queueSecurityConf.remove(name);
-      }
-      else
-      {
-         topicSecurityConf.remove(name);
-      }
-   }
-   
    public Subject authenticate(String user, String password) throws JMSSecurityException
    {
       if (trace) { log.trace("authenticating user " + user); }
-      
+
       SimplePrincipal principal = new SimplePrincipal(user);
       char[] passwordChars = null;
       if (password != null)
@@ -204,17 +99,17 @@
       }
 
       Subject subject = new Subject();
-      
+
       boolean authenticated = false;
-      
+
       if (SUCKER_USER.equals(user))
       {
       	if (trace) { log.trace("Authenticating sucker user"); }
-      	
+
       	checkDefaultSuckerPassword(password);
-      	
+
       	// The special user SUCKER_USER is used for creating internal connections that suck messages between nodes
-      	
+
       	authenticated = suckerPassword.equals(password);
       }
       else
@@ -235,35 +130,55 @@
       }
    }
 
-   public boolean authorize(String user, Set rolePrincipals, CheckType checkType)
+   public boolean authorize(String user, Destination destination, CheckType checkType)
    {
-      if (trace) { log.trace("authorizing user " + user + " for role(s) " + rolePrincipals.toString()); }
-      
+      if (trace) { log.trace("authorizing user " + user + " for destination " + destination.getName()); }
+
       if (SUCKER_USER.equals(user))
       {
       	//The special user SUCKER_USER is used for creating internal connections that suck messages between nodes
       	//It has automatic read/write access to all destinations
       	return (checkType.equals(CheckType.READ) || checkType.equals(CheckType.WRITE));
       }
+      StringBuilder match = new StringBuilder(destination.getType().equals(DestinationType.QUEUE) ? "queues/" : "topics/")
+              .append(destination.getName());
 
+      HashSet<Role> roles = securityRepository.getMatch(match.toString());
+
       Principal principal = user == null ? null : new SimplePrincipal(user);
-	
+      Set rolePrincipals = getRolePrincipals(checkType, roles);
       boolean hasRole = realmMapping.doesUserHaveRole(principal, rolePrincipals);
 
       if (trace) { log.trace("user " + user + (hasRole ? " is " : " is NOT ") + "authorized"); }
 
-      return hasRole;     
+      return hasRole;
    }
-   
+
+   private Set getRolePrincipals(CheckType checkType, HashSet<Role> roles)
+   {
+      Set<SimplePrincipal> principals = new HashSet<SimplePrincipal>();
+      for (Role role : roles)
+      {
+         SimplePrincipal principal = new SimplePrincipal(role.getName());
+         if((checkType.equals(CheckType.CREATE) && role.isCreate()) ||
+                 (checkType.equals(CheckType.WRITE) && role.isWrite()) ||
+                 (checkType.equals(CheckType.READ) && role.isRead()))
+         {
+            principals.add(new SimplePrincipal(role.getName()));
+         }
+      }
+      return principals;
+   }
+
    // Public --------------------------------------------------------
-   
+
    public void setSuckerPassword(String password)
-   {   	   	
+   {
    	checkDefaultSuckerPassword(password);
-   	   	
+
    	this.suckerPassword = password;
    }
-   
+
    public void start() throws NamingException
    {
       if (trace) { log.trace("initializing SecurityMetadataStore"); }
@@ -307,14 +222,17 @@
    {
    }
 
+   public void setSecurityRepository(HierarchicalRepository<HashSet<Role>> securityRepository)
+   {
+      this.securityRepository = securityRepository;
+   }
 
-
    // Protected -----------------------------------------------------
 
    // Package Private -----------------------------------------------
 
    // Private -------------------------------------------------------
-   
+
    private void checkDefaultSuckerPassword(String password)
    {
    	// Sanity check

Modified: trunk/src/main/org/jboss/messaging/core/MessagingServer.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/MessagingServer.java	2008-01-22 13:47:58 UTC (rev 3611)
+++ trunk/src/main/org/jboss/messaging/core/MessagingServer.java	2008-01-22 15:47:50 UTC (rev 3612)
@@ -21,20 +21,19 @@
  */
 package org.jboss.messaging.core;
 
-import java.util.Collection;
-import java.util.List;
-
-import org.jboss.jms.server.ConnectionFactoryManager;
 import org.jboss.jms.server.ConnectionManager;
-import org.jboss.jms.server.DestinationManager;
 import org.jboss.jms.server.SecurityStore;
 import org.jboss.jms.server.TransactionRepository;
 import org.jboss.jms.server.endpoint.ServerSessionEndpoint;
 import org.jboss.jms.server.plugin.contract.JMSUserManager;
-import org.jboss.messaging.core.impl.ConditionImpl;
+import org.jboss.jms.server.security.Role;
 import org.jboss.messaging.core.remoting.impl.mina.MinaService;
+import org.jboss.messaging.util.HierarchicalRepository;
 import org.jboss.messaging.util.Version;
 
+import java.util.Collection;
+import java.util.HashSet;
+
 /**
  * This interface defines the internal interface of the Messaging Server exposed
  * to other components of the server.
@@ -81,10 +80,6 @@
 
    SecurityStore getSecurityManager();
 
-   DestinationManager getDestinationManager();
-
-   ConnectionFactoryManager getConnectionFactoryManager();
-
    ConnectionManager getConnectionManager();
 
    MemoryManager getMemoryManager();
@@ -101,15 +96,17 @@
 
    PostOffice getPostOffice();
 
+   HierarchicalRepository<HashSet<Role>> getSecurityRepository();
+
    void setPostOffice(PostOffice postOffice);
    
-   void createQueue(String name, String jndiName) throws Exception;
+   void createQueue(String name) throws Exception;
    
-   void createTopic(String name, String jndiName) throws Exception;
+   void createTopic(String name) throws Exception;
    
-   void destroyQueue(String name, String jndiName) throws Exception;
+   void destroyQueue(String name) throws Exception;
    
-   void destroyTopic(String name, String jndiName) throws Exception;
+   void destroyTopic(String name) throws Exception;
    
    void enableMessageCounters();
 

Modified: trunk/src/main/org/jboss/messaging/core/MessagingServerManagement.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/MessagingServerManagement.java	2008-01-22 13:47:58 UTC (rev 3611)
+++ trunk/src/main/org/jboss/messaging/core/MessagingServerManagement.java	2008-01-22 15:47:50 UTC (rev 3612)
@@ -21,10 +21,10 @@
   */
 package org.jboss.messaging.core;
 
+import org.jboss.messaging.core.impl.server.SubscriptionInfo;
+
 import java.util.List;
 
-import org.jboss.messaging.core.impl.server.SubscriptionInfo;
-
 /**
  * This interface describes the management interface exposed by the server
  * 
@@ -45,13 +45,13 @@
    
    List<SubscriptionInfo> listAllSubscriptionsForTopic(String topicName) throws Exception;
    
-   void createQueue(String name, String jndiName) throws Exception;
+   void createQueue(String name) throws Exception;
    
-   void createTopic(String name, String jndiName) throws Exception;
+   void createTopic(String name) throws Exception;
    
-   void destroyQueue(String name, String jndiName) throws Exception;
+   void destroyQueue(String name) throws Exception;
    
-   void destroyTopic(String name, String jndiName) throws Exception;
+   void destroyTopic(String name) throws Exception;
    
    boolean isStarted();
 //

Modified: trunk/src/main/org/jboss/messaging/core/QueueFactory.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/QueueFactory.java	2008-01-22 13:47:58 UTC (rev 3611)
+++ trunk/src/main/org/jboss/messaging/core/QueueFactory.java	2008-01-22 15:47:50 UTC (rev 3612)
@@ -21,7 +21,9 @@
   */
 package org.jboss.messaging.core;
 
+import org.jboss.messaging.util.HierarchicalRepository;
 
+
 /**
  * 
  * A QueueFactory
@@ -36,4 +38,6 @@
 {
    Queue createQueue(long id, String name, Filter filter,
                      boolean durable, boolean temporary);
+   
+   void setQueueSettingsRepository(HierarchicalRepository<QueueSettings> queueSettingsRepository);
 }

Added: trunk/src/main/org/jboss/messaging/core/QueueSettings.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/QueueSettings.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/QueueSettings.java	2008-01-22 15:47:50 UTC (rev 3612)
@@ -0,0 +1,177 @@
+/*
+   * 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;
+
+import org.jboss.logging.Logger;
+import org.jboss.messaging.core.impl.RoundRobinDistributionPolicy;
+
+/**
+ * The Queue Settings that will be used to configure a queue
+ * 
+ * @author <a href="ataylor at redhat.com">Andy Taylor</a>
+ */
+public class QueueSettings
+{
+   private static Logger log = Logger.getLogger(QueueSettings.class);
+   private static final DistributionPolicy DEFAULT_DISTRIBUTION_POLICY = new RoundRobinDistributionPolicy();
+   boolean clustered = false;
+   int maxSize = -1;
+   String distributionPolicyClass = null;
+   int maxDeliveryAttempts = 10;
+   int messageCounterHistoryDayLimit = 0;
+   long redeliveryDelay = 500;
+   private String DLQ;
+   private String ExpiryQueue;
+
+
+   public boolean isClustered()
+   {
+      return clustered;
+   }
+
+   public void setClustered(boolean clustered)
+   {
+      this.clustered = clustered;
+   }
+
+   public int getMaxSize()
+   {
+      return maxSize;
+   }
+
+   public void setMaxSize(int maxSize)
+   {
+      this.maxSize = maxSize;
+   }
+
+   public int getMaxDeliveryAttempts()
+   {
+      return maxDeliveryAttempts;
+   }
+
+   public void setMaxDeliveryAttempts(int maxDeliveryAttempts)
+   {
+      this.maxDeliveryAttempts = maxDeliveryAttempts;
+   }
+
+   public int getMessageCounterHistoryDayLimit()
+   {
+      return messageCounterHistoryDayLimit;
+   }
+
+   public void setMessageCounterHistoryDayLimit(int messageCounterHistoryDayLimit)
+   {
+      this.messageCounterHistoryDayLimit = messageCounterHistoryDayLimit;
+   }
+
+   public long getRedeliveryDelay()
+   {
+      return redeliveryDelay;
+   }
+
+   public void setRedeliveryDelay(long redeliveryDelay)
+   {
+      this.redeliveryDelay = redeliveryDelay;
+   }
+
+   public String getDistributionPolicyClass()
+   {
+      return distributionPolicyClass;
+   }
+
+   public void setDistributionPolicyClass(String distributionPolicyClass)
+   {
+      this.distributionPolicyClass = distributionPolicyClass;
+   }
+
+
+   public String getDLQ()
+   {
+      return DLQ;
+   }
+
+   public void setDLQ(String DLQ)
+   {
+      this.DLQ = DLQ;
+   }
+
+   public String getExpiryQueue()
+   {
+      return ExpiryQueue;
+   }
+
+   public void setExpiryQueue(String expiryQueue)
+   {
+      ExpiryQueue = expiryQueue;
+   }
+
+   public DistributionPolicy getDistributionPolicy()
+   {
+      if(distributionPolicyClass != null)
+      {
+         try
+         {
+            return (DistributionPolicy) getClass().getClassLoader().loadClass(distributionPolicyClass).newInstance();
+         }
+         catch (Exception e)
+         {
+            log.warn("unable to create Distribution Policy using default", e);
+         }
+      }
+      return DEFAULT_DISTRIBUTION_POLICY;
+   }
+
+
+   public boolean equals(Object o)
+   {
+      if (this == o) return true;
+      if (o == null || getClass() != o.getClass()) return false;
+
+      QueueSettings that = (QueueSettings) o;
+
+      if (clustered != that.clustered) return false;
+      if (maxDeliveryAttempts != that.maxDeliveryAttempts) return false;
+      if (maxSize != that.maxSize) return false;
+      if (messageCounterHistoryDayLimit != that.messageCounterHistoryDayLimit) return false;
+      if (redeliveryDelay != that.redeliveryDelay) return false;
+      if (DLQ != null ? !DLQ.equals(that.DLQ) : that.DLQ != null) return false;
+      if (ExpiryQueue != null ? !ExpiryQueue.equals(that.ExpiryQueue) : that.ExpiryQueue != null) return false;
+      if (distributionPolicyClass != null ? !distributionPolicyClass.equals(that.distributionPolicyClass) : that.distributionPolicyClass != null)
+         return false;
+
+      return true;
+   }
+
+   public int hashCode()
+   {
+      int result;
+      result = (clustered ? 1 : 0);
+      result = 31 * result + maxSize;
+      result = 31 * result + (distributionPolicyClass != null ? distributionPolicyClass.hashCode() : 0);
+      result = 31 * result + maxDeliveryAttempts;
+      result = 31 * result + messageCounterHistoryDayLimit;
+      result = 31 * result + (int) (redeliveryDelay ^ (redeliveryDelay >>> 32));
+      result = 31 * result + (DLQ != null ? DLQ.hashCode() : 0);
+      result = 31 * result + (ExpiryQueue != null ? ExpiryQueue.hashCode() : 0);
+      return result;
+   }
+}

Modified: trunk/src/main/org/jboss/messaging/core/impl/QueueFactoryImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/impl/QueueFactoryImpl.java	2008-01-22 13:47:58 UTC (rev 3611)
+++ trunk/src/main/org/jboss/messaging/core/impl/QueueFactoryImpl.java	2008-01-22 15:47:50 UTC (rev 3612)
@@ -24,6 +24,9 @@
 import org.jboss.messaging.core.Filter;
 import org.jboss.messaging.core.Queue;
 import org.jboss.messaging.core.QueueFactory;
+import org.jboss.messaging.core.QueueSettings;
+import org.jboss.messaging.util.HierarchicalObjectRepository;
+import org.jboss.messaging.util.HierarchicalRepository;
 
 /**
  * 
@@ -34,20 +37,33 @@
  */
 public class QueueFactoryImpl implements QueueFactory
 {
+   HierarchicalRepository<QueueSettings> queueSettingsRepository;
 
+
+   public QueueFactoryImpl()
+   {
+      queueSettingsRepository = new HierarchicalObjectRepository<QueueSettings>();
+      queueSettingsRepository.setDefault(new QueueSettings());
+   }
+
    public Queue createQueue(long id, String name, Filter filter,
                             boolean durable, boolean temporary)
    {
-      //TODO apply settings groups according to configuration
+      QueueSettings queueSettings = queueSettingsRepository.getMatch(name);
+
+      Queue queue =  new QueueImpl(id, name, filter, queueSettings.isClustered(), durable, temporary, queueSettings.getMaxSize());
       
-      Queue queue =  new QueueImpl(id, name, filter, false, durable, temporary, -1);
-      
-      //FIXME For now just hardcode some defaults
-      
-      queue.setMaxDeliveryAttempts(10);
-      
+      queue.setMaxDeliveryAttempts(queueSettings.getMaxDeliveryAttempts());
+      queue.setMessageCounterHistoryDayLimit(queueSettings.getMessageCounterHistoryDayLimit());
+      queue.setRedeliveryDelay(queueSettings.getRedeliveryDelay());                           
+      queue.setDistributionPolicy(queueSettings.getDistributionPolicy());
+
       return queue;
 
    }
 
+   public void setQueueSettingsRepository(HierarchicalRepository<QueueSettings> queueSettingsRepository)
+   {
+      this.queueSettingsRepository = queueSettingsRepository;
+   }
 }

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-22 13:47:58 UTC (rev 3611)
+++ trunk/src/main/org/jboss/messaging/core/impl/server/MessagingServerImpl.java	2008-01-22 15:47:50 UTC (rev 3612)
@@ -21,47 +21,39 @@
   */
 package org.jboss.messaging.core.impl.server;
 
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
 import org.jboss.aop.microcontainer.aspects.jmx.JMX;
-import org.jboss.jms.server.ConnectionFactoryManager;
 import org.jboss.jms.server.ConnectionManager;
-import org.jboss.jms.server.DestinationJNDIMapper;
-import org.jboss.jms.server.DestinationManager;
 import org.jboss.jms.server.MessagingTimeoutFactory;
 import org.jboss.jms.server.SecurityStore;
 import org.jboss.jms.server.TransactionRepository;
-import org.jboss.jms.server.connectionfactory.ConnectionFactoryDeployer;
-import org.jboss.jms.server.connectionfactory.ConnectionFactoryJNDIMapper;
 import org.jboss.jms.server.connectionmanager.SimpleConnectionManager;
-import org.jboss.jms.server.destination.DestinationDeployer;
 import org.jboss.jms.server.endpoint.ServerSessionEndpoint;
 import org.jboss.jms.server.plugin.contract.JMSUserManager;
+import org.jboss.jms.server.security.Role;
 import org.jboss.jms.server.security.SecurityMetadataStore;
-import org.jboss.messaging.util.Logger;
-import org.jboss.messaging.core.Binding;
-import org.jboss.messaging.core.Condition;
-import org.jboss.messaging.core.Configuration;
-import org.jboss.messaging.core.DestinationType;
-import org.jboss.messaging.core.MemoryManager;
-import org.jboss.messaging.core.MessagingServer;
-import org.jboss.messaging.core.PersistenceManager;
-import org.jboss.messaging.core.PostOffice;
-import org.jboss.messaging.core.Queue;
+import org.jboss.logging.Logger;
+import org.jboss.messaging.core.*;
 import org.jboss.messaging.core.impl.ConditionImpl;
 import org.jboss.messaging.core.impl.QueueFactoryImpl;
 import org.jboss.messaging.core.impl.memory.SimpleMemoryManager;
 import org.jboss.messaging.core.impl.messagecounter.MessageCounterManager;
 import org.jboss.messaging.core.impl.postoffice.PostOfficeImpl;
 import org.jboss.messaging.core.remoting.impl.mina.MinaService;
+import org.jboss.messaging.deployers.queue.QueueSettingsDeployer;
+import org.jboss.messaging.deployers.security.SecurityDeployer;
 import org.jboss.messaging.util.ExceptionUtil;
+import org.jboss.messaging.util.HierarchicalObjectRepository;
+import org.jboss.messaging.util.HierarchicalRepository;
 import org.jboss.messaging.util.Version;
 
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
 /**
  * A Messaging Server
  *
@@ -95,26 +87,27 @@
 
    // wired components
 
-   private DestinationManager destinationJNDIMapper;
    private SecurityMetadataStore securityStore;
-   private ConnectionFactoryJNDIMapper connFactoryJNDIMapper;
    private SimpleConnectionManager connectionManager;
    private MemoryManager memoryManager;
    private MessageCounterManager messageCounterManager;
    private TransactionRepository transactionRepository = new TransactionRepository();
    private PostOffice postOffice;
-   private DestinationDeployer destinationDeployer;
-   private ConnectionFactoryDeployer connectionFactoryDeployer;
+   private SecurityDeployer securityDeployer;
+   private QueueSettingsDeployer queueSettingsDeployer;
 
    // plugins
 
    private PersistenceManager persistenceManager;
 
    private JMSUserManager jmsUserManager;
-      
+
    private MinaService minaService;
-   
+
    private Configuration configuration;
+   private HierarchicalObjectRepository<HashSet<Role>> securityRepository = new HierarchicalObjectRepository<HashSet<Role>>();
+   private HierarchicalObjectRepository<QueueSettings> queueSettingsRepository = new HierarchicalObjectRepository<QueueSettings>();
+   private QueueFactoryImpl queueFactory = new QueueFactoryImpl();
 
    // Constructors ---------------------------------------------------------------------------------
    public MessagingServerImpl() throws Exception
@@ -150,13 +143,17 @@
 
          // Create the wired components
 
-         securityStore = new SecurityMetadataStore(this);         
-         destinationJNDIMapper = new DestinationJNDIMapper(this);
-         connFactoryJNDIMapper = new ConnectionFactoryJNDIMapper(this);
+         securityStore = new SecurityMetadataStore(this);
+         securityRepository.setDefault(new HashSet<Role>());
+         securityStore.setSecurityRepository(securityRepository);
+         securityDeployer = new SecurityDeployer();
+         securityDeployer.setSecurityRepository(securityRepository);
+         queueSettingsDeployer = new QueueSettingsDeployer();
+         queueSettingsRepository.setDefault(new QueueSettings());
+         queueSettingsDeployer.setQueueSettingsRepository(queueSettingsRepository);
+         queueFactory.setQueueSettingsRepository(queueSettingsRepository);
          connectionManager = new SimpleConnectionManager();
          memoryManager = new SimpleMemoryManager();
-         destinationDeployer = new DestinationDeployer(this);
-         connectionFactoryDeployer = new ConnectionFactoryDeployer(this, minaService);
          messageCounterManager = new MessageCounterManager(configuration.getMessageCounterSamplePeriod());
          configuration.addPropertyChangeListener(new PropertyChangeListener()
          {
@@ -166,20 +163,17 @@
                   messageCounterManager.reschedule(configuration.getMessageCounterSamplePeriod());
             }
          });
-         postOffice = new PostOfficeImpl(configuration.getMessagingServerID(), 
-                                         persistenceManager, new QueueFactoryImpl());
+         postOffice = new PostOfficeImpl(configuration.getMessagingServerID(),
+                                         persistenceManager, queueFactory);
 
          // Start the wired components
-
-         destinationJNDIMapper.start();
-         connFactoryJNDIMapper.start();
+         securityDeployer.start();
+         queueSettingsDeployer.start();
          connectionManager.start();
-         memoryManager.start();         
+         memoryManager.start();
          securityStore.start();
-         connectionFactoryDeployer.start();
-         destinationDeployer.start();
          postOffice.start();
-         
+
          started = true;
          log.info("JBoss Messaging " + getVersion().getProviderVersion() + " server [" +
                  configuration.getMessagingServerID() + "] started");
@@ -204,14 +198,8 @@
          started = false;
 
          // Stop the wired components
-         destinationDeployer.stop();
-         destinationDeployer = null;
-         connectionFactoryDeployer.stop();
-         connectionFactoryDeployer = null;
-         destinationJNDIMapper.stop();
-         destinationJNDIMapper = null;
-         connFactoryJNDIMapper.stop();
-         connFactoryJNDIMapper = null;
+         securityDeployer.stop();
+         queueSettingsDeployer.stop();
          connectionManager.stop();
          connectionManager = null;
          memoryManager.stop();
@@ -231,20 +219,20 @@
          throw ExceptionUtil.handleJMXInvocation(t, this + " stopService");
       }
    }
-   
 
+
    // MessagingServer implementation -----------------------------------------------------------
-   
+
    public Version getVersion()
    {
       return version;
    }
-   
+
    public Configuration getConfiguration()
    {
       return configuration;
    }
-   
+
    public boolean isStarted()
    {
       return started;
@@ -254,16 +242,16 @@
    {
       this.configuration = configuration;
    }
-   
+
    public void setMinaService(MinaService minaService)
    {
       this.minaService = minaService;
    }
-   
+
    public MinaService getMinaService()
    {
       return minaService;
-   }   
+   }
 
    public ServerSessionEndpoint getSession(String sessionID)
    {
@@ -293,7 +281,7 @@
       if (configuration.getDefaultDLQ() != null)
       {
          List<Binding> bindings = postOffice.getBindingsForQueueName(configuration.getDefaultDLQ());
-         
+
          if (bindings.isEmpty())
          {
             throw new IllegalStateException("Cannot find binding for queue " + configuration.getDefaultDLQ());
@@ -304,7 +292,7 @@
       else
       {
          return null;
-      }   
+      }
    }
 
    public synchronized Queue getDefaultExpiryQueueInstance() throws Exception
@@ -312,7 +300,7 @@
       if (configuration.getDefaultExpiryQueue() != null)
       {
          List<Binding> bindings = postOffice.getBindingsForQueueName(configuration.getDefaultExpiryQueue());
-         
+
          if (bindings.isEmpty())
          {
             throw new IllegalStateException("Cannot find binding for queue " + configuration.getDefaultExpiryQueue());
@@ -323,9 +311,9 @@
       else
       {
          return null;
-      }  
+      }
    }
-   
+
    public void enableMessageCounters()
    {
       messageCounterManager.start();
@@ -340,24 +328,34 @@
       messageCounterManager.resetAllCounterHistories();
    }
 
-   public void createQueue(String name, String jndiName) throws Exception
+   public void createQueue(String name) throws Exception
    {
-      destinationDeployer.createQueue(name, jndiName);
+      Condition queueCond = new ConditionImpl(DestinationType.QUEUE, name);
+
+      if (!getPostOffice().containsCondition(queueCond))
+      {
+         getPostOffice().addQueue(queueCond, name, null, true, false, false);
+         getPostOffice().addCondition(queueCond);
+      }
    }
-   
-   public void destroyQueue(String name, String jndiName) throws Exception
+
+   public void destroyQueue(String name) throws Exception
    {
-      destinationDeployer.destroyQueue(name, jndiName);
+      destroyDestination(true, name);
    }
-   
-   public void createTopic(String name, String jndiName) throws Exception
+
+   public void createTopic(String name) throws Exception
    {
-      this.destinationDeployer.createTopic(name, jndiName);
+      Condition topicCond = new ConditionImpl(DestinationType.TOPIC, name);
+      if (!getPostOffice().containsCondition(topicCond));
+      {
+         getPostOffice().addCondition(topicCond);
+      }
    }
 
-   public void destroyTopic(String name, String jndiName) throws Exception
+   public void destroyTopic(String name) throws Exception
    {
-      destinationDeployer.destroyTopic(name, jndiName);
+      destroyDestination(false, name);
    }
 
    public void resetAllMessageCounters()
@@ -373,15 +371,15 @@
    public void removeAllMessagesForQueue(String queueName) throws Exception
    {
       Condition condition = new ConditionImpl(DestinationType.QUEUE, queueName);
-      
+
       List<Binding> bindings = postOffice.getBindingsForCondition(condition);
-      
+
       if (!bindings.isEmpty())
       {
          Queue queue = bindings.get(0).getQueue();
-         
+
          persistenceManager.deleteAllReferences(queue);
-         
+
          queue.removeAllReferences();
       }
    }
@@ -389,37 +387,27 @@
    public void removeAllMessagesForTopic(String queueName) throws Exception
    {
       Condition condition = new ConditionImpl(DestinationType.QUEUE, queueName);
-      
+
       List<Binding> bindings = postOffice.getBindingsForCondition(condition);
-      
+
       for (Binding binding: bindings)
       {
          Queue queue = binding.getQueue();
-         
+
          if (queue.isDurable())
          {
             persistenceManager.deleteAllReferences(queue);
          }
-         
+
          queue.removeAllReferences();
       }
    }
-  
+
    public SecurityStore getSecurityManager()
    {
       return securityStore;
    }
 
-   public DestinationManager getDestinationManager()
-   {
-      return destinationJNDIMapper;
-   }
-
-   public ConnectionFactoryManager getConnectionFactoryManager()
-   {
-      return connFactoryJNDIMapper;
-   }
-
    public ConnectionManager getConnectionManager()
    {
       return connectionManager;
@@ -434,7 +422,7 @@
    {
       return transactionRepository;
    }
-   
+
    public PersistenceManager getPersistenceManager()
    {
       return persistenceManager;
@@ -465,16 +453,51 @@
       this.postOffice = postOffice;
    }
 
+
+   public HierarchicalRepository<HashSet<Role>> getSecurityRepository()
+   {
+      return securityRepository;
+   }
+
    public String toString()
    {
       return "MessagingServer[" + configuration.getMessagingServerID() + "]";
    }
-   
+
    // Public ---------------------------------------------------------------------------------------
 
    // Package protected ----------------------------------------------------------------------------
 
    // Protected ------------------------------------------------------------------------------------
 
-   // Private -------------------------------------------------------------------------------------- 
+   // Private --------------------------------------------------------------------------------------
+
+   private boolean destroyDestination(boolean isQueue, String name) throws Exception
+   {
+      Condition condition = new ConditionImpl(isQueue ? DestinationType.QUEUE : DestinationType.TOPIC, name);
+
+      List<Binding> bindings = getPostOffice().getBindingsForCondition(condition);
+
+      boolean destroyed = false;
+
+      for (Binding binding: bindings)
+      {
+         Queue queue = binding.getQueue();
+
+         getPersistenceManager().deleteAllReferences(queue);
+
+         queue.removeAllReferences();
+
+         //Durable subs need to be removed on all nodes
+         boolean all = !isQueue && queue.isDurable();
+
+         getPostOffice().removeQueue(condition, queue.getName(), all);
+
+         destroyed = true;
+      }
+
+      getPostOffice().removeCondition(condition);
+
+      return destroyed;
+   }
 }

Modified: trunk/src/main/org/jboss/messaging/core/impl/server/MessagingServerManagementImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/impl/server/MessagingServerManagementImpl.java	2008-01-22 13:47:58 UTC (rev 3611)
+++ trunk/src/main/org/jboss/messaging/core/impl/server/MessagingServerManagementImpl.java	2008-01-22 15:47:50 UTC (rev 3612)
@@ -21,31 +21,22 @@
    */
 package org.jboss.messaging.core.impl.server;
 
-import java.io.CharArrayWriter;
-import java.io.PrintWriter;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.StringTokenizer;
-
 import org.jboss.aop.microcontainer.aspects.jmx.JMX;
 import org.jboss.jms.client.SelectorTranslator;
 import org.jboss.jms.server.endpoint.ServerConnectionEndpoint;
-import org.jboss.messaging.core.Binding;
-import org.jboss.messaging.core.Condition;
-import org.jboss.messaging.core.Configuration;
-import org.jboss.messaging.core.DestinationType;
-import org.jboss.messaging.core.Filter;
-import org.jboss.messaging.core.Message;
-import org.jboss.messaging.core.MessageReference;
-import org.jboss.messaging.core.MessagingServer;
-import org.jboss.messaging.core.MessagingServerManagement;
-import org.jboss.messaging.core.Queue;
+import org.jboss.messaging.core.*;
 import org.jboss.messaging.core.impl.ConditionImpl;
 import org.jboss.messaging.core.impl.filter.FilterImpl;
 import org.jboss.messaging.core.impl.messagecounter.MessageCounter;
 import org.jboss.messaging.util.MessageQueueNameHelper;
 
+import java.io.CharArrayWriter;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.StringTokenizer;
+
 /**
  * This interface describes the properties and operations that comprise the management interface of the
  * Messaging Server.
@@ -82,24 +73,24 @@
       return messagingServer.isStarted();
    }
    
-   public void createQueue(String name, String jndiName) throws Exception
+   public void createQueue(String name) throws Exception
    {
-      messagingServer.createQueue(name, jndiName);
+      messagingServer.createQueue(name);
    }
    
-   public void createTopic(String name, String jndiName) throws Exception
+   public void createTopic(String name) throws Exception
    {
-      messagingServer.createTopic(name, jndiName);
+      messagingServer.createTopic(name);
    }
    
-   public void destroyQueue(String name, String jndiName) throws Exception
+   public void destroyQueue(String name) throws Exception
    {
-      messagingServer.destroyQueue(name, jndiName);
+      messagingServer.destroyQueue(name);
    }
    
-   public void destroyTopic(String name, String jndiName) throws Exception
+   public void destroyTopic(String name) throws Exception
    {
-      messagingServer.destroyTopic(name, jndiName);
+      messagingServer.destroyTopic(name);
    }
 
    public void removeAllMessagesForQueue(String queueName) throws Exception

Added: trunk/src/main/org/jboss/messaging/deployers/Deployable.java
===================================================================
--- trunk/src/main/org/jboss/messaging/deployers/Deployable.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/deployers/Deployable.java	2008-01-22 15:47:50 UTC (rev 3612)
@@ -0,0 +1,41 @@
+package org.jboss.messaging.deployers;
+
+import java.net.URL;
+
+/**
+ * Extended to allow objects to be deployed via the Deploymwntmanager
+ *
+ * @author <a href="ataylor at redhat.com">Andy Taylor</a>
+ */
+public interface Deployable
+{
+   /**
+    * The name of the configuration file name to look for for deployment
+    *
+    * @return The name of the config file
+    */
+   public String getConfigFileName();
+
+   /**
+    * Deploy the URL for the first time
+    *
+    * @param url The resource todeploy
+    * @throws Exception .
+    */
+   public void deploy(URL url) throws Exception;
+
+   /**
+    * Redeploys a URL if changed
+    *
+    * @param url The resource to redeploy
+    * @throws Exception .
+    */
+   public void redeploy(URL url) throws Exception;
+
+   /**
+    * Undeploys a resource that has been removed
+    * @param url The Resource that was deleted
+    * @throws Exception .
+    */
+   public void undeploy(URL url) throws Exception;
+}

Added: trunk/src/main/org/jboss/messaging/deployers/Deployer.java
===================================================================
--- trunk/src/main/org/jboss/messaging/deployers/Deployer.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/deployers/Deployer.java	2008-01-22 15:47:50 UTC (rev 3612)
@@ -0,0 +1,247 @@
+/*
+   * 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.deployers;
+
+import org.jboss.logging.Logger;
+import org.jboss.messaging.core.MessagingComponent;
+import org.jboss.messaging.util.XMLUtil;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Set;
+
+/**
+ * abstract class that helps with deployment of messaging components.
+ *
+ * @author <a href="ataylor at redhat.com">Andy Taylor</a>
+ */
+public abstract class Deployer implements Deployable, MessagingComponent
+{
+   private static Logger log = Logger.getLogger(Deployer.class);
+   protected static final String NAME_ATTR = "name";
+
+   private HashMap<URL, HashMap<String, Node>> configuration = new HashMap<URL, HashMap<String, Node>>();
+
+   /**
+    * adds a URL to the already configured set of url's this deployer is handling
+    * @param url The URL to add
+    * @param name the name of the element
+    * @param e .
+    */
+   public void addToConfiguration(URL url, String name, Node e)
+   {
+      if (configuration.get(url) == null)
+      {
+         configuration.put(url, new HashMap<String, Node>());
+      }
+      configuration.get(url).put(name, e);
+   }
+
+   /**
+    * Redeploys a URL if changed
+    *
+    * @param url The resource to redeploy
+    * @throws Exception .
+    */
+   public void redeploy(URL url) throws Exception
+   {
+      Element e = getRootElement(url);
+      ArrayList<String> added = new ArrayList<String>();
+      //pull out the elements that need deploying
+      String elements[] = getElementTagName();
+      for (String element : elements)
+      {
+         NodeList children = e.getElementsByTagName(element);
+         for (int i = 0; i < children.getLength(); i++)
+         {
+            Node node = children.item(i);
+            String name = node.getAttributes().getNamedItem(getKeyAttribute()).getNodeValue();
+            added.add(name);
+            //if this has never been deployed deploy
+            if (configuration.get(url) == null || (configuration.get(url) != null && configuration.get(url).get(name) == null))
+            {
+               log.info(new StringBuilder(name).append(" doesn't exist deploying"));
+               deploy(node);
+            }
+            //or if it has changed redeploy
+            else if (hasNodeChanged(url, node, name))
+            {
+               log.info(new StringBuilder(name).append(" has changed redeploying"));
+               undeploy(node);
+               deploy(node);
+               addToConfiguration(url, name, node);
+            }
+
+         }
+      }
+      //now check for anything thathas been removed and undeploy
+      if (configuration.get(url) != null)
+      {
+         Set<String> keys = configuration.get(url).keySet();
+         ArrayList<String> removed = new ArrayList<String>();
+
+         for (String key : keys)
+         {
+            if(!added.contains(key))
+            {
+               undeploy(configuration.get(url).get(key));
+               removed.add(key);
+            }
+         }
+         for (String s : removed)
+         {
+            configuration.get(url).remove(s);
+         }
+      }
+   }
+
+   protected Element getRootElement(URL url)
+           throws Exception
+   {
+      return XMLUtil.urlToElement(url);
+   }
+
+   private boolean hasNodeChanged(URL url, Node child, String name)
+   {
+      String newTextContent = child.getTextContent();
+      String origTextContent = configuration.get(url).get(name).getTextContent();
+      return !newTextContent.equals(origTextContent);
+   }
+
+   /**
+    * Undeploys a resource that has been removed
+    * @param url The Resource that was deleted
+    * @throws Exception .
+    */
+   public void undeploy(URL url) throws Exception
+   {
+      Set<String> keys = configuration.get(url).keySet();
+      for (String key : keys)
+      {
+         undeploy(configuration.get(url).get(key));
+      }
+      configuration.remove(url);
+   }
+
+   /**
+    * Deploy the URL for the first time
+    *
+    * @param url The resource todeploy
+    * @throws Exception .
+    */
+   public void deploy(URL url) throws Exception
+   {
+      Element e = getRootElement(url);
+      //find all thenodes to deploy
+      String elements[] = getElementTagName();
+      for (String element : elements)
+      {
+         NodeList children = e.getElementsByTagName(element);
+         for (int i = 0; i < children.getLength(); i++)
+         {
+            Node node = children.item(i);
+            Node keyNode = node.getAttributes().getNamedItem(getKeyAttribute());
+            if(keyNode == null)
+            {
+               log.error("key attribuet missing for configuration " + node);
+               continue;
+            }
+            String name = keyNode.getNodeValue();
+            log.info(new StringBuilder("deploying ").append(name));
+            try
+            {
+               deploy(node);
+            }
+            catch (Exception e1)
+            {
+               log.error(new StringBuilder("Unable to deploy node ").append(node), e1);
+               continue;
+            }
+            addToConfiguration(url, name, node);
+         }
+      }
+   }
+
+   /**
+    * the key attribute for theelement, usually 'name' but can be overridden
+    * @return the key attribute
+    */
+   public String getKeyAttribute()
+   {
+      return NAME_ATTR;
+   }
+
+   //register with the deploymenmt manager
+   public void start() throws Exception
+   {
+      DeploymentManager.getInstance().registerDeployable(this);
+   }
+
+   //undeploy everything
+   public void stop() throws Exception
+   {
+      Collection<HashMap<String, Node>> urls = configuration.values();
+      for (HashMap<String, Node> hashMap : urls)
+      {
+         for (Node node : hashMap.values())
+         {
+            try
+            {
+               undeploy(node);
+            }
+            catch (Exception e)
+            {
+               log.warn("problem deploying " + node, e);
+            }
+         }
+      }
+   }
+
+   /**
+    * the names of the elements to deploy
+    * @return the names of the elements todeploy
+    */
+   public abstract String[] getElementTagName();
+
+
+   /**
+    * deploy an element
+    * @param node the element to deploy
+    * @throws Exception .
+    */
+   public abstract void deploy(Node node)
+           throws Exception;
+
+   /**
+    * undeploys an element
+    * @param node the element to undeploy
+    * @throws Exception .
+    */
+   public abstract void undeploy(Node node)
+           throws Exception;
+
+}

Added: trunk/src/main/org/jboss/messaging/deployers/DeploymentManager.java
===================================================================
--- trunk/src/main/org/jboss/messaging/deployers/DeploymentManager.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/deployers/DeploymentManager.java	2008-01-22 15:47:50 UTC (rev 3612)
@@ -0,0 +1,319 @@
+/*
+   * 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.deployers;
+
+import org.jboss.logging.Logger;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.util.*;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * This class manages any configuration files available. It will notify any deployers registered with it on changes.
+ *
+ * @author <a href="ataylor at redhat.com">Andy Taylor</a>
+ */
+public class DeploymentManager implements Runnable
+{
+   private static final Logger log = Logger.getLogger(DeploymentManager.class);
+   //use the singleton pattern we only need one of these
+   private static DeploymentManager singleton;
+   //these are the list of deployers, typically destination and connection factory.
+   private static ArrayList<Deployable> deployables = new ArrayList<Deployable>();
+   //any config files deployed and the time they were deployed
+   private static HashMap<URL, Long> deployed = new HashMap<URL, Long>();
+   // the list of URL's to deploy
+   private static ArrayList<URL> toDeploy = new ArrayList<URL>();
+   //the list of URL's to undeploy if removed
+   private static ArrayList<URL> toUndeploy = new ArrayList<URL>();
+   //the list of URL's to redeploy if changed
+   private static ArrayList<URL> toRedeploy = new ArrayList<URL>();
+
+   //we want to use a singleton
+   private DeploymentManager()
+   {
+
+   }
+
+   public static DeploymentManager getInstance() throws Exception
+   {
+      //if the first time initialise and get the URL's to deploy
+      if (singleton == null)
+      {
+         singleton = new DeploymentManager();
+         //get the URL's to deploy and add them to the list with the timestamp
+         Collection<ConfigurationURL> configurations = getConfigurations();
+         for (ConfigurationURL configuration : configurations)
+         {
+            Iterator<URL> urls = configuration.getUrls();
+            while (urls.hasNext())
+            {
+               URL url = urls.next();
+               log.info(new StringBuilder("adding url ").append(url).append(" to be deployed"));
+               deployed.put(url, new File(url.getFile()).lastModified());
+            }
+         }
+
+         // Get the scheduler
+         ScheduledExecutorService scheduler =
+                 Executors.newSingleThreadScheduledExecutor();
+
+         scheduler.scheduleAtFixedRate(singleton, 10, 5, TimeUnit.SECONDS);
+
+      }
+      return singleton;
+   }
+
+   /**
+    * will return any resources available
+    *
+    * @return a set of configurationUrls
+    * @throws IOException .
+    */
+   private static Collection<ConfigurationURL> getConfigurations() throws IOException
+   {
+      HashMap<String, ConfigurationURL> configurations = new HashMap<String, ConfigurationURL>();
+      for (Deployable deployable : deployables)
+      {
+         Enumeration<URL> urls = Thread.currentThread().getContextClassLoader().getResources(deployable.getConfigFileName());
+
+         if(!configurations.keySet().contains(deployable.getConfigFileName()))
+         {
+            ConfigurationURL conf = new ConfigurationURL(urls, deployable.getConfigFileName());
+            configurations.put(deployable.getConfigFileName(), conf);
+         }
+         else
+         {
+            configurations.get(deployable.getConfigFileName()).add(urls);
+         }
+      }
+      return configurations.values();
+   }
+
+   /**
+    * registers a deployable object which will handle the deployment of URL's
+    *
+    * @param deployable The deployable object
+    * @throws Exception .
+    */
+   public void registerDeployable(Deployable deployable) throws Exception
+   {
+      synchronized (this)
+      {
+         deployables.add(deployable);
+         Enumeration<URL> urls = Thread.currentThread().getContextClassLoader().getResources(deployable.getConfigFileName());
+         while (urls.hasMoreElements())
+         {
+            URL url = urls.nextElement();
+            if (!deployed.keySet().contains(url))
+            {
+               deployed.put(url, new File(url.getFile()).lastModified());
+            }
+            try
+            {
+               log.info(new StringBuilder("Deploying ").append(deployable).append(" with url").append(url));
+               deployable.deploy(url);
+
+            }
+            catch (Exception e)
+            {
+               log.error(new StringBuilder("Error deploying ").append(url), e);
+            }
+         }
+      }
+   }
+
+   /**
+    * called by the ExecutorService every n seconds
+    */
+   public void run()
+   {
+      synchronized (this)
+      {
+         try
+         {
+            scan();
+         }
+         catch (Exception e)
+         {
+            log.warn("error scanning for URL's " + e);
+         }
+      }
+   }
+
+   /**
+    * scans for changes to any of the configuration files registered
+    *
+    * @throws Exception .
+    */
+   private void scan() throws Exception
+   {
+      Collection<ConfigurationURL> configurations = getConfigurations();
+      for (ConfigurationURL configuration : configurations)
+      {
+         Iterator<URL> urls = configuration.getUrls();
+         while (urls.hasNext())
+         {
+            URL url = urls.next();
+            if (!deployed.keySet().contains(url))
+            {
+               log.info(new StringBuilder("adding url ").append(url).append(" to be deployed"));
+               toDeploy.add(url);
+            }
+            else if (new File(url.getFile()).lastModified() > deployed.get(url))
+            {
+               log.info(new StringBuilder("adding url ").append(url).append(" to be redeployed"));
+               toRedeploy.add(url);
+            }
+         }
+         for (URL url : deployed.keySet())
+         {
+            if (!new File(url.getFile()).exists())
+            {
+               log.info(new StringBuilder("adding url ").append(url).append(" to be undeployed"));
+               toUndeploy.add(url);
+            }
+         }
+      }
+
+      for (URL url : toDeploy)
+      {
+         deploy(url);
+      }
+      for (URL url : toRedeploy)
+      {
+         redeploy(url);
+      }
+      for (URL url : toUndeploy)
+      {
+         undeploy(url);
+      }
+      toRedeploy.clear();
+      toUndeploy.clear();
+      toDeploy.clear();
+   }
+
+   /**
+    * undeploys a url, delegates to appropiate registered deployables
+    * @param url the url to undeploy
+    */
+   private void undeploy(URL url)
+   {
+      deployed.remove(url);
+
+      for (Deployable deployable : deployables)
+      {
+         try
+         {
+            log.info(new StringBuilder("Undeploying ").append(deployable).append(" with url").append(url));
+            deployable.undeploy(url);
+         }
+         catch (Exception e)
+         {
+            log.error(new StringBuilder("Error undeploying ").append(url), e);
+         }
+      }
+   }
+
+    /**
+    * redeploys a url, delegates to appropiate registered deployables
+    * @param url the url to redeploy
+    */
+   private void redeploy(URL url)
+   {
+      deployed.put(url, new File(url.getFile()).lastModified());
+      for (Deployable deployable : deployables)
+      {
+         try
+         {
+            log.info(new StringBuilder("Redeploying ").append(deployable).append(" with url").append(url));
+            deployable.redeploy(url);
+         }
+         catch (Exception e)
+         {
+            log.error(new StringBuilder("Error redeploying ").append(url), e);
+         }
+      }
+   }
+
+    /**
+    * deploys a url, delegates to appropiate registered deployables 
+    * @param url the url to deploy
+    * @throws Exception .
+    */
+   private void deploy(URL url)
+           throws Exception
+   {
+      deployed.put(url, new File(url.getFile()).lastModified());
+      for (Deployable deployable : deployables)
+      {
+         try
+         {
+            log.info(new StringBuilder("Deploying ").append(deployable).append(" with url").append(url));
+            deployable.deploy(url);
+         }
+         catch (Exception e)
+         {
+            log.error(new StringBuilder("Error deploying ").append(url), e);
+         }
+      }
+   }
+
+   static class ConfigurationURL
+   {
+      private ArrayList<URL> urls = new ArrayList<URL>();
+      private String configFileName;
+
+      public ConfigurationURL(Enumeration<URL> urls, String configFileName)
+      {
+         while (urls.hasMoreElements())
+         {
+            URL url = urls.nextElement();
+            this.urls.add(url);
+         }
+         this.configFileName = configFileName;
+      }
+
+      public Iterator<URL> getUrls()
+      {
+         return urls.iterator();
+      }
+
+      public String getConfigFileName()
+      {
+         return configFileName;
+      }
+
+      public void add(Enumeration<URL> urls)
+      {
+         while (urls.hasMoreElements())
+         {
+            URL url = urls.nextElement();
+            this.urls.add(url);
+         }
+      }
+   }
+}

Added: trunk/src/main/org/jboss/messaging/deployers/queue/QueueSettingsDeployer.java
===================================================================
--- trunk/src/main/org/jboss/messaging/deployers/queue/QueueSettingsDeployer.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/deployers/queue/QueueSettingsDeployer.java	2008-01-22 15:47:50 UTC (rev 3612)
@@ -0,0 +1,140 @@
+/*
+   * 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.deployers.queue;
+
+import org.jboss.messaging.core.QueueSettings;
+import org.jboss.messaging.deployers.Deployer;
+import org.jboss.messaging.util.HierarchicalRepository;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * A deployer for creating a set of queue settings and adding them to a repository
+ * @author <a href="ataylor at redhat.com">Andy Taylor</a>
+ */
+public class QueueSettingsDeployer extends Deployer
+{
+   /**
+    * The repository to add to
+    */
+   HierarchicalRepository<QueueSettings> queueSettingsRepository;
+   private static final String CLUSTERED_NODE_NAME = "clustered";
+   private static final String DLQ_NODE_NAME = "dlq";
+   private static final String EXPIREY_QUEUE_NODE_NAME = "expiry-queue";
+   private static final String REDELIVERY_DELAY_NODE_NAME = "redelivery-delay";
+   private static final String MAX_SIZE_NODE_NAME = "max-size";
+   private static final String DISTRIBUTION_POLICY_CLASS_NODE_NAME = "distribution-policy-class";
+   private static final String MESSAGE_COUNTER_HISTORY_DAY_LIMIT_NODE_NAME = "message-counter-history-day-limit";
+
+   public void setQueueSettingsRepository(HierarchicalRepository<QueueSettings> queueSettingsRepository)
+   {
+      this.queueSettingsRepository = queueSettingsRepository;
+   }
+
+   /**
+    * the names of the elements to deploy
+    * @return the names of the elements todeploy
+    */
+   public String[] getElementTagName()
+   {
+      return new String[]{"queue-settings"};
+   }
+
+   /**
+    * deploy an element
+    * @param node the element to deploy
+    * @throws Exception .
+    */
+   public void deploy(Node node) throws Exception
+   {
+      String match = node.getAttributes().getNamedItem(getKeyAttribute()).getNodeValue();
+      NodeList children = node.getChildNodes();
+      QueueSettings queueSettings = new QueueSettings();
+      for (int i = 0; i < children.getLength(); i++)
+      {
+         Node child = children.item(i);
+         if(CLUSTERED_NODE_NAME.equalsIgnoreCase(child.getNodeName()))
+         {
+            queueSettings.setClustered(Boolean.valueOf(child.getTextContent()));
+         }
+         if(DLQ_NODE_NAME.equalsIgnoreCase(child.getNodeName()))
+         {
+            queueSettings.setDLQ(child.getTextContent());
+         }
+         if(EXPIREY_QUEUE_NODE_NAME.equalsIgnoreCase(child.getNodeName()))
+         {
+            queueSettings.setExpiryQueue(child.getTextContent());
+         }
+         if(REDELIVERY_DELAY_NODE_NAME.equalsIgnoreCase(child.getNodeName()))
+         {
+            queueSettings.setRedeliveryDelay(Long.valueOf(child.getTextContent()));
+         }
+         if(MAX_SIZE_NODE_NAME.equalsIgnoreCase(child.getNodeName()))
+         {
+            queueSettings.setMaxSize(Integer.valueOf(child.getTextContent()));   
+         }
+         if(DISTRIBUTION_POLICY_CLASS_NODE_NAME.equalsIgnoreCase(child.getNodeName()))
+         {
+            queueSettings.setDistributionPolicyClass(child.getTextContent());
+         }
+         if(MESSAGE_COUNTER_HISTORY_DAY_LIMIT_NODE_NAME.equalsIgnoreCase(child.getNodeName()))
+         {
+            queueSettings.setMessageCounterHistoryDayLimit(Integer.valueOf(child.getTextContent()));
+         }
+      }
+
+
+      
+      queueSettingsRepository.addMatch(match, queueSettings);
+   }
+
+   /**
+    * The name of the configuration file name to look for for deployment
+    *
+    * @return The name of the config file
+    */
+   public String getConfigFileName()
+   {
+      return "queues.xml";
+   }
+
+   /**
+    * undeploys an element
+    * @param node the element to undeploy
+    * @throws Exception .
+    */
+   public void undeploy(Node node) throws Exception
+   {
+      String match = node.getAttributes().getNamedItem(getKeyAttribute()).getNodeValue();
+      queueSettingsRepository.removeMatch(match);
+   }
+
+   /**
+    * the key attribute for theelement, usually 'name' but can be overridden
+    * @return the key attribute
+    */
+   public String getKeyAttribute()
+   {
+      return "match";
+   }
+
+}

Added: trunk/src/main/org/jboss/messaging/deployers/security/SecurityDeployer.java
===================================================================
--- trunk/src/main/org/jboss/messaging/deployers/security/SecurityDeployer.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/deployers/security/SecurityDeployer.java	2008-01-22 15:47:50 UTC (rev 3612)
@@ -0,0 +1,146 @@
+/*
+   * 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.deployers.security;
+
+import org.jboss.jms.server.security.Role;
+import org.jboss.messaging.deployers.Deployer;
+import org.jboss.messaging.util.HierarchicalRepository;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+
+/**
+ * Deploys the security settings into a security repository and adds them to the security store.
+ *
+ * @author <a href="ataylor at redhat.com">Andy Taylor</a>
+ */
+public class SecurityDeployer extends Deployer
+{
+
+   private static final String PERMISSION_ELEMENT_NAME = "permission";
+   private static final String TYPE_ATTR_NAME = "type";
+   private static final String ROLES_ATTR_NAME = "roles";
+   private static final String QUEUES_XML = "queues.xml";
+   private static final String MATCH = "match";
+   private static final String SECURITY_ELEMENT_NAME = "security";
+
+   /**
+    * The repository to add to
+    */
+   private HierarchicalRepository<HashSet<Role>> securityRepository;
+
+   /**
+    * the names of the elements to deploy
+    * @return the names of the elements todeploy
+    */
+   public String[] getElementTagName()
+   {
+      return new String[]{SECURITY_ELEMENT_NAME};
+   }
+
+   /**
+    * the key attribute for theelement, usually 'name' but can be overridden
+    * @return the key attribute
+    */
+   public String getKeyAttribute()
+   {
+      return MATCH;
+   }
+
+   public void setSecurityRepository(HierarchicalRepository<HashSet<Role>> securityRepository)
+   {
+      this.securityRepository = securityRepository;
+   }
+
+   /**
+    * deploy an element
+    * @param node the element to deploy
+    * @throws Exception .
+    */
+   public void deploy(Node node) throws Exception
+   {
+      HashSet<Role> securityRoles = new HashSet<Role>();
+      ArrayList<String> create = new ArrayList<String>();
+      ArrayList<String> write = new ArrayList<String>();
+      ArrayList<String> read = new ArrayList<String>();
+      ArrayList<String> allRoles = new ArrayList<String>();
+      String match = node.getAttributes().getNamedItem(getKeyAttribute()).getNodeValue();
+      NodeList children = node.getChildNodes();
+      for (int i = 0; i < children.getLength(); i++)
+      {
+         Node child = children.item(i);
+
+         if (PERMISSION_ELEMENT_NAME.equalsIgnoreCase(child.getNodeName()))
+         {
+            String type = child.getAttributes().getNamedItem(TYPE_ATTR_NAME).getNodeValue();
+            String roleString = child.getAttributes().getNamedItem(ROLES_ATTR_NAME).getNodeValue();
+            String[] roles = roleString.split(",");
+            for (String role : roles)
+            {
+               if (Role.CREATE_NAME.equals(type))
+               {
+                  create.add(role);
+               }
+               else if (Role.WRITE_NAME.equals(type))
+               {
+                  write.add(role);
+               }
+               else if (Role.READ_NAME.equals(type))
+               {
+                  read.add(role);
+               }
+               if (!allRoles.contains(role))
+                  allRoles.add(role);
+            }
+         }
+
+      }
+      for (String role : allRoles)
+      {
+         securityRoles.add(new Role(role, read.contains(role), write.contains(role), create.contains(role)));
+      }
+      securityRepository.addMatch(match, securityRoles);
+   }
+
+   /**
+    * undeploys an element
+    * @param node the element to undeploy
+    * @throws Exception .
+    */
+   public void undeploy(Node node) throws Exception
+   {
+      String match = node.getAttributes().getNamedItem(getKeyAttribute()).getNodeValue();
+      securityRepository.removeMatch(match);
+   }
+
+   /**
+    * The name of the configuration file name to look for for deployment
+    *
+    * @return The name of the config file
+    */
+   public String getConfigFileName()
+   {
+      return QUEUES_XML;
+   }
+}

Added: trunk/src/main/org/jboss/messaging/util/HierarchicalObjectRepository.java
===================================================================
--- trunk/src/main/org/jboss/messaging/util/HierarchicalObjectRepository.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/util/HierarchicalObjectRepository.java	2008-01-22 15:47:50 UTC (rev 3612)
@@ -0,0 +1,99 @@
+/*
+   * 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.util;
+
+import java.util.HashMap;
+
+/**
+ * allows objects to be mapped against a regex pattern and held in order in a list
+ *
+ * @author <a href="ataylor at redhat.com">Andy Taylor</a>
+ */
+public class HierarchicalObjectRepository<E> implements HierarchicalRepository<E>
+{
+   /**
+    * The default Match to fall back to
+    */
+   E defaultmatch;
+
+   /**
+    * all the matches
+    */
+   HashMap<String, Match> matches = new HashMap<String, Match>();
+
+   /**
+    * Add a new match to the repository
+    * @param match The regex to use to match against
+    * @param value the value to hold agains the match
+    */
+   public void addMatch(String match, E value)
+   {
+      //create a match and add it to the list
+      if(match.equals("*"))
+      {
+         defaultmatch = value;   
+      }
+      else
+      {
+         Match match1 = new Match(match);
+         match1.setValue(value);
+         matches.put(match, match1);
+      }
+   }
+
+   /**
+    * return the value held against the nearest match
+    * @param match the match to look for
+    * @return the value
+    */
+   //todo implement a better algorithm for returning a match!
+   public E getMatch(String match)
+   {
+      for (Match securityMatch : matches.values())
+      {
+         if(securityMatch.getPattern().matcher(match).matches())
+         {
+            //noinspection unchecked
+            return (E) securityMatch.getValue();
+         }
+      }
+      return defaultmatch;
+   }
+
+   /**
+    * remove a match from the repository
+    * @param match the match to remove
+    */
+   public void removeMatch(String match)
+   {
+      matches.remove(match);
+   }
+
+   /**
+    * set the default value to fallback to if none found
+    * @param defaultValue the value
+    */
+   public void setDefault(E defaultValue)
+   {
+      defaultmatch = defaultValue;
+   }
+}

Added: trunk/src/main/org/jboss/messaging/util/HierarchicalRepository.java
===================================================================
--- trunk/src/main/org/jboss/messaging/util/HierarchicalRepository.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/util/HierarchicalRepository.java	2008-01-22 15:47:50 UTC (rev 3612)
@@ -0,0 +1,36 @@
+package org.jboss.messaging.util;
+
+
+/**
+ * allows objects to be mapped against a regex pattern and held in order in a list
+ *
+ * @author <a href="ataylor at redhat.com">Andy Taylor</a>
+ */
+public interface HierarchicalRepository<E>
+{
+   /**
+    * Add a new match to the repository
+    * @param match The regex to use to match against
+    * @param value the value to hold agains the match
+    */
+    void addMatch(String match, E value);
+
+   /**
+    * return the value held against the nearest match
+    * @param match the match to look for
+    * @return the value
+    */
+   E getMatch(String match);
+
+   /**
+    * set the default value to fallback to if none found
+    * @param defaultValue the value
+    */
+   void setDefault(E defaultValue);
+
+   /**
+    * remove a match from the repository
+    * @param match the match to remove
+    */
+   void removeMatch(String match);
+}

Added: trunk/src/main/org/jboss/messaging/util/Match.java
===================================================================
--- trunk/src/main/org/jboss/messaging/util/Match.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/util/Match.java	2008-01-22 15:47:50 UTC (rev 3612)
@@ -0,0 +1,92 @@
+/*
+   * 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.util;
+
+import java.util.regex.Pattern;
+
+/**
+    * a Match is the holder for the match string and the object to hold against it.
+ */
+public class Match
+{
+   private String match;
+   private Pattern pattern;
+   private Object value;
+
+
+   public Match(String match)
+   {
+      this.match = match;
+      //compile in advance for performance reasons
+      //check for dangling characters
+      if(match.length() > 1)
+         pattern = Pattern.compile(match);
+      else
+      {
+         pattern = Pattern.compile(new StringBuilder("[").append(match).append("]").toString());
+      }
+   }
+
+
+   public String getMatch()
+   {
+      return match;
+   }
+
+   public void setMatch(String match)
+   {
+      this.match = match;
+   }
+
+   public Pattern getPattern()
+   {
+      return pattern;
+   }
+
+
+   public Object getValue()
+   {
+      return value;
+   }
+
+   public void setValue(Object value)
+   {
+      this.value = value;
+   }
+
+   public boolean equals(Object o)
+   {
+      if (this == o) return true;
+      if (o == null || getClass() != o.getClass()) return false;
+
+      Match that = (Match) o;
+
+      if (match != null ? !match.equals(that.match) : that.match != null) return false;
+
+      return true;
+   }
+
+   public int hashCode()
+   {
+      return (match != null ? match.hashCode() : 0);
+   }
+}

Added: trunk/tests/src/org/jboss/jms/server/deployer/test/unit/DeployerTest.java
===================================================================
--- trunk/tests/src/org/jboss/jms/server/deployer/test/unit/DeployerTest.java	                        (rev 0)
+++ trunk/tests/src/org/jboss/jms/server/deployer/test/unit/DeployerTest.java	2008-01-22 15:47:50 UTC (rev 3612)
@@ -0,0 +1,242 @@
+/*
+   * 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.jms.server.deployer.test.unit;
+
+
+import junit.framework.TestCase;
+import org.jboss.messaging.deployers.Deployer;
+import org.jboss.messaging.util.XMLUtil;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashMap;
+
+/**
+ * tests the abstract deployer class
+ * @author <a href="ataylor at redhat.com">Andy Taylor</a>
+ */
+public class DeployerTest  extends TestCase
+{
+   private String conf1 = "<deployment>\n" +
+           "   <test name=\"test1\">content1</test>\n" +
+           "   <test name=\"test2\">content2</test>\n" +
+           "   <test name=\"test3\">content3</test>\n" +
+           "   <test name=\"test4\">content4</test>\n" +
+           "</deployment>";
+
+   private String conf2 = "<deployment>\n" +
+           "   <test name=\"test1\">content1</test>\n" +
+           "   <test name=\"test2\">contenthaschanged2</test>\n" +
+           "   <test name=\"test3\">contenthaschanged3</test>\n" +
+           "   <test name=\"test4\">content4</test>\n" +
+           "</deployment>";
+
+   private String conf3 = "<deployment>\n" +
+           "   <test name=\"test1\">content1</test>\n" +
+           "   <test name=\"test2\">contenthaschanged2</test>\n" +
+           "</deployment>";
+
+   private String conf4 = "<deployment>\n" +
+           "   <test name=\"test1\">content1</test>\n" +
+           "   <test name=\"test2\">content2</test>\n" +
+           "   <test name=\"test3\">content3</test>\n" +
+           "   <test name=\"test4\">content4</test>\n" +
+           "   <test name=\"test5\">content5</test>\n" +
+           "   <test name=\"test6\">content6</test>\n" +
+           "</deployment>";
+
+   private URL url;
+
+
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+      url = new URL("http://thisdoesntmatter");
+   }
+
+   public void testDeploy() throws Exception
+   {
+      Element e = XMLUtil.stringToElement(conf1);
+      TestDeployer testDeployer = new TestDeployer();
+      testDeployer.setElement(e);
+      testDeployer.deploy(url);
+      assertEquals(testDeployer.getDeployments(), 4);
+      assertNotNull(testDeployer.getNodes().get("test1"));
+      assertNotNull(testDeployer.getNodes().get("test2"));
+      assertNotNull(testDeployer.getNodes().get("test3"));
+      assertNotNull(testDeployer.getNodes().get("test4"));
+      assertEquals(testDeployer.getNodes().get("test1").getTextContent(), "content1");
+      assertEquals(testDeployer.getNodes().get("test2").getTextContent(), "content2");
+      assertEquals(testDeployer.getNodes().get("test3").getTextContent(), "content3");
+      assertEquals(testDeployer.getNodes().get("test4").getTextContent(), "content4");
+   }
+
+   public void testRedeploy() throws Exception
+   {
+      Element e = XMLUtil.stringToElement(conf1);
+      TestDeployer testDeployer = new TestDeployer();
+      testDeployer.setElement(e);
+      testDeployer.deploy(url);
+      e = XMLUtil.stringToElement(conf2);
+      testDeployer.setElement(e);
+      testDeployer.redeploy(url);
+      assertEquals(testDeployer.getDeployments(), 4);
+      assertNotNull(testDeployer.getNodes().get("test1"));
+      assertNotNull(testDeployer.getNodes().get("test2"));
+      assertNotNull(testDeployer.getNodes().get("test3"));
+      assertNotNull(testDeployer.getNodes().get("test4"));
+      assertEquals(testDeployer.getNodes().get("test1").getTextContent(), "content1");
+      assertEquals(testDeployer.getNodes().get("test2").getTextContent(), "contenthaschanged2");
+      assertEquals(testDeployer.getNodes().get("test3").getTextContent(), "contenthaschanged3");
+      assertEquals(testDeployer.getNodes().get("test4").getTextContent(), "content4");
+   }
+
+   public void testRedeployRemovingNodes() throws Exception
+   {
+      Element e = XMLUtil.stringToElement(conf1);
+      TestDeployer testDeployer = new TestDeployer();
+      testDeployer.setElement(e);
+      testDeployer.deploy(url);
+      e = XMLUtil.stringToElement(conf3);
+      testDeployer.setElement(e);
+      testDeployer.redeploy(url);
+      assertEquals(testDeployer.getDeployments(), 2);
+      assertNotNull(testDeployer.getNodes().get("test1"));
+      assertNotNull(testDeployer.getNodes().get("test2"));
+      assertNull(testDeployer.getNodes().get("test3"));
+      assertNull(testDeployer.getNodes().get("test4"));
+      assertEquals(testDeployer.getNodes().get("test1").getTextContent(), "content1");
+      assertEquals(testDeployer.getNodes().get("test2").getTextContent(), "contenthaschanged2");
+   }
+
+   public void testRedeployAddingNodes() throws Exception
+   {
+      Element e = XMLUtil.stringToElement(conf1);
+      TestDeployer testDeployer = new TestDeployer();
+      testDeployer.setElement(e);
+      testDeployer.deploy(url);
+      e = XMLUtil.stringToElement(conf4);
+      testDeployer.setElement(e);
+      testDeployer.redeploy(url);
+      assertEquals(testDeployer.getDeployments(), 6);
+      assertNotNull(testDeployer.getNodes().get("test1"));
+      assertNotNull(testDeployer.getNodes().get("test2"));
+      assertNotNull(testDeployer.getNodes().get("test3"));
+      assertNotNull(testDeployer.getNodes().get("test4"));
+      assertNotNull(testDeployer.getNodes().get("test5"));
+      assertNotNull(testDeployer.getNodes().get("test6"));
+      assertEquals(testDeployer.getNodes().get("test1").getTextContent(), "content1");
+      assertEquals(testDeployer.getNodes().get("test2").getTextContent(), "content2");
+      assertEquals(testDeployer.getNodes().get("test3").getTextContent(), "content3");
+      assertEquals(testDeployer.getNodes().get("test4").getTextContent(), "content4");      
+      assertEquals(testDeployer.getNodes().get("test5").getTextContent(), "content5");
+      assertEquals(testDeployer.getNodes().get("test6").getTextContent(), "content6");
+   }
+
+   public void testUndeploy() throws Exception
+   {
+      Element e = XMLUtil.stringToElement(conf1);
+      TestDeployer testDeployer = new TestDeployer();
+      testDeployer.setElement(e);
+      testDeployer.deploy(url);
+      testDeployer.undeploy(url);
+      assertEquals(testDeployer.getDeployments(), 0);
+      assertNull(testDeployer.getNodes().get("test1"));
+      assertNull(testDeployer.getNodes().get("test2"));
+      assertNull(testDeployer.getNodes().get("test3"));
+      assertNull(testDeployer.getNodes().get("test4"));
+   }
+   class TestDeployer extends Deployer
+   {
+      private String elementname = "test";
+      Element element = null;
+      private int deployments = 0;
+      ArrayList<String> contents = new ArrayList<String>();
+      HashMap<String, Node> nodes = new HashMap<String, Node>();
+
+      public HashMap<String, Node> getNodes()
+      {
+         return nodes;
+      }
+
+      public ArrayList<String> getContents()
+      {
+         return contents;
+      }
+
+      public int getDeployments()
+      {
+         return deployments;
+      }
+
+      public String getElementname()
+      {
+         return elementname;
+      }
+
+      public void setElementname(String elementname)
+      {
+         this.elementname = elementname;
+      }
+
+      public Element getElement()
+      {
+         return element;
+      }
+
+      public void setElement(Element element)
+      {
+         this.element = element;
+      }
+
+      public String[] getElementTagName()
+      {
+         return new String[]{elementname};
+      }
+
+
+      public String getConfigFileName()
+      {
+         return "test";
+      }
+
+      public void deploy(Node node) throws Exception
+      {
+         deployments++;
+         contents.add(node.getTextContent());
+         nodes.put(node.getAttributes().getNamedItem(NAME_ATTR).getNodeValue(), node);
+      }
+
+      public void undeploy(Node node) throws Exception
+      {
+         deployments--;
+         nodes.remove(node.getAttributes().getNamedItem(NAME_ATTR).getNodeValue());
+      }
+
+      protected Element getRootElement(URL url)
+      {
+         return element;
+      }
+   }
+}

Added: trunk/tests/src/org/jboss/jms/server/destination/settings/test/unit/QueueSettingsDeployerTest.java
===================================================================
--- trunk/tests/src/org/jboss/jms/server/destination/settings/test/unit/QueueSettingsDeployerTest.java	                        (rev 0)
+++ trunk/tests/src/org/jboss/jms/server/destination/settings/test/unit/QueueSettingsDeployerTest.java	2008-01-22 15:47:50 UTC (rev 3612)
@@ -0,0 +1,70 @@
+/*
+   * 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.jms.server.destination.settings.test.unit;
+
+import junit.framework.TestCase;
+import org.easymock.EasyMock;
+import org.jboss.messaging.core.QueueSettings;
+import org.jboss.messaging.deployers.queue.QueueSettingsDeployer;
+import org.jboss.messaging.util.HierarchicalRepository;
+import org.jboss.messaging.util.XMLUtil;
+
+/**
+ * @author <a href="ataylor at redhat.com">Andy Taylor</a>
+ */
+public class QueueSettingsDeployerTest extends TestCase
+{
+   private String conf = "<queue-settings match=\"queues.*\">\n" +
+           "      <clustered>false</clustered>\n" +
+           "      <dlq>DLQtest</dlq>\n" +
+           "      <expiry-queue>ExpiryQueueTest</expiry-queue>\n" +
+           "      <redelivery-delay>100</redelivery-delay>\n" +
+           "      <max-size>-100</max-size>\n" +
+           "      <distribution-policy-class>org.jboss.messaging.core.impl.RoundRobinDistributionPolicy</distribution-policy-class>\n" +
+           "      <message-counter-history-day-limit>1000</message-counter-history-day-limit>\n" +
+           "   </queue-settings>";
+
+   QueueSettingsDeployer queueSettingsDeployer;
+
+
+   protected void setUp() throws Exception
+   {
+      queueSettingsDeployer = new QueueSettingsDeployer();
+   }
+
+   public void testSimple() throws Exception
+   {
+      HierarchicalRepository<QueueSettings> repository = EasyMock.createStrictMock(HierarchicalRepository.class);
+      queueSettingsDeployer.setQueueSettingsRepository(repository);
+      QueueSettings queueSettings = new QueueSettings();
+      queueSettings.setClustered(false);
+      queueSettings.setDLQ("DLQtest");
+      queueSettings.setExpiryQueue("ExpiryQueueTest");
+      queueSettings.setRedeliveryDelay(100);
+      queueSettings.setMaxSize(-100);
+      queueSettings.setDistributionPolicyClass("org.jboss.messaging.core.impl.RoundRobinDistributionPolicy");
+      queueSettings.setMessageCounterHistoryDayLimit(1000);
+      repository.addMatch("queues.*", queueSettings);
+      EasyMock.replay(repository);
+      queueSettingsDeployer.deploy(XMLUtil.stringToElement(conf));
+   }
+}

Added: trunk/tests/src/org/jboss/jms/server/security/test/unit/SecurityDeployerTest.java
===================================================================
--- trunk/tests/src/org/jboss/jms/server/security/test/unit/SecurityDeployerTest.java	                        (rev 0)
+++ trunk/tests/src/org/jboss/jms/server/security/test/unit/SecurityDeployerTest.java	2008-01-22 15:47:50 UTC (rev 3612)
@@ -0,0 +1,110 @@
+/*
+   * 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.jms.server.security.test.unit;
+
+import junit.framework.TestCase;
+import org.easymock.EasyMock;
+import org.jboss.jms.server.security.Role;
+import org.jboss.messaging.deployers.security.SecurityDeployer;
+import org.jboss.messaging.util.HierarchicalRepository;
+import org.jboss.messaging.util.XMLUtil;
+import org.w3c.dom.Element;
+
+import java.util.HashSet;
+
+/**
+ * @author <a href="ataylor at redhat.com">Andy Taylor</a>
+ */
+public class SecurityDeployerTest extends TestCase
+{
+   private SecurityDeployer deployer;
+   private String conf = 
+           "   <security match=\"topics.testTopic\">\n" +
+           "      <permission type=\"create\" roles=\"durpublisher\"/>\n" +
+           "      <permission type=\"read\" roles=\"guest,publisher,durpublisher\"/>\n" +
+           "      <permission type=\"write\" roles=\"guest,publisher,durpublisher\"/>\n" +
+           "   </security>";
+
+   private String conf2 =
+           "   <security match=\"queues.testQueue\">\n" +
+           "      <permission type=\"create\" roles=\"durpublisher\"/>\n" +
+           "      <permission type=\"read\" roles=\"guest,publisher,durpublisher\"/>\n" +
+           "      <permission type=\"write\" roles=\"guest,publisher,durpublisher\"/>\n" +
+           "   </security>";
+
+   private String noRoles =
+           "   <securityfoo match=\"queues.testQueue\">\n" +
+           "   </securityfoo>";
+
+   protected void setUp() throws Exception
+   {
+      deployer = new SecurityDeployer();
+   }
+
+   public void testSingle() throws Exception
+   {
+
+      HierarchicalRepository<HashSet<Role>> repository = EasyMock.createStrictMock(HierarchicalRepository.class);
+      deployer.setSecurityRepository(repository);
+      Element e = XMLUtil.stringToElement(conf);
+      Role role = new Role("durpublisher", true, true, true);
+      Role role2 = new Role("guest", true, true, false);
+      Role role3 = new Role("publisher", true, true, false);
+      HashSet<Role> roles = new HashSet<Role>();
+      roles.add(role);
+      roles.add(role2);
+      roles.add(role3);
+      repository.addMatch("topics.testTopic", roles);
+      EasyMock.replay(repository);
+      deployer.deploy(e);
+      
+   }
+
+   public void testMultiple() throws Exception
+   {
+      HierarchicalRepository<HashSet<Role>> repository = EasyMock.createStrictMock(HierarchicalRepository.class);
+      deployer.setSecurityRepository(repository);
+      Role role = new Role("durpublisher", true, true, true);
+      Role role2 = new Role("guest", true, true, false);
+      Role role3 = new Role("publisher", true, true, false);
+      HashSet<Role> roles = new HashSet<Role>();
+      roles.add(role);
+      roles.add(role2);
+      roles.add(role3);
+      repository.addMatch("topics.testTopic", roles);
+      repository.addMatch("queues.testQueue", roles);
+      EasyMock.replay(repository);
+      deployer.deploy(XMLUtil.stringToElement(conf));
+      deployer.deploy(XMLUtil.stringToElement(conf2));
+
+   }
+   public void testNoRolesAdded() throws Exception
+   {
+      HierarchicalRepository<HashSet<Role>> repository = EasyMock.createStrictMock(HierarchicalRepository.class);
+      deployer.setSecurityRepository(repository);
+      HashSet<Role> roles = new HashSet<Role>();
+      repository.addMatch("queues.testQueue", roles);
+      EasyMock.replay(repository);
+      deployer.deploy(XMLUtil.stringToElement(noRoles));
+
+   }
+}

Added: trunk/tests/src/org/jboss/jms/server/security/test/unit/SecurityRepositoryTest.java
===================================================================
--- trunk/tests/src/org/jboss/jms/server/security/test/unit/SecurityRepositoryTest.java	                        (rev 0)
+++ trunk/tests/src/org/jboss/jms/server/security/test/unit/SecurityRepositoryTest.java	2008-01-22 15:47:50 UTC (rev 3612)
@@ -0,0 +1,85 @@
+/*
+   * 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.jms.server.security.test.unit;
+
+import junit.framework.TestCase;
+import org.jboss.jms.server.security.Role;
+import org.jboss.messaging.util.HierarchicalObjectRepository;
+import org.jboss.messaging.util.HierarchicalRepository;
+
+import java.util.HashSet;
+
+/**
+ * @author <a href="ataylor at redhat.com">Andy Taylor</a>
+ */
+public class SecurityRepositoryTest extends TestCase
+{
+   HierarchicalRepository<HashSet<Role>> securityRepository;
+
+
+   protected void setUp() throws Exception
+   {
+      securityRepository = new HierarchicalObjectRepository<HashSet<Role>>();
+   }
+
+   public void testDefault()
+   {
+      securityRepository.setDefault(new HashSet<Role>());
+      HashSet<Role> roles = securityRepository.getMatch("queues.something");
+
+      assertEquals(roles.size(), 0);
+   }
+
+   public void testSingleMatch()
+   {
+      securityRepository.addMatch("queues.*", new HashSet<Role>());
+      HashSet<Role> hashSet = securityRepository.getMatch("queues.something");
+      assertEquals(hashSet.size(), 0);
+   }
+
+   public void testSingletwo()
+   {
+      securityRepository.addMatch("queues.another.aq.*", new HashSet<Role>());
+      HashSet<Role> roles = new HashSet<Role>(2);
+      roles.add(new Role("test1"));
+      roles.add(new Role("test2"));
+      securityRepository.addMatch("queues.aq", roles);
+      HashSet<Role> roles2 = new HashSet<Role>(2);
+      roles2.add(new Role("test1"));
+      roles2.add(new Role("test2"));
+      roles2.add(new Role("test3"));
+      securityRepository.addMatch("queues.another.andanother.*", roles2);
+      HashSet<Role> hashSet = securityRepository.getMatch("queues.another.andanother");
+      assertEquals(hashSet.size(), 3);
+   }
+
+   public void testWithoutWildcard()
+   {
+      securityRepository.addMatch("queues.1.*", new HashSet<Role>());
+      HashSet<Role> roles = new HashSet<Role>(2);
+      roles.add(new Role("test1"));
+      roles.add(new Role("test2"));
+      securityRepository.addMatch("queues.2.aq", roles);
+      HashSet<Role> hashSet = securityRepository.getMatch("queues.2.aq");
+      assertEquals(hashSet.size(), 2);
+   }
+}

Modified: trunk/tests/src/org/jboss/test/messaging/JBMServerTestCase.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/JBMServerTestCase.java	2008-01-22 13:47:58 UTC (rev 3611)
+++ trunk/tests/src/org/jboss/test/messaging/JBMServerTestCase.java	2008-01-22 15:47:50 UTC (rev 3612)
@@ -21,21 +21,6 @@
    */
 package org.jboss.test.messaging;
 
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-
-import javax.jms.Queue;
-import javax.jms.Topic;
-import javax.management.ObjectName;
-import javax.naming.InitialContext;
-import javax.sql.DataSource;
-import javax.transaction.TransactionManager;
-
 import org.jboss.jms.client.JBossConnectionFactory;
 import org.jboss.jms.server.security.Role;
 import org.jboss.jms.tx.ResourceManagerFactory;
@@ -47,6 +32,20 @@
 import org.jboss.test.messaging.tools.container.Server;
 import org.jboss.tm.TransactionManagerLocator;
 
+import javax.jms.Queue;
+import javax.jms.Topic;
+import javax.management.ObjectName;
+import javax.naming.InitialContext;
+import javax.sql.DataSource;
+import javax.transaction.TransactionManager;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+
 /**
  * @author <a href="mailto:adrian at jboss.org">Adrian Brock</a>
  * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
@@ -257,22 +256,7 @@
       //deployAdministeredObjects();
    }
 
-   public synchronized void stopDestinationManager() throws Exception
-   {
-      for (int i = 0; i < getServerCount(); i++)
-      {
-         servers.get(i).stopDestinationManager();
-      }
-   }
 
-   public synchronized void startDestinationManager() throws Exception
-   {
-      for (int i = 0; i < getServerCount(); i++)
-      {
-         servers.get(i).startDestinationManager();
-      }
-   }
-
    protected boolean getClearDatabase()
    {
       return true;

Modified: trunk/tests/src/org/jboss/test/messaging/tools/ServerManagement.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/ServerManagement.java	2008-01-22 13:47:58 UTC (rev 3611)
+++ trunk/tests/src/org/jboss/test/messaging/tools/ServerManagement.java	2008-01-22 15:47:50 UTC (rev 3612)
@@ -21,31 +21,18 @@
 */
 package org.jboss.test.messaging.tools;
 
-import java.io.BufferedReader;
-import java.io.InputStreamReader;
-import java.rmi.Naming;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
+import org.jboss.messaging.util.Logger;
+import org.jboss.test.messaging.tools.container.*;
 
 import javax.management.Notification;
 import javax.management.NotificationListener;
 import javax.management.ObjectName;
 import javax.transaction.UserTransaction;
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.rmi.Naming;
+import java.util.*;
 
-import org.jboss.jms.server.DestinationManager;
-import org.jboss.messaging.util.Logger;
-import org.jboss.test.messaging.tools.container.InVMInitialContextFactory;
-import org.jboss.test.messaging.tools.container.LocalTestServer;
-import org.jboss.test.messaging.tools.container.NotificationListenerID;
-import org.jboss.test.messaging.tools.container.RMITestServer;
-import org.jboss.test.messaging.tools.container.RemoteInitialContextFactory;
-import org.jboss.test.messaging.tools.container.Server;
-import org.jboss.test.messaging.tools.container.ServiceAttributeOverrides;
-
 /**
  * Collection of static methods to use to start/stop and interact with the in-memory JMS server. It
  * is also use to start/stop a remote server.

Modified: trunk/tests/src/org/jboss/test/messaging/tools/container/LocalTestServer.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/container/LocalTestServer.java	2008-01-22 13:47:58 UTC (rev 3611)
+++ trunk/tests/src/org/jboss/test/messaging/tools/container/LocalTestServer.java	2008-01-22 15:47:50 UTC (rev 3612)
@@ -21,40 +21,41 @@
 */
 package org.jboss.test.messaging.tools.container;
 
-import java.io.File;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-import javax.management.NotificationListener;
-import javax.management.ObjectName;
-import javax.naming.InitialContext;
-import javax.sql.DataSource;
-import javax.transaction.TransactionManager;
-import javax.transaction.UserTransaction;
-
+import org.jboss.jms.client.JBossConnectionFactory;
+import org.jboss.jms.client.impl.ClientConnectionFactoryImpl;
+import org.jboss.jms.destination.JBossQueue;
+import org.jboss.jms.destination.JBossTopic;
 import org.jboss.jms.server.connectionfactory.ConnectionFactory;
+import org.jboss.jms.server.endpoint.ServerConnectionFactoryEndpoint;
 import org.jboss.jms.server.security.Role;
 import org.jboss.jms.tx.ResourceManagerFactory;
-import org.jboss.messaging.util.Logger;
-import org.jboss.messaging.core.Binding;
-import org.jboss.messaging.core.Condition;
-import org.jboss.messaging.core.DestinationType;
-import org.jboss.messaging.core.MessagingServer;
-import org.jboss.messaging.core.MessagingServerManagement;
+import org.jboss.logging.Logger;
+import org.jboss.messaging.core.*;
 import org.jboss.messaging.core.impl.ConditionImpl;
+import org.jboss.messaging.core.remoting.ServerLocator;
 import org.jboss.messaging.microcontainer.JBMBootstrapServer;
+import org.jboss.messaging.util.JNDIUtil;
+import org.jboss.messaging.util.Version;
 import org.jboss.test.messaging.tools.ConfigurationHelper;
 import org.jboss.test.messaging.tools.ServerManagement;
 import org.jboss.test.messaging.tools.jboss.MBeanConfigurationElement;
 import org.jboss.tm.TransactionManagerLocator;
 
+import javax.jms.InvalidDestinationException;
+import javax.management.NotificationListener;
+import javax.management.ObjectName;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NameNotFoundException;
+import javax.sql.DataSource;
+import javax.transaction.TransactionManager;
+import javax.transaction.UserTransaction;
+import java.io.File;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.util.*;
+
 /**
  * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
@@ -69,6 +70,7 @@
    private static final Logger log = Logger.getLogger(LocalTestServer.class);
    private boolean started = false;
    private Map<String, ConnectionFactory> factories = new HashMap<String, ConnectionFactory>();
+   private HashMap<String, List<String>> allBindings = new HashMap<String, List<String>>();
    // Static ---------------------------------------------------------------------------------------
 
    public static void setEnvironmentServerIndex(int serverIndex)
@@ -85,7 +87,7 @@
 
    private ServiceContainer sc;
 
-   // service dependencies   
+   // service dependencies
    private ObjectName persistenceManagerObjectName;
    private ObjectName postOfficeObjectName;
    private ObjectName jmsUserManagerObjectName;
@@ -127,18 +129,18 @@
       {
          return;
       }
-      
+
       if (clearDatabase)
-      {      
+      {
          //Delete the BDB environment
-         
+
          File dir = new File(System.getProperty("user.home") + "/bdbje/env");
-         
+
          boolean deleted = deleteDirectory(dir);
-         
+
          log.info("Deleted dir: " +dir.getAbsolutePath() + " deleted: " + deleted);
       }
-      
+
       ConfigurationHelper.addServerConfig(getServerID(), configuration);
 
       JBMPropertyKernelConfig propertyKernelConfig = new JBMPropertyKernelConfig(System.getProperties());
@@ -149,7 +151,7 @@
       started = true;
 
    }
-   
+
    private static boolean deleteDirectory(File directory)
    {
       if (directory.isDirectory())
@@ -259,6 +261,7 @@
    {
       bootstrap.shutDown();
       started=false;
+      unbindAll();
       return true;
    }
 
@@ -369,19 +372,23 @@
    {
       System.setProperty(Constants.SERVER_INDEX_PROPERTY_NAME, "" + getServerID());
       getMessagingServer().stop();
+      //also unbind everything
+      unbindAll();
    }
 
-   public synchronized void stopDestinationManager() throws Exception
+   private void unbindAll()
+           throws Exception
    {
-      System.setProperty(Constants.SERVER_INDEX_PROPERTY_NAME, "" + getServerID());
-      getMessagingServer().getDestinationManager().stop();
+      Collection<List<String>> bindings = allBindings.values();
+      for (List<String> binding : bindings)
+      {
+         for (String s : binding)
+         {
+            getInitialContext().unbind(s);
+         }
+      }
    }
 
-   public synchronized void startDestinationManager() throws Exception
-   {
-      System.setProperty(Constants.SERVER_INDEX_PROPERTY_NAME, "" + getServerID());
-      getMessagingServer().getDestinationManager().start();
-   }
 
    public boolean isServerPeerStarted() throws Exception
    {
@@ -489,27 +496,69 @@
 //         return getMessagingServer().undeployTopic(name);
 //   }
 
-   
+
    public void destroyQueue(String name, String jndiName) throws Exception
    {
-      this.getMessagingServerManagement().destroyQueue(name, jndiName);
+      this.getMessagingServerManagement().destroyQueue(name);
+      getInitialContext().unbind(jndiName);
    }
-   
+
    public void destroyTopic(String name, String jndiName) throws Exception
    {
-      this.getMessagingServerManagement().destroyTopic(name, jndiName);
+      this.getMessagingServerManagement().destroyTopic(name);
+      getInitialContext().unbind(jndiName);
    }
-   
+
    public void createQueue(String name, String jndiName) throws Exception
    {
-      this.getMessagingServerManagement().createQueue(name, jndiName);
+      this.getMessagingServerManagement().createQueue(name);
+      JBossQueue jBossQueue = new JBossQueue(name);
+      bindObject("/queue/" + (jndiName != null ? jndiName : name), jBossQueue);
+      List<String> bindings = new ArrayList<String>();
+      bindings.add("/queue/" + (jndiName != null ? jndiName : name));
+      allBindings.put(name, bindings);
    }
-   
+
    public void createTopic(String name, String jndiName) throws Exception
    {
-      this.getMessagingServerManagement().createTopic(name, jndiName);
+      this.getMessagingServerManagement().createTopic(name);
+      JBossTopic jBossTopic = new JBossTopic(name);
+      bindObject("/topic/" + (jndiName != null ? jndiName : name), jBossTopic);
+      List<String> bindings = new ArrayList<String>();
+      bindings.add("/topic/" + (jndiName != null ? jndiName : name));
+      allBindings.put(name, bindings);
    }
 
+   private void bindObject(String jndiName, Object object)
+           throws Exception
+   {
+      String parentContext;
+      String jndiNameInContext;
+      int sepIndex = jndiName.lastIndexOf('/');
+      if (sepIndex == -1)
+      {
+         parentContext = "";
+      }
+      else
+      {
+         parentContext = jndiName.substring(0, sepIndex);
+      }
+      jndiNameInContext = jndiName.substring(sepIndex + 1);
+      try
+      {
+         getInitialContext().lookup(jndiName);
+         throw new InvalidDestinationException("Destination " + jndiName + " already exists");
+      }
+      catch (NameNotFoundException e)
+      {
+         // OK
+      }
+
+      Context c = JNDIUtil.createContext(getInitialContext(), parentContext);
+
+      c.rebind(jndiNameInContext, object);
+   }
+
    public void deployConnectionFactory(String clientId, String objectName,
                                        String[] jndiBindings) throws Exception
    {
@@ -592,20 +641,60 @@
       connectionFactory.setSupportsFailover(supportsFailover);
       connectionFactory.setSupportsLoadBalancing(supportsLoadBalancing);
       connectionFactory.setStrictTck(strictTck);
-      connectionFactory.setMessagingServer(getMessagingServer());
-      connectionFactory.setMinaService(getMessagingServer().getMinaService());
       factories.put(objectName, connectionFactory);
-      connectionFactory.start();
+      ServerLocator serverLocator = getMessagingServer().getMinaService().getLocator();
+
+      log.info("Server locator is " + serverLocator);
+      log.info(this + " started");
+      // See http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4076040#4076040
+      final String id = connectionFactory.getName();
+
+      Version version = getMessagingServer().getVersion();
+
+      ServerConnectionFactoryEndpoint endpoint =
+              new ServerConnectionFactoryEndpoint(connectionFactory.getName(), id, getMessagingServer(), connectionFactory.getClientID(),
+                      connectionFactory.getPrefetchSize(),
+                      connectionFactory.getDefaultTempQueueFullSize(),
+                      connectionFactory.getDefaultTempQueuePageSize(),
+                      connectionFactory.getDefaultTempQueueDownCacheSize(),
+                      connectionFactory.getDupsOKBatchSize());
+
+      //The server peer strict setting overrides the connection factory
+      boolean useStrict = getMessagingServer().getConfiguration().isStrictTck() || connectionFactory.isStrictTck();
+
+      ClientConnectionFactoryImpl delegate =
+              new ClientConnectionFactoryImpl(connectionFactory.getName(), id, getMessagingServer().getConfiguration().getMessagingServerID(),
+                      serverLocator.getURI(), version, false, useStrict);
+
+      log.debug(this + " created local delegate " + delegate);
+
+      // Registering with the dispatcher should always be the last thing otherwise a client could
+      // use a partially initialised object
+
+      getMessagingServer().getMinaService().getDispatcher().register(endpoint.newHandler());
+      JBossConnectionFactory jBossConnectionFactory = new JBossConnectionFactory(delegate);
+      for (String binding : bindings)
+      {
+         bindObject(binding, jBossConnectionFactory);
+      }
+      allBindings.put(objectName, bindings);
    }
 
    public void undeployConnectionFactory(String objectName) throws Exception
    {
-      getMessagingServer().getConnectionFactoryManager().unregisterConnectionFactory(objectName);
+      getMessagingServer().getMinaService().getDispatcher().unregister(objectName);
+      List<String> bindings = allBindings.get(objectName);
+      for (String binding : bindings)
+      {
+         getInitialContext().unbind(binding);
+      }
+      allBindings.remove(objectName);
    }
 
    public void configureSecurityForDestination(String destName, boolean isQueue, HashSet<Role> roles) throws Exception
    {
-      getMessagingServer().getSecurityManager().setSecurityConfig(isQueue, destName, roles);
+      String prefix = isQueue ? "queues." : "topics";
+      getMessagingServer().getSecurityRepository().addMatch(prefix + destName, roles);
    }
 
    public void setDefaultSecurityConfig(String config) throws Exception
@@ -762,18 +851,19 @@
 
    public void setSecurityConfigOnManager(boolean b, String s, HashSet<Role> conf) throws Exception
    {
-      getMessagingServer().getSecurityManager().setSecurityConfig(b, s, conf);
+      String prefix = b ? "queues." : "topics";
+      getMessagingServer().getSecurityRepository().addMatch(prefix + s, conf);
    }
 
 
    public void setRedeliveryDelayOnDestination(String dest, boolean queue, long delay) throws Exception
    {
       //getMessagingServer().getDestinationManager().getDestination(dest, queue).setRedeliveryDelay(delay);
-      
+
       Condition condition = new ConditionImpl(queue ? DestinationType.QUEUE : DestinationType.TOPIC, dest);
-      
+
       List<Binding> bindings = this.getMessagingServer().getPostOffice().getBindingsForCondition(condition);
-      
+
       bindings.get(0).getQueue().setRedeliveryDelay(delay);
    }
 
@@ -795,7 +885,6 @@
       return ResourceManagerFactory.instance.size();
    }
 
-
    // Inner classes --------------------------------------------------------------------------------
 
 }

Modified: trunk/tests/src/org/jboss/test/messaging/tools/container/Server.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/container/Server.java	2008-01-22 13:47:58 UTC (rev 3611)
+++ trunk/tests/src/org/jboss/test/messaging/tools/container/Server.java	2008-01-22 15:47:50 UTC (rev 3612)
@@ -21,20 +21,19 @@
 */
 package org.jboss.test.messaging.tools.container;
 
-import java.rmi.Remote;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
+import org.jboss.jms.server.security.Role;
+import org.jboss.messaging.core.MessagingServer;
+import org.jboss.messaging.core.MessagingServerManagement;
 
 import javax.management.NotificationListener;
 import javax.management.ObjectName;
 import javax.naming.InitialContext;
 import javax.transaction.UserTransaction;
+import java.rmi.Remote;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
 
-import org.jboss.jms.server.security.Role;
-import org.jboss.messaging.core.MessagingServer;
-import org.jboss.messaging.core.MessagingServerManagement;
-
 /**
  * The remote interface exposed by TestServer.
  *
@@ -113,10 +112,6 @@
 
    void stopServerPeer() throws Exception;
 
-   public void stopDestinationManager() throws Exception;
-
-   public void startDestinationManager() throws Exception;
-
    boolean isServerPeerStarted() throws Exception;
 
    ObjectName getServerPeerObjectName() throws Exception;

Modified: trunk/util/release-admin.xml
===================================================================
--- trunk/util/release-admin.xml	2008-01-22 13:47:58 UTC (rev 3611)
+++ trunk/util/release-admin.xml	2008-01-22 15:47:50 UTC (rev 3612)
@@ -80,6 +80,7 @@
          <fileset dir="${jboss.home}/server/${messaging.config.source}">
             <include name="conf/**"/>
             <include name="deploy/**"/>
+            <include name="deployers/**"/>
             <include name="lib/**"/>
 	    <include name="farm/**"/>
 	    <include name="deploy-hasingleton/**"/>
@@ -107,28 +108,30 @@
 
       <!-- copy jboss-messaging.jar to the lib directory. It needs to be in lib so it can be seen by the JTA
            recovery manager for example -->
-      <copy file="${artifacts.location}/${jar.name}" todir="${jboss.home}/server/${messaging.config.name}/lib"/>
+      <copy file="${artifacts.location}/${jar.name}" todir="${jboss.home}/server/${messaging.config.name}/lib" overwrite="true"/>
 
       <!-- Copy the default security properties files to conf/props-->
-      <copy todir="${jboss.home}/server/${messaging.config.name}/conf/props">
+      <!--<copy todir="${jboss.home}/server/${messaging.config.name}/conf/props">
           <fileset dir="../src/etc/server/default/config">
              <include name="messaging-*.properties"/>
           </fileset>
-      </copy>
+      </copy>-->
 
       <!-- Copy the JMS JCA resource adaptor -->
-      <copy file="${jboss.home}/server/${messaging.config.source}/deploy/jms/jms-ra.rar"
-            todir="${jboss.home}/server/${messaging.config.name}/deploy"/>
+      
+      <!--<copy file="${jboss.home}/server/${messaging.config.source}/deploy/jms/jms-ra.rar"
+            todir="${jboss.home}/server/${messaging.config.name}/deploy"/>-->
 
       <!-- Copy the JMS provider loader stuff -->
-      <copy todir="${jboss.home}/server/${messaging.config.name}/deploy">
+      <!--<copy todir="${jboss.home}/server/${messaging.config.name}/deploy">
          <fileset dir="${jboss.home}/server/${messaging.config.source}/deploy/jms" includes="jms-ds.xml,hajndi-jms-ds.xml"/>
          <filterset begintoken="&quot;" endtoken="&quot;">
             <filter token="jboss.mq:service=JMSProviderLoader,name=JMSProvider" value="&quot;jboss.messaging:service=JMSProviderLoader,name=JMSProvider&quot;"/>
             <filter token="jboss.mq:service=ServerSessionPoolMBean,name=StdJMSPool" value="&quot;jboss.messaging:service=ServerSessionPoolMBean,name=StdJMSPool&quot;"/>
          </filterset>
-      </copy>
-
+      </copy>-->
+      <echo message="Removing old JBoss Messaging deployment ${jboss.home}/server/deploy/${messaging.config.name}/messaging"/>
+      <delete dir="${jboss.home}/server/${messaging.config.name}/deploy/messaging"/>
    </target>
 
 




More information about the jboss-cvs-commits mailing list