[jboss-cvs] JBossAS SVN: r102126 - in branches/Branch_Hornet_Temporary_2/hornetq-int/src: resources and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Mar 9 07:00:59 EST 2010


Author: alesj
Date: 2010-03-09 07:00:59 -0500 (Tue, 09 Mar 2010)
New Revision: 102126

Added:
   branches/Branch_Hornet_Temporary_2/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/deployers/HornetQConfigMultiParserDeployer.java
Modified:
   branches/Branch_Hornet_Temporary_2/hornetq-int/src/resources/hornetq-deployers-jboss-beans.xml
Log:
Add fix to ordering problem + new multi parser deployer.

Added: branches/Branch_Hornet_Temporary_2/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/deployers/HornetQConfigMultiParserDeployer.java
===================================================================
--- branches/Branch_Hornet_Temporary_2/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/deployers/HornetQConfigMultiParserDeployer.java	                        (rev 0)
+++ branches/Branch_Hornet_Temporary_2/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/deployers/HornetQConfigMultiParserDeployer.java	2010-03-09 12:00:59 UTC (rev 102126)
@@ -0,0 +1,92 @@
+package org.jboss.as.integration.hornetq.deployers;
+
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.jboss.deployers.vfs.spi.deployer.MultipleVFSParsingDeployer;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.logging.Logger;
+import org.jboss.virtual.VirtualFile;
+
+import org.hornetq.core.config.Configuration;
+import org.hornetq.core.deployers.impl.FileConfigurationParser;
+
+/**
+ * This Deployer will take a hornetq-configuration.xml parse the Configuration
+ * and attach the Configuration output into the deployment unit. Another
+ * deployer that takes Configuration as an input will then take over and install
+ * the queues at the proper places.
+ *
+ * @author <mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ * @author <mailto:ales.justin at jboss.org">Ales Justin</a>
+ * @see org.jboss.as.integration.hornetq.deployers.HornetQJMSRealDeployer
+ */
+public class HornetQConfigMultiParserDeployer extends MultipleVFSParsingDeployer<Configuration>
+{
+   private static final Logger log = Logger.getLogger(HornetQConfigMultiParserDeployer.class);
+   private final FileConfigurationParser parser;
+
+   public HornetQConfigMultiParserDeployer(final Set<String> names)
+   {
+      super(Configuration.class, mappings(names));
+      this.parser = new FileConfigurationParser();
+      this.setNames(names);
+   }
+
+   protected static Map<String, Class<?>> mappings(Set<String> names)
+   {
+      if (names == null || names.isEmpty())
+         throw new IllegalArgumentException("Null or empty names: " + names);
+
+      Map<String, Class<?>> mappings = new HashMap<String, Class<?>>(names.size());
+      for (String name : names)
+      {
+         mappings.put(name, Configuration.class); // all are mapped to Configuration
+      }
+      return mappings;
+   }
+
+   @Override
+   @SuppressWarnings("unchecked")
+   protected Object parse(Class expectedType, VirtualFile file, Object root) throws Exception
+   {
+      InputStream deploymentStream = openStreamAndValidate(file);
+      try
+      {
+         Configuration config = parser.parseMainConfig(deploymentStream);
+         log.debug("Main Config = " + config);
+         return config;
+      }
+      finally
+      {
+         try
+         {
+            deploymentStream.close();
+         }
+         catch (Exception ignored)
+         {
+         }
+      }
+   }
+
+   @Override
+   protected Configuration mergeMetaData(VFSDeploymentUnit unit, Map<Class<?>, List<Object>> metadata) throws Exception
+   {
+      List<Object> instances = metadata.get(Configuration.class); // we should only have Configuration instances
+      if (instances.size() == 1)
+      {
+         return (Configuration) instances.get(0);
+      }
+      else
+      {
+         for (int i = 0; i < instances.size(); i++)
+         {
+            unit.getTransientManagedObjects().addAttachment(Configuration.class.getName() + "#" + i, instances.get(i));
+         }
+         return null;
+      }
+   }
+}
\ No newline at end of file

Modified: branches/Branch_Hornet_Temporary_2/hornetq-int/src/resources/hornetq-deployers-jboss-beans.xml
===================================================================
--- branches/Branch_Hornet_Temporary_2/hornetq-int/src/resources/hornetq-deployers-jboss-beans.xml	2010-03-09 11:47:59 UTC (rev 102125)
+++ branches/Branch_Hornet_Temporary_2/hornetq-int/src/resources/hornetq-deployers-jboss-beans.xml	2010-03-09 12:00:59 UTC (rev 102126)
@@ -41,6 +41,7 @@
 
 	<bean name="HornetQManagedObjectCreator" class="org.jboss.as.integration.hornetq.management.HornetQManagedObjectCreator">
 		<constructor><parameter><inject bean="ManagedObjectFactory" /></parameter></constructor>
+        <demand>HornetQDestinationCreator</demand>
 	</bean>
 
 </deployment>
\ No newline at end of file




More information about the jboss-cvs-commits mailing list