osdir.com
mailing list archive
Mozy Online Backup: 2GB Free. Automatic. Secure.

Subject: [picocontainer-scm] [2318] java/nanocontainer-sandbox/trunk: http://jira.codehaus.org/browse/NANOSANDBOX-7 by Michael Rimov applied - msg#00209

List: java.picocontainer.cvs

Date: Prev Next Index Thread: Prev Next Index
Revision 2318 Author paul Date 2005-08-26 00:54:23 -0400 (Fri, 26 Aug 2005) Log Message
http://jira.codehaus.org/browse/NANOSANDBOX-7 by Michael Rimov applied
Modified Paths Added Paths Diff Modified: java/nanocontainer-sandbox/trunk/deployer/project.xml (2317 => 2318)
--- java/nanocontainer-sandbox/trunk/deployer/project.xml	2005-08-26 02:02:06 UTC (rev 2317)
+++ java/nanocontainer-sandbox/trunk/deployer/project.xml	2005-08-26 04:54:23 UTC (rev 2318)
@@ -29,19 +29,24 @@
         </dependency>
 
         <dependency>
+            <id>antlr</id>
+            <version>2.7.5</version>
+        </dependency>
+
+        <dependency>
             <id>groovy</id>
-            <version>1.0-beta-7</version>
+            <version>1.0-jsr-03-SNAPSHOT</version>
         </dependency>
 
         <dependency>
             <id>asm</id>
-            <version>1.4.3</version>
+            <version>2.0</version>
         </dependency>
 
         <dependency>
             <groupId>asm</groupId>
             <artifactId>asm-util</artifactId>
-            <version>1.4.3</version>
+            <version>2.0</version>
         </dependency>
 
     </dependencies>
Added: java/nanocontainer-sandbox/trunk/deployer/src/badbuildscriptdeploy.jar
(Binary files differ)
Property changes on: java/nanocontainer-sandbox/trunk/deployer/src/badbuildscriptdeploy.jar ___________________________________________________________________ Name: svn:executable + * Name: svn:mime-type + application/octet-stream Modified: java/nanocontainer-sandbox/trunk/deployer/src/deploytest/META-INF/nanocontainer.groovy (2317 => 2318)
--- java/nanocontainer-sandbox/trunk/deployer/src/deploytest/META-INF/nanocontainer.groovy	2005-08-26 02:02:06 UTC (rev 2317)
+++ java/nanocontainer-sandbox/trunk/deployer/src/deploytest/META-INF/nanocontainer.groovy	2005-08-26 04:54:23 UTC (rev 2318)
@@ -1,5 +1,5 @@
 builder = new org.nanocontainer.script.groovy.NanoContainerBuilder()
 pico = builder.container(parent:parent) {
  component(instance:'Groovy')
- component(key:'zap', class:foo.bar.Zap)
+ component(key:'zap', class:'foo.bar.Zap')
 }
Modified: java/nanocontainer-sandbox/trunk/deployer/src/deploytest/foo/bar/Zap.class
(Binary files differ)
Modified: java/nanocontainer-sandbox/trunk/deployer/src/java/org/nanocontainer/tools/deployer/NanoContainerDeployer.java (2317 => 2318)
--- java/nanocontainer-sandbox/trunk/deployer/src/java/org/nanocontainer/tools/deployer/NanoContainerDeployer.java	2005-08-26 02:02:06 UTC (rev 2317)
+++ java/nanocontainer-sandbox/trunk/deployer/src/java/org/nanocontainer/tools/deployer/NanoContainerDeployer.java	2005-08-26 04:54:23 UTC (rev 2318)
@@ -14,21 +14,20 @@
  */
 package org.nanocontainer.tools.deployer;
 
+import java.io.InputStreamReader;
+import java.io.Reader;
+
 import org.apache.commons.vfs.FileObject;
 import org.apache.commons.vfs.FileSelectInfo;
 import org.apache.commons.vfs.FileSelector;
 import org.apache.commons.vfs.FileSystemException;
 import org.apache.commons.vfs.FileSystemManager;
 import org.apache.commons.vfs.impl.VFSClassLoader;
