[jboss-svn-commits] JBoss Common SVN: r3619 - in tmpdpl/trunk: api and 33 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Wed Oct 21 13:40:45 EDT 2009


Author: ALRubinger
Date: 2009-10-21 13:40:45 -0400 (Wed, 21 Oct 2009)
New Revision: 3619

Added:
   tmpdpl/trunk/api-shrinkwrap/
   tmpdpl/trunk/api-shrinkwrap/pom.xml
   tmpdpl/trunk/api-shrinkwrap/src/
   tmpdpl/trunk/api-shrinkwrap/src/main/
   tmpdpl/trunk/api-shrinkwrap/src/main/java/
   tmpdpl/trunk/api-shrinkwrap/src/main/java/org/
   tmpdpl/trunk/api-shrinkwrap/src/main/java/org/jboss/
   tmpdpl/trunk/api-shrinkwrap/src/main/java/org/jboss/tmpdpl/
   tmpdpl/trunk/api-shrinkwrap/src/main/java/org/jboss/tmpdpl/api/
   tmpdpl/trunk/api-shrinkwrap/src/main/java/org/jboss/tmpdpl/api/shrinkwrap/
   tmpdpl/trunk/api-shrinkwrap/src/main/java/org/jboss/tmpdpl/api/shrinkwrap/container/
   tmpdpl/trunk/api-shrinkwrap/src/main/java/org/jboss/tmpdpl/api/shrinkwrap/container/ArchiveContainer.java
   tmpdpl/trunk/api-shrinkwrap/src/main/java/org/jboss/tmpdpl/api/shrinkwrap/container/deployable/
   tmpdpl/trunk/api-shrinkwrap/src/main/java/org/jboss/tmpdpl/api/shrinkwrap/container/deployable/DeployableArchiveFactory.java
   tmpdpl/trunk/api-shrinkwrap/src/main/java/org/jboss/tmpdpl/api/shrinkwrap/container/deployable/SecurityActions.java
   tmpdpl/trunk/impl-shrinkwrap/
   tmpdpl/trunk/impl-shrinkwrap/pom.xml
   tmpdpl/trunk/impl-shrinkwrap/src/
   tmpdpl/trunk/impl-shrinkwrap/src/main/
   tmpdpl/trunk/impl-shrinkwrap/src/main/java/
   tmpdpl/trunk/impl-shrinkwrap/src/main/java/org/
   tmpdpl/trunk/impl-shrinkwrap/src/main/java/org/jboss/
   tmpdpl/trunk/impl-shrinkwrap/src/main/java/org/jboss/tmpdpl/
   tmpdpl/trunk/impl-shrinkwrap/src/main/java/org/jboss/tmpdpl/impl/
   tmpdpl/trunk/impl-shrinkwrap/src/main/java/org/jboss/tmpdpl/impl/shrinkwrap/
   tmpdpl/trunk/impl-shrinkwrap/src/main/java/org/jboss/tmpdpl/impl/shrinkwrap/deployable/
   tmpdpl/trunk/impl-shrinkwrap/src/main/java/org/jboss/tmpdpl/impl/shrinkwrap/deployable/DeployableArchiveFactoryVfsVdfImpl.java
   tmpdpl/trunk/impl-shrinkwrap/src/test/
   tmpdpl/trunk/impl-shrinkwrap/src/test/java/
   tmpdpl/trunk/impl-shrinkwrap/src/test/java/org/
   tmpdpl/trunk/impl-shrinkwrap/src/test/java/org/jboss/
   tmpdpl/trunk/impl-shrinkwrap/src/test/java/org/jboss/tmpdpl/
   tmpdpl/trunk/impl-shrinkwrap/src/test/java/org/jboss/tmpdpl/impl/
   tmpdpl/trunk/impl-shrinkwrap/src/test/java/org/jboss/tmpdpl/impl/shrinkwrap/
   tmpdpl/trunk/impl-shrinkwrap/src/test/java/org/jboss/tmpdpl/impl/shrinkwrap/DeployableArchiveFactoryTestCase.java
Removed:
   tmpdpl/trunk/api/src/main/java/org/jboss/tmpdpl/api/deployable/SecurityActions.java
   tmpdpl/trunk/api/src/main/java/org/jboss/tmpdpl/api/deployable/VfsVdfDeployableFactory.java
Modified:
   tmpdpl/trunk/api/pom.xml
   tmpdpl/trunk/api/src/main/java/org/jboss/tmpdpl/api/container/Container.java
   tmpdpl/trunk/api/src/main/java/org/jboss/tmpdpl/api/deployable/Deployable.java
   tmpdpl/trunk/impl-vdf/pom.xml
   tmpdpl/trunk/impl-vdf/src/main/java/org/jboss/tmpdpl/impl/vdf/VfsVdfDeployableImpl.java
   tmpdpl/trunk/impl-vdf/src/test/java/org/jboss/tmpdpl/impl/vdf/VfsVdfDeployableImplTestCase.java
   tmpdpl/trunk/pom.xml
Log:
[TMPDPL-8] Decouple ShrinkWrap dependency from TMPDPL proper; add integration components

Modified: tmpdpl/trunk/api/pom.xml
===================================================================
--- tmpdpl/trunk/api/pom.xml	2009-10-19 20:58:52 UTC (rev 3618)
+++ tmpdpl/trunk/api/pom.xml	2009-10-21 17:40:45 UTC (rev 3619)
@@ -32,11 +32,6 @@
   <!-- Dependencies -->
   <dependencies>
   
-      <dependency>
-        <groupId>org.jboss.shrinkwrap</groupId>
-        <artifactId>shrinkwrap-api</artifactId>
-      </dependency>
-
   </dependencies>
 </project>
 

Modified: tmpdpl/trunk/api/src/main/java/org/jboss/tmpdpl/api/container/Container.java
===================================================================
--- tmpdpl/trunk/api/src/main/java/org/jboss/tmpdpl/api/container/Container.java	2009-10-19 20:58:52 UTC (rev 3618)
+++ tmpdpl/trunk/api/src/main/java/org/jboss/tmpdpl/api/container/Container.java	2009-10-21 17:40:45 UTC (rev 3619)
@@ -16,7 +16,6 @@
  */
 package org.jboss.tmpdpl.api.container;
 
