[jboss-osgi-commits] JBoss-OSGI SVN: r101776 - in projects/jboss-osgi/projects/runtime/framework/trunk: vfs21/src/main/java/org/jboss/osgi/framework/classloading and 1 other directories.

jboss-osgi-commits at lists.jboss.org jboss-osgi-commits at lists.jboss.org
Wed Mar 3 09:59:37 EST 2010


Author: thomas.diesler at jboss.com
Date: 2010-03-03 09:59:36 -0500 (Wed, 03 Mar 2010)
New Revision: 101776

Added:
   projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/deployers/AbstractDeployment.java
   projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/deployers/DeploymentAdaptor.java
   projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/main/java/org/jboss/osgi/framework/deployers/DeploymentAdaptor21.java
Modified:
   projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderPolicy.java
   projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/main/java/org/jboss/osgi/framework/deployers/OSGiFragmentAttachmentDeployer.java
Log:
Add Deployment abstraction

Added: projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/deployers/AbstractDeployment.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/deployers/AbstractDeployment.java	                        (rev 0)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/deployers/AbstractDeployment.java	2010-03-03 14:59:36 UTC (rev 101776)
@@ -0,0 +1,69 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file 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.framework.deployers;
+
+// $Id: AbstractOSGiClassLoadingDeployer.java 101391 2010-02-24 12:58:50Z thomas.diesler at jboss.com $
+
+import org.jboss.deployers.client.spi.Deployment;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.osgi.vfs.VirtualFile;
+
+/**
+ * The AbstractDeployment delegates to the jboss-vfs specific {@link DeploymentAdaptor}.
+ * 
+ * @author Thomas.Diesler at jboss.com
+ * @since 03-Mar-2010
+ */
+public abstract class AbstractDeployment
+{
+   private static DeploymentAdaptor adaptor;
+
+   public static Deployment createDeployment(VirtualFile root)
+   {
+      return getDeploymentAdaptor().createDeployment(root);
+   }
+
+   public static VirtualFile getRoot(DeploymentUnit unit)
+   {
+      return getDeploymentAdaptor().getRoot(unit);
+   }
+   
+   @SuppressWarnings("unchecked")
+   private static DeploymentAdaptor getDeploymentAdaptor()
+   {
+      if (adaptor == null)
+      {
+         try
+         {
+            String classname = "org.jboss.osgi.framework.deployers.DeploymentAdaptor21";
+            ClassLoader classLoader = AbstractDeployment.class.getClassLoader();
+            Class<DeploymentAdaptor> clazz = (Class<DeploymentAdaptor>)classLoader.loadClass(classname);
+            adaptor = clazz.newInstance();
+         }
+         catch (Exception e)
+         {
+            throw new IllegalStateException("Cannot load DeploymentAdaptor");
+         }
+      }
+      return adaptor;
+   }
+}

Added: projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/deployers/DeploymentAdaptor.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/deployers/DeploymentAdaptor.java	                        (rev 0)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/deployers/DeploymentAdaptor.java	2010-03-03 14:59:36 UTC (rev 101776)
@@ -0,0 +1,41 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file 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.framework.deployers;
+
+// $Id: AbstractOSGiClassLoadingDeployer.java 101391 2010-02-24 12:58:50Z thomas.diesler at jboss.com $
+
+import org.jboss.deployers.client.spi.Deployment;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.osgi.vfs.VirtualFile;
+
+/**
+ * An abstraction of the VFSDeploymentFactory. 
+ * 
+ * @author Thomas.Diesler at jboss.com
+ * @since 03-Mar-2010
+ */
+public interface DeploymentAdaptor 
+{
+   Deployment createDeployment(VirtualFile root);
+
+   VirtualFile getRoot(DeploymentUnit unit);
+}

Modified: projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderPolicy.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderPolicy.java	2010-03-03 14:45:40 UTC (rev 101775)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderPolicy.java	2010-03-03 14:59:36 UTC (rev 101776)
@@ -45,6 +45,7 @@
 import org.jboss.osgi.framework.metadata.NativeLibrary;
 import org.jboss.osgi.framework.metadata.NativeLibraryMetaData;
 import org.jboss.osgi.framework.plugins.BundleStoragePlugin;