+import org.nanocontainer.integrationkit.ContainerBuilder;
 import org.nanocontainer.script.ScriptedContainerBuilderFactory;
-import org.nanocontainer.script.ScriptedContainerBuilderFactory;
-import org.nanocontainer.integrationkit.ContainerBuilder;
 import org.picocontainer.defaults.ObjectReference;
 import org.picocontainer.defaults.SimpleReference;
 
-import java.io.InputStreamReader;
-import java.io.Reader;
-
 /**
  * This class is capable of deploying an application from any kind of file system
  * supported by <a href="" VFS</a>.
@@ -83,12 +82,37 @@
  * @author Aslak Helles&oslash;y
  */
 public class NanoContainerDeployer implements Deployer {
+
+    /**
+     * VFS file system manager.
+     */
     private final FileSystemManager fileSystemManager;
 
-    public NanoContainerDeployer(FileSystemManager fileSystemManager) {
+    /**
+     * File system basename.  Defaults to 'nanocontainer'.  May be set differently
+     * for other applications.
+     */
+    private final String fileBasename;
+
+    /**
+     * Constructs a nanocontainer deployer with the specified file system manager.
+     * @param fileSystemManager A VFS FileSystemManager.
+     */
+    public NanoContainerDeployer(final FileSystemManager fileSystemManager) {
+        this(fileSystemManager,"nanocontainer");
+    }
+
+    /**
+     * Constructs a nanocontainer deployer with the specified file system manager
+     * and specifies a 'base name' for the configuration file that will be loaded.
+     * @param fileSystemManager A VFS FileSystemManager.
+     */
+    public NanoContainerDeployer(final FileSystemManager fileSystemManager, String baseFileName) {
         this.fileSystemManager = fileSystemManager;
+        fileBasename = baseFileName;
     }
 
+
     /**
      * Deploys an application.
      *
@@ -110,6 +134,11 @@
         Reader scriptReader = new InputStreamReader(deploymentScript.getContent().getInputStream());
         String builderClassName = ScriptedContainerBuilderFactory.getBuilderClassName(extension);
 
+        if (builderClassName == null) {
+          throw new FileSystemException("Could not find a suitable builder for: " + deploymentScript.getName()
+              + ".  Known extensions are: [groovy|bsh|js|py|xml]");
+        }
+
         ScriptedContainerBuilderFactory scriptedContainerBuilderFactory = new ScriptedContainerBuilderFactory(scriptReader, builderClassName, applicationClassLoader);
         ContainerBuilder builder = scriptedContainerBuilderFactory.getContainerBuilder();
         builder.buildContainer(result, parentContainerRef, null, true);
@@ -117,22 +146,56 @@
         return result;
     }
 
+    /**
+     * Given the base application folder, return a file object that represents the
+     * nanocontainer configuration script.
+     * @param applicationFolder FileObject
+     * @return FileObject
+     * @throws FileSystemException
+     */
     private FileObject getDeploymentScript(FileObject applicationFolder) throws FileSystemException {
         final FileObject metaInf = applicationFolder.getChild("META-INF");
         if(metaInf == null) {
             throw new FileSystemException("Missing META-INF folder in " + applicationFolder.getName().getPath());
         }
         final FileObject[] nanocontainerScripts = metaInf.findFiles(new FileSelector(){
+
             public boolean includeFile(FileSelectInfo fileSelectInfo) throws Exception {
-                return fileSelectInfo.getFile().getName().getBaseName().startsWith("nanocontainer");
+                return fileSelectInfo.getFile().getName().getBaseName().startsWith(getFileBasename());
             }
+
             public boolean traverseDescendents(FileSelectInfo fileSelectInfo) throws Exception {
+              //
+              //nanocontainer.* can easily be deep inside a directory tree and
+              //we end up not picking up our desired script.
+              //
+              if (fileSelectInfo.getDepth() > 1) {
+                return false;
+              } else {
                 return true;
+              }
             }
         });
+
         if(nanocontainerScripts == null || nanocontainerScripts.length < 1) {
-            throw new FileSystemException("No deployment script (nanocontainer.[groovy|bsh|js|py|xml]) in " + applicationFolder.getName().getPath() + "/META-INF");
+            throw new FileSystemException("No deployment script ("+ getFileBasename() +".[groovy|bsh|js|py|xml]) in " + applicationFolder.getName().getPath() + "/META-INF");
         }
-        return nanocontainerScripts[0];
+
+        if (nanocontainerScripts.length == 1) {
+          return nanocontainerScripts[0];
+        } else {
+          throw new FileSystemException("Found more than one candidate config script in : " + applicationFolder.getName().getPath() + "/META-INF."
+              + "Please only have one " + getFileBasename() + ".[groovy|bsh|js|py|xml] this directory.");
+        }
+
     }
-}
\ No newline at end of file
+
+
+    /**
+     * Retrieve the file base name.
+     * @return String
+     */
+    public String getFileBasename() {
+        return fileBasename;
+    }
+}
Added: java/nanocontainer-sandbox/trunk/deployer/src/malformed-deployment.jar
(Binary files differ)
Property changes on: java/nanocontainer-sandbox/trunk/deployer/src/malformed-deployment.jar ___________________________________________________________________ Name: svn:executable + * Name: svn:mime-type + application/octet-stream Modified: java/nanocontainer-sandbox/trunk/deployer/src/test/org/nanocontainer/tools/deployer/NanoContainerDeployerTestCase.java (2317 => 2318)
--- java/nanocontainer-sandbox/trunk/deployer/src/test/org/nanocontainer/tools/deployer/NanoContainerDeployerTestCase.java	2005-08-26 02:02:06 UTC (rev 2317)
+++ java/nanocontainer-sandbox/trunk/deployer/src/test/org/nanocontainer/tools/deployer/NanoContainerDeployerTestCase.java	2005-08-26 04:54:23 UTC (rev 2318)
@@ -1,6 +1,5 @@
 package org.nanocontainer.tools.deployer;
 