-import org.jboss.shrinkwrap.api.Archive;
 import org.jboss.tmpdpl.api.deployable.Deployable;
 
 /**
@@ -44,16 +43,6 @@
    void deploy(Deployable... deployables) throws DeploymentException, IllegalArgumentException;
 
    /**
-    * Deploys the specified archives into the server as one atomic operation. 
-    * 
-    * @param archives
-    * @throws DeploymentException
-    * @throws IllegalArgumentException If no archives were specified or the type of archive
-    * is not supported by this server
-    */
-   void deploy(Archive<?>... archives) throws DeploymentException, IllegalArgumentException;
-
-   /**
     * Undeploys the specified deployables from the server as one atomic operation.
     * The deployables must have been previously deployed.
     * 
@@ -63,15 +52,4 @@
     * is not supported by this server
     */
    void undeploy(Deployable... deployables) throws DeploymentException, IllegalArgumentException;
-
-   /**
-    * Undeploys the specified archives from the server as one atomic operation.
-    * The archives must have been previously deployed.
-    * 
-    * @param archives
-    * @throws DeploymentException
-    * @throws IllegalArgumentException If no archives were specified or the type of archive
-    * is not supported by this server
-    */
-   void undeploy(Archive<?>... archives) throws DeploymentException, IllegalArgumentException;
 }

Modified: tmpdpl/trunk/api/src/main/java/org/jboss/tmpdpl/api/deployable/Deployable.java
===================================================================
--- tmpdpl/trunk/api/src/main/java/org/jboss/tmpdpl/api/deployable/Deployable.java	2009-10-19 20:58:52 UTC (rev 3618)
+++ tmpdpl/trunk/api/src/main/java/org/jboss/tmpdpl/api/deployable/Deployable.java	2009-10-21 17:40:45 UTC (rev 3619)
@@ -16,13 +16,15 @@
  */
 package org.jboss.tmpdpl.api.deployable;
 
+import java.awt.Container;
+
 /**
  * Deployable
  * 
- * Represents an entity which is eligible for deployment into an
- * Embedded Server.
+ * Represents an entity which is eligible for deployment into a
+ * {@link Container}.
  * 
- * In practice, this is a marker interface, where an embedded server may 
+ * In practice, this is a marker interface, where an Container may 
  * support a finite set of the children of this type.
  *
  * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>

Deleted: tmpdpl/trunk/api/src/main/java/org/jboss/tmpdpl/api/deployable/SecurityActions.java
===================================================================
--- tmpdpl/trunk/api/src/main/java/org/jboss/tmpdpl/api/deployable/SecurityActions.java	2009-10-19 20:58:52 UTC (rev 3618)
+++ tmpdpl/trunk/api/src/main/java/org/jboss/tmpdpl/api/deployable/SecurityActions.java	2009-10-21 17:40:45 UTC (rev 3619)
@@ -1,124 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jboss.tmpdpl.api.deployable;
-
-import java.lang.reflect.Constructor;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
-
-/**
- * SecurityActions
- * 
- * A set of privileged actions that are not to leak out
- * of this package 
- *
- * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
- * @version $Revision: $
- */
-class SecurityActions
-{
-
-   //-------------------------------------------------------------------------------||
-   // Constructor ------------------------------------------------------------------||
-   //-------------------------------------------------------------------------------||
-
-   /**
-    * No external instantiation
-    */
-   private SecurityActions()
-   {
-
-   }
-
-   //-------------------------------------------------------------------------------||
-   // Utility Methods --------------------------------------------------------------||
-   //-------------------------------------------------------------------------------||
-
-   /**
-    * Obtains the Thread Context ClassLoader
-    */
-   static ClassLoader getThreadContextClassLoader()
-   {
-      return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>()
-      {
-         public ClassLoader run()
-         {
-            return Thread.currentThread().getContextClassLoader();
-         }
-      });
-   }
-
-   /**
-    * Obtains the constructor for the specified class with the specified param types
-    * according to the contract of {@link Class#getConstructor(Class...)}
-    * 
-    * @param clazz
-    * @param paramTypes
-    * @return
-    * @throws NoSuchMethodException
-    * @throws SecurityException
-    * @throws IllegalArgumentException If the class or param types were not specified
-    */
-   static Constructor<?> getConstructor(final Class<?> clazz, final Class<?>... paramTypes)
-         throws NoSuchMethodException, SecurityException, IllegalArgumentException
-   {
-      // Precondition checks
-      if (clazz == null)
-      {
-         throw new IllegalArgumentException("class must be specified");
-      }
-      if (paramTypes == null)
-      {
-         throw new IllegalArgumentException("param types must be specified");
-      }
-
-      try
-      {
-         return AccessController.doPrivileged(new PrivilegedExceptionAction<Constructor<?>>()
-         {
-
-            @Override
-            public Constructor<?> run() throws Exception
-            {
-               return clazz.getConstructor(paramTypes);
-            }
-         });
-      }
-      catch (final PrivilegedActionException pae)
-      {
-         // Throw nsme and se
-         final Throwable unwrapped = pae.getCause();
-         if (unwrapped instanceof NoSuchMethodException)
-         {
-            final NoSuchMethodException nsme = (NoSuchMethodException) unwrapped;
-            throw nsme;
-         }
-         if (unwrapped instanceof SecurityException)
-         {
-            final SecurityException se = (SecurityException) unwrapped;
-            throw se;
-         }
-
-         // Throw the cause as encountered
-         throw new RuntimeException("Error in obtaining constructor", unwrapped);
-
-      }
-   }
-
-}

