[jboss-cvs] JBossAS SVN: r70174 - in projects/microcontainer/trunk/osgi-int: src/main/org/jboss/osgi/plugins/facade and 3 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Feb 27 09:30:33 EST 2008


Author: johnbailey
Date: 2008-02-27 09:30:33 -0500 (Wed, 27 Feb 2008)
New Revision: 70174

Added:
   projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/helpers/DeploymentStage2BundleState.java
   projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/helpers/DeploymentStage2BundleStateMapper.java
Removed:
   projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/helpers/ControllerState2BundleState.java
   projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/helpers/ControllerState2BundleStateMapper.java
Modified:
   projects/microcontainer/trunk/osgi-int/.settings/
   projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/BundleImpl.java
   projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/BundleState.java
   projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/helpers/BundleHeader.java
   projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/helpers/BundleHeaderBuilder.java
   projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/helpers/BundleHeaderBuilders.java
   projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/helpers/BundleHeaders.java
   projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/helpers/ExportPackageHeaderBuilder.java
   projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/helpers/ImportPackageHeaderBuilder.java
   projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/BundleHeaderTestCase.java
   projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/BundleImplTestCase.java
   projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/BundleTestSuite.java
   projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/support/TestMainDeployer.java
Log:
1.  Added updated License
2.  Mapped Bundle states using DeploymentStages


Property changes on: projects/microcontainer/trunk/osgi-int/.settings
___________________________________________________________________
Name: svn:ignore
   + org.eclipse.jdt.ui.prefs


