[jboss-svn-commits] JBoss Common SVN: r3962 - in shrinkwrap/trunk: build and 17 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Fri Jan 29 19:50:39 EST 2010


Author: aslak
Date: 2010-01-29 19:50:39 -0500 (Fri, 29 Jan 2010)
New Revision: 3962

Added:
   shrinkwrap/trunk/extension-glassfish/
   shrinkwrap/trunk/extension-glassfish/pom.xml
   shrinkwrap/trunk/extension-glassfish/src/
   shrinkwrap/trunk/extension-glassfish/src/main/
   shrinkwrap/trunk/extension-glassfish/src/main/java/
   shrinkwrap/trunk/extension-glassfish/src/main/java/com/
   shrinkwrap/trunk/extension-glassfish/src/main/java/com/jboss/
   shrinkwrap/trunk/extension-glassfish/src/main/java/com/jboss/shrinkwrap/
   shrinkwrap/trunk/extension-glassfish/src/main/java/com/jboss/shrinkwrap/glassfish/
   shrinkwrap/trunk/extension-glassfish/src/main/java/com/jboss/shrinkwrap/glassfish/ShrinkwrapReadableArchive.java
   shrinkwrap/trunk/extension-glassfish/src/main/java/com/jboss/shrinkwrap/glassfish/ShrinkwrapReadableArchiveImpl.java
   shrinkwrap/trunk/extension-glassfish/src/main/resources/
   shrinkwrap/trunk/extension-glassfish/src/main/resources/META-INF/
   shrinkwrap/trunk/extension-glassfish/src/main/resources/META-INF/services/
   shrinkwrap/trunk/extension-glassfish/src/main/resources/META-INF/services/com.jboss.shrinkwrap.glassfish.ShrinkwrapReadableArchive
   shrinkwrap/trunk/extension-glassfish/src/test/
   shrinkwrap/trunk/extension-glassfish/src/test/java/
   shrinkwrap/trunk/extension-glassfish/src/test/java/com/
   shrinkwrap/trunk/extension-glassfish/src/test/java/com/jboss/
   shrinkwrap/trunk/extension-glassfish/src/test/java/com/jboss/shrinkwrap/
   shrinkwrap/trunk/extension-glassfish/src/test/java/com/jboss/shrinkwrap/glassfish/
   shrinkwrap/trunk/extension-glassfish/src/test/java/com/jboss/shrinkwrap/glassfish/ShrinkwrapReadableArchiveTestCase.java
   shrinkwrap/trunk/extension-glassfish/src/test/resources/
Modified:
   shrinkwrap/trunk/build/pom.xml
   shrinkwrap/trunk/pom.xml
Log:
SHRINKWRAP-124 GlassFish ReadableArchive integration


Modified: shrinkwrap/trunk/build/pom.xml
===================================================================
--- shrinkwrap/trunk/build/pom.xml	2010-01-29 15:30:58 UTC (rev 3961)
+++ shrinkwrap/trunk/build/pom.xml	2010-01-30 00:50:39 UTC (rev 3962)
@@ -28,9 +28,24 @@
 
     <!-- Versioning -->
     <version.junit_junit>4.6</version.junit_junit>
+    <version.glassfish_api>3.0</version.glassfish_api>
 
   </properties>
 
+	<!-- Maven 2 Repositories -->
+	<repositories>
+		<repository>
+        	<id>java.dev.net.glassfish</id>
+        	<url>http://download.java.net/maven/glassfish</url>
+        	<releases>
+				<enabled>true</enabled>
+			</releases>
+        	<snapshots>
+				<enabled>true</enabled>
+			</snapshots>
+		</repository>
+	</repositories>
+
   <!-- SCM -->
   <scm>
     <connection>scm:svn:http://anonsvn.jboss.org/repos/common/shrinkwrap/trunk</connection>
@@ -147,6 +162,13 @@
   <dependencyManagement>
     <dependencies>
 
+		<dependency>
+			<groupId>org.glassfish.common</groupId>
+			<artifactId>glassfish-api</artifactId>
+			<version>${version.glassfish_api}</version>
+			<scope>provided</scope>
+		</dependency>
+
       <dependency>
         <groupId>junit</groupId>
         <artifactId>junit</artifactId>