Deleted: tmpdpl/trunk/api/src/main/java/org/jboss/tmpdpl/api/deployable/VfsVdfDeployableFactory.java
===================================================================
--- tmpdpl/trunk/api/src/main/java/org/jboss/tmpdpl/api/deployable/VfsVdfDeployableFactory.java	2009-10-19 20:58:52 UTC (rev 3618)
+++ tmpdpl/trunk/api/src/main/java/org/jboss/tmpdpl/api/deployable/VfsVdfDeployableFactory.java	2009-10-21 17:40:45 UTC (rev 3619)
@@ -1,183 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jboss.tmpdpl.api.deployable;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import org.jboss.shrinkwrap.api.Archive;
-
-/**
- * VfsVdfDeployableFactory
- * 
- * Factory to create {@link Deployable} instances from 
- * {@link Archive}s.  This removes the API
- * dependency upon internals for the client view and additionally
- * acts as a convenience mechanism.
- *
- * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
- * @version $Revision: $
- */
-public class VfsVdfDeployableFactory
-{
-
-   //-------------------------------------------------------------------------------------||
-   // Class Members ----------------------------------------------------------------------||
-   //-------------------------------------------------------------------------------------||
-
-   /**
-    * Logger
-    */
-   private static final Logger log = Logger.getLogger(VfsVdfDeployableFactory.class.getName());
-
-   /**
-    * FQN of implementation Class used in creating new Deployables 
-    */
-   private static final String CLASS_NAME_VFS_VDF_DEPLOYABLE = "org.jboss.tmpdpl.impl.vdf.VfsVdfDeployableImpl";
-
-   /**
-    * FQN of the archive type actually supported by {@link VfsVdfDeployableFactory#createDeployable(VirtualArchive)}
-    */
-   private static final String CLASS_NAME_ARCHIVE_TYPE = "org.jboss.shrinkwrap.api.Archive";
-
-   /**
-    * Name of the method used for creation
-    */
-   private static final String METHOD_NAME_CREATE = "create";
-
-   /**
-    * Method used in creating new {@link Deployable} instances
-    */
-   private static Method method;
-
-   //-------------------------------------------------------------------------------------||
-   // Constructor ------------------------------------------------------------------------||
-   //-------------------------------------------------------------------------------------||
-
-   /**
-    * Internal Constructor to prohibit external
-    * instantiation
-    */
-   private VfsVdfDeployableFactory()
-   {
-   }
-
-   //-------------------------------------------------------------------------------------||
-   // Functional Methods -----------------------------------------------------------------||
-   //-------------------------------------------------------------------------------------||
-
-   /**
-    * Creates a {@link Deployable} from the specified archive
-    * 
-    * @param archive
-    * @throws IllegalArgumentException If the archive is not specified 
-    */
-   public static Deployable createDeployable(final Archive<?> archive) throws IllegalArgumentException
-   {
-      // Precondition check
-      if (archive == null)
-      {
-         throw new IllegalArgumentException("Archive must be specified");
-      }
-
-      final Object obj;
-      try
-      {
-         obj = getMethod().invoke(null, archive);
-         if (log.isLoggable(Level.FINER))
-         {
-            log.log(Level.FINER, "Created: " + obj);
-         }
-      }
-      catch (final IllegalAccessException iae)
-      {
-         throw new RuntimeException("Could not invoke static method: " + method, iae);
-      }
-      catch (final InvocationTargetException ite)
-      {
-         throw new RuntimeException("Could not invoke static method: " + method, ite);
-      }
-
-      // Cast 
-      final Deployable deployable;
-      try
-      {
-         deployable = Deployable.class.cast(obj);
-      }
-      catch (final ClassCastException cce)
-      {
-         throw new RuntimeException("New instance should be of type " + Deployable.class.getName(), cce);
-      }
-
-      // Return
-      return deployable;
-   }
-
-   //-------------------------------------------------------------------------------------||
-   // Internal Helper Methods ------------------------------------------------------------||
-   //-------------------------------------------------------------------------------------||
-
-   /**
-    * Obtains the method used for creating new Deployable instances.
-    * Uses a cached copy unless not yet initialized.
-    */
-   private synchronized static Method getMethod()
-   {
-      // If we haven't yet cached the ctor
-      if (method == null)
-      {
-         // Get the static method
-         final Class<?> clazz = getClass(CLASS_NAME_VFS_VDF_DEPLOYABLE);
-         final Class<?> paramType = getClass(CLASS_NAME_ARCHIVE_TYPE);
-         try
-         {
-            method = clazz.getDeclaredMethod(METHOD_NAME_CREATE, paramType);
-         }
-         catch (final NoSuchMethodException nsme)
-         {
-            throw new RuntimeException("Could not obtain method \"" + METHOD_NAME_CREATE + " from " + clazz.getName(),
-                  nsme);
-         }
-
-      }
-
-      // Return
-      return method;
-   }
-
-   /**
-    * Obtains the class with the specified name from the TCCL
-    *  
-    * @param className
-    * @return
-    */
-   private static Class<?> getClass(final String className)
-   {
-      final ClassLoader cl = SecurityActions.getThreadContextClassLoader();
-      try
-      {
-         return Class.forName(className, false, cl);
-      }
-      catch (ClassNotFoundException cnfe)
-      {
-         throw new RuntimeException("Could not find implementation class \"" + className + "\" in " + cl, cnfe);
-      }
-   }
-
-}


Property changes on: tmpdpl/trunk/api-shrinkwrap
___________________________________________________________________
Name: svn:ignore
   + target
eclipse-target
target-eclipse
.settings
bin
.classpath
.project


Added: tmpdpl/trunk/api-shrinkwrap/pom.xml
===================================================================
--- tmpdpl/trunk/api-shrinkwrap/pom.xml	                        (rev 0)
+++ tmpdpl/trunk/api-shrinkwrap/pom.xml	2009-10-21 17:40:45 UTC (rev 3619)
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+  <!--
+  vi:ts=2:sw=2:expandtab:
+-->
+<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 -->
+  <parent>
+    <groupId>org.jboss.tmpdpl</groupId>
+    <artifactId>tmpdpl-build</artifactId>
+    <version>0.1.1-SNAPSHOT</version>
+    <relativePath>../build/pom.xml</relativePath>
+  </parent>
+
+  <!-- Model Version -->
+  <modelVersion>4.0.0</modelVersion>
+
+  <!-- Artifact Configuration -->
+  <artifactId>tmpdpl-api-shrinkwrap</artifactId>
+  <version>0.1.1-SNAPSHOT</version>
+  <name>TMPDPL ShrinkWrap Integration API</name>
+  <description>Client View of ShrinkWrap Integration for the TMPDPL Project</description>
+
+
+  <!-- Properties -->
+  <properties>
+
+    <!-- Versioning -->
+    <version.org.jboss.tmpdpl_tmpdpl.api>0.1.1-SNAPSHOT</version.org.jboss.tmpdpl_tmpdpl.api>
+
+  </properties>
+
+  <!-- Dependencies -->
+  <dependencies>
+  
+      <dependency>
+        <groupId>org.jboss.tmpdpl</groupId>
+        <artifactId>tmpdpl-api</artifactId>
+        <version>${version.org.jboss.tmpdpl_tmpdpl.api}</version>
+      </dependency>
+
+      <dependency>
+        <groupId>org.jboss.shrinkwrap</groupId>
+        <artifactId>shrinkwrap-api</artifactId>
+      </dependency>
+
+  </dependencies>
+</project>
+

