JBoss-OSGI SVN: r99155 - in projects/jboss-osgi/projects/runtime/framework/trunk/src: main/java/org/jboss/osgi/framework/bundle and 3 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)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(a)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(a)jboss.com">Adrian Brock</a>
* @author Thomas.Diesler(a)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(a)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(a)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(a)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" />
15 years, 11 months
JBoss-OSGI SVN: r99147 - in projects/jboss-osgi/projects/osgitck/trunk: hudson/hudson-home/jobs and 1 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2010-01-08 02:48:23 -0500 (Fri, 08 Jan 2010)
New Revision: 99147
Removed:
projects/jboss-osgi/projects/osgitck/trunk/hudson/hudson-home/jobs/jboss.osgi.framework/
Modified:
projects/jboss-osgi/projects/osgitck/trunk/ant.properties.example
projects/jboss-osgi/projects/osgitck/trunk/hudson/hudson-home/jobs/osgi.core.tests/config.xml
Log:
Add framework build to osgi.core.tests
Modified: projects/jboss-osgi/projects/osgitck/trunk/ant.properties.example
===================================================================
--- projects/jboss-osgi/projects/osgitck/trunk/ant.properties.example 2010-01-08 07:35:07 UTC (rev 99146)
+++ projects/jboss-osgi/projects/osgitck/trunk/ant.properties.example 2010-01-08 07:48:23 UTC (rev 99147)
@@ -5,6 +5,7 @@
# The JBoss OSGi framework version
framework.version=1.0.0-SNAPSHOT
+framework.svn.url=https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/runtime/framework/trunk
# The aQute Bnd version
aQute.bnd.version=0.0.366-SNAPSHOT
Modified: projects/jboss-osgi/projects/osgitck/trunk/hudson/hudson-home/jobs/osgi.core.tests/config.xml
===================================================================
--- projects/jboss-osgi/projects/osgitck/trunk/hudson/hudson-home/jobs/osgi.core.tests/config.xml 2010-01-08 07:35:07 UTC (rev 99146)
+++ projects/jboss-osgi/projects/osgitck/trunk/hudson/hudson-home/jobs/osgi.core.tests/config.xml 2010-01-08 07:48:23 UTC (rev 99147)
@@ -10,6 +10,10 @@
<remote>@hudson.osgi.url@</remote>
<local>osgitck-setup</local>
</hudson.scm.SubversionSCM_-ModuleLocation>
+ <hudson.scm.SubversionSCM_-ModuleLocation>
+ <remote>@framework.svn.url@</remote>
+ <local>jboss-osgi-framework</local>
+ </hudson.scm.SubversionSCM_-ModuleLocation>
</locations>
<useUpdate>true</useUpdate>
</scm>
@@ -22,7 +26,12 @@
<hudson.tasks.Shell>
<command>
TCKSETUPDIR=$WORKSPACE/osgitck-setup
+FRAMEWORKDIR=$WORKSPACE/jboss-osgi-framework
+# Build & Install the Framework
+cd $FRAMEWORKDIR
+mvn -U clean install
+
# Setup the TCK
cd $TCKSETUPDIR
cp ant.properties.example ant.properties
15 years, 11 months
JBoss-OSGI SVN: r99146 - in projects/jboss-osgi/projects/runtime/framework/trunk/src: test/java/org/jboss/test/osgi/service and 2 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2010-01-08 02:35:07 -0500 (Fri, 08 Jan 2010)
New Revision: 99146
Added:
projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/service/service-beans1/META-INF/jboss-beans.xml
Removed:
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/FilterParserAndMatcher.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/service/service-beans1/META-INF/jboss-beans.xml
projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/service/service-beans2/
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/test/java/org/jboss/test/osgi/service/ServiceMixUnitTestCase.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/service/service-beans1/META-INF/MANIFEST.MF
Log:
Rollback broken build -r99123:99115
Deleted: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/FilterParserAndMatcher.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/FilterParserAndMatcher.java 2010-01-08 07:29:22 UTC (rev 99145)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/FilterParserAndMatcher.java 2010-01-08 07:35:07 UTC (rev 99146)
@@ -1,90 +0,0 @@
-/*
-* 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.bundle;
-
-import java.util.Dictionary;
-import java.util.Set;
-
-import org.jboss.beans.metadata.api.model.QualifierContent;
-import org.jboss.dependency.spi.ControllerContext;
-import org.jboss.kernel.spi.qualifier.QualifierMatcher;
-import org.jboss.kernel.spi.qualifier.QualifierParser;
-import org.jboss.metadata.spi.MetaData;
-import org.jboss.metadata.spi.scope.CommonLevels;
-import org.osgi.framework.Filter;
-import org.osgi.framework.FrameworkUtil;
-import org.osgi.framework.InvalidSyntaxException;
-
-/**
- * OSGi filter parsing and matching.
- *
- * @author <a href="ales.justin(a)jboss.org">Ales Justin</a>
- */
-class FilterParserAndMatcher implements QualifierParser, QualifierMatcher<Filter>
-{
- static final FilterParserAndMatcher INSTANCE = new FilterParserAndMatcher();
-
- private FilterParserAndMatcher()
- {
- }
-
- public Class<Filter> getHandledType()
- {
- return Filter.class;
- }
-
- public QualifierContent getHandledContent()
- {
- return QualifierContent.getContent("filter");
- }
-
- public boolean matches(ControllerContext context, Set<Object> suppliedQualifiers, Filter filter)
- {
- MetaData metaData = context.getScopeInfo().getMetaData();
- if (metaData == null)
- return false;
-
- MetaData instanceMD = metaData.getScopeMetaData(CommonLevels.INSTANCE);
- if (instanceMD == null)
- return false;
-
- Dictionary dictionary = instanceMD.getMetaData(Dictionary.class);
- return dictionary != null && filter.match(dictionary);
- }
-
- public Object parseWanted(ClassLoader cl, Object rawQualifier)
- {
- try
- {
- return FrameworkUtil.createFilter(String.valueOf(rawQualifier));
- }
- catch (InvalidSyntaxException e)
- {
- throw new IllegalArgumentException(e);
- }
- }
-
- public Object parseSupplied(ClassLoader cl, Object rawQualifier)
- {
- return parseWanted(cl, rawQualifier);
- }
-}
\ No newline at end of file
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 07:29:22 UTC (rev 99145)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java 2010-01-08 07:35:07 UTC (rev 99146)
@@ -46,8 +46,8 @@
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.jar.Attributes;
-import java.util.jar.Attributes.Name;
import java.util.jar.Manifest;
+import java.util.jar.Attributes.Name;
import org.jboss.dependency.spi.Controller;
import org.jboss.dependency.spi.ControllerContext;
@@ -68,7 +68,6 @@
import org.jboss.deployers.vfs.spi.client.VFSDeploymentFactory;
import org.jboss.kernel.Kernel;
import org.jboss.kernel.spi.dependency.KernelController;
-import org.jboss.kernel.spi.qualifier.QualifierMatchers;
import org.jboss.logging.Logger;
import org.jboss.metadata.plugins.loader.memory.MemoryMetaDataLoader;
import org.jboss.metadata.spi.loader.MutableMetaDataLoader;
@@ -280,15 +279,8 @@
}
}
- // osgi ldap filter parsing and matching
- FilterParserAndMatcher fpm = FilterParserAndMatcher.INSTANCE;
- QualifierMatchers matchers = QualifierMatchers.getInstance();
-
if (register)
{
- matchers.addParser(fpm);
- matchers.addMatcher(fpm);
-
MetaDataRetrievalFactory mdrFactory = factory;
if (mdrFactory == null)
{
@@ -304,9 +296,6 @@
else
{
repository.removeMetaDataRetrievalFactory(CommonLevels.INSTANCE);
-
- matchers.removeParser(fpm.getHandledContent());
- matchers.removeMatcher(fpm.getHandledType());
}
}
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/test/java/org/jboss/test/osgi/service/ServiceMixUnitTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/test/java/org/jboss/test/osgi/service/ServiceMixUnitTestCase.java 2010-01-08 07:29:22 UTC (rev 99145)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/test/java/org/jboss/test/osgi/service/ServiceMixUnitTestCase.java 2010-01-08 07:35:07 UTC (rev 99146)
@@ -460,47 +460,6 @@
}
}
- public void testServiceInjection() throws Throwable
- {
- Bundle bundle = installBundle(assembleBundle("simple2", "/bundles/service/service-bundle2", A.class));
- try
- {
- bundle.start();
- BundleContext bundleContext1 = bundle.getBundleContext();
- assertNotNull(bundleContext1);
-
- Class<?> aClass = bundle.loadClass(A.class.getName());
- Object a = aClass.newInstance();
- Hashtable<String, Object> table = new Hashtable<String, Object>();
- table.put("a", "b");
- ServiceRegistration reg1 = bundleContext1.registerService(A.class.getName(), a, table);
- assertNotNull(reg1);
-
- AssembledDirectory mix = createAssembledDirectory("beans1", "");
- addPath(mix, "/bundles/service/service-beans2", "");
- addPackage(mix, C.class);
- Deployment deployment = assertDeploy(mix);
- try
- {
- checkComplete();
-
- Bundle beans = getBundle(getDeploymentUnit(deployment));
- beans.start();
-
- Object c = getBean("C");
- assertEquals(a, getter(c, "getA", "C"));
- }
- finally
- {
- undeploy(deployment);
- }
- }
- finally
- {
- uninstall(bundle);
- }
- }
-
public void testFiltering() throws Throwable
{
Deployment bean = addBean("beanA", A.class);
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/service/service-beans1/META-INF/MANIFEST.MF
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/service/service-beans1/META-INF/MANIFEST.MF 2010-01-08 07:29:22 UTC (rev 99145)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/service/service-beans1/META-INF/MANIFEST.MF 2010-01-08 07:35:07 UTC (rev 99146)
@@ -2,6 +2,6 @@
Implementation-Title: JBoss OSGi tests
Implementation-Version: test
Implementation-Vendor: jboss.org
-Bundle-Name: Beans1
-Bundle-SymbolicName: org.jboss.test.osgi.beans1
+Bundle-Name: Service1
+Bundle-SymbolicName: org.jboss.test.osgi.service1
Export-Package: org.jboss.test.osgi.service.support.a
Deleted: projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/service/service-beans1/META-INF/jboss-beans.xml
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/service/service-beans1/META-INF/jboss-beans.xml 2010-01-08 07:29:22 UTC (rev 99145)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/service/service-beans1/META-INF/jboss-beans.xml 2010-01-08 07:35:07 UTC (rev 99146)
@@ -1,5 +0,0 @@
-<deployment xmlns="urn:jboss:bean-deployer:2.0">
-
- <bean name="A" class="org.jboss.test.osgi.service.support.a.A"/>
-
-</deployment>
\ No newline at end of file
Copied: projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/service/service-beans1/META-INF/jboss-beans.xml (from rev 99115, projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/service/service-beans1/META-INF/jboss-beans.xml)
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/service/service-beans1/META-INF/jboss-beans.xml (rev 0)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/service/service-beans1/META-INF/jboss-beans.xml 2010-01-08 07:35:07 UTC (rev 99146)
@@ -0,0 +1,5 @@
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <bean name="A" class="org.jboss.test.osgi.service.support.a.A" />
+
+</deployment>
\ No newline at end of file
15 years, 11 months
JBoss-OSGI SVN: r99145 - projects/jboss-osgi/projects/runtime/framework/branches.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2010-01-08 02:29:22 -0500 (Fri, 08 Jan 2010)
New Revision: 99145
Added:
projects/jboss-osgi/projects/runtime/framework/branches/alesj/
Log:
create userbranch
Copied: projects/jboss-osgi/projects/runtime/framework/branches/alesj (from rev 99144, projects/jboss-osgi/projects/runtime/framework/trunk)
15 years, 11 months
JBoss-OSGI SVN: r99131 - projects/jboss-osgi/projects/runtime/framework/branches.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2010-01-07 17:25:44 -0500 (Thu, 07 Jan 2010)
New Revision: 99131
Added:
projects/jboss-osgi/projects/runtime/framework/branches/tdiesler/
Log:
recreate userbranch
Copied: projects/jboss-osgi/projects/runtime/framework/branches/tdiesler (from rev 99115, projects/jboss-osgi/projects/runtime/framework/trunk)
15 years, 11 months
JBoss-OSGI SVN: r99123 - projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle.
by jboss-osgi-commits@lists.jboss.org
Author: alesj
Date: 2010-01-07 11:55:02 -0500 (Thu, 07 Jan 2010)
New Revision: 99123
Modified:
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java
Log:
Extract var.
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-07 16:52:03 UTC (rev 99122)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java 2010-01-07 16:55:02 UTC (rev 99123)
@@ -282,11 +282,12 @@
// osgi ldap filter parsing and matching
FilterParserAndMatcher fpm = FilterParserAndMatcher.INSTANCE;
+ QualifierMatchers matchers = QualifierMatchers.getInstance();
if (register)
{
- QualifierMatchers.getInstance().addParser(fpm);
- QualifierMatchers.getInstance().addMatcher(fpm);
+ matchers.addParser(fpm);
+ matchers.addMatcher(fpm);
MetaDataRetrievalFactory mdrFactory = factory;
if (mdrFactory == null)
@@ -304,8 +305,8 @@
{
repository.removeMetaDataRetrievalFactory(CommonLevels.INSTANCE);
- QualifierMatchers.getInstance().removeParser(fpm.getHandledContent());
- QualifierMatchers.getInstance().removeMatcher(fpm.getHandledType());
+ matchers.removeParser(fpm.getHandledContent());
+ matchers.removeMatcher(fpm.getHandledType());
}
}
15 years, 11 months
JBoss-OSGI SVN: r99122 - in projects/jboss-osgi/projects/runtime/framework/trunk/src: test/java/org/jboss/test/osgi/service and 4 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: alesj
Date: 2010-01-07 11:52:03 -0500 (Thu, 07 Jan 2010)
New Revision: 99122
Added:
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/FilterParserAndMatcher.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/service/service-beans1/META-INF/jboss-beans.xml
projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/service/service-beans2/
projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/service/service-beans2/META-INF/
projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/service/service-beans2/META-INF/MANIFEST.MF
projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/service/service-beans2/META-INF/jboss-beans.xml
Removed:
projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/service/service-beans1/META-INF/jboss-beans.xml
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/test/java/org/jboss/test/osgi/service/ServiceMixUnitTestCase.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/service/service-beans1/META-INF/MANIFEST.MF
Log:
[JBOSGI-141]; allow for service injection into bean via filter.
Copied: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/FilterParserAndMatcher.java (from rev 99103, projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/DescribeAction.java)
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/FilterParserAndMatcher.java (rev 0)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/FilterParserAndMatcher.java 2010-01-07 16:52:03 UTC (rev 99122)
@@ -0,0 +1,90 @@
+/*
+* 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.bundle;
+
+import java.util.Dictionary;
+import java.util.Set;
+
+import org.jboss.beans.metadata.api.model.QualifierContent;
+import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.kernel.spi.qualifier.QualifierMatcher;
+import org.jboss.kernel.spi.qualifier.QualifierParser;
+import org.jboss.metadata.spi.MetaData;
+import org.jboss.metadata.spi.scope.CommonLevels;
+import org.osgi.framework.Filter;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.InvalidSyntaxException;
+
+/**
+ * OSGi filter parsing and matching.
+ *
+ * @author <a href="ales.justin(a)jboss.org">Ales Justin</a>
+ */
+class FilterParserAndMatcher implements QualifierParser, QualifierMatcher<Filter>
+{
+ static final FilterParserAndMatcher INSTANCE = new FilterParserAndMatcher();
+
+ private FilterParserAndMatcher()
+ {
+ }
+
+ public Class<Filter> getHandledType()
+ {
+ return Filter.class;
+ }
+
+ public QualifierContent getHandledContent()
+ {
+ return QualifierContent.getContent("filter");
+ }
+
+ public boolean matches(ControllerContext context, Set<Object> suppliedQualifiers, Filter filter)
+ {
+ MetaData metaData = context.getScopeInfo().getMetaData();
+ if (metaData == null)
+ return false;
+
+ MetaData instanceMD = metaData.getScopeMetaData(CommonLevels.INSTANCE);
+ if (instanceMD == null)
+ return false;
+
+ Dictionary dictionary = instanceMD.getMetaData(Dictionary.class);
+ return dictionary != null && filter.match(dictionary);
+ }
+
+ public Object parseWanted(ClassLoader cl, Object rawQualifier)
+ {
+ try
+ {
+ return FrameworkUtil.createFilter(String.valueOf(rawQualifier));
+ }
+ catch (InvalidSyntaxException e)
+ {
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+ public Object parseSupplied(ClassLoader cl, Object rawQualifier)
+ {
+ return parseWanted(cl, rawQualifier);
+ }
+}
\ No newline at end of file
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-07 16:36:34 UTC (rev 99121)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java 2010-01-07 16:52:03 UTC (rev 99122)
@@ -46,8 +46,8 @@
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.jar.Attributes;
+import java.util.jar.Attributes.Name;
import java.util.jar.Manifest;
-import java.util.jar.Attributes.Name;
import org.jboss.dependency.spi.Controller;
import org.jboss.dependency.spi.ControllerContext;
@@ -68,6 +68,7 @@
import org.jboss.deployers.vfs.spi.client.VFSDeploymentFactory;
import org.jboss.kernel.Kernel;
import org.jboss.kernel.spi.dependency.KernelController;
+import org.jboss.kernel.spi.qualifier.QualifierMatchers;
import org.jboss.logging.Logger;
import org.jboss.metadata.plugins.loader.memory.MemoryMetaDataLoader;
import org.jboss.metadata.spi.loader.MutableMetaDataLoader;
@@ -279,8 +280,14 @@
}
}
+ // osgi ldap filter parsing and matching
+ FilterParserAndMatcher fpm = FilterParserAndMatcher.INSTANCE;
+
if (register)
{
+ QualifierMatchers.getInstance().addParser(fpm);
+ QualifierMatchers.getInstance().addMatcher(fpm);
+
MetaDataRetrievalFactory mdrFactory = factory;
if (mdrFactory == null)
{
@@ -296,6 +303,9 @@
else
{
repository.removeMetaDataRetrievalFactory(CommonLevels.INSTANCE);
+
+ QualifierMatchers.getInstance().removeParser(fpm.getHandledContent());
+ QualifierMatchers.getInstance().removeMatcher(fpm.getHandledType());
}
}
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/test/java/org/jboss/test/osgi/service/ServiceMixUnitTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/test/java/org/jboss/test/osgi/service/ServiceMixUnitTestCase.java 2010-01-07 16:36:34 UTC (rev 99121)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/test/java/org/jboss/test/osgi/service/ServiceMixUnitTestCase.java 2010-01-07 16:52:03 UTC (rev 99122)
@@ -460,6 +460,47 @@
}
}
+ public void testServiceInjection() throws Throwable
+ {
+ Bundle bundle = installBundle(assembleBundle("simple2", "/bundles/service/service-bundle2", A.class));
+ try
+ {
+ bundle.start();
+ BundleContext bundleContext1 = bundle.getBundleContext();
+ assertNotNull(bundleContext1);
+
+ Class<?> aClass = bundle.loadClass(A.class.getName());
+ Object a = aClass.newInstance();
+ Hashtable<String, Object> table = new Hashtable<String, Object>();
+ table.put("a", "b");
+ ServiceRegistration reg1 = bundleContext1.registerService(A.class.getName(), a, table);
+ assertNotNull(reg1);
+
+ AssembledDirectory mix = createAssembledDirectory("beans1", "");
+ addPath(mix, "/bundles/service/service-beans2", "");
+ addPackage(mix, C.class);
+ Deployment deployment = assertDeploy(mix);
+ try
+ {
+ checkComplete();
+
+ Bundle beans = getBundle(getDeploymentUnit(deployment));
+ beans.start();
+
+ Object c = getBean("C");
+ assertEquals(a, getter(c, "getA", "C"));
+ }
+ finally
+ {
+ undeploy(deployment);
+ }
+ }
+ finally
+ {
+ uninstall(bundle);
+ }
+ }
+
public void testFiltering() throws Throwable
{
Deployment bean = addBean("beanA", A.class);
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/service/service-beans1/META-INF/MANIFEST.MF
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/service/service-beans1/META-INF/MANIFEST.MF 2010-01-07 16:36:34 UTC (rev 99121)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/service/service-beans1/META-INF/MANIFEST.MF 2010-01-07 16:52:03 UTC (rev 99122)
@@ -2,6 +2,6 @@
Implementation-Title: JBoss OSGi tests
Implementation-Version: test
Implementation-Vendor: jboss.org
-Bundle-Name: Service1
-Bundle-SymbolicName: org.jboss.test.osgi.service1
+Bundle-Name: Beans1
+Bundle-SymbolicName: org.jboss.test.osgi.beans1
Export-Package: org.jboss.test.osgi.service.support.a
Deleted: projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/service/service-beans1/META-INF/jboss-beans.xml
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/service/service-beans1/META-INF/jboss-beans.xml 2010-01-07 16:36:34 UTC (rev 99121)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/service/service-beans1/META-INF/jboss-beans.xml 2010-01-07 16:52:03 UTC (rev 99122)
@@ -1,5 +0,0 @@
-<deployment xmlns="urn:jboss:bean-deployer:2.0">
-
- <bean name="A" class="org.jboss.test.osgi.service.support.a.A" />
-
-</deployment>
\ No newline at end of file
Added: projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/service/service-beans1/META-INF/jboss-beans.xml
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/service/service-beans1/META-INF/jboss-beans.xml (rev 0)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/service/service-beans1/META-INF/jboss-beans.xml 2010-01-07 16:52:03 UTC (rev 99122)
@@ -0,0 +1,5 @@
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <bean name="A" class="org.jboss.test.osgi.service.support.a.A"/>
+
+</deployment>
\ No newline at end of file
Copied: projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/service/service-beans2/META-INF/MANIFEST.MF (from rev 99113, projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/service/service-beans1/META-INF/MANIFEST.MF)
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/service/service-beans2/META-INF/MANIFEST.MF (rev 0)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/service/service-beans2/META-INF/MANIFEST.MF 2010-01-07 16:52:03 UTC (rev 99122)
@@ -0,0 +1,8 @@
+Manifest-Version: 1.0
+Implementation-Title: JBoss OSGi tests
+Implementation-Version: test
+Implementation-Vendor: jboss.org
+Bundle-Name: Beans2
+Bundle-SymbolicName: org.jboss.test.osgi.beans2
+Export-Package: org.jboss.test.osgi.service.support.c
+Import-Package: org.jboss.test.osgi.service.support.a
Copied: projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/service/service-beans2/META-INF/jboss-beans.xml (from rev 99110, projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/service/service-beans1/META-INF/jboss-beans.xml)
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/service/service-beans2/META-INF/jboss-beans.xml (rev 0)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/service/service-beans2/META-INF/jboss-beans.xml 2010-01-07 16:52:03 UTC (rev 99122)
@@ -0,0 +1,11 @@
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <bean name="C" class="org.jboss.test.osgi.service.support.c.C">
+ <property name="a">
+ <inject>
+ <qualifier content="filter" type="required">(a=b)</qualifier>
+ </inject>
+ </property>
+ </bean>
+
+</deployment>
\ No newline at end of file
15 years, 11 months
JBoss-OSGI SVN: r99116 - projects/jboss-osgi/projects/runtime/deployment/trunk/src/main/java/org/jboss/osgi/deployment/internal.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2010-01-07 09:30:54 -0500 (Thu, 07 Jan 2010)
New Revision: 99116
Modified:
projects/jboss-osgi/projects/runtime/deployment/trunk/src/main/java/org/jboss/osgi/deployment/internal/SystemDeployerService.java
Log:
Throw BundleException on install failure
Modified: projects/jboss-osgi/projects/runtime/deployment/trunk/src/main/java/org/jboss/osgi/deployment/internal/SystemDeployerService.java
===================================================================
--- projects/jboss-osgi/projects/runtime/deployment/trunk/src/main/java/org/jboss/osgi/deployment/internal/SystemDeployerService.java 2010-01-07 14:29:54 UTC (rev 99115)
+++ projects/jboss-osgi/projects/runtime/deployment/trunk/src/main/java/org/jboss/osgi/deployment/internal/SystemDeployerService.java 2010-01-07 14:30:54 UTC (rev 99116)
@@ -60,7 +60,7 @@
{
// Provide logging
private Logger log = LoggerFactory.getLogger(SystemDeployerService.class);
-
+
private BundleContext context;
private ServiceTracker startLevelTracker;
@@ -96,26 +96,19 @@
List<Bundle> resolvableBundles = new ArrayList<Bundle>();
Map<Deployment, Bundle> bundleMap = new HashMap<Deployment, Bundle>();
-
+
for (Deployment dep : depArr)
{
- try
- {
- log.debug("Install: " + dep.getLocation());
-
- String location = dep.getLocation();
- Bundle bundle = context.installBundle(location);
+ log.debug("Install: " + dep.getLocation());
- bundleMap.put(dep, bundle);
- if (dep.isAutoStart())
- resolvableBundles.add(bundle);
+ String location = dep.getLocation();
+ Bundle bundle = context.installBundle(location);
- registry.registerDeployment(dep);
- }
- catch (BundleException ex)
- {
- log.error("Cannot install bundle: " + dep, ex);
- }
+ bundleMap.put(dep, bundle);
+ if (dep.isAutoStart())
+ resolvableBundles.add(bundle);
+
+ registry.registerDeployment(dep);
}
// Resolve the installed bundles through the PackageAdmin
@@ -127,7 +120,7 @@
resolvableBundles.toArray(resolvableBundleArr);
packageAdmin.resolveBundles(resolvableBundleArr);
}
-
+
// Start the installed bundles
for (Entry<Deployment, Bundle> entry : bundleMap.entrySet())
{
@@ -177,7 +170,7 @@
if (bundle != null)
{
log.debug("Uninstall: " + bundle);
-
+
registry.unregisterDeployment(dep);
bundle.uninstall();
@@ -235,7 +228,7 @@
ServiceReference sref = context.getServiceReference(DeploymentRegistryService.class.getName());
if (sref == null)
throw new IllegalStateException("Cannot obtain DeploymentRegistryService");
-
+
return (DeploymentRegistryService)context.getService(sref);
}
15 years, 11 months
JBoss-OSGI SVN: r99115 - in projects/jboss-osgi: projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading and 4 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2010-01-07 09:29:54 -0500 (Thu, 07 Jan 2010)
New Revision: 99115
Added:
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/OSGiFragmentClassLoadingDeployer.java
Modified:
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java
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/OSGiBundleCapability.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderFactory.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderPolicy.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiPackageCapability.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiPackageRequirement.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/AbstractOSGiBundleStateDeployer.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/OSGiBundleStateRemoveDeployer.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiDeployersWrapper.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/service/internal/PackageAdminImpl.java
projects/jboss-osgi/trunk/testsuite/functional/scripts/antrun-test-jars.xml
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/fragments/FragmentTestCase.java
Log:
Fragment bundle install/uninstall
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java 2010-01-07 14:23:36 UTC (rev 99114)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java 2010-01-07 14:29:54 UTC (rev 99115)
@@ -681,8 +681,6 @@
return bundleState.getBundleInternal();
}
- public abstract void uninstall() throws BundleException;
-
/**
* Get the canonical name of the bundle
*
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-07 14:23:36 UTC (rev 99114)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/AbstractDeployedBundleState.java 2010-01-07 14:29:54 UTC (rev 99115)
@@ -33,7 +33,9 @@
import org.jboss.osgi.deployment.deployer.Deployment;
import org.jboss.osgi.framework.metadata.OSGiMetaData;
import org.jboss.virtual.VirtualFile;
+import org.osgi.framework.AdminPermission;
import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleException;
/**
* The abstract state of a deployed bundle or fragment.
@@ -155,4 +157,18 @@
return super.getHeaders(locale);
}
+
+ public void uninstall() throws BundleException
+ {
+ checkAdminPermission(AdminPermission.LIFECYCLE);
+
+ // If this bundle's state is UNINSTALLED then an IllegalStateException is thrown
+ if (getState() == Bundle.UNINSTALLED)
+ throw new IllegalStateException("Bundle already uninstalled: " + this);
+
+ // Cache the headers in the default locale
+ headersOnUninstall = getHeaders(null);
+
+ getBundleManager().uninstallBundle(this);
+ }
}
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-07 14:23:36 UTC (rev 99114)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java 2010-01-07 14:29:54 UTC (rev 99115)
@@ -390,7 +390,6 @@
{
bundleState = (OSGiBundleState)addDeployment(unit);
bundleState.startInternal();
- unit.addAttachment(OSGiBundleState.class, bundleState);
}
catch (Throwable t)
{
@@ -625,7 +624,7 @@
* @return the bundle state
* @throws BundleException for any error
*/
- public OSGiBundleState installBundle(URL url) throws BundleException
+ public AbstractBundleState installBundle(URL url) throws BundleException
{
if (url == null)
throw new BundleException("Null url");
@@ -641,7 +640,7 @@
* @return the bundle state
* @throws BundleException for any error
*/
- public OSGiBundleState installBundle(String location, InputStream input) throws BundleException
+ public AbstractBundleState installBundle(String location, InputStream input) throws BundleException
{
if (location == null)
throw new BundleException("Null location");
@@ -702,7 +701,7 @@
* @return the bundle state
* @throws BundleException for any error
*/
- public OSGiBundleState installBundle(VirtualFile root) throws BundleException
+ public AbstractBundleState installBundle(VirtualFile root) throws BundleException
{
return install(root, root.toString(), false);
}
@@ -710,7 +709,7 @@
/*
* Installs a bundle from the given virtual file.
*/
- private OSGiBundleState install(VirtualFile root, String location, boolean autoStart) throws BundleException
+ private AbstractBundleState install(VirtualFile root, String location, boolean autoStart) throws BundleException
{
if (location == null)
throw new IllegalArgumentException("Null location");
@@ -738,7 +737,7 @@
* @return the bundle state
* @throws BundleException for any error
*/
- public OSGiBundleState installBundle(Deployment dep) throws BundleException
+ public AbstractBundleState installBundle(Deployment dep) throws BundleException
{
// Create the deployment and deploy it
try
@@ -748,15 +747,15 @@
att.addAttachment(Deployment.class, dep);
// In case of update the OSGiBundleState is attached
- OSGiBundleState bundleState = dep.getAttachment(OSGiBundleState.class);
+ AbstractBundleState bundleState = dep.getAttachment(AbstractBundleState.class);
if (bundleState != null)
- att.addAttachment(OSGiBundleState.class, bundleState);
+ att.addAttachment(AbstractBundleState.class, bundleState);
deployerClient.deploy(deployment);
try
{
DeploymentUnit unit = deployerStructure.getDeploymentUnit(deployment.getName());
- bundleState = unit.getAttachment(OSGiBundleState.class);
+ bundleState = unit.getAttachment(AbstractBundleState.class);
if (bundleState == null)
throw new IllegalStateException("Unable to determine bundle state for " + deployment.getName());
@@ -888,7 +887,7 @@
// If the Framework is unable to install the updated version of this bundle, the original version of this bundle must be restored
// and a BundleException must be thrown after completion of the remaining steps.
String location = (updateURL != null ? updateURL.toExternalForm() : bundleState.getCanonicalName() + "/update");
- OSGiBundleState updatedBundleState = null;
+ AbstractBundleState updatedBundleState = null;
BundleException throwAfterUpdate = null;
try
{
@@ -897,7 +896,7 @@
BundleInfo info = BundleInfo.createBundleInfo(root, location);
Deployment dep = DeploymentFactory.createDeployment(info);
- dep.addAttachment(OSGiBundleState.class, bundleState);
+ dep.addAttachment(AbstractBundleState.class, bundleState);
dep.setBundleUpdate(true);
dep.setAutoStart(false);
@@ -927,7 +926,8 @@
// If Bundle.start throws an exception, a Framework event of type FrameworkEvent.ERROR is fired containing the exception
if (activeBeforeUpdate)
{
- startBundle(updatedBundleState);
+ if (updatedBundleState.isFragment() == false)
+ startBundle((OSGiBundleState)updatedBundleState);
}
}
@@ -944,7 +944,7 @@
* @param bundleState the bundle
* @throws BundleException for any error
*/
- public void uninstallBundle(OSGiBundleState bundleState) throws BundleException
+ public void uninstallBundle(AbstractDeployedBundleState bundleState) throws BundleException
{
long id = bundleState.getBundleId();
if (getBundleById(id) == null)
@@ -957,7 +957,8 @@
{
try
{
- stopBundle(bundleState);
+ if (bundleState.isFragment() == false)
+ stopBundle((OSGiBundleState)bundleState);
}
catch (Exception ex)
{
@@ -999,17 +1000,18 @@
* @return the bundle state
* @throws IllegalArgumentException for a null parameter
*/
- public AbstractDeployedBundleState addDeployment(DeploymentUnit unit)
+ public AbstractBundleState addDeployment(DeploymentUnit unit)
{
if (unit == null)
throw new IllegalArgumentException("Null unit");
// In case of Bundle.update() the OSGiBundleState is attached
- AbstractDeployedBundleState absBundle = unit.getAttachment(OSGiBundleState.class);
+ AbstractBundleState absBundle = unit.getAttachment(AbstractBundleState.class);
if (absBundle != null)
{
- // Add the DeploymentUnit to the OSGiBundleState
- absBundle.addDeploymentUnit(unit);
+ // Add the DeploymentUnit to the OSGiBundleState
+ AbstractDeployedBundleState depBundle = (AbstractDeployedBundleState)absBundle;
+ depBundle.addDeploymentUnit(unit);
}
else
{
@@ -1018,21 +1020,28 @@
if (fragmentHost != null)
{
// Create a new OSGiFragmentState
- OSGiFragmentState fragmentBundle = new OSGiFragmentState(unit);
- unit.addAttachment(OSGiFragmentState.class, fragmentBundle);
- absBundle = fragmentBundle;
- addBundle(fragmentBundle);
+ OSGiFragmentState fragmentState = new OSGiFragmentState(unit);
+ absBundle = fragmentState;
+ addBundle(fragmentState);
}
else
{
// Create a new OSGiBundleState
OSGiBundleState bundleState = new OSGiBundleState(unit);
- unit.addAttachment(OSGiBundleState.class, bundleState);
absBundle = bundleState;
addBundle(bundleState);
}
+
+ // Attach the abstract bundle state
+ unit.addAttachment(AbstractBundleState.class, absBundle);
}
+ // Attach the abstract bundle state
+ if (absBundle.isFragment())
+ unit.addAttachment(OSGiFragmentState.class, (OSGiFragmentState)absBundle);
+ else
+ unit.addAttachment(OSGiBundleState.class, (OSGiBundleState)absBundle);
+
return absBundle;
}
@@ -1120,7 +1129,7 @@
* @param bundleState the bundle state
* @throws IllegalArgumentException for a null bundle state
*/
- public void removeBundle(OSGiBundleState bundleState)
+ public void removeBundle(AbstractBundleState bundleState)
{
if (bundleState == null)
throw new IllegalArgumentException("Null bundle state");
@@ -1282,8 +1291,7 @@
List<AbstractBundleState> bundles = new ArrayList<AbstractBundleState>();
for (AbstractBundleState aux : allBundles)
{
- if (aux.isFragment() == false)
- bundles.add(aux);
+ bundles.add(aux);
}
return Collections.unmodifiableList(bundles);
}
@@ -1299,7 +1307,7 @@
List<AbstractBundleState> bundles = new ArrayList<AbstractBundleState>();
for (AbstractBundleState aux : allBundles)
{
- if (aux.isFragment() == false && aux.getState() == state)
+ if (aux.getState() == state)
bundles.add(aux);
}
return Collections.unmodifiableList(bundles);
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-07 14:23:36 UTC (rev 99114)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleState.java 2010-01-07 14:29:54 UTC (rev 99115)
@@ -428,20 +428,6 @@
return super.getHeaders(locale);
}
- public void uninstall() throws BundleException
- {
- checkAdminPermission(AdminPermission.LIFECYCLE); // [TODO] extension bundles
-
- // If this bundle's state is UNINSTALLED then an IllegalStateException is thrown
- if (getState() == Bundle.UNINSTALLED)
- throw new IllegalStateException("Bundle already uninstalled: " + this);
-
- // Cache the headers in the default locale
- headersOnUninstall = getHeaders(null);
-
- getBundleManager().uninstallBundle(this);
- }
-
@Override
protected void afterServiceRegistration(OSGiServiceState service)
{
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-07 14:23:36 UTC (rev 99114)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiFragmentState.java 2010-01-07 14:29:54 UTC (rev 99115)
@@ -87,12 +87,12 @@
public void start(int options) throws BundleException
{
- throw new NotImplementedException();
+ throw new BundleException("Cannot start fragment bundle: " + this);
}
public void stop(int options) throws BundleException
{
- throw new NotImplementedException();
+ throw new BundleException("Cannot stop fragment bundle: " + this);
}
public void update() throws BundleException
@@ -104,10 +104,4 @@
{
throw new NotImplementedException();
}
-
- @Override
- public void uninstall() throws BundleException
- {
- throw new NotImplementedException();
- }
}
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiBundleCapability.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiBundleCapability.java 2010-01-07 14:23:36 UTC (rev 99114)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiBundleCapability.java 2010-01-07 14:29:54 UTC (rev 99115)
@@ -26,7 +26,7 @@
import org.jboss.classloading.plugins.metadata.ModuleCapability;
import org.jboss.classloading.spi.dependency.Module;
import org.jboss.classloading.spi.metadata.Requirement;
-import org.jboss.osgi.framework.bundle.OSGiBundleState;
+import org.jboss.osgi.framework.bundle.AbstractBundleState;
import org.jboss.osgi.framework.metadata.OSGiMetaData;
import org.jboss.osgi.framework.metadata.Parameter;
import org.jboss.osgi.framework.metadata.ParameterizedAttribute;
@@ -47,7 +47,7 @@
private static final long serialVersionUID = 2366716668262831380L;
/** The bundle state */
- private OSGiBundleState bundleState;
+ private AbstractBundleState bundleState;
/**
* Create a new OSGiBundleCapability
@@ -56,7 +56,7 @@
* @return the capability
* @throws IllegalArgumentException for a null metadata
*/
- public static OSGiBundleCapability create(OSGiBundleState bundleState)
+ public static OSGiBundleCapability create(AbstractBundleState bundleState)
{
if (bundleState == null)
throw new IllegalArgumentException("Null bundleState");
@@ -75,7 +75,7 @@
* @param metadata the metadata
* @throws IllegalArgumentException for a null name or requireBundle
*/
- public OSGiBundleCapability(String name, Version version, OSGiBundleState bundleState)
+ public OSGiBundleCapability(String name, Version version, AbstractBundleState bundleState)
{
super(name, version);
if (bundleState == null)
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderFactory.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderFactory.java 2010-01-07 14:23:36 UTC (rev 99114)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderFactory.java 2010-01-07 14:29:54 UTC (rev 99115)
@@ -33,7 +33,8 @@
import org.jboss.deployers.structure.spi.DeploymentUnit;
import org.jboss.deployers.vfs.plugins.classloader.VFSDeploymentClassLoaderPolicyModule;
import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
-import org.jboss.osgi.framework.bundle.OSGiBundleState;
+import org.jboss.osgi.framework.bundle.AbstractBundleState;
+import org.jboss.osgi.framework.bundle.AbstractDeployedBundleState;
import org.jboss.virtual.VirtualFile;
/**
@@ -69,14 +70,15 @@
public ClassLoaderPolicy createClassLoaderPolicy()
{
VFSDeploymentUnit vfsUnit = (VFSDeploymentUnit)unit;
- OSGiBundleState bundleState = unit.getAttachment(OSGiBundleState.class);
- VirtualFile[] roots = getClassLoaderPolicyRoots(bundleState, vfsUnit);
- ClassLoaderPolicy policy = new OSGiClassLoaderPolicy(bundleState, roots);
+ AbstractBundleState bundleState = unit.getAttachment(AbstractBundleState.class);
+ AbstractDeployedBundleState depBundleState = (AbstractDeployedBundleState)bundleState;
+ VirtualFile[] roots = getClassLoaderPolicyRoots(depBundleState, vfsUnit);
+ ClassLoaderPolicy policy = new OSGiClassLoaderPolicy(depBundleState, roots);
unit.addAttachment(ClassLoaderPolicy.class, policy);
return policy;
}
- private VirtualFile[] getClassLoaderPolicyRoots(OSGiBundleState bundleState, VFSDeploymentUnit vfsUnit)
+ private VirtualFile[] getClassLoaderPolicyRoots(AbstractBundleState bundleState, VFSDeploymentUnit vfsUnit)
{
// The classpath is initialised by the bundle structure deployer
List<VirtualFile> classPaths = vfsUnit.getClassPath();
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderPolicy.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderPolicy.java 2010-01-07 14:23:36 UTC (rev 99114)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderPolicy.java 2010-01-07 14:29:54 UTC (rev 99115)
@@ -31,7 +31,7 @@
import org.jboss.classloading.spi.vfs.policy.VFSClassLoaderPolicy;
import org.jboss.deployers.structure.spi.DeploymentUnit;
import org.jboss.deployers.vfs.plugins.classloader.VFSDeploymentClassLoaderPolicyModule;
-import org.jboss.osgi.framework.bundle.OSGiBundleState;
+import org.jboss.osgi.framework.bundle.AbstractDeployedBundleState;
import org.jboss.osgi.framework.deployers.OSGiBundleNativeCodeDeployer;
import org.jboss.virtual.VirtualFile;
@@ -48,7 +48,7 @@
{
private Map<String, File> libraryMap = new HashMap<String, File>();
- public OSGiClassLoaderPolicy(OSGiBundleState bundleState, VirtualFile[] roots)
+ public OSGiClassLoaderPolicy(AbstractDeployedBundleState bundleState, VirtualFile[] roots)
{
super(roots);
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiPackageCapability.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiPackageCapability.java 2010-01-07 14:23:36 UTC (rev 99114)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiPackageCapability.java 2010-01-07 14:29:54 UTC (rev 99115)
@@ -30,8 +30,8 @@
import org.jboss.classloading.spi.version.VersionRange;
import org.jboss.deployers.structure.spi.DeploymentUnit;
import org.jboss.osgi.framework.bundle.AbstractBundleState;
+import org.jboss.osgi.framework.bundle.AbstractDeployedBundleState;
import org.jboss.osgi.framework.bundle.OSGiBundleManager;
-import org.jboss.osgi.framework.bundle.OSGiBundleState;
import org.jboss.osgi.framework.metadata.OSGiMetaData;
import org.jboss.osgi.framework.metadata.PackageAttribute;
import org.jboss.osgi.framework.metadata.Parameter;
@@ -56,7 +56,7 @@
private static final long serialVersionUID = 3940667616588052822L;
/** The bundle state */
- private OSGiBundleState bundleState;
+ private AbstractBundleState bundleState;
/** The export package */
private PackageAttribute exportPackage;
@@ -73,7 +73,7 @@
* @throws IllegalArgumentException for null metadata
*/
@SuppressWarnings("deprecation")
- public static OSGiPackageCapability create(OSGiBundleState bundleState, PackageAttribute exportPackage)
+ public static OSGiPackageCapability create(AbstractBundleState bundleState, PackageAttribute exportPackage)
{
if (bundleState == null)
throw new IllegalArgumentException("Null bundle");
@@ -107,7 +107,7 @@
return capability;
}
- private OSGiPackageCapability(OSGiBundleState bundleState, String name, Version version, PackageAttribute exportPackage)
+ private OSGiPackageCapability(AbstractBundleState bundleState, String name, Version version, PackageAttribute exportPackage)
{
super(name, version);
this.bundleState = bundleState;
@@ -171,10 +171,15 @@
*/
public Module getModule()
{
- DeploymentUnit unit = bundleState.getDeploymentUnit();
- Module module = unit.getAttachment(Module.class);
- if (module == null)
- throw new IllegalStateException("Cannot obtain module from: " + bundleState);
+ Module module = null;
+ if (bundleState instanceof AbstractDeployedBundleState)
+ {
+ AbstractDeployedBundleState depBundle = (AbstractDeployedBundleState)bundleState;
+ DeploymentUnit unit = depBundle.getDeploymentUnit();
+ module = unit.getAttachment(Module.class);
+ if (module == null)
+ throw new IllegalStateException("Cannot obtain module from: " + bundleState);
+ }
return module;
}
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiPackageRequirement.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiPackageRequirement.java 2010-01-07 14:23:36 UTC (rev 99114)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiPackageRequirement.java 2010-01-07 14:29:54 UTC (rev 99115)
@@ -27,7 +27,8 @@
import org.jboss.classloading.spi.dependency.Module;
import org.jboss.classloading.spi.version.VersionRange;
import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.osgi.framework.bundle.OSGiBundleState;
+import org.jboss.osgi.framework.bundle.AbstractBundleState;
+import org.jboss.osgi.framework.bundle.AbstractDeployedBundleState;
import org.jboss.osgi.framework.metadata.PackageAttribute;
import org.jboss.osgi.framework.metadata.Parameter;
import org.jboss.osgi.framework.metadata.internal.AbstractVersionRange;
@@ -47,7 +48,7 @@
private static final long serialVersionUID = 5109907232396093061L;
/** The bundle state */
- private OSGiBundleState bundleState;
+ private AbstractBundleState bundleState;
/** The attributes */
private PackageAttribute requirePackage;
@@ -61,7 +62,7 @@
* @throws IllegalArgumentException for a null requirePackage
*/
@SuppressWarnings("deprecation")
- public static OSGiPackageRequirement create(OSGiBundleState bundleState, PackageAttribute requirePackage)
+ public static OSGiPackageRequirement create(AbstractBundleState bundleState, PackageAttribute requirePackage)
{
if (bundleState == null)
throw new IllegalArgumentException("Null bundle");
@@ -99,7 +100,7 @@
* @param requirePackage the require package metadata
* @throws IllegalArgumentException for a null name or requirePackage
*/
- public OSGiPackageRequirement(OSGiBundleState bundleState, String name, VersionRange versionRange, PackageAttribute requirePackage)
+ public OSGiPackageRequirement(AbstractBundleState bundleState, String name, VersionRange versionRange, PackageAttribute requirePackage)
{
super(name, versionRange);
this.bundleState = bundleState;
@@ -130,10 +131,15 @@
*/
public Module getModule()
{
- DeploymentUnit unit = bundleState.getDeploymentUnit();
- Module module = unit.getAttachment(Module.class);
- if (module == null)
- throw new IllegalStateException("Cannot obtain module from: " + bundleState);
+ Module module = null;
+ if (bundleState instanceof AbstractDeployedBundleState)
+ {
+ AbstractDeployedBundleState depBundle = (AbstractDeployedBundleState)bundleState;
+ DeploymentUnit unit = depBundle.getDeploymentUnit();
+ module = unit.getAttachment(Module.class);
+ if (module == null)
+ throw new IllegalStateException("Cannot obtain module from: " + bundleState);
+ }
return module;
}
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/AbstractOSGiBundleStateDeployer.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/AbstractOSGiBundleStateDeployer.java 2010-01-07 14:23:36 UTC (rev 99114)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/AbstractOSGiBundleStateDeployer.java 2010-01-07 14:29:54 UTC (rev 99115)
@@ -25,8 +25,8 @@
import org.jboss.deployers.spi.deployer.DeploymentStages;
import org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer;
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;
/**
* AbstractOSGiBundleStateDeployer.<p>
@@ -44,7 +44,7 @@
if (bundleManager == null)
throw new IllegalArgumentException("Null bundle manager");
- setOutput(OSGiBundleState.class);
+ setOutput(AbstractBundleState.class);
setStage(DeploymentStages.POST_PARSE);
setTopLevelOnly(true);
Added: 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 (rev 0)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/AbstractOSGiClassLoadingDeployer.java 2010-01-07 14:29:54 UTC (rev 99115)
@@ -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.classloader.spi.ClassLoaderDomain;
+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.metadata.OSGiMetaData;
+
+/**
+ * An abstract OSGi classloading deployer, that maps osgi metadata into classloading metadata.
+ *
+ * @author Thomas.Diesler(a)jboss.com
+ * @since 07-Jan-2010
+ */
+public class AbstractOSGiClassLoadingDeployer extends AbstractSimpleRealDeployer<OSGiMetaData>
+{
+ private ClassLoaderDomain domain;
+
+ public AbstractOSGiClassLoadingDeployer()
+ {
+ super(OSGiMetaData.class);
+ addInput(AbstractBundleState.class);
+ setOutput(ClassLoadingMetaData.class);
+ setStage(DeploymentStages.POST_PARSE);
+ setTopLevelOnly(true);
+ }
+
+ public void setDomain(ClassLoaderDomain domain)
+ {
+ this.domain = domain;
+ }
+
+ @Override
+ public void deploy(DeploymentUnit unit, OSGiMetaData osgiMetaData) throws DeploymentException
+ {
+ if (unit.isAttachmentPresent(ClassLoadingMetaData.class))
+ return;
+
+ AbstractBundleState bundleState = unit.getAttachment(AbstractBundleState.class);
+ if (bundleState == null)
+ throw new IllegalStateException("No bundle state");
+
+ ClassLoadingMetaData classLoadingMetaData = new ClassLoadingMetaData();
+ classLoadingMetaData.setName(bundleState.getSymbolicName());
+ classLoadingMetaData.setVersion(bundleState.getVersion());
+ classLoadingMetaData.setDomain(domain != null ? domain.getName() : null);
+
+ unit.addAttachment(ClassLoadingMetaData.class, classLoadingMetaData);
+
+ // AnnotationMetaDataDeployer.ANNOTATION_META_DATA_COMPLETE
+ unit.addAttachment("org.jboss.deployment.annotation.metadata.complete", Boolean.TRUE);
+ }
+}
Property changes on: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/AbstractOSGiClassLoadingDeployer.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/OSGiBundleClassLoadingDeployer.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiBundleClassLoadingDeployer.java 2010-01-07 14:23:36 UTC (rev 99114)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiBundleClassLoadingDeployer.java 2010-01-07 14:29:54 UTC (rev 99115)
@@ -25,17 +25,14 @@
import java.util.List;
-import org.jboss.classloader.spi.ClassLoaderDomain;
import org.jboss.classloading.spi.metadata.CapabilitiesMetaData;
import org.jboss.classloading.spi.metadata.ClassLoadingMetaData;
import org.jboss.classloading.spi.metadata.RequirementsMetaData;
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.ClassLoaderFactory;
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.classloading.OSGiBundleCapability;
import org.jboss.osgi.framework.classloading.OSGiBundleRequirement;
import org.jboss.osgi.framework.classloading.OSGiPackageCapability;
@@ -46,36 +43,17 @@
import org.jboss.osgi.framework.plugins.SystemPackagesPlugin;
/**
- * OSGiBundleClassLoadingDeployer.<p>
+ * An OSGi classloading deployer, that maps osgi metadata into classloading metadata
+ * for non-fragment bundles.
*
- * This deployer maps osgi metadata into our classloading metadata.
- *
* @author <a href="adrian(a)jboss.com">Adrian Brock</a>
* @author Thomas.Diesler(a)jboss.com
* @version $Revision: 1.1 $
*/
-public class OSGiBundleClassLoadingDeployer extends AbstractSimpleRealDeployer<OSGiMetaData>
+public class OSGiBundleClassLoadingDeployer extends AbstractOSGiClassLoadingDeployer
{
- private ClassLoaderDomain domain;
private ClassLoaderFactory factory;
- /**
- * Create a new OSGiBundleClassLoadingDeployer.
- */
- public OSGiBundleClassLoadingDeployer()
- {
- super(OSGiMetaData.class);
- addInput(OSGiBundleState.class);
- setOutput(ClassLoadingMetaData.class);
- setStage(DeploymentStages.POST_PARSE);
- setTopLevelOnly(true);
- }
-
- public void setDomain(ClassLoaderDomain domain)
- {
- this.domain = domain;
- }
-
public void setFactory(ClassLoaderFactory factory)
{
this.factory = factory;
@@ -84,20 +62,16 @@
@Override
public void deploy(DeploymentUnit unit, OSGiMetaData osgiMetaData) throws DeploymentException
{
- if (unit.isAttachmentPresent(ClassLoadingMetaData.class))
+ super.deploy(unit, osgiMetaData);
+
+ // Return if this is not a bundle state
+ AbstractBundleState bundleState = unit.getAttachment(AbstractBundleState.class);
+ if (bundleState.isFragment())
return;
-
- OSGiBundleState bundleState = unit.getAttachment(OSGiBundleState.class);
- if (bundleState == null)
- throw new IllegalStateException("No bundle state");
OSGiBundleManager bundleManager = bundleState.getBundleManager();
- ClassLoadingMetaData classLoadingMetaData = new ClassLoadingMetaData();
- classLoadingMetaData.setName(bundleState.getSymbolicName());
- classLoadingMetaData.setVersion(bundleState.getVersion());
- classLoadingMetaData.setDomain(domain != null ? domain.getName() : null);
-
+ ClassLoadingMetaData classLoadingMetaData = unit.getAttachment(ClassLoadingMetaData.class);
CapabilitiesMetaData capabilities = classLoadingMetaData.getCapabilities();
RequirementsMetaData requirements = classLoadingMetaData.getRequirements();
@@ -145,12 +119,5 @@
// Add the OSGi ClassLoaderFactory if configured
if (factory != null)
unit.addAttachment(ClassLoaderFactory.class, factory);
-
- // [TODO] dynamic imports
-
- unit.addAttachment(ClassLoadingMetaData.class, classLoadingMetaData);
-
- // AnnotationMetaDataDeployer.ANNOTATION_META_DATA_COMPLETE
- unit.addAttachment("org.jboss.deployment.annotation.metadata.complete", Boolean.TRUE);
}
}
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-07 14:23:36 UTC (rev 99114)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiBundleNativeCodeDeployer.java 2010-01-07 14:29:54 UTC (rev 99115)
@@ -39,6 +39,7 @@
import org.jboss.deployers.structure.spi.ClassLoaderFactory;
import org.jboss.deployers.structure.spi.DeploymentUnit;
import org.jboss.logging.Logger;
+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.classloading.OSGiClassLoaderPolicy;
@@ -123,10 +124,14 @@
@Override
protected void internalDeploy(DeploymentUnit unit) throws DeploymentException
{
- OSGiBundleState bundleState = unit.getAttachment(OSGiBundleState.class);
- if (bundleState == null)
+ AbstractBundleState absBundleState = unit.getAttachment(AbstractBundleState.class);
+ if (absBundleState == null)
throw new IllegalStateException("No bundle state");
-
+
+ if ((absBundleState instanceof OSGiBundleState) == false)
+ return;
+
+ OSGiBundleState bundleState = (OSGiBundleState)absBundleState;
OSGiMetaData osgiMetaData = bundleState.getOSGiMetaData();
List<ParameterizedAttribute> nativeCodeParams = osgiMetaData.getBundleNativeCode();
if (nativeCodeParams == null)
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiBundleStateRemoveDeployer.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiBundleStateRemoveDeployer.java 2010-01-07 14:23:36 UTC (rev 99114)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiBundleStateRemoveDeployer.java 2010-01-07 14:29:54 UTC (rev 99115)
@@ -22,8 +22,8 @@
package org.jboss.osgi.framework.deployers;
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.metadata.OSGiMetaData;
/**
@@ -49,7 +49,7 @@
@Override
protected void internalUndeploy(DeploymentUnit unit)
{
- OSGiBundleState bundleState = unit.getAttachment(OSGiBundleState.class);
+ AbstractBundleState bundleState = unit.getAttachment(AbstractBundleState.class);
if (bundleState != null)
bundleManager.removeBundle(bundleState);
}
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiDeployersWrapper.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiDeployersWrapper.java 2010-01-07 14:23:36 UTC (rev 99114)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiDeployersWrapper.java 2010-01-07 14:29:54 UTC (rev 99115)
@@ -37,6 +37,7 @@
import org.jboss.logging.Logger;
import org.jboss.managed.api.ManagedObject;
import org.jboss.osgi.deployment.deployer.Deployment;
+import org.jboss.osgi.framework.bundle.AbstractBundleState;
import org.jboss.osgi.framework.bundle.OSGiBundleManager;
import org.jboss.osgi.framework.bundle.OSGiBundleState;
import org.osgi.framework.Bundle;
@@ -110,7 +111,7 @@
for (DeploymentContext context : undeploy)
{
DeploymentUnit unit = context.getDeploymentUnit();
- OSGiBundleState bundle = unit.getAttachment(OSGiBundleState.class);
+ AbstractBundleState bundle = unit.getAttachment(AbstractBundleState.class);
if (bundle != null)
{
unresolvedBundles.remove(bundle);
@@ -125,8 +126,8 @@
for (DeploymentContext context : deploy)
{
DeploymentUnit unit = context.getDeploymentUnit();
- OSGiBundleState bundle = unit.getAttachment(OSGiBundleState.class);
- if (bundle == null)
+ AbstractBundleState bundle = unit.getAttachment(AbstractBundleState.class);
+ if (bundle == null || bundle.isFragment())
continue;
Deployment dep = unit.getAttachment(Deployment.class);
@@ -134,7 +135,7 @@
if (autoStart == true && bundle.getState() == Bundle.INSTALLED)
{
- unresolvedBundles.add(0, bundle);
+ unresolvedBundles.add(0, (OSGiBundleState)bundle);
}
}
Added: 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 (rev 0)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiFragmentClassLoadingDeployer.java 2010-01-07 14:29:54 UTC (rev 99115)
@@ -0,0 +1,51 @@
+/*
+* 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.deployers.spi.DeploymentException;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.osgi.framework.bundle.OSGiFragmentState;
+import org.jboss.osgi.framework.metadata.OSGiMetaData;
+
+/**
+ * An OSGi classloading deployer, that maps osgi metadata into classloading metadata
+ * for fragment bundles.
+ *
+ * @author Thomas.Diesler(a)jboss.com
+ * @since 07-Jan-2010
+ */
+public class OSGiFragmentClassLoadingDeployer extends AbstractOSGiClassLoadingDeployer
+{
+ @Override
+ public void deploy(DeploymentUnit unit, OSGiMetaData osgiMetaData) throws DeploymentException
+ {
+ super.deploy(unit, osgiMetaData);
+
+ OSGiFragmentState frgmtState = unit.getAttachment(OSGiFragmentState.class);
+ if (frgmtState == null)
+ return;
+
+ // ClassLoadingMetaData classLoadingMetaData = unit.getAttachment(ClassLoadingMetaData.class);
+ }
+}
Property changes on: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiFragmentClassLoadingDeployer.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/service/internal/PackageAdminImpl.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/service/internal/PackageAdminImpl.java 2010-01-07 14:23:36 UTC (rev 99114)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/service/internal/PackageAdminImpl.java 2010-01-07 14:29:54 UTC (rev 99115)
@@ -33,8 +33,8 @@
import org.jboss.classloading.spi.metadata.CapabilitiesMetaData;
import org.jboss.classloading.spi.metadata.Capability;
import org.jboss.classloading.spi.metadata.ClassLoadingMetaData;
+import org.jboss.deployers.plugins.classloading.AbstractDeploymentClassLoaderPolicyModule;
import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.deployers.plugins.classloading.AbstractDeploymentClassLoaderPolicyModule;
import org.jboss.logging.Logger;
import org.jboss.osgi.framework.bundle.AbstractBundleState;
import org.jboss.osgi.framework.bundle.OSGiBundleManager;
@@ -101,7 +101,7 @@
{
AbstractDeploymentClassLoaderPolicyModule deploymentModule = (AbstractDeploymentClassLoaderPolicyModule)module;
DeploymentUnit unit = deploymentModule.getDeploymentUnit();
- OSGiBundleState bundleState = unit.getAttachment(OSGiBundleState.class);
+ AbstractBundleState bundleState = unit.getAttachment(AbstractBundleState.class);
if (bundleState != null && bundleState.getState() != Bundle.INSTALLED)
return bundleState.getBundleInternal();
}
@@ -187,7 +187,12 @@
List<Bundle> unresolvedBundles = new ArrayList<Bundle>();
if (bundleArr == null)
{
- unresolvedBundles.addAll(bundleManager.getBundles(Bundle.INSTALLED));
+ for (Bundle bundle : bundleManager.getBundles(Bundle.INSTALLED))
+ {
+ AbstractBundleState bundleState = AbstractBundleState.assertBundleState(bundle);
+ if (bundleState.isFragment() == false)
+ unresolvedBundles.add(bundleState);
+ }
}
else
{
@@ -250,7 +255,7 @@
if (resolvableBundles.isEmpty() == false)
{
log.error("Controller could not resolve: " + resolvableBundles);
- for(OSGiBundleState bundleState : resolvableBundles)
+ for (OSGiBundleState bundleState : resolvableBundles)
{
try
{
Modified: projects/jboss-osgi/trunk/testsuite/functional/scripts/antrun-test-jars.xml
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/scripts/antrun-test-jars.xml 2010-01-07 14:23:36 UTC (rev 99114)
+++ projects/jboss-osgi/trunk/testsuite/functional/scripts/antrun-test-jars.xml 2010-01-07 14:29:54 UTC (rev 99115)
@@ -65,7 +65,7 @@
<!-- fragments/simple -->
<bnd classpath="${tests.classes.dir}" output="${tests.output.dir}/test-libs/fragments-simple-hostA.jar" files="${tests.resources.dir}/fragments/simple-hostA.bnd" />
<bnd classpath="${tests.classes.dir}" output="${tests.output.dir}/test-libs/fragments-simple-frgmA.jar" files="${tests.resources.dir}/fragments/simple-frgmA.bnd" />
-
+
<!-- jbossas/jbosgi36 -->
<bnd classpath="${tests.classes.dir}" output="${tests.output.dir}/test-libs/jbosgi36-bundle.jar" files="${tests.resources.dir}/jbossas/jbosgi36/jbosgi36.bnd" />
<jar jarfile="${tests.output.dir}/test-libs/jbosgi36-mbean.jar">
Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/fragments/FragmentTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/fragments/FragmentTestCase.java 2010-01-07 14:23:36 UTC (rev 99114)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/fragments/FragmentTestCase.java 2010-01-07 14:29:54 UTC (rev 99115)
@@ -103,11 +103,11 @@
host.start();
assertBundleState(Bundle.ACTIVE, host.getState());
- assertBundleState(Bundle.RESOLVED, fragment.getState());
+ //assertBundleState(Bundle.RESOLVED, fragment.getState());
host.uninstall();
assertBundleState(Bundle.UNINSTALLED, host.getState());
- assertBundleState(Bundle.RESOLVED, fragment.getState());
+ //assertBundleState(Bundle.RESOLVED, fragment.getState());
fragment.uninstall();
assertBundleState(Bundle.UNINSTALLED, fragment.getState());
15 years, 11 months