Added: shrinkwrap/trunk/extension-glassfish/pom.xml
===================================================================
--- shrinkwrap/trunk/extension-glassfish/pom.xml	                        (rev 0)
+++ shrinkwrap/trunk/extension-glassfish/pom.xml	2010-01-30 00:50:39 UTC (rev 3962)
@@ -0,0 +1,91 @@
+<?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.shrinkwrap</groupId>
+    <artifactId>shrinkwrap-build</artifactId>
+    <version>1.0.0-SNAPSHOT</version>
+    <relativePath>../build/pom.xml</relativePath>
+  </parent>
+
+  <!-- Model Version -->
+  <modelVersion>4.0.0</modelVersion>
+
+  <!-- Artifact Configuration -->
+  <artifactId>shrinkwrap-extension-glassfish</artifactId>
+  <name>ShrinkWrap Extension GlassFish</name>
+  <description>ShrinkWrap extension for the GlassFish Project</description>
+
+
+  <!-- Properties -->
+  <properties>
+
+  </properties>
+
+  <!-- Dependencies -->
+  <dependencies>
+
+    <!-- 
+    org.jboss.shrinkwrap    
+     -->
+    <dependency>
+      <groupId>org.jboss.shrinkwrap</groupId>
+      <artifactId>shrinkwrap-api</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.shrinkwrap</groupId>
+      <artifactId>shrinkwrap-impl-base</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+
+	<dependency>
+		<groupId>org.glassfish.common</groupId>
+		<artifactId>glassfish-api</artifactId>
+	</dependency>
+
+    <!-- 
+    External Projects
+     -->
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+  </dependencies>
+
+  <!-- Build Configuration -->
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-jar-plugin</artifactId>
+        <executions>
+          <execution>
+            <goals>
+              <goal>test-jar</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+
+      <!-- Resources Plugin -->
+      <plugin>
+        <artifactId>maven-resources-plugin</artifactId>
+        <version>2.3</version> <!-- Required for empty dirs config to be used -->
+        <configuration>
+          <!-- For the importer tests, we must copy empty directories -->
+          <includeEmptyDirs>true</includeEmptyDirs>
+        </configuration>
+      </plugin>
+
+    </plugins>
+  </build>
+</project>
+

