[jboss-svn-commits] JBoss Common SVN: r4724 - in shrinkwrap/trunk: impl-base/src/main/java/org/jboss/shrinkwrap/impl/base and 2 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Mon Jul 12 19:55:00 EDT 2010


Author: ALRubinger
Date: 2010-07-12 19:55:00 -0400 (Mon, 12 Jul 2010)
New Revision: 4724

Added:
   shrinkwrap/trunk/api/src/main/java/org/jboss/shrinkwrap/api/GenericArchive.java
   shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/GenericArchiveImpl.java
   shrinkwrap/trunk/impl-base/src/main/resources/META-INF/services/org.jboss.shrinkwrap.api.GenericArchive
   shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/spec/GenericArchiveImplTestCase.java
Log:
[SHRINKWRAP-200] Add a GenericArchive to close the generic context of Archive<?> as a convenience to users

Added: shrinkwrap/trunk/api/src/main/java/org/jboss/shrinkwrap/api/GenericArchive.java
===================================================================
--- shrinkwrap/trunk/api/src/main/java/org/jboss/shrinkwrap/api/GenericArchive.java	                        (rev 0)
+++ shrinkwrap/trunk/api/src/main/java/org/jboss/shrinkwrap/api/GenericArchive.java	2010-07-12 23:55:00 UTC (rev 4724)
@@ -0,0 +1,28 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, 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.shrinkwrap.api;
+
+/**
+ * Simple {@link Archive} extension which closes the generic context
+ * as a convenience to users not requiring any spec archive type.
+ * 
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ */
+public interface GenericArchive extends Archive<GenericArchive>
+{
+
+}

Added: shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/GenericArchiveImpl.java
===================================================================
--- shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/GenericArchiveImpl.java	                        (rev 0)
+++ shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/GenericArchiveImpl.java	2010-07-12 23:55:00 UTC (rev 4724)
@@ -0,0 +1,91 @@
+/*
+ * 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.shrinkwrap.impl.base;
+
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ArchivePath;
+import org.jboss.shrinkwrap.api.GenericArchive;
+import org.jboss.shrinkwrap.impl.base.container.ContainerBase;
+
+/**
+ * Implementation of a {@link GenericArchive}
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ */
+public class GenericArchiveImpl extends ContainerBase<GenericArchive> implements GenericArchive
+{
+
+   /**
+    * Unsupported operation
+    */
+   private static final UnsupportedOperationException UNSUPPORTED = new UnsupportedOperationException(
+         GenericArchive.class.getSimpleName() + " does not support container spec paths.");
+
+   //-------------------------------------------------------------------------------------||
+   // Constructor ------------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   /**
+    * Creates a new instance
+    * 
+    * @param delegate The storage backing.
+    */
+   public GenericArchiveImpl(final Archive<?> delegate)
+   {
+      super(GenericArchive.class, delegate);
+   }
+
+   /**
+    * {@inheritDoc}
+    * @see org.jboss.shrinkwrap.impl.base.container.ContainerBase#getClassesPath()
+    */
+   @Override
+   protected ArchivePath getClassesPath()
+   {
+      throw UNSUPPORTED;
+   }
+
+   /**
+    * {@inheritDoc}
+    * @see org.jboss.shrinkwrap.impl.base.container.ContainerBase#getLibraryPath()
+    */
+   @Override
+   protected ArchivePath getLibraryPath()
+   {
+      throw UNSUPPORTED;
+   }
+
+   /**
+    * {@inheritDoc}
+    * @see org.jboss.shrinkwrap.impl.base.container.ContainerBase#getManinfestPath()
+    */
+   @Override
+   protected ArchivePath getManinfestPath()
+   {
+      throw UNSUPPORTED;
+   }
+
+   /**
+    * {@inheritDoc}
+    * @see org.jboss.shrinkwrap.impl.base.container.ContainerBase#getResourcePath()
+    */
+   @Override
+   protected ArchivePath getResourcePath()
+   {
+      throw UNSUPPORTED;
+   }
+}