+import org.jboss.osgi.vfs.AbstractVFS;
 import org.jboss.virtual.VFSUtils;
 import org.jboss.virtual.VirtualFile;
 
@@ -251,7 +252,8 @@
          if (libraryFile == null)
          {
             // Get the virtual file for entry for the library
-            VirtualFile fileSource = bundleState.getRoot().getChild(libpath);
+            VirtualFile root = (VirtualFile)AbstractVFS.adapt(bundleState.getRoot());
+            VirtualFile fileSource = root.getChild(libpath);
             
             // Create a unique local file location
             libraryFile = getUniqueLibraryFile(bundleState, libpath);

Added: projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/main/java/org/jboss/osgi/framework/deployers/DeploymentAdaptor21.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/main/java/org/jboss/osgi/framework/deployers/DeploymentAdaptor21.java	                        (rev 0)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/main/java/org/jboss/osgi/framework/deployers/DeploymentAdaptor21.java	2010-03-03 14:59:36 UTC (rev 101776)
@@ -0,0 +1,52 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file 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.framework.deployers;
+
+// $Id: AbstractOSGiClassLoadingDeployer.java 101391 2010-02-24 12:58:50Z thomas.diesler at jboss.com $
+
+import org.jboss.deployers.client.spi.Deployment;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.deployers.vfs.spi.client.VFSDeploymentFactory;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.osgi.vfs.AbstractVFS;
+import org.jboss.osgi.vfs.VirtualFile;
+
+/**
+ * An abstraction of the VFSDeploymentFactory for jboss-vfs-2.1.x 
+ * 
+ * @author Thomas.Diesler at jboss.com
+ * @since 03-Mar-2010
+ */
+public class DeploymentAdaptor21 implements DeploymentAdaptor 
+{
+   public Deployment createDeployment(VirtualFile root)
+   {
+      VFSDeploymentFactory factory = VFSDeploymentFactory.getInstance();
+      return factory.createVFSDeployment((org.jboss.virtual.VirtualFile)AbstractVFS.adapt(root));
+   }
+
+   public VirtualFile getRoot(DeploymentUnit unit)
+   {
+      VFSDeploymentUnit vfsUnit = (VFSDeploymentUnit)unit;
+      return AbstractVFS.adapt(vfsUnit.getRoot());
+   }
+}

Modified: projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/main/java/org/jboss/osgi/framework/deployers/OSGiFragmentAttachmentDeployer.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/main/java/org/jboss/osgi/framework/deployers/OSGiFragmentAttachmentDeployer.java	2010-03-03 14:45:40 UTC (rev 101775)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/main/java/org/jboss/osgi/framework/deployers/OSGiFragmentAttachmentDeployer.java	2010-03-03 14:59:36 UTC (rev 101776)
@@ -34,6 +34,8 @@
 import org.jboss.osgi.framework.bundle.OSGiBundleState;
 import org.jboss.osgi.framework.bundle.OSGiFragmentState;
 import org.jboss.osgi.framework.classloading.OSGiClassLoaderPolicy;
+import org.jboss.osgi.vfs.AbstractVFS;
+import org.jboss.virtual.VirtualFile;
 import org.osgi.framework.Bundle;
 
 /**
@@ -94,7 +96,7 @@
          OSGiBundleState hostState = fragState.getFragmentHost();
          DeploymentUnit hostUnit = hostState.getDeploymentUnit();
          OSGiClassLoaderPolicy hostPolicy = (OSGiClassLoaderPolicy)hostUnit.getAttachment(ClassLoaderPolicy.class);
-         hostPolicy.attachFragment(fragState.getRoot());
+         hostPolicy.attachFragment((VirtualFile)AbstractVFS.adapt(fragState.getRoot()));
       }
    }
 }



More information about the jboss-osgi-commits mailing list