Added: shrinkwrap/trunk/extension-glassfish/src/main/java/com/jboss/shrinkwrap/glassfish/ShrinkwrapReadableArchive.java
===================================================================
--- shrinkwrap/trunk/extension-glassfish/src/main/java/com/jboss/shrinkwrap/glassfish/ShrinkwrapReadableArchive.java	                        (rev 0)
+++ shrinkwrap/trunk/extension-glassfish/src/main/java/com/jboss/shrinkwrap/glassfish/ShrinkwrapReadableArchive.java	2010-01-30 00:50:39 UTC (rev 3962)
@@ -0,0 +1,31 @@
+/*
+ * 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 com.jboss.shrinkwrap.glassfish;
+
+import org.glassfish.api.deployment.archive.ReadableArchive;
+import org.jboss.shrinkwrap.api.Assignable;
+
+/**
+ * ShrinkWrap extension to support GlassFishs ReadableArchive.
+ *
+ * @author <a href="mailto:aslak at conduct.no">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+public interface ShrinkwrapReadableArchive extends ReadableArchive, Assignable
+{
+
+}

Added: shrinkwrap/trunk/extension-glassfish/src/main/java/com/jboss/shrinkwrap/glassfish/ShrinkwrapReadableArchiveImpl.java
===================================================================
--- shrinkwrap/trunk/extension-glassfish/src/main/java/com/jboss/shrinkwrap/glassfish/ShrinkwrapReadableArchiveImpl.java	                        (rev 0)
+++ shrinkwrap/trunk/extension-glassfish/src/main/java/com/jboss/shrinkwrap/glassfish/ShrinkwrapReadableArchiveImpl.java	2010-01-30 00:50:39 UTC (rev 3962)
@@ -0,0 +1,304 @@
+/*
+ * 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 com.jboss.shrinkwrap.glassfish;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.Map.Entry;
+import java.util.jar.Manifest;
+
+import org.glassfish.api.deployment.archive.ReadableArchive;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ArchivePath;
+import org.jboss.shrinkwrap.api.ArchivePaths;
+import org.jboss.shrinkwrap.api.Asset;
+import org.jboss.shrinkwrap.impl.base.AssignableBase;
+import org.jboss.shrinkwrap.impl.base.Validate;
+import org.jboss.shrinkwrap.impl.base.asset.ArchiveAsset;
+import org.jboss.shrinkwrap.impl.base.asset.DirectoryAsset;
+import org.jboss.shrinkwrap.impl.base.io.IOUtil;
+
+/**
+ * ShrinkWrap extension to support GlassFishs ReadableArchive.
+ *
+ * @author <a href="mailto:aslak at conduct.no">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+public class ShrinkwrapReadableArchiveImpl extends AssignableBase implements ShrinkwrapReadableArchive
+{
+   private Archive<?> archive;
+   
+   /**
+    * @param archive
+    */
+   public ShrinkwrapReadableArchiveImpl(Archive<?> archive)
+   {
+      Validate.notNull(archive, "Archive must be specified");
+      this.archive = archive;
+   }
+   
+   /* (non-Javadoc)
+    * @see org.jboss.shrinkwrap.impl.base.AssignableBase#getArchive()
+    */
+   @Override
+   protected Archive<?> getArchive()
+   {
+      return archive;
+   }
+
+   /**
+    * A ShrinkWrap archive can not be deleted. 
+    * 
+    * @return This always returns false.
+    */
+   @Override
+   public boolean delete()
+   {
+      return false;
+   }
+
+   /**
+    * A ShrinkWrap archive can never not-exist. 
+    * 
+    * @return This always returns true.
+    */
+   @Override
+   public boolean exists()
+   {
+      return true;
+   }
+
+   /* (non-Javadoc)
+    * @see org.glassfish.api.deployment.archive.ReadableArchive#exists(java.lang.String)
+    */
+   @Override
+   public boolean exists(String path) throws IOException
+   {
+      return archive.contains(ArchivePaths.create(path));
+   }
+
+   /* (non-Javadoc)
+    * @see org.glassfish.api.deployment.archive.ReadableArchive#getEntry(java.lang.String)
+    */
+   @Override
+   public InputStream getEntry(String path) throws IOException
+   {
+      return archive.get(ArchivePaths.create(path)).openStream();
+   }
+
+   /* (non-Javadoc)
+    * @see org.glassfish.api.deployment.archive.ReadableArchive#getEntrySize(java.lang.String)
+    */
+   // TODO: ShrinkWrap have not know the size of a Asset. Hacking figure it out runtime. 
+   // Needed by GlassFish for buff sizes.
+   @Override
+   public long getEntrySize(String path)
+   {
+      Asset asset = archive.get(ArchivePaths.create(path));
+      ByteArrayOutputStream output = new ByteArrayOutputStream();
+      try
+      {
+         IOUtil.copyWithClose(asset.openStream(), output);
+         return output.toByteArray().length;
+      } 
+      catch (IOException e) 
+      {
+         throw new RuntimeException(e);
+      }
+   }
+
+   /**
+    * ShrinkWrap does not have a bi-directional relationship between parent-child. 
+    * 
+    * @return This always return null.
+    */
+   @Override
+   public ReadableArchive getParentArchive()
+   {
+      return null;
+   }
+
+   /**
+    * ShrinkWrap does not have a bi-directional relationship between parent-child.
+    * 
+    *  This does nothing.
+    */
+   @Override
+   public void setParentArchive(ReadableArchive arg0)
+   {
+   }
+
+   /* (non-Javadoc)
+    * @see org.glassfish.api.deployment.archive.ReadableArchive#getSubArchive(java.lang.String)
+    */
+   // TODO: We should support non ShrinkWrap nested Archives as well. ie: external jar files.
+   @Override
+   public ReadableArchive getSubArchive(String path) throws IOException
+   {
+      Asset archiveAsset = archive.get(ArchivePaths.create(path));
+      if(archiveAsset instanceof ArchiveAsset)
+      {
+         return ((ArchiveAsset)archiveAsset).getArchive().as(ShrinkwrapReadableArchive.class);
+      }
+      throw new IOException(path + " not a Archive");
+   }
+
+   /* (non-Javadoc)
+    * @see org.glassfish.api.deployment.archive.ReadableArchive#open(java.net.URI)
+    */
+   @Override
+   public void open(URI arg0) throws IOException
+   {
+   }
+
+   /**
+    * A ShrinkWrap archive can not be renamed. 
+    * 
+    * @return This always return false.
+    */
+   @Override
+   public boolean renameTo(String arg0)
+   {
+      return false;
+   }
+
+   /* (non-Javadoc)
+    * @see org.glassfish.api.deployment.archive.Archive#close()
+    */
+   @Override
+   public void close() throws IOException
+   {
+   }
+
+   /* (non-Javadoc)
+    * @see org.glassfish.api.deployment.archive.Archive#entries()
+    */
+   @Override
+   public Enumeration<String> entries()
+   {
+      List<String> entries = new ArrayList<String>();
+      
+      for(Entry<ArchivePath, Asset> entry : archive.getContent().entrySet()) 
+      {
+         entries.add(entry.getKey().get());
+      }
+      return Collections.enumeration(entries);
+   }
+
+   /* (non-Javadoc)
+    * @see org.glassfish.api.deployment.archive.Archive#entries(java.lang.String)
+    */
+   @Override
+   public Enumeration<String> entries(String path)
+   {
+      List<String> entries = new ArrayList<String>();
+      
+      for(Entry<ArchivePath, Asset> entry : archive.getContent().entrySet()) 
+      {
+         if(entry.getKey().get().startsWith(path))
+         {
+            entries.add(entry.getKey().get());
+         }
+      }
+      return Collections.enumeration(entries);
+   }
+
+   /**
+    * ShrinkWrap does not track Asset sizes.
+    * 
+    * @return This always return -1
+    */
+   @Override
+   public long getArchiveSize() throws SecurityException
+   {
+      return -1;
+   }
+
+   /* (non-Javadoc)
+    * @see org.glassfish.api.deployment.archive.Archive#getDirectories()
+    */
+   @Override
+   public Collection<String> getDirectories() throws IOException
+   {
+      List<String> entries = new ArrayList<String>();
+      
+      for(Entry<ArchivePath, Asset> entry : archive.getContent().entrySet()) 
+      {
+         if(entry.getValue() == DirectoryAsset.INSTANCE)
+         {
+            entries.add(entry.getKey().get());
+         }
+      }
+      return entries;
+   }
+
+   /* (non-Javadoc)
+    * @see org.glassfish.api.deployment.archive.Archive#getManifest()
+    */
+   @Override
+   public Manifest getManifest() throws IOException
+   {
+      ArchivePath manifestPath = ArchivePaths.create("META-INF/MANIFEST.MF");
+      if(archive.contains(manifestPath)) 
+      {
+         return new Manifest(archive.get(manifestPath).openStream());
+      }
+      return null;
+   }
+
+   /* (non-Javadoc)
+    * @see org.glassfish.api.deployment.archive.Archive#getName()
+    */
+   @Override
+   public String getName()
+   {
+      return archive.getName();
+   }
+
+   /* (non-Javadoc)
+    * @see org.glassfish.api.deployment.archive.Archive#getURI()
+    */
+   @Override
+   public URI getURI()
+   {
+      try
+      {
+         return new URI("archive://" + archive.getName());
+      }
+      catch (URISyntaxException e)
+      {
+         throw new RuntimeException(e);
+      }
+   }
+
+   /* (non-Javadoc)
+    * @see org.glassfish.api.deployment.archive.Archive#isDirectory(java.lang.String)
+    */
+   @Override
+   public boolean isDirectory(String path)
+   {
+      return archive.get(ArchivePaths.create(path)) == DirectoryAsset.INSTANCE;
+   }
+}
\ No newline at end of file