Added: shrinkwrap/trunk/impl-base/src/main/resources/META-INF/services/org.jboss.shrinkwrap.api.GenericArchive
===================================================================
--- shrinkwrap/trunk/impl-base/src/main/resources/META-INF/services/org.jboss.shrinkwrap.api.GenericArchive	                        (rev 0)
+++ shrinkwrap/trunk/impl-base/src/main/resources/META-INF/services/org.jboss.shrinkwrap.api.GenericArchive	2010-07-12 23:55:00 UTC (rev 4724)
@@ -0,0 +1 @@
+implementingClassName=org.jboss.shrinkwrap.impl.base.GenericArchiveImpl
\ No newline at end of file

Added: shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/spec/GenericArchiveImplTestCase.java
===================================================================
--- shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/spec/GenericArchiveImplTestCase.java	                        (rev 0)
+++ shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/spec/GenericArchiveImplTestCase.java	2010-07-12 23:55:00 UTC (rev 4724)
@@ -0,0 +1,150 @@
+/*
+ * 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.shrinkwrap.impl.base.spec;
+
+import java.util.UUID;
+
+import org.jboss.shrinkwrap.api.ArchivePath;
+import org.jboss.shrinkwrap.api.GenericArchive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.container.ClassContainer;
+import org.jboss.shrinkwrap.api.container.LibraryContainer;
+import org.jboss.shrinkwrap.api.container.ManifestContainer;
+import org.jboss.shrinkwrap.api.container.ResourceContainer;
+import org.jboss.shrinkwrap.impl.base.GenericArchiveImpl;
+import org.jboss.shrinkwrap.impl.base.test.ArchiveType;
+import org.jboss.shrinkwrap.impl.base.test.DynamicContainerTestBase;
+import org.junit.After;
+import org.junit.Before;
+
+/**
+ * Test case to ensure that the {@link GenericArchiveImpl}
+ * is working as contracted
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ */
+ at ArchiveType(GenericArchive.class)
+public class GenericArchiveImplTestCase extends DynamicContainerTestBase<GenericArchive>
+{
+
+   //-------------------------------------------------------------------------------------||
+   // Class Members ----------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   /**
+    * Unsupported operation
+    */
+   private static final UnsupportedOperationException UNSUPPORTED = new UnsupportedOperationException(
+         GenericArchive.class.getSimpleName() + " does not support container spec paths.");
+
+   //-------------------------------------------------------------------------------------||
+   // Instance Members -------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   private GenericArchive archive;
+
+   //-------------------------------------------------------------------------------------||
+   // Lifecycle Methods ------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   @Before
+   public void createArchive()
+   {
+      archive = createNewArchive();
+   }
+
+   @After
+   public void ls()
+   {
+      System.out.println("test at jboss:/$ ls -l " + archive.getName());
+      System.out.println(archive.toString(true));
+   }
+
+   //-------------------------------------------------------------------------------------||
+   // Required Impls - ArchiveTestBase ---------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   /**
+    * Return the archive to super class
+    */
+   @Override
+   protected GenericArchive getArchive()
+   {
+      return archive;
+   }
+
+   /** 
+    * Create a new JavaArchive instance
+    */
+   @Override
+   protected GenericArchive createNewArchive()
+   {
+      return ShrinkWrap.create(GenericArchive.class, UUID.randomUUID().toString() + ".jar");
+   }
+
+   //-------------------------------------------------------------------------------------||
+   // Required Impls - ContainerTestBase ---------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   @Override
+   protected ResourceContainer<GenericArchive> getResourceContainer()
+   {
+      throw UNSUPPORTED;
+   }
+
+   @Override
+   protected ClassContainer<GenericArchive> getClassContainer()
+   {
+      throw UNSUPPORTED;
+   }
+
+   @Override
+   protected ManifestContainer<GenericArchive> getManifestContainer()
+   {
+      throw UNSUPPORTED;
+   }
+
+   @Override
+   protected LibraryContainer<GenericArchive> getLibraryContainer()
+   {
+      throw UNSUPPORTED;
+   }
+
+   @Override
+   protected ArchivePath getManifestPath()
+   {
+      throw UNSUPPORTED;
+   }
+
+   @Override
+   protected ArchivePath getResourcePath()
+   {
+      throw UNSUPPORTED;
+   }
+
+   @Override
+   protected ArchivePath getClassPath()
+   {
+      throw UNSUPPORTED;
+   }
+
+   @Override
+   protected ArchivePath getLibraryPath()
+   {
+      throw UNSUPPORTED;
+   }
+}



More information about the jboss-svn-commits mailing list