Added: tmpdpl/trunk/api-shrinkwrap/src/main/java/org/jboss/tmpdpl/api/shrinkwrap/container/ArchiveContainer.java
===================================================================
--- tmpdpl/trunk/api-shrinkwrap/src/main/java/org/jboss/tmpdpl/api/shrinkwrap/container/ArchiveContainer.java	                        (rev 0)
+++ tmpdpl/trunk/api-shrinkwrap/src/main/java/org/jboss/tmpdpl/api/shrinkwrap/container/ArchiveContainer.java	2009-10-21 17:40:45 UTC (rev 3619)
@@ -0,0 +1,56 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.tmpdpl.api.shrinkwrap.container;
+
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.tmpdpl.api.container.DeploymentException;
+
+/**
+ * ArchiveContainer
+ * 
+ * An entity capable of deploying/undeploying {@link Archive} types
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public interface ArchiveContainer
+{
+   //-------------------------------------------------------------------------------||
+   // Contracts --------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------||
+
+   /**
+    * Deploys the specified archives into the server as one atomic operation. 
+    * 
+    * @param archives
+    * @throws DeploymentException
+    * @throws IllegalArgumentException If no archives were specified or the type of archive
+    * is not supported by this server
+    */
+   void deploy(Archive<?>... archives) throws DeploymentException, IllegalArgumentException;
+
+   /**
+    * Undeploys the specified archives from the server as one atomic operation.
+    * The archives must have been previously deployed.
+    * 
+    * @param archives
+    * @throws DeploymentException
+    * @throws IllegalArgumentException If no archives were specified or the type of archive
+    * is not supported by this server
+    */
+   void undeploy(Archive<?>... archives) throws DeploymentException, IllegalArgumentException;
+}

Copied: tmpdpl/trunk/api-shrinkwrap/src/main/java/org/jboss/tmpdpl/api/shrinkwrap/container/deployable/DeployableArchiveFactory.java (from rev 3574, tmpdpl/trunk/api/src/main/java/org/jboss/tmpdpl/api/deployable/VfsVdfDeployableFactory.java)
===================================================================
--- tmpdpl/trunk/api-shrinkwrap/src/main/java/org/jboss/tmpdpl/api/shrinkwrap/container/deployable/DeployableArchiveFactory.java	                        (rev 0)
+++ tmpdpl/trunk/api-shrinkwrap/src/main/java/org/jboss/tmpdpl/api/shrinkwrap/container/deployable/DeployableArchiveFactory.java	2009-10-21 17:40:45 UTC (rev 3619)
@@ -0,0 +1,184 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.tmpdpl.api.shrinkwrap.container.deployable;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.tmpdpl.api.deployable.Deployable;
+
+/**
+ * DeployableArchiveFactory
+ * 
+ * Factory to create {@link Deployable} instances from 
+ * {@link Archive}s.  This removes the API
+ * dependency upon internals for the client view and additionally
+ * acts as a convenience mechanism.
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class DeployableArchiveFactory
+{
+
+   //-------------------------------------------------------------------------------------||
+   // Class Members ----------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   /**
+    * Logger
+    */
+   private static final Logger log = Logger.getLogger(DeployableArchiveFactory.class.getName());
+
+   /**
+    * FQN of implementation Class used in creating new Deployables 
+    */
+   private static final String CLASS_NAME_VFS_VDF_DEPLOYABLE = "org.jboss.tmpdpl.impl.shrinkwrap.deployable.DeployableArchiveFactoryVfsVdfImpl";
+
+   /**
+    * FQN of the archive type actually supported by {@link DeployableArchiveFactory#createDeployable(VirtualArchive)}
+    */
+   private static final String CLASS_NAME_ARCHIVE_TYPE = "org.jboss.shrinkwrap.api.Archive";
+
+   /**
+    * Name of the method used for creation
+    */
+   private static final String METHOD_NAME_CREATE = "create";
+
+   /**
+    * Method used in creating new {@link Deployable} instances
+    */
+   private static Method method;
+
+   //-------------------------------------------------------------------------------------||
+   // Constructor ------------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   /**
+    * Internal Constructor to prohibit external
+    * instantiation
+    */
+   private DeployableArchiveFactory()
+   {
+   }
+
+   //-------------------------------------------------------------------------------------||
+   // Functional Methods -----------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   /**
+    * Creates a {@link Deployable} from the specified archive
+    * 
+    * @param archive
+    * @throws IllegalArgumentException If the archive is not specified 
+    */
+   public static Deployable createDeployable(final Archive<?> archive) throws IllegalArgumentException
+   {
+      // Precondition check
+      if (archive == null)
+      {
+         throw new IllegalArgumentException("Archive must be specified");
+      }
+
+      final Object obj;
+      try
+      {
+         obj = getMethod().invoke(null, archive);
+         if (log.isLoggable(Level.FINER))
+         {
+            log.log(Level.FINER, "Created: " + obj);
+         }
+      }
+      catch (final IllegalAccessException iae)
+      {
+         throw new RuntimeException("Could not invoke static method: " + method, iae);
+      }
+      catch (final InvocationTargetException ite)
+      {
+         throw new RuntimeException("Could not invoke static method: " + method, ite);
+      }
+
+      // Cast 
+      final Deployable deployable;
+      try
+      {
+         deployable = Deployable.class.cast(obj);
+      }
+      catch (final ClassCastException cce)
+      {
+         throw new RuntimeException("New instance should be of type " + Deployable.class.getName(), cce);
+      }
+
+      // Return
+      return deployable;
+   }
+
+   //-------------------------------------------------------------------------------------||
+   // Internal Helper Methods ------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   /**
+    * Obtains the method used for creating new Deployable instances.
+    * Uses a cached copy unless not yet initialized.
+    */
+   private synchronized static Method getMethod()
+   {
+      // If we haven't yet cached the ctor
+      if (method == null)
+      {
+         // Get the static method
+         final Class<?> clazz = getClass(CLASS_NAME_VFS_VDF_DEPLOYABLE);
+         final Class<?> paramType = getClass(CLASS_NAME_ARCHIVE_TYPE);
+         try
+         {
+            method = clazz.getDeclaredMethod(METHOD_NAME_CREATE, paramType);
+         }
+         catch (final NoSuchMethodException nsme)
+         {
+            throw new RuntimeException("Could not obtain method \"" + METHOD_NAME_CREATE + " from " + clazz.getName(),
+                  nsme);
+         }
+
+      }
+
+      // Return
+      return method;
+   }
+
+   /**
+    * Obtains the class with the specified name from the TCCL
+    *  
+    * @param className
+    * @return
+    */
+   private static Class<?> getClass(final String className)
+   {
+      final ClassLoader cl = SecurityActions.getThreadContextClassLoader();
+      try
+      {
+         return Class.forName(className, false, cl);
+      }
+      catch (ClassNotFoundException cnfe)
+      {
+         throw new RuntimeException("Could not find implementation class \"" + className + "\" in " + cl, cnfe);
+      }
+   }
+
+}

