[jboss-cvs] JBossAS SVN: r99155 - in projects/jboss-osgi/projects/runtime/framework/trunk/src: main/java/org/jboss/osgi/framework/bundle and 3 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Jan 8 06:55:24 EST 2010
Author: thomas.diesler at jboss.com
Date: 2010-01-08 06:55:23 -0500 (Fri, 08 Jan 2010)
New Revision: 99155
Added:
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoadingMetaData.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiFragmentAttachmentDeployer.java
Modified:
projects/jboss-osgi/projects/runtime/framework/trunk/src/etc/osgitck/jboss-osgi-bootstrap.xml
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/AbstractDeployedBundleState.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleState.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiFragmentState.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiBundleClassLoader.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/AbstractOSGiClassLoadingDeployer.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiBundleClassLoadingDeployer.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiBundleNativeCodeDeployer.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiFragmentClassLoadingDeployer.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bootstrap/jboss-osgi-bootstrap.xml
Log:
Fragments resolve a part of the host bundle.
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/etc/osgitck/jboss-osgi-bootstrap.xml
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/etc/osgitck/jboss-osgi-bootstrap.xml 2010-01-08 11:33:21 UTC (rev 99154)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/etc/osgitck/jboss-osgi-bootstrap.xml 2010-01-08 11:55:23 UTC (rev 99155)
@@ -168,6 +168,10 @@
<property name="domain"><inject bean="OSGiClassLoaderDomain"/></property>
<property name="factory"><inject bean="OSGiClassLoaderFactory"/></property>
</bean>
+ <bean name="OSGiFragmentClassLoadingDeployer" class="org.jboss.osgi.framework.deployers.OSGiFragmentClassLoadingDeployer">
+ <property name="domain"><inject bean="OSGiClassLoaderDomain"/></property>
+ </bean>
+ <bean name="OSGiFragmentAttachmentDeployer" class="org.jboss.osgi.framework.deployers.OSGiFragmentAttachmentDeployer"/>
<bean name="ClassLoading" class="org.jboss.classloading.spi.dependency.ClassLoading">
<incallback method="addModule" state="Configured" />
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/AbstractDeployedBundleState.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/AbstractDeployedBundleState.java 2010-01-08 11:33:21 UTC (rev 99154)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/AbstractDeployedBundleState.java 2010-01-08 11:55:23 UTC (rev 99155)
@@ -38,7 +38,7 @@
import org.osgi.framework.BundleException;
/**
- * The abstract state of a deployed bundle or fragment.
+ * The abstract state of a user deployed {@link Bundle} or Fragment.
*
* @author Thomas.Diesler at jboss.com
* @since 25-Dec-2009
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java 2010-01-08 11:33:21 UTC (rev 99154)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java 2010-01-08 11:55:23 UTC (rev 99155)
@@ -1046,29 +1046,6 @@
}
/**
- * Generate a name for the deployment unit
- *
- * todo some better solution
- *
- * @param unit the deployment unit
- * @return the name
- */
- protected String generateName(DeploymentUnit unit)
- {
- StringBuilder result = new StringBuilder();
- String name = unit.getName();
- for (int i = 0; i < name.length(); ++i)
- {
- char c = name.charAt(i);
- if (Character.isJavaIdentifierPart(c))
- result.append(c);
- else
- result.append('_');
- }
- return result.toString();
- }
-
- /**
* Add a bundle
*
* @param bundleState the bundle state
@@ -1364,7 +1341,11 @@
{
deployerClient.change(unit.getName(), DeploymentStages.CLASSLOADER);
deployerClient.checkComplete(unit.getName());
+
bundleState.changeState(Bundle.RESOLVED);
+ for (OSGiFragmentState fragment : bundleState.getAttachedFragments())
+ fragment.changeState(Bundle.RESOLVED);
+
return true;
}
catch (DeploymentException ex)
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleState.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleState.java 2010-01-08 11:33:21 UTC (rev 99154)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleState.java 2010-01-08 11:55:23 UTC (rev 99155)
@@ -21,16 +21,24 @@
*/
package org.jboss.osgi.framework.bundle;
+// $Id: $
+
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
+import java.util.Collections;
import java.util.Dictionary;
import java.util.Enumeration;
+import java.util.List;
import java.util.Set;
+import java.util.concurrent.CopyOnWriteArrayList;
+import org.jboss.classloading.spi.metadata.ClassLoadingMetaData;
import org.jboss.dependency.spi.ControllerContext;
import org.jboss.deployers.structure.spi.DeploymentUnit;
import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.osgi.framework.classloading.OSGiClassLoadingMetaData;
+import org.jboss.osgi.framework.classloading.OSGiClassLoadingMetaData.FragmentHost;
import org.jboss.osgi.framework.metadata.OSGiMetaData;
import org.jboss.osgi.framework.plugins.PackageAdminPlugin;
import org.jboss.virtual.VirtualFile;
@@ -39,9 +47,10 @@
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
+import org.osgi.framework.Version;
/**
- * BundleState.
+ * The state of a user deployed {@link Bundle} and its associated {@link BundleContext}.
*
* @author <a href="adrian at jboss.com">Adrian Brock</a>
* @author Thomas.Diesler at jboss.com
@@ -50,6 +59,9 @@
*/
public class OSGiBundleState extends AbstractDeployedBundleState
{
+ // The list of attached fragments
+ private List<OSGiFragmentState> attachedFragments = new CopyOnWriteArrayList<OSGiFragmentState>();
+
/**
* Create a new BundleState.
*
@@ -73,12 +85,52 @@
return (OSGiBundleState)bundle;
}
-
+
+ public List<OSGiFragmentState> getAttachedFragments()
+ {
+ return Collections.unmodifiableList(attachedFragments);
+ }
+
+ public boolean isFragmentAttachable(OSGiFragmentState fragmentState)
+ {
+ String hostName = getSymbolicName();
+ Version hostVersion = getVersion();
+
+ FragmentHost fragmentHost = fragmentState.getFragmentHost();
+ if (hostName.equals(fragmentHost.getSymbolicName()) == false)
+ return false;
+
+ Version version = fragmentHost.getBundleVersion();
+ if (version != null && hostVersion.equals(version) == false)
+ return false;
+
+ return true;
+ }
+
+ public void attachFragment(OSGiFragmentState fragmentState)
+ {
+ DeploymentUnit unit = getDeploymentUnit();
+ OSGiClassLoadingMetaData clMetaData = (OSGiClassLoadingMetaData)unit.getAttachment(ClassLoadingMetaData.class);
+ if (clMetaData == null)
+ throw new IllegalStateException("Cannot obtain ClassLoadingMetaData for: " + this);
+
+ DeploymentUnit fragUnit = fragmentState.getDeploymentUnit();
+ OSGiClassLoadingMetaData fragMetaData = (OSGiClassLoadingMetaData)fragUnit.getAttachment(ClassLoadingMetaData.class);
+ if (fragMetaData == null)
+ throw new IllegalStateException("Cannot obtain ClassLoadingMetaData for: " + fragmentState);
+
+ log.debug("Attach " + fragmentState + " -> " + this);
+ attachedFragments.add(fragmentState);
+
+ // attach classloading metadata to the hosts classloading metadata
+ clMetaData.attachedFragmentMetaData(fragMetaData);
+ }
+
public boolean isFragment()
{
return false;
}
-
+
protected Set<ControllerContext> getRegisteredContexts()
{
return getBundleManager().getRegisteredContext(this);
@@ -103,7 +155,7 @@
if (path.startsWith("/"))
path = path.substring(1);
-
+
return vfsDeploymentUnit.getResourceLoader().getResource(path);
}
return null;
@@ -424,7 +476,7 @@
// however the header values must only be available in the raw and default locale values
if (getState() == Bundle.UNINSTALLED)
return headersOnUninstall;
-
+
return super.getHeaders(locale);
}
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiFragmentState.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiFragmentState.java 2010-01-08 11:33:21 UTC (rev 99154)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiFragmentState.java 2010-01-08 11:55:23 UTC (rev 99155)
@@ -26,7 +26,10 @@
import java.net.URL;
import java.util.Enumeration;
+import org.jboss.classloading.spi.metadata.ClassLoadingMetaData;
import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.osgi.framework.classloading.OSGiClassLoadingMetaData;
+import org.jboss.osgi.framework.classloading.OSGiClassLoadingMetaData.FragmentHost;
import org.jboss.osgi.spi.NotImplementedException;
import org.osgi.framework.BundleException;
@@ -104,4 +107,13 @@
{
throw new NotImplementedException();
}
+
+ public FragmentHost getFragmentHost()
+ {
+ FragmentHost fhMetaData = null;
+ ClassLoadingMetaData clMetaData = getDeploymentUnit().getAttachment(ClassLoadingMetaData.class);
+ if (clMetaData != null)
+ fhMetaData = ((OSGiClassLoadingMetaData)clMetaData).getFragmentHost();
+ return fhMetaData;
+ }
}
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiBundleClassLoader.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiBundleClassLoader.java 2010-01-08 11:33:21 UTC (rev 99154)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiBundleClassLoader.java 2010-01-08 11:55:23 UTC (rev 99155)
@@ -34,7 +34,7 @@
* The library map is initialized in {@link OSGiBundleNativeCodeDeployer}.
*
* @author Thomas.Diesler at jboss.com
- * @since 19-Dec-2209
+ * @since 19-Dec-2009
*/
public class OSGiBundleClassLoader extends BaseClassLoader
{
Added: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoadingMetaData.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoadingMetaData.java (rev 0)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoadingMetaData.java 2010-01-08 11:55:23 UTC (rev 99155)
@@ -0,0 +1,118 @@
+/*
+* 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.classloading;
+
+// $Id$
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.jboss.classloading.spi.metadata.ClassLoadingMetaData;
+import org.osgi.framework.Version;
+
+/**
+ * An extension of {@link ClassLoadingMetaData} that captures OSGi specific
+ * classloading metadata.
+ *
+ * @author Thomas.Diesler at jboss.com
+ * @since 08-Jan-2010
+ */
+public class OSGiClassLoadingMetaData extends ClassLoadingMetaData
+{
+ private static final long serialVersionUID = 1L;
+
+ // The optional fragment host
+ private FragmentHost fragmentHost;
+ // The list of attached fragment classloading metadata
+ private List<OSGiClassLoadingMetaData> attachedFragments = new ArrayList<OSGiClassLoadingMetaData>();
+
+ public FragmentHost getFragmentHost()
+ {
+ return fragmentHost;
+ }
+
+ public void setFragmentHost(FragmentHost fragmentHost)
+ {
+ this.fragmentHost = fragmentHost;
+ }
+
+ public List<OSGiClassLoadingMetaData> getAttachedFragmentMetaData()
+ {
+ return Collections.unmodifiableList(attachedFragments);
+ }
+
+ public void attachedFragmentMetaData(OSGiClassLoadingMetaData fragment)
+ {
+ if (fragment == null)
+ throw new IllegalArgumentException("Null fragment");
+ if (fragment.getFragmentHost() == null)
+ throw new IllegalArgumentException("Not a fragment: " + fragment);
+ if (getFragmentHost() != null)
+ throw new IllegalArgumentException("Cannot attach a fragment to a fragment: " + fragment);
+
+ attachedFragments.add(fragment);
+ }
+
+ /**
+ * Fragment-Host metadata.
+ */
+ public static class FragmentHost
+ {
+ private String symbolicName;
+ private Version bundleVersion;
+ private String extension;
+
+ public FragmentHost(String symbolicName)
+ {
+ if (symbolicName == null)
+ throw new IllegalArgumentException("Null symbolicName");
+
+ this.symbolicName = symbolicName;
+ }
+
+ public String getSymbolicName()
+ {
+ return symbolicName;
+ }
+
+ public Version getBundleVersion()
+ {
+ return bundleVersion;
+ }
+
+ public String getExtension()
+ {
+ return extension;
+ }
+
+ public void setExtension(String extension)
+ {
+ this.extension = extension;
+ }
+
+ public void setBundleVersion(Version bundleVersion)
+ {
+ this.bundleVersion = bundleVersion;
+ }
+ }
+}
Property changes on: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoadingMetaData.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/AbstractOSGiClassLoadingDeployer.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/AbstractOSGiClassLoadingDeployer.java 2010-01-08 11:33:21 UTC (rev 99154)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/AbstractOSGiClassLoadingDeployer.java 2010-01-08 11:55:23 UTC (rev 99155)
@@ -30,6 +30,7 @@
import org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer;
import org.jboss.deployers.structure.spi.DeploymentUnit;
import org.jboss.osgi.framework.bundle.AbstractBundleState;
+import org.jboss.osgi.framework.classloading.OSGiClassLoadingMetaData;
import org.jboss.osgi.framework.metadata.OSGiMetaData;
/**
@@ -66,7 +67,7 @@
if (bundleState == null)
throw new IllegalStateException("No bundle state");
- ClassLoadingMetaData classLoadingMetaData = new ClassLoadingMetaData();
+ OSGiClassLoadingMetaData classLoadingMetaData = new OSGiClassLoadingMetaData();
classLoadingMetaData.setName(bundleState.getSymbolicName());
classLoadingMetaData.setVersion(bundleState.getVersion());
classLoadingMetaData.setDomain(domain != null ? domain.getName() : null);
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiBundleClassLoadingDeployer.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiBundleClassLoadingDeployer.java 2010-01-08 11:33:21 UTC (rev 99154)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiBundleClassLoadingDeployer.java 2010-01-08 11:55:23 UTC (rev 99155)
@@ -64,7 +64,7 @@
{
super.deploy(unit, osgiMetaData);
- // Return if this is not a bundle state
+ // Return if this is not a real bundle (i.e. a fragment)
AbstractBundleState bundleState = unit.getAttachment(AbstractBundleState.class);
if (bundleState.isFragment())
return;
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiBundleNativeCodeDeployer.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiBundleNativeCodeDeployer.java 2010-01-08 11:33:21 UTC (rev 99154)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiBundleNativeCodeDeployer.java 2010-01-08 11:55:23 UTC (rev 99155)
@@ -59,7 +59,7 @@
*/
public class OSGiBundleNativeCodeDeployer extends AbstractRealDeployer
{
- /** The log */
+ // Provide logging
private static final Logger log = Logger.getLogger(OSGiBundleNativeCodeDeployer.class);
/** Maps an alias to an OSGi processor name */
Added: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiFragmentAttachmentDeployer.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiFragmentAttachmentDeployer.java (rev 0)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiFragmentAttachmentDeployer.java 2010-01-08 11:55:23 UTC (rev 99155)
@@ -0,0 +1,79 @@
+/*
+* 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$
+
+import org.jboss.classloading.spi.metadata.ClassLoadingMetaData;
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.DeploymentStages;
+import org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.osgi.framework.bundle.AbstractBundleState;
+import org.jboss.osgi.framework.bundle.OSGiBundleManager;
+import org.jboss.osgi.framework.bundle.OSGiBundleState;
+import org.jboss.osgi.framework.bundle.OSGiFragmentState;
+import org.osgi.framework.Bundle;
+
+/**
+ * A deployer, that handles OSGi fragment attachments.
+ *
+ * Fragments are bundles that can be attached to one or more host bundles by the
+ * Framework. Attaching is done as part of resolving: the Framework appends
+ * the relevant definitions of the fragment bundles to the host’s definitions
+ * before the host is resolved.
+ *
+ * @author Thomas.Diesler at jboss.com
+ * @since 08-Jan-2010
+ */
+public class OSGiFragmentAttachmentDeployer extends AbstractSimpleRealDeployer<ClassLoadingMetaData>
+{
+ public OSGiFragmentAttachmentDeployer()
+ {
+ super(ClassLoadingMetaData.class);
+ setStage(DeploymentStages.CLASSLOADER);
+ setTopLevelOnly(true);
+ }
+
+ @Override
+ public void deploy(DeploymentUnit unit, ClassLoadingMetaData classLoadingMetaData) throws DeploymentException
+ {
+ // Return if this is not a real bundle (i.e. a fragment)
+ AbstractBundleState absBundleState = unit.getAttachment(AbstractBundleState.class);
+ if (absBundleState.isFragment())
+ return;
+
+ OSGiBundleState bundleState = (OSGiBundleState)absBundleState;
+
+ // Iterate over all installed fragments and attach when appropriate
+ OSGiBundleManager bundleManager = bundleState.getBundleManager();
+ for (AbstractBundleState auxBundle : bundleManager.getBundles(Bundle.INSTALLED))
+ {
+ if (auxBundle.isFragment())
+ {
+ OSGiFragmentState auxState = (OSGiFragmentState)auxBundle;
+ if (bundleState.isFragmentAttachable(auxState))
+ bundleState.attachFragment(auxState);
+ }
+ }
+ }
+}
Property changes on: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiFragmentAttachmentDeployer.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiFragmentClassLoadingDeployer.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiFragmentClassLoadingDeployer.java 2010-01-08 11:33:21 UTC (rev 99154)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiFragmentClassLoadingDeployer.java 2010-01-08 11:55:23 UTC (rev 99155)
@@ -23,10 +23,17 @@
// $Id$
+import org.jboss.classloading.spi.metadata.ClassLoadingMetaData;
import org.jboss.deployers.spi.DeploymentException;
import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.osgi.framework.bundle.OSGiFragmentState;
+import org.jboss.osgi.framework.bundle.AbstractBundleState;
+import org.jboss.osgi.framework.classloading.OSGiClassLoadingMetaData;
+import org.jboss.osgi.framework.classloading.OSGiClassLoadingMetaData.FragmentHost;
import org.jboss.osgi.framework.metadata.OSGiMetaData;
+import org.jboss.osgi.framework.metadata.Parameter;
+import org.jboss.osgi.framework.metadata.ParameterizedAttribute;
+import org.osgi.framework.Constants;
+import org.osgi.framework.Version;
/**
* An OSGi classloading deployer, that maps osgi metadata into classloading metadata
@@ -42,10 +49,26 @@
{
super.deploy(unit, osgiMetaData);
- OSGiFragmentState frgmtState = unit.getAttachment(OSGiFragmentState.class);
- if (frgmtState == null)
+ // Return if this is not a bundle fragment
+ AbstractBundleState bundleState = unit.getAttachment(AbstractBundleState.class);
+ if (bundleState.isFragment() == false)
return;
- // ClassLoadingMetaData classLoadingMetaData = unit.getAttachment(ClassLoadingMetaData.class);
+ OSGiClassLoadingMetaData classLoadingMetaData = (OSGiClassLoadingMetaData)unit.getAttachment(ClassLoadingMetaData.class);
+ if (classLoadingMetaData == null)
+ throw new IllegalStateException("Null ClassLoadingMetaData");
+
+ // Initialize the Fragment-Host
+ ParameterizedAttribute hostAttr = osgiMetaData.getFragmentHost();
+ FragmentHost fragmentHost = new FragmentHost(hostAttr.getAttribute());
+ classLoadingMetaData.setFragmentHost(fragmentHost);
+
+ Parameter bundleVersionAttr = hostAttr.getAttribute(Constants.BUNDLE_VERSION_ATTRIBUTE);
+ if (bundleVersionAttr != null)
+ fragmentHost.setBundleVersion((Version)bundleVersionAttr.getValue());
+
+ Parameter extensionDirective = hostAttr.getDirective(Constants.EXTENSION_DIRECTIVE);
+ if (extensionDirective != null)
+ fragmentHost.setExtension((String)extensionDirective.getValue());
}
}
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bootstrap/jboss-osgi-bootstrap.xml
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bootstrap/jboss-osgi-bootstrap.xml 2010-01-08 11:33:21 UTC (rev 99154)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bootstrap/jboss-osgi-bootstrap.xml 2010-01-08 11:55:23 UTC (rev 99155)
@@ -167,6 +167,10 @@
<property name="domain"><inject bean="OSGiClassLoaderDomain"/></property>
<property name="factory"><inject bean="OSGiClassLoaderFactory"/></property>
</bean>
+ <bean name="OSGiFragmentClassLoadingDeployer" class="org.jboss.osgi.framework.deployers.OSGiFragmentClassLoadingDeployer">
+ <property name="domain"><inject bean="OSGiClassLoaderDomain"/></property>
+ </bean>
+ <bean name="OSGiFragmentAttachmentDeployer" class="org.jboss.osgi.framework.deployers.OSGiFragmentAttachmentDeployer"/>
<bean name="ClassLoading" class="org.jboss.classloading.spi.dependency.ClassLoading">
<incallback method="addModule" state="Configured" />
More information about the jboss-cvs-commits
mailing list