JBoss-OSGI SVN: r97452 - projects/jboss-osgi/projects/runtime/framework/trunk/src/test/java/org/jboss/test/osgi/service.
by jboss-osgi-commits@lists.jboss.org
Author: alesj
Date: 2009-12-04 07:06:19 -0500 (Fri, 04 Dec 2009)
New Revision: 97452
Modified:
projects/jboss-osgi/projects/runtime/framework/trunk/src/test/java/org/jboss/test/osgi/service/ServiceMixUnitTestCase.java
Log:
Assert on invoke.
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 2009-12-04 11:52:01 UTC (rev 97451)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/test/java/org/jboss/test/osgi/service/ServiceMixUnitTestCase.java 2009-12-04 12:06:19 UTC (rev 97452)
@@ -105,8 +105,9 @@
}
}
- private static Object invoke(Object target, String getter) throws Throwable
+ private static Object invoke(Object target, String getter, String name) throws Throwable
{
+ assertNotNull("Target" + name + " is not null", target);
Class<?> clazz = target.getClass();
Method m = clazz.getDeclaredMethod(getter);
return m.invoke(target);
@@ -138,7 +139,7 @@
checkComplete();
Object c = getBean("C");
- assertSame(a, invoke(c, "getA"));
+ assertSame(a, invoke(c, "getA", "C"));
ServiceReference ref1 = bundleContext1.getServiceReference(A.class.getName());
assertUsingBundles(ref1, LazyBundle.getBundle(getDeploymentUnit(bean)));
@@ -197,7 +198,7 @@
checkComplete();
Object c = getBean("C");
- assertSame(a, invoke(c, "getA"));
+ assertSame(a, invoke(c, "getA", "C"));
ServiceReference ref1 = bundleContext1.getServiceReference(A.class.getName());
assertUsingBundles(ref1, LazyBundle.getBundle(getDeploymentUnit(bean)));
@@ -261,15 +262,13 @@
checkComplete();
Object c1 = getBean("C1");
- assertNotNull("Bean C1 not null", c1);
- Object a1 = invoke(c1, "getA");
- assertNotNull("Bean A not null", a1);
- Object msg1 = invoke(a1, "getMsg");
+ Object a1 = invoke(c1, "getA", "C1");
+ Object msg1 = invoke(a1, "getMsg", "A1");
assertEquals(msg1, getBundle(bean1).getSymbolicName());
Object c2 = getBean("C2");
- Object a2 = invoke(c2, "getA");
- Object msg2 = invoke(a2, "getMsg");
+ Object a2 = invoke(c2, "getA", "C2");
+ Object msg2 = invoke(a2, "getMsg", "A2");
assertEquals(msg2, getBundle(bean2).getSymbolicName());
}
finally
16 years, 7 months
JBoss-OSGI SVN: r97451 - projects/jboss-osgi/projects/runtime/framework/trunk/src/test/java/org/jboss/test/osgi/service.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-12-04 06:52:01 -0500 (Fri, 04 Dec 2009)
New Revision: 97451
Modified:
projects/jboss-osgi/projects/runtime/framework/trunk/src/test/java/org/jboss/test/osgi/service/ServiceMixUnitTestCase.java
Log:
Add not null assertions
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 2009-12-04 11:43:26 UTC (rev 97450)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/test/java/org/jboss/test/osgi/service/ServiceMixUnitTestCase.java 2009-12-04 11:52:01 UTC (rev 97451)
@@ -228,7 +228,7 @@
}
}
- public void disabled_testServiceFactoryInjection() throws Throwable
+ public void testServiceFactoryInjection() throws Throwable
{
BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder("C1", C.class.getName());
builder.addPropertyMetaData("a", builder.createInject("A"));
@@ -261,7 +261,9 @@
checkComplete();
Object c1 = getBean("C1");
+ assertNotNull("Bean C1 not null", c1);
Object a1 = invoke(c1, "getA");
+ assertNotNull("Bean A not null", a1);
Object msg1 = invoke(a1, "getMsg");
assertEquals(msg1, getBundle(bean1).getSymbolicName());
16 years, 7 months
JBoss-OSGI SVN: r97450 - in projects/jboss-osgi/projects/runtime/framework/trunk: .settings and 5 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-12-04 06:43:26 -0500 (Fri, 04 Dec 2009)
New Revision: 97450
Modified:
projects/jboss-osgi/projects/runtime/framework/trunk/.settings/org.eclipse.jdt.core.prefs
projects/jboss-osgi/projects/runtime/framework/trunk/pom.xml
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/deployers/OSGiDeployersWrapper.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/plugins/internal/AutoInstallPluginImpl.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/service/internal/MicrocontainerServiceImpl.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/test/java/org/jboss/test/osgi/resolver/BasicResolverTest.java
Log:
Merge changes from Alpha2 branch
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/.settings/org.eclipse.jdt.core.prefs 2009-12-04 11:24:43 UTC (rev 97449)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/.settings/org.eclipse.jdt.core.prefs 2009-12-04 11:43:26 UTC (rev 97450)
@@ -1,12 +1,6 @@
-#Thu Nov 19 14:05:44 CET 2009
+#Fri Dec 04 12:28:37 CET 2009
eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
-org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.5
-org.eclipse.jdt.core.compiler.debug.lineNumber=generate
-org.eclipse.jdt.core.compiler.debug.localVariable=generate
-org.eclipse.jdt.core.compiler.debug.sourceFile=generate
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.5
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/pom.xml 2009-12-04 11:24:43 UTC (rev 97449)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/pom.xml 2009-12-04 11:43:26 UTC (rev 97450)
@@ -44,18 +44,18 @@
<version.jboss.classloading>2.0.8.GA</version.jboss.classloading>
<version.jboss.deployers>2.2.0-SNAPSHOT</version.jboss.deployers>
<version.jboss.kernel>2.2.0-SNAPSHOT</version.jboss.kernel>
- <version.jboss.osgi.apache.xerces>2.9.1.SP2</version.jboss.osgi.apache.xerces>
+ <version.jboss.osgi.apache.xerces>2.9.1.SP3</version.jboss.osgi.apache.xerces>
<version.jboss.osgi.common>1.0.3</version.jboss.osgi.common>
<version.jboss.osgi.common.core>2.2.13.GA</version.jboss.osgi.common.core>
<version.jboss.osgi.deployment>1.0.0</version.jboss.osgi.deployment>
<version.jboss.osgi.husky>1.0.2</version.jboss.osgi.husky>
- <version.jboss.osgi.jaxb>2.1.10.SP2</version.jboss.osgi.jaxb>
+ <version.jboss.osgi.jaxb>2.1.10.SP3</version.jboss.osgi.jaxb>
<version.jboss.osgi.jmx>1.0.2</version.jboss.osgi.jmx>
<version.jboss.osgi.runtime.deployers>1.0.3</version.jboss.osgi.runtime.deployers>
<version.jboss.osgi.spi>1.0.3</version.jboss.osgi.spi>
- <version.jboss.osgi.xml.binding>2.0.1.SP1</version.jboss.osgi.xml.binding>
+ <version.jboss.osgi.xml.binding>2.0.2.Beta3</version.jboss.osgi.xml.binding>
<version.jboss.test>1.1.4.GA</version.jboss.test>
- <version.ops4j.pax.web>0.7.2-SNAPSHOT</version.ops4j.pax.web>
+ <version.ops4j.pax.web>0.7.2</version.ops4j.pax.web>
<version.osgi>4.2.0</version.osgi>
</properties>
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 2009-12-04 11:24:43 UTC (rev 97449)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java 2009-12-04 11:43:26 UTC (rev 97450)
@@ -44,8 +44,8 @@
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import java.util.jar.Attributes;
+import java.util.jar.Manifest;
import java.util.jar.Attributes.Name;
-import java.util.jar.Manifest;
import org.jboss.dependency.spi.Controller;
import org.jboss.dependency.spi.ControllerContext;
@@ -72,6 +72,7 @@
import org.jboss.metadata.spi.scope.CommonLevels;
import org.jboss.metadata.spi.scope.ScopeKey;
import org.jboss.osgi.deployment.deployer.Deployment;
+import org.jboss.osgi.deployment.deployer.DeploymentFactory;
import org.jboss.osgi.framework.metadata.OSGiMetaData;
import org.jboss.osgi.framework.metadata.PackageAttribute;
import org.jboss.osgi.framework.metadata.internal.AbstractOSGiMetaData;
@@ -83,7 +84,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.osgi.spi.util.BundleInfo;
import org.jboss.virtual.VFS;
import org.jboss.virtual.VFSUtils;
import org.jboss.virtual.VirtualFile;
@@ -684,6 +685,21 @@
return install(root, root.toString(), false);
}
+ /*
+ * Installs a bundle from the given virtual file.
+ */
+ private AbstractBundleState install(VirtualFile root, String location, boolean autoStart) throws BundleException
+ {
+ if (location == null)
+ throw new IllegalArgumentException("Null location");
+
+ BundleInfo info = BundleInfo.createBundleInfo(root, location);
+ Deployment dep = DeploymentFactory.createDeployment(info);
+ dep.setAutoStart(autoStart);
+
+ return installBundle(dep);
+ }
+
/**
* Install a bundle from a deployment.
*
@@ -694,25 +710,12 @@
*/
public AbstractBundleState installBundle(Deployment dep) throws BundleException
{
- String location = dep.getLocation().toExternalForm();
- return install(dep.getRoot(), location, dep.isAutoStart());
- }
-
- /*
- * Installs a bundle from the given virtual file.
- */
- private AbstractBundleState install(VirtualFile root, String location, boolean autoStart) throws BundleException
- {
- if (location == null)
- throw new IllegalArgumentException("Null location");
-
// Create the deployment and deploy it
try
{
- VFSDeployment deployment = VFSDeploymentFactory.getInstance().createVFSDeployment(root);
+ VFSDeployment deployment = VFSDeploymentFactory.getInstance().createVFSDeployment(dep.getRoot());
MutableAttachments att = (MutableAttachments)deployment.getPredeterminedManagedObjects();
- att.addAttachment(PROPERTY_BUNDLE_LOCATION, location);
- att.addAttachment(PROPERTY_AUTO_START, autoStart);
+ att.addAttachment(Deployment.class, dep);
deployerClient.deploy(deployment);
try
@@ -739,7 +742,7 @@
if (cause instanceof BundleException)
throw (BundleException)cause;
}
- throw new BundleException("Error installing bundle from location=" + root, (cause != null ? cause : ex));
+ throw new BundleException("Error installing bundle from: " + dep, (cause != null ? cause : ex));
}
}
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 2009-12-04 11:24:43 UTC (rev 97449)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiDeployersWrapper.java 2009-12-04 11:43:26 UTC (rev 97450)
@@ -21,14 +21,11 @@
*/
package org.jboss.osgi.framework.deployers;
-import static org.jboss.osgi.spi.OSGiConstants.PROPERTY_AUTO_START;
-
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList;
-import org.jboss.deployers.client.spi.Deployment;
import org.jboss.deployers.client.spi.main.MainDeployer;
import org.jboss.deployers.plugins.main.MainDeployerImpl;
import org.jboss.deployers.spi.DeploymentException;
@@ -39,6 +36,7 @@
import org.jboss.deployers.structure.spi.DeploymentUnit;
import org.jboss.logging.Logger;
import org.jboss.managed.api.ManagedObject;
+import org.jboss.osgi.deployment.deployer.Deployment;
import org.jboss.osgi.framework.bundle.OSGiBundleManager;
import org.jboss.osgi.framework.bundle.OSGiBundleState;
import org.osgi.framework.Bundle;
@@ -131,9 +129,8 @@
if (bundle == null)
continue;
- Boolean autoStart = (Boolean)unit.getAttachment(PROPERTY_AUTO_START);
- if (autoStart == null)
- autoStart = Boolean.TRUE;
+ Deployment dep = unit.getAttachment(Deployment.class);
+ boolean autoStart = (dep != null ? dep.isAutoStart() : true);
if (autoStart == true && bundle.getState() == Bundle.INSTALLED)
{
@@ -185,7 +182,7 @@
deployers.checkComplete(contexts);
}
- public void checkComplete(Collection<DeploymentContext> errors, Collection<Deployment> missingDeployer) throws DeploymentException
+ public void checkComplete(Collection<DeploymentContext> errors, Collection<org.jboss.deployers.client.spi.Deployment> missingDeployer) throws DeploymentException
{
deployers.checkComplete(errors, missingDeployer);
}
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/plugins/internal/AutoInstallPluginImpl.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/plugins/internal/AutoInstallPluginImpl.java 2009-12-04 11:24:43 UTC (rev 97449)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/plugins/internal/AutoInstallPluginImpl.java 2009-12-04 11:43:26 UTC (rev 97450)
@@ -24,6 +24,7 @@
//$Id$
import java.net.URL;
+import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@@ -45,8 +46,8 @@
// Provide logging
final Logger log = Logger.getLogger(AutoInstallPluginImpl.class);
- private List<URL> autoInstall;
- private List<URL> autoStart;
+ private List<URL> autoInstall = Collections.emptyList();
+ private List<URL> autoStart = Collections.emptyList();
private Map<URL, Bundle> autoBundles = new ConcurrentHashMap<URL, Bundle>();
@@ -55,7 +56,6 @@
super(bundleManager);
}
-
public void setAutoInstall(List<URL> autoInstall)
{
this.autoInstall = autoInstall;
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/service/internal/MicrocontainerServiceImpl.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/service/internal/MicrocontainerServiceImpl.java 2009-12-04 11:24:43 UTC (rev 97449)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/service/internal/MicrocontainerServiceImpl.java 2009-12-04 11:43:26 UTC (rev 97450)
@@ -76,7 +76,7 @@
public void startService()
{
- installKernelBean(BEAN_SYSTEM_BUNDLE_CONTEXT, getSystemContext());
+ installKernelBean(BEAN_BUNDLE_CONTEXT, getSystemContext());
registration = getSystemContext().registerService(MicrocontainerService.class.getName(), this, null);
// Track the MBeanServer and register this service as an MBean
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/test/java/org/jboss/test/osgi/resolver/BasicResolverTest.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/test/java/org/jboss/test/osgi/resolver/BasicResolverTest.java 2009-12-04 11:24:43 UTC (rev 97449)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/test/java/org/jboss/test/osgi/resolver/BasicResolverTest.java 2009-12-04 11:43:26 UTC (rev 97450)
@@ -51,36 +51,36 @@
@Override
public void testOptionalImportPackageWired() throws Exception
{
- System.out.println("WONTFIX: testOptionalImportPackageWired");
+ // WONTFIX: testOptionalImportPackageWired
}
@Override
public void testRequireBundleVersionFails() throws Exception
{
- System.out.println("WONTFIX: testRequireBundleVersionFails");
+ // WONTFIX: testRequireBundleVersionFails
}
@Override
public void testPreferredExporterHigherVersion() throws Exception
{
- System.out.println("WONTFIX: testPreferredExporterHigherVersion");
+ // WONTFIX: testPreferredExporterHigherVersion
}
@Override
public void testPreferredExporterLowerId() throws Exception
{
- System.out.println("WONTFIX: testPreferredExporterLowerId");
+ // WONTFIX: testPreferredExporterLowerId
}
@Override
public void testPreferredExporterLowerIdReverse() throws Exception
{
- System.out.println("WONTFIX: testPreferredExporterLowerIdReverse");
+ // WONTFIX: testPreferredExporterLowerIdReverse
}
@Override
public void testPackageAttributeMandatoryFails() throws Exception
{
- System.out.println("WONTFIX: testPackageAttributeMandatoryFails");
+ // WONTFIX: testPackageAttributeMandatoryFails
}
}
\ No newline at end of file
16 years, 7 months
JBoss-OSGI SVN: r97449 - in projects/jboss-osgi: trunk/reactor and 1 other directory.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-12-04 06:24:43 -0500 (Fri, 04 Dec 2009)
New Revision: 97449
Added:
projects/jboss-osgi/projects/runtime/framework/trunk/
Removed:
projects/jboss-osgi/trunk/reactor/framework/
Log:
Move framework from reator to framework/trunk
Copied: projects/jboss-osgi/projects/runtime/framework/trunk (from rev 97448, projects/jboss-osgi/trunk/reactor/framework)
16 years, 7 months
JBoss-OSGI SVN: r97448 - in projects/jboss-osgi/trunk/reactor/framework/src: test/java/org/jboss/test/osgi/service/support/d and 1 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: alesj
Date: 2009-12-04 06:19:50 -0500 (Fri, 04 Dec 2009)
New Revision: 97448
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/OSGiServiceState.java
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/support/d/D.java
projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/service/service-bundle4/META-INF/MANIFEST.MF
Log:
Expose NCDFE for Bundle class.
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-12-04 10:52:06 UTC (rev 97447)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java 2009-12-04 11:19:50 UTC (rev 97448)
@@ -371,9 +371,16 @@
OSGiBundleState bundleState = unit.getAttachment(OSGiBundleState.class);
if (bundleState == null)
{
- bundleState = addDeployment(unit);
- bundleState.changeState(Bundle.ACTIVE);
- unit.addAttachment(OSGiBundleState.class, bundleState);
+ try
+ {
+ bundleState = addDeployment(unit);
+ bundleState.startInternal();
+ unit.addAttachment(OSGiBundleState.class, bundleState);
+ }
+ catch (Throwable t)
+ {
+ throw new RuntimeException("Cannot dynamically add generic bundle: " + unit, t);
+ }
}
return bundleState;
}
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-12-04 10:52:06 UTC (rev 97447)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiServiceState.java 2009-12-04 11:19:50 UTC (rev 97448)
@@ -307,6 +307,11 @@
public ClassLoader getClassLoader() throws Throwable
{
+ return getClassLoaderInternal();
+ }
+
+ private ClassLoader getClassLoaderInternal()
+ {
SecurityManager sm = System.getSecurityManager();
if (sm != null)
sm.checkPermission(GET_CLASSLOADER_PERMISSION);
@@ -370,7 +375,7 @@
checkPermission("get", false);
Object service = serviceOrFactory;
- if (serviceOrFactory instanceof ServiceFactory)
+ if (isServiceFactory)
{
if (serviceCache == null)
serviceCache = new ConcurrentHashMap<AbstractBundleState, Object>();
@@ -589,7 +594,7 @@
builder.append("id=").append(getServiceId());
builder.append(" bundle=").append(getBundleState().getCanonicalName());
builder.append(" classes=").append(Arrays.asList(getClasses()));
- builder.append(serviceOrFactory instanceof ServiceFactory ? " factory=" : " service=").append(serviceOrFactory);
+ builder.append(isServiceFactory ? " factory=" : " service=").append(serviceOrFactory);
if (properties != null)
builder.append(" properties=").append(properties);
builder.append("}");
@@ -627,7 +632,7 @@
if (using.ungetContex(this) == false)
{
- if (serviceOrFactory instanceof ServiceFactory)
+ if (isServiceFactory)
{
ServiceFactory serviceFactory = (ServiceFactory)serviceOrFactory;
try
Modified: projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/support/d/D.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/support/d/D.java 2009-12-04 10:52:06 UTC (rev 97447)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/support/d/D.java 2009-12-04 11:19:50 UTC (rev 97448)
@@ -34,6 +34,7 @@
public Object getService(Bundle bundle, ServiceRegistration registration)
{
A a = new A();
+ // TODO -- why this doesn't work? java.lang.NoClassDefFoundError: org/osgi/framework/Bundle
a.msg = bundle.getSymbolicName();
return a;
}
Modified: projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/service/service-bundle4/META-INF/MANIFEST.MF
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/service/service-bundle4/META-INF/MANIFEST.MF 2009-12-04 10:52:06 UTC (rev 97447)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/service/service-bundle4/META-INF/MANIFEST.MF 2009-12-04 11:19:50 UTC (rev 97448)
@@ -4,4 +4,4 @@
Implementation-Vendor: jboss.org
Bundle-Name: Service4
Bundle-SymbolicName: org.jboss.test.osgi.service4
-Import-Package: org.jboss.test.osgi.service.support.a;org.jboss.test.osgi.service.support.c;org.jboss.test.osgi.service.support.d
+Import-Package: org.jboss.test.osgi.service.support.a;org.jboss.test.osgi.service.support.c;org.jboss.test.osgi.service.support.d;org.osgi.framework
16 years, 7 months
JBoss-OSGI SVN: r97440 - projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle.
by jboss-osgi-commits@lists.jboss.org
Author: alesj
Date: 2009-12-03 23:13:58 -0500 (Thu, 03 Dec 2009)
New Revision: 97440
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/OSGiServiceState.java
Log:
Prepare code for SF fix.
(can fail atm as I didn't upload new Kernel snapshot yet)
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-12-04 04:01:59 UTC (rev 97439)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java 2009-12-04 04:13:58 UTC (rev 97440)
@@ -1228,7 +1228,7 @@
* @param clazz the class
* @return class or null
*/
- private Class<?> loadClass(Bundle bundle, String clazz)
+ Class<?> loadClass(Bundle bundle, String clazz)
{
try
{
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-12-04 04:01:59 UTC (rev 97439)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiServiceState.java 2009-12-04 04:13:58 UTC (rev 97440)
@@ -96,6 +96,9 @@
/** The service or service factory */
private Object serviceOrFactory;
+ /** Is this service facotry */
+ private boolean isServiceFactory;
+
/** The service factory provided service cache */
private Map<AbstractBundleState, Object> serviceCache;
@@ -136,8 +139,9 @@
this.bundleState = bundleState;
this.clazzes = clazzes;
this.serviceOrFactory = service;
+ this.isServiceFactory = (service instanceof ServiceFactory);
- if (service instanceof ServiceFactory == false)
+ if (isServiceFactory == false)
checkObjClass(service);
if (properties != null)
@@ -222,10 +226,16 @@
Class<?> clazz = null;
Object target = serviceOrFactory;
- if (target != null && target instanceof ServiceFactory == false)
+ if (isServiceFactory == false)
+ {
clazz = target.getClass();
+ }
else if (clazzes.length == 1)
+ {
className = clazzes[0];
+ OSGiBundleManager manager = bundleState.getBundleManager();
+ clazz = manager.loadClass(bundleState, className);
+ }
ScopeInfo info = OSGiScopeInfo.createScopeInfo(getName(), className, clazz, this);
setScopeInfo(info);
@@ -273,8 +283,7 @@
@Override
public Object getTarget()
{
- // get service directly
- return getService(bundleState);
+ return isServiceFactory ? null : serviceOrFactory;
}
protected Object getActualUser(ControllerContext context)
@@ -322,6 +331,9 @@
*/
protected BeanInfo getBeanInfo()
{
+ if (isServiceFactory)
+ throw new IllegalArgumentException("Cannot use DispatchContext on ServiceFactory: " + this);
+
if (isUnregistered())
return null;
@@ -329,7 +341,8 @@
{
try
{
- Kernel kernel = bundleState.getBundleManager().getKernel();
+ OSGiBundleManager manager = bundleState.getBundleManager();
+ Kernel kernel = manager.getKernel();
KernelConfigurator configurator = kernel.getConfigurator();
Object service = getTarget(); // should not be null, we're not unregistered
beanInfo = configurator.getBeanInfo(service.getClass());
@@ -470,13 +483,13 @@
if (ct == null)
return null;
+ OSGiBundleManager manager = bundleState.getBundleManager();
Set<Object> users = ct.getUsers(this);
Set<Bundle> bundles = new HashSet<Bundle>();
for (Object user : users)
{
if (ct.getUsedByCount(this, user) > 0)
{
- OSGiBundleManager manager = bundleState.getBundleManager();
AbstractBundleState abs = manager.getBundleForUser(user);
bundles.add(abs.getBundleInternal());
}
16 years, 7 months
JBoss-OSGI SVN: r97432 - in projects/jboss-osgi/trunk/reactor/framework/src/test: java/org/jboss/test/osgi/service/support and 3 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: alesj
Date: 2009-12-03 16:05:24 -0500 (Thu, 03 Dec 2009)
New Revision: 97432
Added:
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/support/d/
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/support/d/D.java
Modified:
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/ServiceMixUnitTestCase.java
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/support/a/A.java
projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/service/service-bundle4/META-INF/MANIFEST.MF
Log:
Add new SF test -- TODO make it work.
Modified: projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/ServiceMixUnitTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/ServiceMixUnitTestCase.java 2009-12-03 21:03:31 UTC (rev 97431)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/ServiceMixUnitTestCase.java 2009-12-03 21:05:24 UTC (rev 97432)
@@ -36,6 +36,7 @@
import org.jboss.test.osgi.service.support.LazyBundle;
import org.jboss.test.osgi.service.support.a.A;
import org.jboss.test.osgi.service.support.c.C;
+import org.jboss.test.osgi.service.support.d.D;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
@@ -227,6 +228,69 @@
}
}
+ public void disabled_testServiceFactoryInjection() throws Throwable
+ {
+ BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder("C1", C.class.getName());
+ builder.addPropertyMetaData("a", builder.createInject("A"));
+ BeanMetaData bmd = builder.getBeanMetaData();
+ Deployment bean1 = addBean("beanA1", C.class, bmd, A.class, D.class);
+ try
+ {
+ builder = BeanMetaDataBuilder.createBuilder("C2", C.class.getName());
+ builder.addPropertyMetaData("a", builder.createInject("A"));
+ bmd = builder.getBeanMetaData();
+ Deployment bean2 = addBean("beanA2", C.class, bmd, A.class, D.class);
+ try
+ {
+ Bundle bundle1 = assembleBundle("simple2", "/bundles/service/service-bundle4");
+ try
+ {
+ bundle1.start();
+ BundleContext bundleContext1 = bundle1.getBundleContext();
+ assertNotNull(bundleContext1);
+
+ Class<?> dClass = bundle1.loadClass(D.class.getName());
+ Object d = dClass.newInstance();
+ Hashtable<String, Object> table = new Hashtable<String, Object>();
+ table.put("service.alias.1", "A");
+ ServiceRegistration reg1 = bundleContext1.registerService(A.class.getName(), d, table);
+ assertNotNull(reg1);
+
+ try
+ {
+ checkComplete();
+
+ Object c1 = getBean("C1");
+ Object a1 = invoke(c1, "getA");
+ Object msg1 = invoke(a1, "getMsg");
+ assertEquals(msg1, getBundle(bean1).getSymbolicName());
+
+ Object c2 = getBean("C2");
+ Object a2 = invoke(c2, "getA");
+ Object msg2 = invoke(a2, "getMsg");
+ assertEquals(msg2, getBundle(bean2).getSymbolicName());
+ }
+ finally
+ {
+ reg1.unregister();
+ }
+ }
+ finally
+ {
+ uninstall(bundle1);
+ }
+ }
+ finally
+ {
+ undeploy(bean2);
+ }
+ }
+ finally
+ {
+ undeploy(bean1);
+ }
+ }
+
public void testFiltering() throws Throwable
{
Deployment bean = addBean("beanA", A.class);
Modified: projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/support/a/A.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/support/a/A.java 2009-12-03 21:03:31 UTC (rev 97431)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/support/a/A.java 2009-12-03 21:05:24 UTC (rev 97432)
@@ -29,4 +29,10 @@
*/
public class A
{
+ public String msg;
+
+ public String getMsg()
+ {
+ return msg;
+ }
}
Added: projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/support/d/D.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/support/d/D.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/support/d/D.java 2009-12-03 21:05:24 UTC (rev 97432)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.test.osgi.service.support.d;
+
+import org.jboss.test.osgi.service.support.a.A;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.ServiceFactory;
+import org.osgi.framework.ServiceRegistration;
+
+/**
+ * @author <a href="mailto:ales.justin@jboss.org">Ales Justin</a>
+ */
+public class D implements ServiceFactory
+{
+ public Object getService(Bundle bundle, ServiceRegistration registration)
+ {
+ A a = new A();
+ a.msg = bundle.getSymbolicName();
+ return a;
+ }
+
+ public void ungetService(Bundle bundle, ServiceRegistration registration, Object service)
+ {
+ }
+}
Modified: projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/service/service-bundle4/META-INF/MANIFEST.MF
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/service/service-bundle4/META-INF/MANIFEST.MF 2009-12-03 21:03:31 UTC (rev 97431)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/service/service-bundle4/META-INF/MANIFEST.MF 2009-12-03 21:05:24 UTC (rev 97432)
@@ -4,4 +4,4 @@
Implementation-Vendor: jboss.org
Bundle-Name: Service4
Bundle-SymbolicName: org.jboss.test.osgi.service4
-Export-Package: org.jboss.test.osgi.service.support.a;org.jboss.test.osgi.service.support.c
+Import-Package: org.jboss.test.osgi.service.support.a;org.jboss.test.osgi.service.support.c;org.jboss.test.osgi.service.support.d
16 years, 7 months
JBoss-OSGI SVN: r97427 - projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle.
by jboss-osgi-commits@lists.jboss.org
Author: alesj
Date: 2009-12-03 13:38:04 -0500 (Thu, 03 Dec 2009)
New Revision: 97427
Modified:
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiServiceState.java
Log:
Enable proper service factory usage.
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-12-03 18:19:20 UTC (rev 97426)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiServiceState.java 2009-12-03 18:38:04 UTC (rev 97427)
@@ -48,8 +48,8 @@
import org.jboss.osgi.framework.plugins.FrameworkEventsPlugin;
import org.jboss.osgi.framework.util.CaseInsensitiveDictionary;
import org.jboss.osgi.spi.util.BundleClassLoader;
+import org.jboss.util.collection.CollectionsFactory;
import org.jboss.util.id.GUID;
-import org.jboss.util.collection.CollectionsFactory;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleException;
import org.osgi.framework.Constants;
@@ -277,16 +277,20 @@
return getService(bundleState);
}
- protected Object getTargetForTracker(ContextTracker tracker)
+ protected Object getActualUser(ControllerContext context)
{
- if (tracker instanceof AbstractBundleState)
- {
- AbstractBundleState abs = (AbstractBundleState)tracker;
- return getService(abs);
- }
- return getTarget();
+ OSGiBundleManager manager = bundleState.getBundleManager();
+ return manager.getBundleForContext(context);
}
+ protected Object getTargetForActualUser(Object user)
+ {
+ if (user instanceof AbstractBundleState)
+ return getService(AbstractBundleState.class.cast(user));
+ else
+ return getTarget();
+ }
+
public Object invoke(String name, Object[] parameters, String[] signature) throws Throwable
{
return getBeanInfo().invoke(getTarget(), name, signature, parameters);
16 years, 7 months
JBoss-OSGI SVN: r97416 - projects/jboss-osgi/trunk.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-12-03 11:30:27 -0500 (Thu, 03 Dec 2009)
New Revision: 97416
Modified:
projects/jboss-osgi/trunk/pom.xml
Log:
Update to released versions
Modified: projects/jboss-osgi/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/pom.xml 2009-12-03 16:22:22 UTC (rev 97415)
+++ projects/jboss-osgi/trunk/pom.xml 2009-12-03 16:30:27 UTC (rev 97416)
@@ -49,28 +49,28 @@
<version.apache.felix.log>1.0.0</version.apache.felix.log>
<version.apache.felix.metatype>1.0.2</version.apache.felix.metatype>
<version.izpack>4.3.1</version.izpack>
- <version.jboss.osgi.apache.xerces>2.9.1-SNAPSHOT</version.jboss.osgi.apache.xerces>
+ <version.jboss.osgi.apache.xerces>2.9.1.SP3</version.jboss.osgi.apache.xerces>
<version.jboss.osgi.blueprint>1.0.0.Alpha3</version.jboss.osgi.blueprint>
- <version.jboss.osgi.common>1.0.3-SNAPSHOT</version.jboss.osgi.common>
+ <version.jboss.osgi.common>1.0.3</version.jboss.osgi.common>
<version.jboss.osgi.common.core>2.2.13.GA</version.jboss.osgi.common.core>
- <version.jboss.osgi.deployment>1.0.0-SNAPSHOT</version.jboss.osgi.deployment>
- <version.jboss.osgi.framework>1.0.0.Alpha2-SNAPSHOT</version.jboss.osgi.framework>
- <version.jboss.osgi.hotdeploy>1.0.3-SNAPSHOT</version.jboss.osgi.hotdeploy>
- <version.jboss.osgi.husky>1.0.2-SNAPSHOT</version.jboss.osgi.husky>
- <version.jboss.osgi.jaxb>2.1.10-SNAPSHOT</version.jboss.osgi.jaxb>
- <version.jboss.osgi.jmx>1.0.2-SNAPSHOT</version.jboss.osgi.jmx>
- <version.jboss.osgi.jndi>1.0.2-SNAPSHOT</version.jboss.osgi.jndi>
- <version.jboss.osgi.jta>1.0.0-SNAPSHOT</version.jboss.osgi.jta>
- <version.jboss.osgi.microcontainer>2.0.9-SNAPSHOT</version.jboss.osgi.microcontainer>
- <version.jboss.osgi.reflect>2.0.2-SNAPSHOT</version.jboss.osgi.reflect>
- <version.jboss.osgi.runtime.deployers>1.0.3-SNAPSHOT</version.jboss.osgi.runtime.deployers>
- <version.jboss.osgi.runtime.equinox>3.5.1-SNAPSHOT</version.jboss.osgi.runtime.equinox>
- <version.jboss.osgi.runtime.felix>2.0.2-SNAPSHOT</version.jboss.osgi.runtime.felix>
- <version.jboss.osgi.runtime.jbossas>1.0.2-SNAPSHOT</version.jboss.osgi.runtime.jbossas>
- <version.jboss.osgi.spi>1.0.3-SNAPSHOT</version.jboss.osgi.spi>
- <version.jboss.osgi.webapp>0.7.2-SNAPSHOT</version.jboss.osgi.webapp>
+ <version.jboss.osgi.deployment>1.0.0</version.jboss.osgi.deployment>
+ <version.jboss.osgi.framework>1.0.0.Alpha2</version.jboss.osgi.framework>
+ <version.jboss.osgi.hotdeploy>1.0.3</version.jboss.osgi.hotdeploy>
+ <version.jboss.osgi.husky>1.0.2</version.jboss.osgi.husky>
+ <version.jboss.osgi.jaxb>2.1.10.SP3</version.jboss.osgi.jaxb>
+ <version.jboss.osgi.jmx>1.0.2</version.jboss.osgi.jmx>
+ <version.jboss.osgi.jndi>1.0.2</version.jboss.osgi.jndi>
+ <version.jboss.osgi.jta>1.0.0</version.jboss.osgi.jta>
+ <version.jboss.osgi.microcontainer>2.0.9</version.jboss.osgi.microcontainer>
+ <version.jboss.osgi.reflect>2.0.2</version.jboss.osgi.reflect>
+ <version.jboss.osgi.runtime.deployers>1.0.3</version.jboss.osgi.runtime.deployers>
+ <version.jboss.osgi.runtime.equinox>3.5.1</version.jboss.osgi.runtime.equinox>
+ <version.jboss.osgi.runtime.felix>2.0.2</version.jboss.osgi.runtime.felix>
+ <version.jboss.osgi.runtime.jbossas>1.0.2</version.jboss.osgi.runtime.jbossas>
+ <version.jboss.osgi.spi>1.0.3</version.jboss.osgi.spi>
+ <version.jboss.osgi.webapp>0.7.2</version.jboss.osgi.webapp>
<version.jboss.osgi.webconsole>1.0.2</version.jboss.osgi.webconsole>
- <version.jboss.osgi.xml.binding>2.0.2-SNAPSHOT</version.jboss.osgi.xml.binding>
+ <version.jboss.osgi.xml.binding>2.0.2.Beta3</version.jboss.osgi.xml.binding>
<version.ops4j.pax.web>0.7.2</version.ops4j.pax.web>
<version.osgi>4.2.0</version.osgi>
16 years, 7 months