Copied: tmpdpl/trunk/api-shrinkwrap/src/main/java/org/jboss/tmpdpl/api/shrinkwrap/container/deployable/SecurityActions.java (from rev 3618, tmpdpl/trunk/api/src/main/java/org/jboss/tmpdpl/api/deployable/SecurityActions.java)
===================================================================
--- tmpdpl/trunk/api-shrinkwrap/src/main/java/org/jboss/tmpdpl/api/shrinkwrap/container/deployable/SecurityActions.java	                        (rev 0)
+++ tmpdpl/trunk/api-shrinkwrap/src/main/java/org/jboss/tmpdpl/api/shrinkwrap/container/deployable/SecurityActions.java	2009-10-21 17:40:45 UTC (rev 3619)
@@ -0,0 +1,124 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.tmpdpl.api.shrinkwrap.container.deployable;
+
+import java.lang.reflect.Constructor;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+
+/**
+ * SecurityActions
+ * 
+ * A set of privileged actions that are not to leak out
+ * of this package 
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+class SecurityActions
+{
+
+   //-------------------------------------------------------------------------------||
+   // Constructor ------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------||
+
+   /**
+    * No external instantiation
+    */
+   private SecurityActions()
+   {
+
+   }
+
+   //-------------------------------------------------------------------------------||
+   // Utility Methods --------------------------------------------------------------||
+   //-------------------------------------------------------------------------------||
+
+   /**
+    * Obtains the Thread Context ClassLoader
+    */
+   static ClassLoader getThreadContextClassLoader()
+   {
+      return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>()
+      {
+         public ClassLoader run()
+         {
+            return Thread.currentThread().getContextClassLoader();
+         }
+      });
+   }
+
+   /**
+    * Obtains the constructor for the specified class with the specified param types
+    * according to the contract of {@link Class#getConstructor(Class...)}
+    * 
+    * @param clazz
+    * @param paramTypes
+    * @return
+    * @throws NoSuchMethodException
+    * @throws SecurityException
+    * @throws IllegalArgumentException If the class or param types were not specified
+    */
+   static Constructor<?> getConstructor(final Class<?> clazz, final Class<?>... paramTypes)
+         throws NoSuchMethodException, SecurityException, IllegalArgumentException
+   {
+      // Precondition checks
+      if (clazz == null)
+      {
+         throw new IllegalArgumentException("class must be specified");
+      }
+      if (paramTypes == null)
+      {
+         throw new IllegalArgumentException("param types must be specified");
+      }
+
+      try
+      {
+         return AccessController.doPrivileged(new PrivilegedExceptionAction<Constructor<?>>()
+         {
+
+            @Override
+            public Constructor<?> run() throws Exception
+            {
+               return clazz.getConstructor(paramTypes);
+            }
+         });
+      }
+      catch (final PrivilegedActionException pae)
+      {
+         // Throw nsme and se
+         final Throwable unwrapped = pae.getCause();
+         if (unwrapped instanceof NoSuchMethodException)
+         {
+            final NoSuchMethodException nsme = (NoSuchMethodException) unwrapped;
+            throw nsme;
+         }
+         if (unwrapped instanceof SecurityException)
+         {
+            final SecurityException se = (SecurityException) unwrapped;
+            throw se;
+         }
+
+         // Throw the cause as encountered
+         throw new RuntimeException("Error in obtaining constructor", unwrapped);
+
+      }
+   }
+
+}


Property changes on: tmpdpl/trunk/api-shrinkwrap/src/main/java/org/jboss/tmpdpl/api/shrinkwrap/container/deployable/SecurityActions.java
___________________________________________________________________
Name: svn:executable
   + *


Property changes on: tmpdpl/trunk/impl-shrinkwrap
___________________________________________________________________
Name: svn:ignore
   + target
eclipse-target
target-eclipse
.settings
bin
.classpath
.project