-import junit.framework.TestCase;
 import org.apache.commons.vfs.FileObject;
 import org.apache.commons.vfs.FileSystemException;
 import org.apache.commons.vfs.impl.DefaultFileSystemManager;
@@ -11,10 +10,11 @@
 import org.nanocontainer.tools.deployer.NanoContainerDeployer;
 import org.picocontainer.PicoContainer;
 import org.picocontainer.defaults.ObjectReference;
+import junit.framework.TestCase;
 
+import java.net.MalformedURLException;
+import java.lang.reflect.InvocationTargetException;
 import java.io.File;
-import java.lang.reflect.InvocationTargetException;
-import java.net.MalformedURLException;
 
 /**
  * @author Aslak Helles&oslash;y
@@ -26,16 +26,25 @@
         DefaultFileSystemManager manager = new DefaultFileSystemManager();
         FileObject applicationFolder = getApplicationFolder(manager);
 
-        Deployer deployer = new NanoContainerDeployer(manager);
-        ObjectReference containerRef = deployer.deploy(applicationFolder, getClass().getClassLoader(), null);
-        PicoContainer pico = (PicoContainer) containerRef.get();
-        Object zap = pico.getComponentInstance("zap");
-        assertEquals("Groovy Started", zap.toString());
+        try {
+            Deployer deployer = null;
+            deployer = new NanoContainerDeployer(manager);
+            ObjectReference containerRef = deployer.deploy(applicationFolder, getClass().getClassLoader(), null);
+            PicoContainer pico = (PicoContainer) containerRef.get();
+            Object zap = pico.getComponentInstance("zap");
+            assertEquals("Groovy Started", zap.toString());
+
+        } catch (Exception e) {
+            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+        }
     }
 
+
+
+
     public void testZipWithDeploymentScriptAndClassesCanBeDeployed() throws FileSystemException, MalformedURLException, ClassNotFoundException, IllegalAccessException, NoSuchMethodException, InvocationTargetException, InstantiationException {
         DefaultFileSystemManager manager = new DefaultFileSystemManager();
-        FileObject applicationFolder = getApplicationArchive(manager);
+        FileObject applicationFolder = getApplicationArchive(manager, "/deploytest.jar");
 
         Deployer deployer = new NanoContainerDeployer(manager);
         ObjectReference containerRef = deployer.deploy(applicationFolder, getClass().getClassLoader(), null);
@@ -44,6 +53,36 @@
         assertEquals("Groovy Started", zap.toString());
     }
 
+    public void testZipWithBadScriptNameThrowsFileSystemException() throws ClassNotFoundException, FileSystemException {
+
+      DefaultFileSystemManager manager = new DefaultFileSystemManager();
+      FileObject applicationFolder = getApplicationArchive(manager, "/badbuildscriptdeploy.jar");
+
+      try {
+        Deployer deployer = new NanoContainerDeployer(manager);
+        ObjectReference containerRef= deployer.deploy(applicationFolder, getClass().getClassLoader(), null);
+        fail("Deployment should have thrown FileSystemException for bad script file name.  Instead got:" + containerRef.toString() + " built.");
+      }
+      catch (FileSystemException ex) {
+        //a-ok
+      }
+    }
+
+    public void testMalformedDeployerArchiveThrowsFileSystemException() throws ClassNotFoundException, FileSystemException {
+      DefaultFileSystemManager manager = new DefaultFileSystemManager();
+      FileObject applicationFolder = getApplicationArchive(manager, "/malformed-deployment.jar");
+
+      try {
+        Deployer deployer = new NanoContainerDeployer(manager);
+        ObjectReference containerRef= deployer.deploy(applicationFolder, getClass().getClassLoader(), null);
+        fail("Deployment should have thrown FileSystemException for badly formed archive. Instead got:" + containerRef.toString() + " built.");
+      }
+      catch (FileSystemException ex) {
+        //a-ok
+      }
+    }
+
+
     public void testZapClassCanBeLoadedByVFSClassLoader() throws FileSystemException, MalformedURLException, ClassNotFoundException {
         DefaultFileSystemManager manager = new DefaultFileSystemManager();
         FileObject applicationFolder = getApplicationFolder(manager);
@@ -51,7 +90,26 @@
         applicationClassLoader.loadClass("foo.bar.Zap");
     }
 
-    private FileObject getApplicationFolder(DefaultFileSystemManager manager) throws FileSystemException, MalformedURLException {
+    public void testSettingDifferentBaseNameWillResultInChangeForWhatBuilderLooksFor() throws FileSystemException, MalformedURLException, ClassNotFoundException {
+        DefaultFileSystemManager manager = new DefaultFileSystemManager();
+        FileObject applicationFolder = getApplicationFolder(manager);
+        NanoContainerDeployer deployer = new NanoContainerDeployer(manager);
+        assertEquals("nanocontainer", deployer.getFileBasename());
+
+        deployer = new NanoContainerDeployer(manager,"foo");
+        assertEquals("foo", deployer.getFileBasename());
+
+        try {
+            ObjectReference containerRef = deployer.deploy(applicationFolder, getClass().getClassLoader(), null);
+            fail("Deployer should have now thrown an exception after changing the base name. Instead got: " + containerRef.toString());
+        }
+        catch (FileSystemException ex) {
+            //a-ok
+        }
+
+    }
+
+    private FileObject getApplicationFolder(final DefaultFileSystemManager manager) throws FileSystemException, MalformedURLException {
         manager.setDefaultProvider(new DefaultLocalFileProvider());
         manager.init();
         File testapp = new File("src/deploytest");
@@ -63,12 +121,13 @@
         return applicationFolder;
     }
 
-    private FileObject getApplicationArchive(DefaultFileSystemManager manager) throws FileSystemException {
+    private FileObject getApplicationArchive(final DefaultFileSystemManager manager, final String jarName) throws FileSystemException {
         manager.addProvider("file", new DefaultLocalFileProvider());
         manager.addProvider("zip", new ZipFileProvider());
         manager.init();
         File src = "" File("src");
-        FileObject applicationFolder = manager.resolveFile("zip:/" + src.getAbsolutePath() + "/deploytest.jar");
+        FileObject applicationFolder = manager.resolveFile("zip:/" + src.getAbsolutePath() + jarName);
         return applicationFolder;
     }
-}
\ No newline at end of file
+
+}
Modified: java/nanocontainer-sandbox/trunk/project.properties (2317 => 2318)
--- java/nanocontainer-sandbox/trunk/project.properties	2005-08-26 02:02:06 UTC (rev 2317)
+++ java/nanocontainer-sandbox/trunk/project.properties	2005-08-26 04:54:23 UTC (rev 2318)
@@ -35,7 +35,7 @@
 maven.multiproject.aggregateDir=components/
 maven.multiproject.includes=*/project.xml
 #the following fail and therefore are excluded