Added: shrinkwrap/trunk/extension-glassfish/src/main/resources/META-INF/services/com.jboss.shrinkwrap.glassfish.ShrinkwrapReadableArchive
===================================================================
--- shrinkwrap/trunk/extension-glassfish/src/main/resources/META-INF/services/com.jboss.shrinkwrap.glassfish.ShrinkwrapReadableArchive	                        (rev 0)
+++ shrinkwrap/trunk/extension-glassfish/src/main/resources/META-INF/services/com.jboss.shrinkwrap.glassfish.ShrinkwrapReadableArchive	2010-01-30 00:50:39 UTC (rev 3962)
@@ -0,0 +1 @@
+com.jboss.shrinkwrap.glassfish.ShrinkwrapReadableArchiveImpl
\ No newline at end of file

Added: shrinkwrap/trunk/extension-glassfish/src/test/java/com/jboss/shrinkwrap/glassfish/ShrinkwrapReadableArchiveTestCase.java
===================================================================
--- shrinkwrap/trunk/extension-glassfish/src/test/java/com/jboss/shrinkwrap/glassfish/ShrinkwrapReadableArchiveTestCase.java	                        (rev 0)
+++ shrinkwrap/trunk/extension-glassfish/src/test/java/com/jboss/shrinkwrap/glassfish/ShrinkwrapReadableArchiveTestCase.java	2010-01-30 00:50:39 UTC (rev 3962)
@@ -0,0 +1,39 @@
+/*
+ * 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 com.jboss.shrinkwrap.glassfish;
+
+import junit.framework.Assert;
+
+import org.jboss.shrinkwrap.api.Archives;
+import org.junit.Test;
+
+
+/**
+ * ShrinkwrapReadableArchiveTestCase
+ *
+ * @author <a href="mailto:aslak at conduct.no">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+public class ShrinkwrapReadableArchiveTestCase
+{
+   @Test
+   public void shouldBeAbleToLoadExtension() throws Exception 
+   {
+      ShrinkwrapReadableArchive archive = Archives.create("test", ShrinkwrapReadableArchive.class);
+      Assert.assertNotNull(archive);
+   }
+}

Modified: shrinkwrap/trunk/pom.xml
===================================================================
--- shrinkwrap/trunk/pom.xml	2010-01-29 15:30:58 UTC (rev 3961)
+++ shrinkwrap/trunk/pom.xml	2010-01-30 00:50:39 UTC (rev 3962)
@@ -69,6 +69,8 @@
     <module>build</module>
     <module>impl-base</module>
     <module>spi</module>
+
+    <module>extension-glassfish</module>
   </modules>
 
 </project>



More information about the jboss-svn-commits mailing list