[jboss-cvs] JBossAS SVN: r94557 - in projects/mc-int/trunk: common and 15 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Oct 9 05:05:32 EDT 2009


Author: alesj
Date: 2009-10-09 05:05:31 -0400 (Fri, 09 Oct 2009)
New Revision: 94557

Added:
   projects/mc-int/trunk/common/
   projects/mc-int/trunk/common/pom.xml
   projects/mc-int/trunk/common/src/
   projects/mc-int/trunk/common/src/main/
   projects/mc-int/trunk/common/src/main/java/
   projects/mc-int/trunk/common/src/main/java/org/
   projects/mc-int/trunk/common/src/main/java/org/jboss/
   projects/mc-int/trunk/common/src/main/java/org/jboss/mc/
   projects/mc-int/trunk/common/src/main/java/org/jboss/mc/common/
   projects/mc-int/trunk/common/src/main/java/org/jboss/mc/common/ThreadLocalUtils.java
   projects/mc-int/trunk/common/src/test/
   projects/mc-int/trunk/common/src/test/java/
   projects/mc-int/trunk/common/src/test/java/org/
   projects/mc-int/trunk/common/src/test/java/org/jboss/
   projects/mc-int/trunk/common/src/test/java/org/jboss/mc/
   projects/mc-int/trunk/common/src/test/java/org/jboss/mc/common/
   projects/mc-int/trunk/common/src/test/java/org/jboss/mc/common/CommonTestSuite.java
   projects/mc-int/trunk/common/src/test/java/org/jboss/mc/common/test/
   projects/mc-int/trunk/common/src/test/java/org/jboss/mc/common/test/ThreadLocalUtilsTestCase.java
Modified:
   projects/mc-int/trunk/pom.xml
   projects/mc-int/trunk/servlet/pom.xml
Log:
Add simple common int MC stuff.

Added: projects/mc-int/trunk/common/pom.xml
===================================================================
--- projects/mc-int/trunk/common/pom.xml	                        (rev 0)
+++ projects/mc-int/trunk/common/pom.xml	2009-10-09 09:05:31 UTC (rev 94557)
@@ -0,0 +1,81 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <parent>
+    <groupId>org.jboss.mc-int</groupId>
+    <artifactId>jboss-mc-int-parent</artifactId>
+    <version>2.2.0-SNAPSHOT</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.jboss.mc-int</groupId>
+  <artifactId>jboss-mc-int-common</artifactId>
+  <packaging>jar</packaging>
+  <name>JBoss MC Integration - Common</name>
+  <url>http://www.jboss.org/jbossmc</url>
+  <description>JBoss MC Integration - Common</description>
+
+  <dependencies>
+    <!-- Compile (global dependencies) -->
+    <dependency>
+      <groupId>org.jboss.deployers</groupId>
+      <artifactId>jboss-deployers-vfs-spi</artifactId>
+      <exclusions>
+        <exclusion>
+          <groupId>jboss</groupId>
+          <artifactId>jboss-vfs</artifactId>
+        </exclusion>
+      </exclusions>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss</groupId>
+      <artifactId>jboss-vfs</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss</groupId>
+      <artifactId>jboss-common-core</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.logging</groupId>
+      <artifactId>jboss-logging-spi</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.microcontainer</groupId>
+      <artifactId>jboss-dependency</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.deployers</groupId>
+      <artifactId>jboss-deployers-spi</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.deployers</groupId>
+      <artifactId>jboss-deployers-structure-spi</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.deployers</groupId>
+      <artifactId>jboss-deployers-vfs</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.deployers</groupId>
+      <artifactId>jboss-deployers-core-spi</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.microcontainer</groupId>
+      <artifactId>jboss-kernel</artifactId>
+    </dependency>
+    <!-- test dependencies -->
+    <dependency>
+      <groupId>org.jboss</groupId>
+      <artifactId>jboss-test</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.logging</groupId>
+      <artifactId>jboss-logging-log4j</artifactId>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+</project>
\ No newline at end of file