Added: tmpdpl/trunk/impl-shrinkwrap/pom.xml
===================================================================
--- tmpdpl/trunk/impl-shrinkwrap/pom.xml	                        (rev 0)
+++ tmpdpl/trunk/impl-shrinkwrap/pom.xml	2009-10-21 17:40:45 UTC (rev 3619)
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="UTF-8"?>
+  <!--
+  vi:ts=2:sw=2:expandtab:
+-->
+<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 -->
+  <parent>
+    <groupId>org.jboss.tmpdpl</groupId>
+    <artifactId>tmpdpl-build</artifactId>
+    <version>0.1.1-SNAPSHOT</version>
+    <relativePath>../build/pom.xml</relativePath>
+  </parent>
+
+  <!-- Model Version -->
+  <modelVersion>4.0.0</modelVersion>
+
+  <!-- Artifact Configuration -->
+  <artifactId>tmpdpl-impl-shrinkwrap</artifactId>
+  <version>0.1.1-SNAPSHOT</version>
+  <name>TMPDPL Implementations for ShrinkWrap Integration</name>
+  <description>TMPDPL Implementations for ShrinkWrap Integration</description>
+
+
+  <!-- Properties -->
+  <properties>
+
+    <!-- Versioning -->
+    <version.org.jboss.tmpdpl_tmpdpl.api.shrinkwrap>0.1.1-SNAPSHOT</version.org.jboss.tmpdpl_tmpdpl.api.shrinkwrap>
+    <version.org.jboss.tmpdpl_tmpdpl.impl.vdf>0.1.1-SNAPSHOT</version.org.jboss.tmpdpl_tmpdpl.impl.vdf>
+    <version.org.jboss.shrinkwrap_shrinkwrap.impl.base>1.0.0-alpha-1</version.org.jboss.shrinkwrap_shrinkwrap.impl.base>
+
+  </properties>
+
+  <!-- Dependencies -->
+  <dependencies>
+
+    <!-- 
+    org.jboss.tmpdpl
+    -->
+    <dependency>
+      <groupId>org.jboss.tmpdpl</groupId>
+      <artifactId>tmpdpl-api-shrinkwrap</artifactId>
+      <version>${version.org.jboss.tmpdpl_tmpdpl.api.shrinkwrap}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.tmpdpl</groupId>
+      <artifactId>tmpdpl-impl-vdf</artifactId>
+      <version>${version.org.jboss.tmpdpl_tmpdpl.impl.vdf}</version>
+    </dependency>
+
+    <!--
+    External Dependencies
+    -->
+    <dependency>
+      <groupId>org.jboss.shrinkwrap</groupId>
+      <artifactId>shrinkwrap-impl-base</artifactId>
+      <version>${version.org.jboss.shrinkwrap_shrinkwrap.impl.base}</version>
+    </dependency>
+
+    <!-- 
+    Test Dependencies
+    -->
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+    </dependency>    
+    <dependency>
+      <groupId>org.jboss.deployers</groupId>
+      <artifactId>jboss-deployers-vfs</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+  </dependencies>
+</project>
+

Added: tmpdpl/trunk/impl-shrinkwrap/src/main/java/org/jboss/tmpdpl/impl/shrinkwrap/deployable/DeployableArchiveFactoryVfsVdfImpl.java
===================================================================
--- tmpdpl/trunk/impl-shrinkwrap/src/main/java/org/jboss/tmpdpl/impl/shrinkwrap/deployable/DeployableArchiveFactoryVfsVdfImpl.java	                        (rev 0)
+++ tmpdpl/trunk/impl-shrinkwrap/src/main/java/org/jboss/tmpdpl/impl/shrinkwrap/deployable/DeployableArchiveFactoryVfsVdfImpl.java	2009-10-21 17:40:45 UTC (rev 3619)
@@ -0,0 +1,78 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.tmpdpl.impl.shrinkwrap.deployable;
+
+import java.io.InputStream;
+
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.export.ZipExporter;
+import org.jboss.tmpdpl.api.deployable.Deployable;
+import org.jboss.tmpdpl.impl.vdf.VfsVdfDeployableImpl;
+import org.jboss.tmpdpl.spi.vdf.VdfDeployable;
+
+/**
+ * DeployableArchiveFactoryImpl
+ * 
+ * Factory to create {@link Deployable} types from {@link Archive}s with
+ * direct dependence upon the VFS/VDF Implementation
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class DeployableArchiveFactoryVfsVdfImpl
+{
+   //-------------------------------------------------------------------------------------||
+   // Constructor ------------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   /**
+    * Internal Constructor; do not call
+    */
+   private DeployableArchiveFactoryVfsVdfImpl()
+   {
+      throw new UnsupportedOperationException("Should not be instantiated");
+   }
+
+   //-------------------------------------------------------------------------------------||
+   // Factory Methods --------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   /**
+   * Creates a new {@link VdfDeployable} from the specified archive
+   * 
+   * @throws IllegalArgumentException If the archive is not specified 
+   */
+   public static Deployable create(final Archive<?> archive) throws IllegalArgumentException
+   {
+      // Precondition check
+      if (archive == null)
+      {
+         throw new IllegalArgumentException("archive must be specified");
+      }
+
+      // Export to ZIP
+      final InputStream zipStream = ZipExporter.exportZip(archive);
+
+      // Create
+      final String name = archive.getName();
+      final VdfDeployable deployable = (VfsVdfDeployableImpl) VfsVdfDeployableImpl.create(name, zipStream);
+
+      // Return
+      return deployable;
+   }
+
+}