-maven.multiproject.excludes=idea/project.xml,deployer/project.xml
+maven.multiproject.excludes=idea/project.xml
 maven.simian.linecount = 4
 maven.license.licenseFile=${maven.multiproject.basedir}/LICENSE.txt
 

Was this page helpful?
Yes No
Thread at a glance:

Previous Message by Date: click to view message preview

[picocontainer-scm] [jira] Commented: (PICO-251) DecoratingCA may not extend MonitoringCA

[ http://jira.codehaus.org/browse/PICO-251?page=comments#action_45241 ] peter royal commented on PICO-251: ---------------------------------- DecoratingCA does delegate a new CM to its delegate. Thus this issue is resolved? > DecoratingCA may not extend MonitoringCA > ---------------------------------------- > > Key: PICO-251 > URL: http://jira.codehaus.org/browse/PICO-251 > Project: PicoContainer > Type: Bug > Components: PicoContainer (Java) > Versions: 1.2 > Reporter: Joerg Schaible > Assignee: Mauro Talevi > Fix For: 1.2 > > > The DecoratingCA must delegate the new CM to its delegate, otherwise the Pico > cannot exchange the monitors. Therefore DecoratingCA may not extend > MonitoringCA, but implement only CMStrategy. In case of a change if has to > test its delegate for implementing CMStrategy also. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira

Next Message by Date: click to view message preview

[picocontainer-scm] [jira] Closed: (NANOSANDBOX-7) Deployer Invalidly traverses too deep looking for nanoconainer.*

[ http://jira.codehaus.org/browse/NANOSANDBOX-7?page=all ] Paul Hammant closed NANOSANDBOX-7: ---------------------------------- Resolution: Fixed applied > Deployer Invalidly traverses too deep looking for nanoconainer.* > ---------------------------------------------------------------- > > Key: NANOSANDBOX-7 > URL: http://jira.codehaus.org/browse/NANOSANDBOX-7 > Project: NanoContainer Sandbox > Type: Bug > Components: deployer > Environment: Windows JDK 1.5. Using Latest SVN code. > Reporter: Michael Rimov > Assignee: Joerg Schaible > Priority: Minor > Attachments: deploy-patch.zip, deployer-patch.zip > > > A couple of issues with deployer: > It would: > 1 - Search indefinitely deep and only return the first in the array. So > something in the lines of: > > META-INF > |-nanocontainer.groovy > |-.svn > |--nanocontainer.svn.props-base > Would return nanocontainer.svn.props-base instead of the correct file. Fix > only searches one layer deep. (Tested against VFS's SVN source base) > 2 - Null Pointer Exception if the wrong type of file extension is found. > (Given the above case, I bet you can't figure out why I found this bug ;) ) > Fixed. > 3 - Added test cases for badly formed jar files and badly named scripts. > (malformed-deployment.jar and badbuildscriptdeploy.jar respectively) > 4 - Added a constructor to NanoContainerDeployer to not have to hard code the > configuration script name. (before hardcoded to 'nanocontainer') -- the old > default is provided. > The entire zip file should be able to drop into > nanocontainer-sandbox\trunk\deployer\src and test case jars and patch files > should match up. I'll be happy to modify the exceptio handling as per my > post to the list and/or modify anything else in the design mods. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira

Previous Message by Thread: click to view message preview

[picocontainer-scm] [jira] Closed: (PICO-233) Have BeanPropertyComponentAdapter handle real objects and not just strings

[ http://jira.codehaus.org/browse/PICO-233?page=all ] peter royal closed PICO-233: ---------------------------- Resolution: Fixed Fix Version: 1.2 patch applied, please cross-check. thanks! > Have BeanPropertyComponentAdapter handle real objects and not just strings > -------------------------------------------------------------------------- > > Key: PICO-233 > URL: http://jira.codehaus.org/browse/PICO-233 > Project: PicoContainer > Type: New Feature > Components: PicoContainer (Java) > Versions: 1.2 > Reporter: Michael Rimov > Assignee: peter royal > Fix For: 1.2 > Attachments: BeanPropertyComponentAdapter-patch.zip, > BeanPropertyComponentAdapter.diff, BeanPropertyComponentAdapter.diff > > > I've attached a patch to BeanPropertyComponentAdapter to allow it to handle > real objects for parameters (such as Date objects, Calendars, etc). > 3 Test Cases attached as well. The main one (for explanation's sake is:) > public void testSetBeanPropertiesWithValueObjects() { > BeanPropertyComponentAdapterFactory factory = > (BeanPropertyComponentAdapterFactory) createComponentAdapterFactory(); > Map properties = new HashMap(); > properties.put("lenient", Boolean.FALSE); > properties.put("2DigitYearStart", new Date(0)); > BeanPropertyComponentAdapter adapter = > (BeanPropertyComponentAdapter)factory.createComponentAdapter(SimpleDateFormat.class,SimpleDateFormat.class,null); > adapter.setProperties(properties); > picoContainer.registerComponent(adapter); > SimpleDateFormat dateFormat = > (SimpleDateFormat)picoContainer.getComponentInstance(SimpleDateFormat.class); > assertNotNull(dateFormat); > assertEquals(false, dateFormat.isLenient()); > assertEquals(new Date(0), dateFormat.get2DigitYearStart()); > } -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira

Next Message by Thread: click to view message preview

[picocontainer-scm] [jira] Closed: (NANOSANDBOX-7) Deployer Invalidly traverses too deep looking for nanoconainer.*

[ http://jira.codehaus.org/browse/NANOSANDBOX-7?page=all ] Paul Hammant closed NANOSANDBOX-7: ---------------------------------- Resolution: Fixed applied > Deployer Invalidly traverses too deep looking for nanoconainer.* > ---------------------------------------------------------------- > > Key: NANOSANDBOX-7 > URL: http://jira.codehaus.org/browse/NANOSANDBOX-7 > Project: NanoContainer Sandbox > Type: Bug > Components: deployer > Environment: Windows JDK 1.5. Using Latest SVN code. > Reporter: Michael Rimov > Assignee: Joerg Schaible > Priority: Minor > Attachments: deploy-patch.zip, deployer-patch.zip > > > A couple of issues with deployer: > It would: > 1 - Search indefinitely deep and only return the first in the array. So > something in the lines of: > > META-INF > |-nanocontainer.groovy > |-.svn > |--nanocontainer.svn.props-base > Would return nanocontainer.svn.props-base instead of the correct file. Fix > only searches one layer deep. (Tested against VFS's SVN source base) > 2 - Null Pointer Exception if the wrong type of file extension is found. > (Given the above case, I bet you can't figure out why I found this bug ;) ) > Fixed. > 3 - Added test cases for badly formed jar files and badly named scripts. > (malformed-deployment.jar and badbuildscriptdeploy.jar respectively) > 4 - Added a constructor to NanoContainerDeployer to not have to hard code the > configuration script name. (before hardcoded to 'nanocontainer') -- the old > default is provided. > The entire zip file should be able to drop into > nanocontainer-sandbox\trunk\deployer\src and test case jars and patch files > should match up. I'll be happy to modify the exceptio handling as per my > post to the list and/or modify anything else in the design mods. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira
Sign up for updates to this mailing list. email:
Loading Comments...
Home | News | Patents | Sitemap | FAQ | advertise

Advertising by