Added: projects/mc-int/trunk/common/src/main/java/org/jboss/mc/common/ThreadLocalUtils.java
===================================================================
--- projects/mc-int/trunk/common/src/main/java/org/jboss/mc/common/ThreadLocalUtils.java	                        (rev 0)
+++ projects/mc-int/trunk/common/src/main/java/org/jboss/mc/common/ThreadLocalUtils.java	2009-10-09 09:05:31 UTC (rev 94557)
@@ -0,0 +1,143 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.mc.common;
+
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.kernel.Kernel;
+import org.jboss.kernel.spi.dependency.KernelController;
+
+/**
+ * Simple MC thread local helper.
+ * 
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class ThreadLocalUtils
+{
+   private static ThreadLocal<Kernel> tlKernel = new ThreadLocal<Kernel>();
+   private static ThreadLocal<DeploymentUnit> tlDU = new ThreadLocal<DeploymentUnit>();
+
+   /**
+    * Put Kernel.
+    *
+    * @param kernel the kernel instance
+    */
+   public static void putKernel(Kernel kernel)
+   {
+      tlKernel.set(kernel);
+   }
+
+   /**
+    * Get Kernel.
+    *
+    * @return the kernel
+    */
+   public static Kernel getKernel()
+   {
+      return tlKernel.get();   
+   }
+
+   /**
+    * Remove the Kernel.
+    */
+   public static void removeKernel()
+   {
+      tlKernel.remove();
+   }
+
+   /**
+    * Get controller.
+    *
+    * @return the controller
+    */
+   public static KernelController getController()
+   {
+      Kernel kernel = getKernel();
+      return (kernel != null) ? kernel.getController() : null;
+   }
+
+   /**
+    * Put DeploymentUnit.
+    *
+    * @param unit the deployment unit
+    */
+   public static void putUnit(DeploymentUnit unit)
+   {
+      tlDU.set(unit);
+   }
+
+   /**
+    * Get DeploymentUnit.
+    *
+    * @return the deployment unit
+    */
+   public static DeploymentUnit getUnit()
+   {
+      return tlDU.get();
+   }
+
+   /**
+    * Remove DeploymentUnit.
+    */
+   public static void removeUnit()
+   {
+      tlDU.remove();
+   }
+
+   /**
+    * Get attachment.
+    *
+    * @param attachmentClass the attachment class
+    * @param <T> exact attachment type
+    * @return the attachment
+    */
+   public static <T> T getAttachment(Class<T> attachmentClass)
+   {
+      DeploymentUnit unit = getUnit();
+      return (unit != null) ? unit.getAttachment(attachmentClass) : null;
+   }
+
+   /**
+    * Get attachment.
+    *
+    * @param attachmentName the attachment name
+    * @return the attachment
+    */
+   public static Object getAttachment(String attachmentName)
+   {
+      DeploymentUnit unit = getUnit();
+      return (unit != null) ? unit.getAttachment(attachmentName) : null;
+   }
+
+   /**
+    * Get attachment.
+    *
+    * @param attachmentName the attachment name
+    * @param attachmentClass the attachment class
+    * @param <T> exact attachment type
+    * @return the attachment
+    */
+   public static <T> T getAttachment(String attachmentName, Class<T> attachmentClass)
+   {
+      DeploymentUnit unit = getUnit();
+      return (unit != null) ? unit.getAttachment(attachmentName, attachmentClass) : null;
+   }
+}

Added: projects/mc-int/trunk/common/src/test/java/org/jboss/mc/common/CommonTestSuite.java
===================================================================
--- projects/mc-int/trunk/common/src/test/java/org/jboss/mc/common/CommonTestSuite.java	                        (rev 0)
+++ projects/mc-int/trunk/common/src/test/java/org/jboss/mc/common/CommonTestSuite.java	2009-10-09 09:05:31 UTC (rev 94557)
@@ -0,0 +1,59 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.mc.common;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+import org.jboss.mc.common.test.ThreadLocalUtilsTestCase;
+
+/**
+ * Common test suite.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class CommonTestSuite extends TestSuite
+{
+   /**
+    * For running the testsuite from the command line
+    *
+    * @param args the command line args
+    */
+   public static void main(String[] args)
+   {
+      TestRunner.run(suite());
+   }
+
+   /**
+    * Create the testsuite
+    *
+    * @return the testsuite
+    */
+   public static Test suite()
+   {
+      TestSuite suite = new TestSuite("Common Tests");
+
+      suite.addTest(ThreadLocalUtilsTestCase.suite());
+
+      return suite;
+   }
+}