Added: tmpdpl/trunk/impl-shrinkwrap/src/test/java/org/jboss/tmpdpl/impl/shrinkwrap/DeployableArchiveFactoryTestCase.java
===================================================================
--- tmpdpl/trunk/impl-shrinkwrap/src/test/java/org/jboss/tmpdpl/impl/shrinkwrap/DeployableArchiveFactoryTestCase.java	                        (rev 0)
+++ tmpdpl/trunk/impl-shrinkwrap/src/test/java/org/jboss/tmpdpl/impl/shrinkwrap/DeployableArchiveFactoryTestCase.java	2009-10-21 17:40:45 UTC (rev 3619)
@@ -0,0 +1,90 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.tmpdpl.impl.shrinkwrap;
+
+import java.util.logging.Logger;
+
+import junit.framework.Assert;
+
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.jboss.shrinkwrap.api.spec.JavaArchiveFactory;
+import org.jboss.tmpdpl.api.deployable.Deployable;
+import org.jboss.tmpdpl.api.shrinkwrap.container.deployable.DeployableArchiveFactory;
+import org.jboss.virtual.VFS;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * DeployableArchiveFactoryTestCase
+ * 
+ * Test Cases to assert that the {@link DeployableArchiveFactory} is 
+ * working correctly
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class DeployableArchiveFactoryTestCase
+{
+
+   //-------------------------------------------------------------------------------------||
+   // Class Members ----------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   /**
+    * Logger
+    */
+   private static final Logger log = Logger.getLogger(DeployableArchiveFactoryTestCase.class.getName());
+
+   //-------------------------------------------------------------------------------------||
+   // Lifecycle --------------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   /**
+    * Initializes the virtual file system
+    */
+   @BeforeClass
+   public static void initVfs() throws Exception
+   {
+      // Init VFS
+      VFS.init();
+   }
+
+   //-------------------------------------------------------------------------------------||
+   // Tests ------------------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   /**
+    * Tests that using a {@link DeployableArchiveFactory} to create a deployable
+    * type results in a new instance backed by VFS/VDF
+    */
+   @Test
+   public void testDeployableArchiveFactory() throws Exception
+   {
+      // Log
+      log.info("testDeployableFactory");
+
+      // Make an archive
+      final JavaArchive archive = JavaArchiveFactory.create("test.jar");
+      archive.addClass(this.getClass());
+
+      // Make a Deployable
+      final Deployable deployable = DeployableArchiveFactory.createDeployable(archive);
+
+      // Ensure exists
+      Assert.assertNotNull("Deployable was not created/null", deployable);
+   }
+}

Modified: tmpdpl/trunk/impl-vdf/pom.xml
===================================================================
--- tmpdpl/trunk/impl-vdf/pom.xml	2009-10-19 20:58:52 UTC (rev 3618)
+++ tmpdpl/trunk/impl-vdf/pom.xml	2009-10-21 17:40:45 UTC (rev 3619)
@@ -27,7 +27,6 @@
 
     <!-- Versioning -->
     <version.org.jboss.tmpdpl_tmpdpl.spi.vdf>0.1.1-SNAPSHOT</version.org.jboss.tmpdpl_tmpdpl.spi.vdf>
-    <version.org.jboss.shrinkwrap_shrinkwrap.impl.base>1.0.0-alpha-1</version.org.jboss.shrinkwrap_shrinkwrap.impl.base>
 
   </properties>
 
@@ -59,12 +58,6 @@
       <artifactId>junit</artifactId>
     </dependency>
     <dependency>
-      <groupId>org.jboss.shrinkwrap</groupId>
-      <artifactId>shrinkwrap-impl-base</artifactId>
-      <version>${version.org.jboss.shrinkwrap_shrinkwrap.impl.base}</version>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
       <groupId>org.jboss.deployers</groupId>
       <artifactId>jboss-deployers-vfs</artifactId>
       <scope>test</scope>

Modified: tmpdpl/trunk/impl-vdf/src/main/java/org/jboss/tmpdpl/impl/vdf/VfsVdfDeployableImpl.java
===================================================================
--- tmpdpl/trunk/impl-vdf/src/main/java/org/jboss/tmpdpl/impl/vdf/VfsVdfDeployableImpl.java	2009-10-19 20:58:52 UTC (rev 3618)
+++ tmpdpl/trunk/impl-vdf/src/main/java/org/jboss/tmpdpl/impl/vdf/VfsVdfDeployableImpl.java	2009-10-21 17:40:45 UTC (rev 3619)
@@ -22,7 +22,6 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
-import java.lang.ref.SoftReference;
 import java.net.URI;
 import java.net.URL;
 import java.security.AccessController;
@@ -32,8 +31,6 @@
 
 import org.jboss.deployers.client.spi.Deployment;
 import org.jboss.deployers.vfs.spi.client.VFSDeploymentFactory;
-import org.jboss.shrinkwrap.api.Archive;
-import org.jboss.shrinkwrap.api.export.ZipExporter;
 import org.jboss.tmpdpl.spi.vdf.VdfDeployable;
 import org.jboss.virtual.VFS;
 import org.jboss.virtual.VirtualFile;
@@ -72,12 +69,6 @@
     */
    private Deployment deployment;
 
-   /**
-    * The possibly-null archive from which this Deployable was
-    * created.  Used in determining equals() comparison.
-    */
-   private SoftReference<Archive<?>> createdFromArchive;
-
    //-------------------------------------------------------------------------------------||
    // Constructor ------------------------------------------------------------------------||
    //-------------------------------------------------------------------------------------||
@@ -85,7 +76,7 @@
    /**
     * Internal Constructor
     */
