Author: alesj
Date: 2009-11-19 18:08:37 -0500 (Thu, 19 Nov 2009)
New Revision: 96602
Modified:
projects/jboss-osgi/trunk/reactor/framework/pom.xml
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiServiceState.java
Log:
[JBOSGI-141]; initial ungetTarget impl.
Update Kernel to 2.2.x.
Modified: projects/jboss-osgi/trunk/reactor/framework/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/pom.xml 2009-11-19 23:08:35 UTC (rev
96601)
+++ projects/jboss-osgi/trunk/reactor/framework/pom.xml 2009-11-19 23:08:37 UTC (rev
96602)
@@ -41,7 +41,7 @@
<version.jboss.aop>2.1.0.CR3</version.jboss.aop>
<version.jboss.classloading>2.0.8-SNAPSHOT</version.jboss.classloading>
<version.jboss.deployers>2.0.9-SNAPSHOT</version.jboss.deployers>
- <version.jboss.microcontainer>2.0.9.GA</version.jboss.microcontainer>
+ <version.jboss.kernel>2.2.0-SNAPSHOT</version.jboss.kernel>
<version.jboss.test>1.1.4.GA</version.jboss.test>
<surefire.system.args>${surefire.memory.args} ${surefire.jpda.args}
${surefire.profiler.args}</surefire.system.args>
</properties>
@@ -87,9 +87,21 @@
</exclusion>
<exclusion>
<groupId>org.jboss.microcontainer</groupId>
+ <artifactId>jboss-kernel</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.jboss.microcontainer</groupId>
<artifactId>jboss-dependency</artifactId>
</exclusion>
<exclusion>
+ <groupId>org.jboss.kernel</groupId>
+ <artifactId>jboss-dependency</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.jboss.kernel</groupId>
+ <artifactId>jboss-kernel</artifactId>
+ </exclusion>
+ <exclusion>
<groupId>org.jboss</groupId>
<artifactId>jboss-reflect</artifactId>
</exclusion>
@@ -111,11 +123,47 @@
<groupId>org.jboss.cl</groupId>
<artifactId>jboss-classloader</artifactId>
<version>${version.jboss.classloading}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.jboss.microcontainer</groupId>
+ <artifactId>jboss-dependency</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.jboss.microcontainer</groupId>
+ <artifactId>jboss-kernel</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.jboss.kernel</groupId>
+ <artifactId>jboss-dependency</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.jboss.kernel</groupId>
+ <artifactId>jboss-kernel</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>org.jboss.cl</groupId>
<artifactId>jboss-classloading</artifactId>
<version>${version.jboss.classloading}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.jboss.microcontainer</groupId>
+ <artifactId>jboss-dependency</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.jboss.microcontainer</groupId>
+ <artifactId>jboss-kernel</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.jboss.kernel</groupId>
+ <artifactId>jboss-dependency</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.jboss.kernel</groupId>
+ <artifactId>jboss-kernel</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>org.jboss.cl</groupId>
@@ -126,12 +174,46 @@
<groupId>org.jboss</groupId>
<artifactId>jboss-vfs</artifactId>
</exclusion>
+ <exclusion>
+ <groupId>org.jboss.microcontainer</groupId>
+ <artifactId>jboss-dependency</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.jboss.microcontainer</groupId>
+ <artifactId>jboss-kernel</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.jboss.kernel</groupId>
+ <artifactId>jboss-dependency</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.jboss.kernel</groupId>
+ <artifactId>jboss-kernel</artifactId>
+ </exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.jboss.deployers</groupId>
<artifactId>jboss-deployers-impl</artifactId>
<version>${version.jboss.deployers}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.jboss.microcontainer</groupId>
+ <artifactId>jboss-dependency</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.jboss.microcontainer</groupId>
+ <artifactId>jboss-kernel</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.jboss.kernel</groupId>
+ <artifactId>jboss-dependency</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.jboss.kernel</groupId>
+ <artifactId>jboss-kernel</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>org.jboss.deployers</groupId>
@@ -142,6 +224,22 @@
<groupId>org.jboss</groupId>
<artifactId>jboss-vfs</artifactId>
</exclusion>
+ <exclusion>
+ <groupId>org.jboss.microcontainer</groupId>
+ <artifactId>jboss-dependency</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.jboss.microcontainer</groupId>
+ <artifactId>jboss-kernel</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.jboss.kernel</groupId>
+ <artifactId>jboss-dependency</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.jboss.kernel</groupId>
+ <artifactId>jboss-kernel</artifactId>
+ </exclusion>
</exclusions>
</dependency>
<dependency>
@@ -153,22 +251,83 @@
<groupId>org.jboss</groupId>
<artifactId>jboss-vfs</artifactId>
</exclusion>
+ <exclusion>
+ <groupId>org.jboss.microcontainer</groupId>
+ <artifactId>jboss-dependency</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.jboss.microcontainer</groupId>
+ <artifactId>jboss-kernel</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.jboss.kernel</groupId>
+ <artifactId>jboss-dependency</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.jboss.kernel</groupId>
+ <artifactId>jboss-kernel</artifactId>
+ </exclusion>
</exclusions>
</dependency>
<dependency>
- <groupId>org.jboss.microcontainer</groupId>
+ <groupId>org.jboss.kernel</groupId>
<artifactId>jboss-kernel</artifactId>
- <version>${version.jboss.microcontainer}</version>
+ <version>${version.jboss.kernel}</version>
<exclusions>
<exclusion>
<groupId>org.jboss</groupId>
<artifactId>jboss-vfs</artifactId>
</exclusion>
+ <exclusion>
+ <groupId>org.jboss.microcontainer</groupId>
+ <artifactId>jboss-dependency</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.jboss.microcontainer</groupId>
+ <artifactId>jboss-kernel</artifactId>
+ </exclusion>
</exclusions>
</dependency>
<dependency>
+ <groupId>org.jboss.kernel</groupId>
+ <artifactId>jboss-dependency</artifactId>
+ <version>${version.jboss.kernel}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-vfs</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.jboss.microcontainer</groupId>
+ <artifactId>jboss-dependency</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.jboss.microcontainer</groupId>
+ <artifactId>jboss-kernel</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
<groupId>org.jboss.osgi</groupId>
<artifactId>jboss-osgi-spi</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>org.jboss.microcontainer</groupId>
+ <artifactId>jboss-dependency</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.jboss.microcontainer</groupId>
+ <artifactId>jboss-kernel</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.jboss.kernel</groupId>
+ <artifactId>jboss-dependency</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.jboss.kernel</groupId>
+ <artifactId>jboss-kernel</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>org.jboss.osgi.runtime</groupId>
@@ -178,6 +337,22 @@
<groupId>org.jboss</groupId>
<artifactId>jboss-vfs</artifactId>
</exclusion>
+ <exclusion>
+ <groupId>org.jboss.microcontainer</groupId>
+ <artifactId>jboss-dependency</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.jboss.microcontainer</groupId>
+ <artifactId>jboss-kernel</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.jboss.kernel</groupId>
+ <artifactId>jboss-dependency</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.jboss.kernel</groupId>
+ <artifactId>jboss-kernel</artifactId>
+ </exclusion>
</exclusions>
</dependency>
<dependency>
@@ -188,6 +363,22 @@
<groupId>org.jboss</groupId>
<artifactId>jboss-vfs</artifactId>
</exclusion>
+ <exclusion>
+ <groupId>org.jboss.microcontainer</groupId>
+ <artifactId>jboss-dependency</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.jboss.microcontainer</groupId>
+ <artifactId>jboss-kernel</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.jboss.kernel</groupId>
+ <artifactId>jboss-dependency</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.jboss.kernel</groupId>
+ <artifactId>jboss-kernel</artifactId>
+ </exclusion>
</exclusions>
</dependency>
Modified:
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java
===================================================================
---
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java 2009-11-19
23:08:35 UTC (rev 96601)
+++
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java 2009-11-19
23:08:37 UTC (rev 96602)
@@ -443,6 +443,11 @@
return getBundleManager().getService(this, reference);
}
+ Object getService(OSGiServiceState serviceState)
+ {
+ return getBundleManager().getService(this, serviceState);
+ }
+
public ServiceReference getServiceReference(String clazz)
{
checkValidBundleContext();
Modified:
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java
===================================================================
---
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java 2009-11-19
23:08:35 UTC (rev 96601)
+++
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java 2009-11-19
23:08:37 UTC (rev 96602)
@@ -21,8 +21,6 @@
*/
package org.jboss.osgi.framework.bundle;
-import static org.jboss.osgi.spi.OSGiConstants.PROPERTY_AUTO_START;
-
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
@@ -48,8 +46,8 @@
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
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;
@@ -77,6 +75,7 @@
import org.jboss.osgi.framework.plugins.ResolverPlugin;
import org.jboss.osgi.framework.plugins.ServicePlugin;
import org.jboss.osgi.framework.util.NoFilter;
+import static org.jboss.osgi.spi.OSGiConstants.PROPERTY_AUTO_START;
import org.jboss.util.collection.ConcurrentSet;
import org.jboss.virtual.VFS;
import org.jboss.virtual.VFSUtils;
@@ -1219,6 +1218,18 @@
{
OSGiServiceReferenceWrapper serviceReference =
(OSGiServiceReferenceWrapper)reference;
OSGiServiceState serviceState = serviceReference.getServiceState();
+ return getService(bundleState, serviceState);
+ }
+
+ /**
+ * Get a service
+ *
+ * @param bundleState the bundle that requests the service
+ * @param serviceState the service state
+ * @return the service
+ */
+ Object getService(AbstractBundleState bundleState, OSGiServiceState serviceState)
+ {
Object result = serviceState.getService(bundleState);
if (result != null)
bundleState.addServiceInUse(serviceState);
Modified:
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiServiceState.java
===================================================================
---
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiServiceState.java 2009-11-19
23:08:35 UTC (rev 96601)
+++
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiServiceState.java 2009-11-19
23:08:37 UTC (rev 96602)
@@ -32,10 +32,17 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;
+import org.jboss.beans.info.spi.BeanInfo;
import org.jboss.dependency.plugins.AbstractControllerContext;
+import org.jboss.dependency.plugins.AbstractScopeInfo;
+import org.jboss.dependency.spi.dispatch.InvokeDispatchContext;
+import org.jboss.kernel.Kernel;
+import org.jboss.kernel.spi.config.KernelConfigurator;
import org.jboss.logging.Logger;
import org.jboss.osgi.framework.plugins.FrameworkEventsPlugin;
import org.jboss.osgi.framework.util.CaseInsensitiveDictionary;
+import org.jboss.osgi.spi.util.BundleClassLoader;
+import org.jboss.reflect.spi.ClassInfo;
import org.jboss.util.collection.ConcurrentSet;
import org.jboss.util.id.GUID;
import org.osgi.framework.Bundle;
@@ -55,7 +62,7 @@
* @author <a href="ales.justin(a)jboss.org">Ales Justin</a>
* @version $Revision: 1.1 $
*/
-public class OSGiServiceState extends AbstractControllerContext implements
ServiceReference, ServiceRegistration
+public class OSGiServiceState extends AbstractControllerContext implements
ServiceReference, ServiceRegistration, InvokeDispatchContext
{
/** The log */
private static final Logger log = Logger.getLogger(OSGiServiceState.class);
@@ -90,6 +97,9 @@
/** The using bundles */
private Set<AbstractBundleState> usingBundles = new
ConcurrentSet<AbstractBundleState>();
+ /** The bean info */
+ private BeanInfo beanInfo;
+
/**
* Create a new OSGiServiceState.
*
@@ -129,6 +139,8 @@
this.properties = new CaseInsensitiveDictionary(properties);
serviceRegistration = new OSGiServiceRegistrationWrapper(this);
+
+ initOSGiScopeInfo();
}
/**
@@ -165,12 +177,80 @@
}
@Override
+ protected void initScopeInfo()
+ {
+ // nothing
+ }
+
+ protected void initOSGiScopeInfo()
+ {
+ String className = null;
+ Object target = serviceOrFactory;
+ if (target != null)
+ className = target.getClass().getName();
+ setScopeInfo(new AbstractScopeInfo(getName(), className));
+ }
+
+ @Override
public Object getTarget()
{
- // do we cache this? or how to unget?
- return getService(getBundleState());
+ return bundleState.getService(this);
}
+ public Object ungetTarget()
+ {
+ bundleState.ungetService(this);
+ return getService(bundleState);
+ }
+
+ public Object invoke(String name, Object[] parameters, String[] signature) throws
Throwable
+ {
+ Object service = getService(bundleState);
+ return getBeanInfo().invoke(service, name, signature, parameters);
+ }
+
+ public ClassInfo getClassInfo()
+ {
+ return getBeanInfo().getClassInfo();
+ }
+
+ public ClassLoader getClassLoader() throws Throwable
+ {
+ return BundleClassLoader.createClassLoader(getBundle());
+ }
+
+ public Object get(String name) throws Throwable
+ {
+ Object service = getService(bundleState);
+ return getBeanInfo().getProperty(service, name);
+ }
+
+ public void set(String name, Object value) throws Throwable
+ {
+ Object service = getService(bundleState);
+ getBeanInfo().setProperty(service, name, value);
+ }
+
+ public BeanInfo getBeanInfo()
+ {
+ if (beanInfo == null)
+ {
+ try
+ {
+ Kernel kernel = bundleState.getBundleManager().getKernel();
+ KernelConfigurator configurator = kernel.getConfigurator();
+ Object service = getService(bundleState);
+ if (service != null)
+ beanInfo = configurator.getBeanInfo(service.getClass());
+ }
+ catch (Throwable t)
+ {
+ throw new RuntimeException(t);
+ }
+ }
+ return beanInfo;
+ }
+
/**
* Get the service.
*