Modified: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/BundleImpl.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/BundleImpl.java	2008-02-27 14:15:54 UTC (rev 70173)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/BundleImpl.java	2008-02-27 14:30:33 UTC (rev 70174)
@@ -1,24 +1,24 @@
 /*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
+* JBoss, Home of Professional Open Source
+* Copyright 2008, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
 package org.jboss.osgi.plugins.facade;
 
 import java.io.IOException;
@@ -35,8 +35,9 @@
 import org.jboss.deployers.spi.DeploymentException;
 import org.jboss.deployers.spi.deployer.DeploymentStages;
 import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.logging.Logger;
 import org.jboss.osgi.plugins.facade.helpers.BundleHeaders;
-import org.jboss.osgi.plugins.facade.helpers.ControllerState2BundleStateMapper;
+import org.jboss.osgi.plugins.facade.helpers.DeploymentStage2BundleStateMapper;
 import org.osgi.framework.AdminPermission;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleException;
@@ -50,23 +51,48 @@
  */
 public class BundleImpl implements Bundle
 {
+
+   /** The log */
+   private static final Logger log = Logger.getLogger(BundleImpl.class);
+
    protected DeploymentUnit unit;
 
    protected BundleHeaders bundleHeaders;
 
    private long lastModified = -1;
-   
+
+   /**
+    * 
+    * Create a new BundleImpl.
+    * 
+    * @param unit
+    */
    public BundleImpl(DeploymentUnit unit)
    {
       this.unit = unit;
-      
+
    }
 
+   /**
+    *   Get Bundle state based on the current DeployentStage
+    */
    public int getState()
    {
-      return ControllerState2BundleStateMapper.mapBundleState(getControllerContext().getState()).getState();
+      try
+      {
+         return DeploymentStage2BundleStateMapper.mapBundleState(
+               unit.getMainDeployer().getDeploymentStage(unit.getName())).getState();
+      }
+      catch (DeploymentException e)
+      {
+         log.error("Unable to get DeploymentStage for DeploymentUnit " + unit.getName(), e);
+         return Bundle.INSTALLED;
+      }
    }
 
+   /**
+    * Deligate to the MainDeployer to start the Bundle
+    */
    public void start() throws BundleException
    {
       checkPermission(AdminPermission.EXECUTE);

Modified: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/BundleState.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/BundleState.java	2008-02-27 14:15:54 UTC (rev 70173)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/BundleState.java	2008-02-27 14:30:33 UTC (rev 70174)
@@ -1,6 +1,6 @@
 /*
  * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * Copyright 2008, JBoss Inc., and individual contributors as indicated
  * by the @authors tag. See the copyright.txt in the distribution for a
  * full listing of individual contributors.
  *
@@ -18,7 +18,7 @@
  * License along with this software; if not, write to the Free
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
+*/
 package org.jboss.osgi.plugins.facade;
 
 import org.osgi.framework.Bundle;

Modified: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/helpers/BundleHeader.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/helpers/BundleHeader.java	2008-02-27 14:15:54 UTC (rev 70173)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/helpers/BundleHeader.java	2008-02-27 14:30:33 UTC (rev 70174)
@@ -1,6 +1,6 @@
 /*
  * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * Copyright 2008, JBoss Inc., and individual contributors as indicated
  * by the @authors tag. See the copyright.txt in the distribution for a
  * full listing of individual contributors.
  *
@@ -18,7 +18,7 @@
  * License along with this software; if not, write to the Free
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
+*/
 package org.jboss.osgi.plugins.facade.helpers;
 
 /**

Modified: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/helpers/BundleHeaderBuilder.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/helpers/BundleHeaderBuilder.java	2008-02-27 14:15:54 UTC (rev 70173)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/helpers/BundleHeaderBuilder.java	2008-02-27 14:30:33 UTC (rev 70174)
@@ -1,6 +1,6 @@
 /*
  * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * Copyright 2008, JBoss Inc., and individual contributors as indicated
  * by the @authors tag. See the copyright.txt in the distribution for a
  * full listing of individual contributors.
  *
@@ -18,7 +18,7 @@
  * License along with this software; if not, write to the Free
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
+*/
 package org.jboss.osgi.plugins.facade.helpers;
 
 

Modified: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/helpers/BundleHeaderBuilders.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/helpers/BundleHeaderBuilders.java	2008-02-27 14:15:54 UTC (rev 70173)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/helpers/BundleHeaderBuilders.java	2008-02-27 14:30:33 UTC (rev 70174)
@@ -1,6 +1,6 @@
 /*
  * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * Copyright 2008, JBoss Inc., and individual contributors as indicated
  * by the @authors tag. See the copyright.txt in the distribution for a
  * full listing of individual contributors.
  *
@@ -18,7 +18,7 @@
  * License along with this software; if not, write to the Free
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
+*/
 package org.jboss.osgi.plugins.facade.helpers;
 
 /**

Modified: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/helpers/BundleHeaders.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/helpers/BundleHeaders.java	2008-02-27 14:15:54 UTC (rev 70173)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/helpers/BundleHeaders.java	2008-02-27 14:30:33 UTC (rev 70174)
@@ -1,6 +1,6 @@
 /*
  * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * Copyright 2008, JBoss Inc., and individual contributors as indicated
  * by the @authors tag. See the copyright.txt in the distribution for a
  * full listing of individual contributors.
  *
@@ -18,7 +18,7 @@
  * License along with this software; if not, write to the Free
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
+*/
 package org.jboss.osgi.plugins.facade.helpers;
 
 import java.util.ArrayList;

Deleted: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/helpers/ControllerState2BundleState.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/helpers/ControllerState2BundleState.java	2008-02-27 14:15:54 UTC (rev 70173)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/helpers/ControllerState2BundleState.java	2008-02-27 14:30:33 UTC (rev 70174)
@@ -1,72 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.osgi.plugins.facade.helpers;
-
-import org.jboss.dependency.spi.ControllerState;
-import org.jboss.osgi.plugins.facade.BundleState;
-
-/**
- * 
- * A BundleState2DeploymentStage - Maps a DeploymentStage to BundleState
- * 
- * @author <a href="baileyje at gmail.com">John Bailey</a>
- * @version $Revision: 1.1 $
- */
-public class ControllerState2BundleState
-{
-   private final ControllerState controllerState;
-   private final BundleState bundleState;
-   
-   /**
-    * 
-    * Create a new DeploymentStage2BundleState.
-    * 
-    * @param deploymentStage
-    * @param bundleState
-    */
-   public ControllerState2BundleState(ControllerState controllerState, BundleState bundleState)
-   {
-      super();
-      this.controllerState = controllerState;
-      this.bundleState = bundleState;
-   }
-   
-   /**
-    * Get controllerState
-    * 
-    * @return
-    */
-   public ControllerState getControllerState()
-   {
-      return controllerState;
-   }
-   
-   /**
-    * Get BundleState
-    * 
-    * @return
-    */
-   public BundleState getBundleState()
-   {
-      return bundleState;
-   }
-}

Deleted: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/helpers/ControllerState2BundleStateMapper.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/helpers/ControllerState2BundleStateMapper.java	2008-02-27 14:15:54 UTC (rev 70173)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/helpers/ControllerState2BundleStateMapper.java	2008-02-27 14:30:33 UTC (rev 70174)
@@ -1,72 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.osgi.plugins.facade.helpers;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.jboss.dependency.spi.ControllerState;
-import org.jboss.osgi.plugins.facade.BundleState;
-
-/**
- * 
- * A DeploymentStage2BundleStateMapper - Maps a DeploymentStage to a BundleState
- * 
- * @author <a href="baileyje at gmail.com">John Bailey</a>
- * @version $Revision: 1.1 $
- */
-public class ControllerState2BundleStateMapper
-{
-
-   private static List<ControllerState2BundleState> deploymentStage2BundleStates = new ArrayList<ControllerState2BundleState>();
-   static
-   {
-      deploymentStage2BundleStates.add(new ControllerState2BundleState(ControllerState.ERROR, BundleState.UNINSTALLED));
-      deploymentStage2BundleStates.add(new ControllerState2BundleState(ControllerState.NOT_INSTALLED, BundleState.INSTALLED));
-      deploymentStage2BundleStates.add(new ControllerState2BundleState(ControllerState.PRE_INSTALL, BundleState.INSTALLED));
-      deploymentStage2BundleStates.add(new ControllerState2BundleState(ControllerState.DESCRIBED, BundleState.INSTALLED));
-      deploymentStage2BundleStates.add(new ControllerState2BundleState(ControllerState.INSTANTIATED, BundleState.RESOLVED));
-      deploymentStage2BundleStates.add(new ControllerState2BundleState(ControllerState.CONFIGURED, BundleState.RESOLVED));
-      deploymentStage2BundleStates.add(new ControllerState2BundleState(ControllerState.CREATE, BundleState.RESOLVED));
-      deploymentStage2BundleStates.add(new ControllerState2BundleState(ControllerState.START, BundleState.STARTING));
-      deploymentStage2BundleStates.add(new ControllerState2BundleState(ControllerState.INSTALLED, BundleState.ACTIVE));
-   }
-
-   /**
-    * Given a DeploymentStage returns corresponding BundleState
-    * 
-    * @param controllerState
-    * @return BundleState
-    */
-   public static BundleState mapBundleState(final ControllerState controllerState)
-   {
-      for (ControllerState2BundleState deploymentStage2BundleState : deploymentStage2BundleStates)
-      {
-         if (deploymentStage2BundleState.getControllerState().equals(controllerState))
-         {
-            return deploymentStage2BundleState.getBundleState();
-         }
-      }
-      return BundleState.UNINSTALLED;
-   }
-
-}

Copied: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/helpers/DeploymentStage2BundleState.java (from rev 70172, projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/helpers/ControllerState2BundleState.java)
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/helpers/DeploymentStage2BundleState.java	                        (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/helpers/DeploymentStage2BundleState.java	2008-02-27 14:30:33 UTC (rev 70174)
@@ -0,0 +1,71 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.osgi.plugins.facade.helpers;
+
+import org.jboss.deployers.spi.deployer.DeploymentStage;
+import org.jboss.osgi.plugins.facade.BundleState;
+
+/**
+ * 
+ * A DeploymentStage2BundleState - Maps a DeploymentStage to BundleState
+ * 
+ * @author <a href="baileyje at gmail.com">John Bailey</a>
+ * @version $Revision: 1.1 $
+ */
+public class DeploymentStage2BundleState
+{
+   private final DeploymentStage deploymentStage;
+   private final BundleState bundleState;
+   
+   /**
+    * 
+    * Create a new DeploymentStage2BundleState.
+    * 
+    * @param deploymentStage
+    * @param bundleState
+    */
+   public DeploymentStage2BundleState(DeploymentStage deploymentStage, BundleState bundleState)
+   {
+      this.deploymentStage = deploymentStage;
+      this.bundleState = bundleState;
+   }
+   
+   /**
+    * Get deploymentStage
+    * 
+    * @return
+    */
+   public DeploymentStage getDeploymentStage()
+   {
+      return deploymentStage;
+   }
+   
+   /**
+    * Get BundleState
+    * 
+    * @return
+    */
+   public BundleState getBundleState()
+   {
+      return bundleState;
+   }
+}


Property changes on: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/helpers/DeploymentStage2BundleState.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Copied: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/helpers/DeploymentStage2BundleStateMapper.java (from rev 70172, projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/helpers/ControllerState2BundleStateMapper.java)
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/helpers/DeploymentStage2BundleStateMapper.java	                        (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/helpers/DeploymentStage2BundleStateMapper.java	2008-02-27 14:30:33 UTC (rev 70174)
@@ -0,0 +1,68 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.osgi.plugins.facade.helpers;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.deployers.spi.deployer.DeploymentStage;
+import org.jboss.deployers.spi.deployer.DeploymentStages;
+import org.jboss.osgi.plugins.facade.BundleState;
+
+/**
+ * 
+ * A DeploymentStage2BundleStateMapper - Maps a DeploymentStage to a BundleState
+ * 
+ * @author <a href="baileyje at gmail.com">John Bailey</a>
+ * @version $Revision: 1.1 $
+ */
+public class DeploymentStage2BundleStateMapper
+{
+
+   private static List<DeploymentStage2BundleState> deploymentStage2BundleStates = new ArrayList<DeploymentStage2BundleState>();
+   static
+   {
+      deploymentStage2BundleStates.add(new DeploymentStage2BundleState(DeploymentStages.NOT_INSTALLED, BundleState.UNINSTALLED));
+      deploymentStage2BundleStates.add(new DeploymentStage2BundleState(DeploymentStages.CLASSLOADER, BundleState.RESOLVED));
+      deploymentStage2BundleStates.add(new DeploymentStage2BundleState(DeploymentStages.REAL, BundleState.STARTING));
+      deploymentStage2BundleStates.add(new DeploymentStage2BundleState(DeploymentStages.INSTALLED, BundleState.ACTIVE));
+   }
+
+   /**
+    * Given a DeploymentStage returns corresponding BundleState
+    * 
+    * @param controllerState
+    * @return BundleState
+    */
+   public static BundleState mapBundleState(final DeploymentStage controllerState)
+   {
+      for (DeploymentStage2BundleState deploymentStage2BundleState : deploymentStage2BundleStates)
+      {
+         if (deploymentStage2BundleState.getDeploymentStage().equals(controllerState))
+         {
+            return deploymentStage2BundleState.getBundleState();
+         }
+      }
+      return BundleState.UNINSTALLED;
+   }
+
+}


Property changes on: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/helpers/DeploymentStage2BundleStateMapper.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/helpers/ExportPackageHeaderBuilder.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/helpers/ExportPackageHeaderBuilder.java	2008-02-27 14:15:54 UTC (rev 70173)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/helpers/ExportPackageHeaderBuilder.java	2008-02-27 14:30:33 UTC (rev 70174)
@@ -1,9 +1,24 @@
 /*
- * JBoss, the OpenSource J2EE webOS
- * 
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
 package org.jboss.osgi.plugins.facade.helpers;
 
 import java.util.ArrayList;

Modified: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/helpers/ImportPackageHeaderBuilder.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/helpers/ImportPackageHeaderBuilder.java	2008-02-27 14:15:54 UTC (rev 70173)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/helpers/ImportPackageHeaderBuilder.java	2008-02-27 14:30:33 UTC (rev 70174)
@@ -1,9 +1,24 @@
 /*
- * JBoss, the OpenSource J2EE webOS
- * 
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
 package org.jboss.osgi.plugins.facade.helpers;
 
 import java.util.ArrayList;

Modified: projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/BundleHeaderTestCase.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/BundleHeaderTestCase.java	2008-02-27 14:15:54 UTC (rev 70173)
+++ projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/BundleHeaderTestCase.java	2008-02-27 14:30:33 UTC (rev 70174)
@@ -1,3 +1,24 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
 package org.jboss.test.bundle;
 
 import java.util.Dictionary;
@@ -17,10 +38,23 @@
 import org.jboss.test.bundle.metadata.AbstractManifestTestCase;
 import org.osgi.framework.Constants;
 
+/**
+ * 
+ * A BundleHeaderTestCase.
+ * 
+ * @author <a href="baileyje at gmail.com">John Bailey</a>
+ * @version $Revision: 1.1 $
+ */
 public class BundleHeaderTestCase extends AbstractManifestTestCase
 {
    private BundleHeaders bundleHeaders;
 
+   /**
+    * 
+    * Create a new BundleHeaderTestCase.
+    * 
+    * @param name
+    */
    public BundleHeaderTestCase(String name)
    {
       super(name);
@@ -50,7 +84,11 @@
       
       bundleHeaders = new BundleHeaders(deploymentUnit);
    }
-
+   /**
+    * Test getting BundleHeaders as a Dictionary
+    * 
+    * @throws Exception
+    */
    @SuppressWarnings("unchecked")
    public void testToDictionary() throws Exception
    {

Modified: projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/BundleImplTestCase.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/BundleImplTestCase.java	2008-02-27 14:15:54 UTC (rev 70173)
+++ projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/BundleImplTestCase.java	2008-02-27 14:30:33 UTC (rev 70174)
@@ -1,3 +1,24 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
 package org.jboss.test.bundle;
 
 
@@ -4,7 +25,6 @@
 import junit.framework.Test;
 
 import org.jboss.dependency.spi.ControllerContext;
-import org.jboss.dependency.spi.ControllerState;
 import org.jboss.deployers.client.spi.main.MainDeployer;
 import org.jboss.deployers.spi.deployer.DeploymentStage;
 import org.jboss.deployers.spi.deployer.DeploymentStages;
@@ -18,6 +38,13 @@
 import org.jboss.test.bundle.support.TestMainDeployer;
 import org.osgi.framework.Bundle;
 
+/**
+ * 
+ * A BundleImplTestCase.
+ * 
+ * @author <a href="baileyje at gmail.com">John Bailey</a>
+ * @version $Revision: 1.1 $
+ */
 public class BundleImplTestCase extends AbstractManifestTestCase
 {
    private Bundle bundle;
@@ -52,47 +79,53 @@
       bundle = new BundleImpl(deploymentUnit);
    }
 
+   /** 
+    * Test the getState method.  Should correctly call DeploymentStage2BundleStateMapper
+    * 
+    * @throws Exception
+    */
    public void testGetBundleState() throws Exception
    {
-      controllerContext.setState(ControllerState.ERROR);
+      mainDeployer.change(deploymentUnit.getName(), DeploymentStages.NOT_INSTALLED);
       assertEquals(Bundle.UNINSTALLED, bundle.getState());
 
-      controllerContext.setState(ControllerState.NOT_INSTALLED);
-      assertEquals(Bundle.INSTALLED, bundle.getState());
-
-      controllerContext.setState(ControllerState.PRE_INSTALL);
-      assertEquals(Bundle.INSTALLED, bundle.getState());
-
-      controllerContext.setState(ControllerState.DESCRIBED);
-      assertEquals(Bundle.INSTALLED, bundle.getState());
-
-      controllerContext.setState(ControllerState.INSTANTIATED);
+      mainDeployer.change(deploymentUnit.getName(), DeploymentStages.CLASSLOADER);
       assertEquals(Bundle.RESOLVED, bundle.getState());
 
-      controllerContext.setState(ControllerState.CONFIGURED);
-      assertEquals(Bundle.RESOLVED, bundle.getState());
-
-      controllerContext.setState(ControllerState.CREATE);
-      assertEquals(Bundle.RESOLVED, bundle.getState());
-
-      controllerContext.setState(ControllerState.START);
+      mainDeployer.change(deploymentUnit.getName(), DeploymentStages.REAL);
       assertEquals(Bundle.STARTING, bundle.getState());
 
-      controllerContext.setState(ControllerState.INSTALLED);
+      mainDeployer.change(deploymentUnit.getName(), DeploymentStages.INSTALLED);
       assertEquals(Bundle.ACTIVE, bundle.getState());
    }
 
+   /**
+    * Returns the DeploymentContext.name as the Unique name
+    * 
+    * @throws Exception
+    */
    public void testGetSymbolicName() throws Exception
    {
       assertEquals("UniqueName", bundle.getSymbolicName());
    }
 
+   /**
+    * Verifies the Bundle.start method calls the MainDeployer.change method with the INSTALL DeploymentStage
+    * 
+    * @throws Exception
+    */
    public void testStartBundle() throws Exception
    {
       bundle.start();
       assertChangeRequested(deploymentUnit.getName(), DeploymentStages.INSTALLED);
    }
 
+   /**
+    * Assert the correct change was requested of the MainDeployer
+    * 
+    * @param deploymentName
+    * @param stage
+    */
    public void assertChangeRequested(String deploymentName, DeploymentStage stage)
    {
       assertTrue(mainDeployer.changeCalled(deploymentName, stage));

Modified: projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/BundleTestSuite.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/BundleTestSuite.java	2008-02-27 14:15:54 UTC (rev 70173)
+++ projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/BundleTestSuite.java	2008-02-27 14:30:33 UTC (rev 70174)
@@ -1,23 +1,23 @@
 /*
-* JBoss, Home of Professional Open Source
-* Copyright 2006, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */
 package org.jboss.test.bundle;
 

Modified: projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/support/TestMainDeployer.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/support/TestMainDeployer.java	2008-02-27 14:15:54 UTC (rev 70173)
+++ projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/support/TestMainDeployer.java	2008-02-27 14:30:33 UTC (rev 70174)
@@ -43,15 +43,16 @@
  */
 public class TestMainDeployer implements MainDeployer
 {
+   private DeploymentStage currentStage;
+   private Map<String, DeploymentStage> changesRequested = new HashMap<String, DeploymentStage>();
 
    /** Create a new TestMainDeployer.
     */
-   public TestMainDeployer()
+   public TestMainDeployer() 
    {
+      
    }
 
-   private Map<String, DeploymentStage> changesRequested = new HashMap<String, DeploymentStage>();
-
    public void shutdown()
    {
 
@@ -62,14 +63,18 @@
 
    }
 
+   /** 
+    * Add requested stage to map, and hold on as the current stage 
+    */
    public void change(String deploymentName, DeploymentStage stage) throws DeploymentException
    {
+      currentStage = stage;
       changesRequested.put(deploymentName, stage);
    }
 
    public DeploymentStage getDeploymentStage(String deploymentName) throws DeploymentException
    {
-      return changesRequested.get(deploymentName);
+      return currentStage;
    }
 
    public void checkComplete() throws DeploymentException
@@ -165,5 +170,7 @@
       }
       return false;
    }
+   
+   
 
 }
\ No newline at end of file




More information about the jboss-cvs-commits mailing list