Added: projects/mc-int/trunk/common/src/test/java/org/jboss/mc/common/test/ThreadLocalUtilsTestCase.java
===================================================================
--- projects/mc-int/trunk/common/src/test/java/org/jboss/mc/common/test/ThreadLocalUtilsTestCase.java	                        (rev 0)
+++ projects/mc-int/trunk/common/src/test/java/org/jboss/mc/common/test/ThreadLocalUtilsTestCase.java	2009-10-09 09:05:31 UTC (rev 94557)
@@ -0,0 +1,72 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.mc.common.test;
+
+import junit.framework.Test;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.deployers.structure.spi.helpers.AbstractDeploymentUnit;
+import org.jboss.kernel.Kernel;
+import org.jboss.kernel.spi.metadata.KernelMetaDataRepository;
+import org.jboss.mc.common.ThreadLocalUtils;
+import org.jboss.test.kernel.junit.MicrocontainerTest;
+
+/**
+ * Simple thread local utils tests.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class ThreadLocalUtilsTestCase extends MicrocontainerTest
+{
+   public ThreadLocalUtilsTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static Test suite()
+   {
+      return suite(ThreadLocalUtilsTestCase.class);
+   }
+
+   public void testKernel() throws Exception
+   {
+      KernelMetaDataRepository repo = getMetaDataRepository();
+      Kernel kernel = repo.getKernel();
+      assertNotNull(kernel);
+
+      ThreadLocalUtils.putKernel(kernel);
+      assertSame(kernel, ThreadLocalUtils.getKernel());
+      assertNotNull(ThreadLocalUtils.getController());
+      ThreadLocalUtils.removeKernel();
+      assertNull(ThreadLocalUtils.getKernel());
+      assertNull(ThreadLocalUtils.getController());
+   }
+
+   public void testUnit() throws Exception
+   {
+      DeploymentUnit unit = new AbstractDeploymentUnit();
+
+      ThreadLocalUtils.putUnit(unit);
+      assertSame(unit, ThreadLocalUtils.getUnit());
+      ThreadLocalUtils.removeUnit();
+      assertNull(ThreadLocalUtils.getUnit());
+   }
+}

Modified: projects/mc-int/trunk/pom.xml
===================================================================
--- projects/mc-int/trunk/pom.xml	2009-10-09 08:57:56 UTC (rev 94556)
+++ projects/mc-int/trunk/pom.xml	2009-10-09 09:05:31 UTC (rev 94557)
@@ -19,25 +19,26 @@
   </scm>
 
   <modules>
+    <module>common</module>
     <module>servlet</module>
     <module>build</module>
   </modules>
   
   <properties>
-    <version.jboss.vfs>2.1.1.GA</version.jboss.vfs>
+    <version.jboss.vfs>2.1.3.SP1</version.jboss.vfs>
     <version.jboss.man>2.1.0.CR8</version.jboss.man>
     <version.jboss.mdr>2.0.1.GA</version.jboss.mdr>
-    <version.jboss.microcontainer>2.0.5.GA</version.jboss.microcontainer>
-    <version.jboss.classloader>2.0.5.GA</version.jboss.classloader>
-    <version.jboss.deployers>2.0.6.GA</version.jboss.deployers>
-    <version.jboss.common.core>2.2.13.GA</version.jboss.common.core>
+    <version.jboss.microcontainer>2.0.9.GA</version.jboss.microcontainer>
+    <version.jboss.classloader>2.0.7.CR1</version.jboss.classloader>
+    <version.jboss.deployers>2.0.8.GA</version.jboss.deployers>
+    <version.jboss.common.core>2.2.16.GA</version.jboss.common.core>
     <version.jboss.common.logging.spi>2.0.5.GA</version.jboss.common.logging.spi>
     <version.jboss.common.logging.log4j>2.0.5.GA</version.jboss.common.logging.log4j>
     <version.jbossxb>2.0.1.GA</version.jbossxb>
     <version.jboss.aop>2.0.1.GA</version.jboss.aop>
     <version.org.jboss.test>1.0.5.GA</version.org.jboss.test>
     <version.junit>4.4</version.junit>
-    <version.javassist>3.10.0.GA</version.javassist>
+    <version.javassist>3.11.0.GA</version.javassist>
     <version.xerces>2.9.1</version.xerces>
     <version.servlet.api>2.5</version.servlet.api>
   </properties>
@@ -141,6 +142,12 @@
 
       <dependency>
         <groupId>org.jboss.mc-int</groupId>
+        <artifactId>jboss-mc-int-common</artifactId>
+        <version>${project.version}</version>
+      </dependency>
+
+      <dependency>
+        <groupId>org.jboss.mc-int</groupId>
         <artifactId>jboss-mc-int-servlet</artifactId>
         <version>${project.version}</version>
       </dependency>

Modified: projects/mc-int/trunk/servlet/pom.xml
===================================================================
--- projects/mc-int/trunk/servlet/pom.xml	2009-10-09 08:57:56 UTC (rev 94556)
+++ projects/mc-int/trunk/servlet/pom.xml	2009-10-09 09:05:31 UTC (rev 94557)
@@ -14,6 +14,10 @@
 
   <dependencies>
     <!-- Compile (global dependencies) -->
+      <dependency>
+        <groupId>org.jboss.mc-int</groupId>
+        <artifactId>jboss-mc-int-common</artifactId>
+      </dependency>
     <dependency>
       <groupId>org.jboss.deployers</groupId>
       <artifactId>jboss-deployers-vfs-spi</artifactId>
@@ -41,10 +45,6 @@
       <artifactId>jboss-logging-spi</artifactId>
     </dependency>
     <dependency>
-      <groupId>org.jboss.logging</groupId>
-      <artifactId>jboss-logging-log4j</artifactId>
-    </dependency>
-    <dependency>
       <groupId>org.jboss.microcontainer</groupId>
       <artifactId>jboss-dependency</artifactId>
     </dependency>
@@ -83,6 +83,11 @@
       <artifactId>junit</artifactId>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>org.jboss.logging</groupId>
+      <artifactId>jboss-logging-log4j</artifactId>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 
 </project>
\ No newline at end of file




More information about the jboss-cvs-commits mailing list