-   private VfsVdfDeployableImpl(final Deployment deployment) throws IllegalArgumentException
+   protected VfsVdfDeployableImpl(final Deployment deployment) throws IllegalArgumentException
    {
       // Precondition check
       assert deployment != null : "Deployment must be specified";
@@ -99,33 +90,6 @@
    //-------------------------------------------------------------------------------------||
 
    /**
-    * Creates a new {@link VdfDeployable} from the specified archive
-    * 
-    * @throws IllegalArgumentException If the archive is not specified 
-    */
-   public static VdfDeployable create(final Archive<?> archive) throws IllegalArgumentException
-   {
-      // Precondition check
-      if (archive == null)
-      {
-         throw new IllegalArgumentException("archive must be specified");
-      }
-
-      // Export to ZIP
-      final InputStream zipStream = ZipExporter.exportZip(archive);
-
-      // Create
-      final String name = archive.getName();
-      VfsVdfDeployableImpl deployable = (VfsVdfDeployableImpl) create(name, zipStream);
-
-      // Set created from
-      deployable.setCreatedFromArchive(new SoftReference<Archive<?>>(archive));
-
-      // Return
-      return deployable;
-   }
-
-   /**
     * Creates a new {@link VdfDeployable} from the specified archive and name 
     * 
     * @param name The name to assign the deployment
@@ -317,12 +281,6 @@
       final int prime = 31;
       int result = 1;
 
-      // If we have been created from an archive, use the archive hashCode
-      if (createdFromArchive != null)
-      {
-         return prime * result + createdFromArchive.get().hashCode();
-      }
-
       // Use the deployment hash code
       result = prime * result + ((deployment == null) ? 0 : deployment.hashCode());
       return result;
@@ -345,22 +303,7 @@
          return false;
       final VfsVdfDeployableImpl other = (VfsVdfDeployableImpl) obj;
 
-      // Equal if the archives created from are equal
-      if (createdFromArchive != null)
-      {
-         final SoftReference<Archive<?>> otherCreatedFromArchive = other.getCreatedFromArchive();
-         if (otherCreatedFromArchive == null)
-         {
-            return false;
-         }
-         else
-         {
-            if (createdFromArchive.get().equals(otherCreatedFromArchive.get()))
-            {
-               return true;
-            }
-         }
-      }
+      // Equal if the underlying deployments are equal
       if (deployment == null)
       {
          if (other.deployment != null)
@@ -384,20 +327,20 @@
       this.deployment = deployment;
    }
 
-   /**
-    * @return the createdFromArchive
-    */
-   private SoftReference<Archive<?>> getCreatedFromArchive()
-   {
-      return createdFromArchive;
-   }
+   //   /**
+   //    * @return the createdFromArchive
+   //    */
+   //   private SoftReference<Archive<?>> getCreatedFromArchive()
+   //   {
+   //      return createdFromArchive;
+   //   }
+   //
+   //   /**
+   //    * @param createdFromArchive the createdFromArchive to set
+   //    */
+   //   private void setCreatedFromArchive(SoftReference<Archive<?>> createdFromArchive)
+   //   {
+   //      this.createdFromArchive = createdFromArchive;
+   //   }
 
-   /**
-    * @param createdFromArchive the createdFromArchive to set
-    */
-   private void setCreatedFromArchive(SoftReference<Archive<?>> createdFromArchive)
-   {
-      this.createdFromArchive = createdFromArchive;
-   }
-
 }

Modified: tmpdpl/trunk/impl-vdf/src/test/java/org/jboss/tmpdpl/impl/vdf/VfsVdfDeployableImplTestCase.java
===================================================================
--- tmpdpl/trunk/impl-vdf/src/test/java/org/jboss/tmpdpl/impl/vdf/VfsVdfDeployableImplTestCase.java	2009-10-19 20:58:52 UTC (rev 3618)
+++ tmpdpl/trunk/impl-vdf/src/test/java/org/jboss/tmpdpl/impl/vdf/VfsVdfDeployableImplTestCase.java	2009-10-21 17:40:45 UTC (rev 3619)
@@ -16,10 +16,11 @@
  */
 package org.jboss.tmpdpl.impl.vdf;
 
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
 import java.util.logging.Logger;
 
-import org.jboss.shrinkwrap.api.spec.JavaArchive;
-import org.jboss.shrinkwrap.api.spec.JavaArchiveFactory;
 import org.jboss.tmpdpl.api.deployable.Deployable;
 import org.jboss.virtual.VFS;
 import org.junit.Assert;
@@ -81,29 +82,25 @@
       final String name2 = "archive2";
 
       // Make some test archives
-      final JavaArchive archive1 = JavaArchiveFactory.create(name1);
-      final JavaArchive archive2 = JavaArchiveFactory.create(name2);
+      final File root = new File(this.getRoot().toURI());
+      final File archive1 = new File(root, name1);
+      final File archive2 = new File(root, name2);
+      createIfNecessary(archive1);
+      createIfNecessary(archive2);
 
       // Make some test Deployables from the archives
       final Deployable deployable1 = VfsVdfDeployableImpl.create(archive1);
       final Deployable deployable2 = VfsVdfDeployableImpl.create(archive2);
-      final Deployable deployable3 = VfsVdfDeployableImpl.create(archive1);
 
       // Test equals
-      Assert.assertTrue("Deployables made from same archive should be equal by value", deployable1.equals(deployable3));
-      Assert.assertTrue("Deployables must be equal by symmetry; a == b then b == a", deployable3.equals(deployable1));
-      Assert.assertFalse("Deployables pointing to different archives should not be equal by value", deployable1
-            .equals(deployable2));
-      Assert.assertFalse("Deployables must not be equal to null value", deployable1.equals(null));
+      Assert.assertTrue("Deployable must be equal to itself by value", deployable1.equals(deployable1));
+      Assert.assertFalse("Different deployables should not be equal by value", deployable1.equals(deployable2));
 
       // Get hashCodes
       final int deployable1HashCode = deployable1.hashCode();
       final int deployable1HashCodeAgain = deployable1.hashCode();
-      final int deployable3HashCode = deployable3.hashCode();
 
       // Test hashCodes
-      Assert.assertEquals("Deployables with equal values must have equal hash codes", deployable1HashCode,
-            deployable3HashCode);
       Assert.assertEquals("hash code op must be indempotent", deployable1HashCode, deployable1HashCodeAgain);
 
       /*
@@ -112,4 +109,30 @@
        */
    }
 
+   //-------------------------------------------------------------------------------------||
+   // Internal Helper Methods ------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   /**
+    * Returns the root of these tests
+    */
+   private final URL getRoot()
+   {
+      return this.getClass().getProtectionDomain().getCodeSource().getLocation();
+   }
+
+   /**
+    * Creates the new specified file if necessary, erring if unable
+    * @param file
+    * @throws IOException
+    */
+   private static void createIfNecessary(final File file) throws IOException
+   {
+      if (!file.exists())
+      {
+         Assert.assertTrue("archive could not be created", file.createNewFile());
+         log.info("Created tmp file: " + file);
+      }
+   }
+
 }

Modified: tmpdpl/trunk/pom.xml
===================================================================
--- tmpdpl/trunk/pom.xml	2009-10-19 20:58:52 UTC (rev 3618)
+++ tmpdpl/trunk/pom.xml	2009-10-21 17:40:45 UTC (rev 3619)
@@ -27,8 +27,10 @@
   <!-- Aggregate Modules -->
   <modules>
     <module>api</module>
+    <module>api-shrinkwrap</module>
     <module>build</module>
     <module>impl-vdf</module>
+    <module>impl-shrinkwrap</module>
     <module>spi-vdf</module>
   </modules>
 



More information about the jboss-svn-commits mailing list