JBoss-OSGI SVN: r92538 - in projects/jboss-osgi/trunk: reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework and 1 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-08-18 15:06:35 -0400 (Tue, 18 Aug 2009)
New Revision: 92538
Modified:
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/ServiceRegistry.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleContextImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceReferenceImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceRegistrationImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceRegistryImpl.java
projects/jboss-osgi/trunk/testsuite/pom.xml
Log:
Fix equinox test build
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/ServiceRegistry.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/ServiceRegistry.java 2009-08-18 18:40:16 UTC (rev 92537)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/ServiceRegistry.java 2009-08-18 19:06:35 UTC (rev 92538)
@@ -45,5 +45,5 @@
ServiceReference[] getServiceReferences(String clazz, String filter);
- Object getService(ServiceReference sref);
+ Object getService(Bundle bundle, ServiceReference sref);
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleContextImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleContextImpl.java 2009-08-18 18:40:16 UTC (rev 92537)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleContextImpl.java 2009-08-18 19:06:35 UTC (rev 92538)
@@ -138,7 +138,7 @@
public Object getService(ServiceReference reference)
{
ServiceRegistry serviceRegistry = getFramework().getServiceRegistry();
- return serviceRegistry.getService(reference);
+ return serviceRegistry.getService(getBundle(), reference);
}
public ServiceReference getServiceReference(String clazz)
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceReferenceImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceReferenceImpl.java 2009-08-18 18:40:16 UTC (rev 92537)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceReferenceImpl.java 2009-08-18 19:06:35 UTC (rev 92538)
@@ -32,6 +32,7 @@
import org.jboss.osgi.spi.NotImplementedException;
import org.osgi.framework.Bundle;
import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
/**
* A simple implementation of a ServiceReference
@@ -47,6 +48,7 @@
private Bundle bundle;
private Object service;
private Dictionary<String, String> properties;
+ private ServiceRegistration registration;
private boolean unregistered;
public ServiceReferenceImpl(Bundle bundle, Object service, Dictionary<String, String> properties)
@@ -71,6 +73,16 @@
return service;
}
+ public ServiceRegistration getServiceRegistration()
+ {
+ return registration;
+ }
+
+ public void setServiceRegistration(ServiceRegistration serviceRegistration)
+ {
+ this.registration = serviceRegistration;
+ }
+
public int compareTo(Object reference)
{
throw new NotImplementedException();
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceRegistrationImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceRegistrationImpl.java 2009-08-18 18:40:16 UTC (rev 92537)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceRegistrationImpl.java 2009-08-18 19:06:35 UTC (rev 92538)
@@ -46,6 +46,7 @@
public ServiceRegistrationImpl(ServiceReferenceImpl serviceRef)
{
this.serviceRef = serviceRef;
+ serviceRef.setServiceRegistration(this);
}
public ServiceReference getReference()
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceRegistryImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceRegistryImpl.java 2009-08-18 18:40:16 UTC (rev 92537)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceRegistryImpl.java 2009-08-18 19:06:35 UTC (rev 92538)
@@ -102,7 +102,7 @@
return srefArr;
}
- public Object getService(ServiceReference sref)
+ public Object getService(Bundle bundle, ServiceReference sref)
{
ServiceReferenceImpl srefImpl = (ServiceReferenceImpl)sref;
@@ -115,7 +115,10 @@
// [TODO] The service was registered with an object implementing the ServiceFactory interface
Object service = srefImpl.getService();
if (service instanceof ServiceFactory)
- throw new NotImplementedException("Get service from a ServiceFactory");
+ {
+ ServiceFactory factory = (ServiceFactory)service;
+ factory.getService(bundle, srefImpl.getServiceRegistration());
+ }
// The service object for the service is returned.
Modified: projects/jboss-osgi/trunk/testsuite/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/testsuite/pom.xml 2009-08-18 18:40:16 UTC (rev 92537)
+++ projects/jboss-osgi/trunk/testsuite/pom.xml 2009-08-18 19:06:35 UTC (rev 92538)
@@ -234,6 +234,13 @@
<version>${version.jboss.osgi.runtime.equinox}</version>
<scope>provided</scope>
</dependency>
+ <!-- equinox-3.5 does not contain package org.osgi.util.xml -->
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ <version>${version.osgi}</version>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
<build>
<plugins>
16 years, 11 months
JBoss-OSGI SVN: r92537 - in projects/jboss-osgi/trunk: testsuite/example/scripts and 2 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-08-18 14:40:16 -0400 (Tue, 18 Aug 2009)
New Revision: 92537
Modified:
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/.classpath
projects/jboss-osgi/trunk/testsuite/example/scripts/assembly-bundles.xml
projects/jboss-osgi/trunk/testsuite/functional/scripts/assembly-bundles.xml
projects/jboss-osgi/trunk/testsuite/trailblazer/scripts/assembly-bundles.xml
Log:
Copy org.osgi.compendium.jar optionally
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/.classpath
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/.classpath 2009-08-18 18:28:18 UTC (rev 92536)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/.classpath 2009-08-18 18:40:16 UTC (rev 92537)
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java"/>
+ <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/>
- <classpathentry kind="src" path="src/main/resources"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
<classpathentry kind="output" path="target/classes"/>
Modified: projects/jboss-osgi/trunk/testsuite/example/scripts/assembly-bundles.xml
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/scripts/assembly-bundles.xml 2009-08-18 18:28:18 UTC (rev 92536)
+++ projects/jboss-osgi/trunk/testsuite/example/scripts/assembly-bundles.xml 2009-08-18 18:40:16 UTC (rev 92537)
@@ -10,11 +10,21 @@
<!-- Dependency Sets -->
<dependencySets>
- <!-- bundle -->
+ <!-- bundles -->
<dependencySet>
<outputDirectory>bundles</outputDirectory>
<outputFileNameMapping>${artifact.artifactId}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
<includes>
+ <include>*:org.osgi.compendium:jar</include>
+ </includes>
+ <useStrictFiltering>false</useStrictFiltering>
+ <scope>provided</scope>
+ <unpack>false</unpack>
+ </dependencySet>
+ <dependencySet>
+ <outputDirectory>bundles</outputDirectory>
+ <outputFileNameMapping>${artifact.artifactId}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
+ <includes>
<include>*:jboss-osgi-apache-xerces:jar</include>
<include>*:jboss-osgi-blueprint:jar</include>
<include>*:jboss-osgi-common:jar</include>
@@ -29,7 +39,6 @@
<include>*:org.apache.felix.http.jetty:jar</include>
<include>*:org.apache.felix.log:jar</include>
<include>*:org.apache.felix.metatype:jar</include>
- <include>*:org.osgi.compendium:jar</include>
</includes>
<useStrictFiltering>true</useStrictFiltering>
<scope>provided</scope>
Modified: projects/jboss-osgi/trunk/testsuite/functional/scripts/assembly-bundles.xml
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/scripts/assembly-bundles.xml 2009-08-18 18:28:18 UTC (rev 92536)
+++ projects/jboss-osgi/trunk/testsuite/functional/scripts/assembly-bundles.xml 2009-08-18 18:40:16 UTC (rev 92537)
@@ -10,11 +10,21 @@
<!-- Dependency Sets -->
<dependencySets>
- <!-- bundle -->
+ <!-- bundles -->
<dependencySet>
<outputDirectory>bundles</outputDirectory>
<outputFileNameMapping>${artifact.artifactId}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
<includes>
+ <include>*:org.osgi.compendium:jar</include>
+ </includes>
+ <useStrictFiltering>false</useStrictFiltering>
+ <scope>provided</scope>
+ <unpack>false</unpack>
+ </dependencySet>
+ <dependencySet>
+ <outputDirectory>bundles</outputDirectory>
+ <outputFileNameMapping>${artifact.artifactId}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
+ <includes>
<include>*:jboss-osgi-apache-xerces:jar</include>
<include>*:jboss-osgi-common:jar</include>
<include>*:jboss-osgi-common-core:jar</include>
@@ -28,7 +38,6 @@
<include>*:org.apache.felix.http.jetty:jar</include>
<include>*:org.apache.felix.log:jar</include>
<include>*:org.apache.felix.metatype:jar</include>
- <include>*:org.osgi.compendium:jar</include>
</includes>
<useStrictFiltering>true</useStrictFiltering>
<scope>provided</scope>
Modified: projects/jboss-osgi/trunk/testsuite/trailblazer/scripts/assembly-bundles.xml
===================================================================
--- projects/jboss-osgi/trunk/testsuite/trailblazer/scripts/assembly-bundles.xml 2009-08-18 18:28:18 UTC (rev 92536)
+++ projects/jboss-osgi/trunk/testsuite/trailblazer/scripts/assembly-bundles.xml 2009-08-18 18:40:16 UTC (rev 92537)
@@ -10,11 +10,21 @@
<!-- Dependency Sets -->
<dependencySets>
- <!-- bundle -->
+ <!-- bundles -->
<dependencySet>
<outputDirectory>bundles</outputDirectory>
<outputFileNameMapping>${artifact.artifactId}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
<includes>
+ <include>*:org.osgi.compendium:jar</include>
+ </includes>
+ <useStrictFiltering>false</useStrictFiltering>
+ <scope>provided</scope>
+ <unpack>false</unpack>
+ </dependencySet>
+ <dependencySet>
+ <outputDirectory>bundles</outputDirectory>
+ <outputFileNameMapping>${artifact.artifactId}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
+ <includes>
<include>*:jboss-osgi-apache-xerces:jar</include>
<include>*:jboss-osgi-common:jar</include>
<include>*:jboss-osgi-common-core:jar</include>
@@ -28,7 +38,6 @@
<include>*:org.apache.felix.http.jetty:jar</include>
<include>*:org.apache.felix.log:jar</include>
<include>*:org.apache.felix.metatype:jar</include>
- <include>*:org.osgi.compendium:jar</include>
</includes>
<useStrictFiltering>true</useStrictFiltering>
<scope>provided</scope>
16 years, 11 months
JBoss-OSGI SVN: r92533 - in projects/jboss-osgi/trunk: reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework and 1 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-08-18 12:13:49 -0400 (Tue, 18 Aug 2009)
New Revision: 92533
Modified:
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/ServiceEventManager.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/ServiceRegistry.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleContextImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceEventManagerImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceReferenceImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceRegistryImpl.java
projects/jboss-osgi/trunk/testsuite/pom.xml
Log:
Basic service registry
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/ServiceEventManager.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/ServiceEventManager.java 2009-08-18 15:22:46 UTC (rev 92532)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/ServiceEventManager.java 2009-08-18 16:13:49 UTC (rev 92533)
@@ -37,4 +37,6 @@
void fireServiceEvent(ServiceEvent event);
void addServiceListener(ServiceListener listener);
+
+ void addServiceListener(ServiceListener listener, String filter);
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/ServiceRegistry.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/ServiceRegistry.java 2009-08-18 15:22:46 UTC (rev 92532)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/ServiceRegistry.java 2009-08-18 16:13:49 UTC (rev 92533)
@@ -44,4 +44,6 @@
ServiceReference getServiceReference(String clazz);
ServiceReference[] getServiceReferences(String clazz, String filter);
+
+ Object getService(ServiceReference sref);
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleContextImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleContextImpl.java 2009-08-18 15:22:46 UTC (rev 92532)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleContextImpl.java 2009-08-18 16:13:49 UTC (rev 92533)
@@ -92,7 +92,8 @@
public void addServiceListener(ServiceListener listener, String filter) throws InvalidSyntaxException
{
- throw new NotImplementedException();
+ ServiceEventManager eventManager = getFramework().getServiceEventManager();
+ eventManager.addServiceListener(listener, filter);
}
public Filter createFilter(String filter) throws InvalidSyntaxException
@@ -136,7 +137,8 @@
public Object getService(ServiceReference reference)
{
- throw new NotImplementedException();
+ ServiceRegistry serviceRegistry = getFramework().getServiceRegistry();
+ return serviceRegistry.getService(reference);
}
public ServiceReference getServiceReference(String clazz)
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceEventManagerImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceEventManagerImpl.java 2009-08-18 15:22:46 UTC (rev 92532)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceEventManagerImpl.java 2009-08-18 16:13:49 UTC (rev 92533)
@@ -56,11 +56,16 @@
for (ServiceListener listener : listeners)
listener.serviceChanged(event);
- // [TODO] ServiceEvent object delivery to ServiceListener objects is filtered
+ // [TODO] ServiceEvent object delivery to ServiceListener objects is filtered
}
public void addServiceListener(ServiceListener listener)
{
listeners.add(listener);
}
+
+ public void addServiceListener(ServiceListener listener, String filter)
+ {
+ listeners.add(listener);
+ }
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceReferenceImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceReferenceImpl.java 2009-08-18 15:22:46 UTC (rev 92532)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceReferenceImpl.java 2009-08-18 16:13:49 UTC (rev 92533)
@@ -45,14 +45,32 @@
final Logger log = Logger.getLogger(ServiceReferenceImpl.class);
private Bundle bundle;
+ private Object service;
private Dictionary<String, String> properties;
+ private boolean unregistered;
- public ServiceReferenceImpl(Bundle bundle, Dictionary<String, String> properties)
+ public ServiceReferenceImpl(Bundle bundle, Object service, Dictionary<String, String> properties)
{
this.bundle = bundle;
+ this.service = service;
this.properties = properties;
}
+ public boolean isUnregistered()
+ {
+ return unregistered;
+ }
+
+ public void setUnregistered(boolean unregistered)
+ {
+ this.unregistered = unregistered;
+ }
+
+ public Object getService()
+ {
+ return service;
+ }
+
public int compareTo(Object reference)
{
throw new NotImplementedException();
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceRegistryImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceRegistryImpl.java 2009-08-18 15:22:46 UTC (rev 92532)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceRegistryImpl.java 2009-08-18 16:13:49 UTC (rev 92533)
@@ -23,8 +23,10 @@
//$Id: SystemBundleContext.java 91789 2009-07-29 20:49:03Z thomas.diesler(a)jboss.com $
+import java.util.ArrayList;
import java.util.Dictionary;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import org.jboss.logging.Logger;
@@ -48,7 +50,7 @@
// Provide logging
final Logger log = Logger.getLogger(ServiceRegistryImpl.class);
- private Map<String, ServiceReference> registry = new HashMap<String, ServiceReference>();
+ private Map<String, List<ServiceReference>> registry = new HashMap<String, List<ServiceReference>>();
private FrameworkImpl framework;
public ServiceRegistryImpl(FrameworkImpl framework)
@@ -68,18 +70,58 @@
public ServiceReference getServiceReference(String clazz)
{
+ ServiceReference sref = null;
+
// [TODO] If multiple such services exist, the service with the highest ranking (as specified in its Constants.SERVICE_RANKING property) is returned.
// [TODO] If there is a tie in ranking, the service with the lowest service ID (as specified in its Constants.SERVICE_ID property); that is, the service that was registered first is returned.
- return registry.get(clazz);
+ List<ServiceReference> srefs = registry.get(clazz);
+ if (srefs != null && srefs.size() > 0)
+ sref = srefs.iterator().next();
+
+ return sref;
}
public ServiceReference[] getServiceReferences(String clazz, String filter)
{
- throw new NotImplementedException();
+ ServiceReference[] srefArr = null;
+
+ // [TODO] The result is an array of ServiceReference objects for all services that meet all of the following conditions:
+ // * If the specified class name, clazz, is not null, the service must have been registered with the specified class name. The complete list of class names with which a service was registered is available from the service's objectClass property.
+ // * If the specified filter is not null, the filter expression must match the service.
+ // * If the Java Runtime Environment supports permissions, the caller must have ServicePermission with the GET action for at least one of the class names under which the service was registered.
+ // * For each class name with which the service was registered, calling ServiceReference.isAssignableTo(Bundle, String) with the context bundle and the class name on the service's ServiceReference object must return true
+
+ List<ServiceReference> srefs = registry.get(clazz);
+ if (srefs != null)
+ {
+ srefArr = new ServiceReference[srefs.size()];
+ srefs.toArray(srefArr);
+ }
+ return srefArr;
}
+ public Object getService(ServiceReference sref)
+ {
+ ServiceReferenceImpl srefImpl = (ServiceReferenceImpl)sref;
+
+ // If the service has been unregistered, null is returned.
+ if (srefImpl.isUnregistered())
+ return null;
+
+ // [TODO] The context bundle's use count for this service is incremented by one.
+
+ // [TODO] The service was registered with an object implementing the ServiceFactory interface
+ Object service = srefImpl.getService();
+ if (service instanceof ServiceFactory)
+ throw new NotImplementedException("Get service from a ServiceFactory");
+
+ // The service object for the service is returned.
+
+ return service;
+ }
+
private ServiceRegistration registerServiceInternal(Bundle bundle, String clazz, Object service, Dictionary properties)
{
// If service is not a ServiceFactory, an IllegalArgumentException is thrown if service
@@ -98,20 +140,26 @@
}
}
- ServiceReferenceImpl serviceRef = new ServiceReferenceImpl(bundle, properties);
+ ServiceReferenceImpl sref = new ServiceReferenceImpl(bundle, service, properties);
// 2. The Framework adds the following service properties to the service properties from the specified Dictionary (which may be null):
// A property named Constants.SERVICE_ID identifying the registration number of the service
// A property named Constants.OBJECTCLASS containing all the specified classes.
// 3. The service is added to the Framework service registry and may now be used by other bundles.
- registry.put(clazz, serviceRef);
+ List<ServiceReference> list = registry.get(clazz);
+ if (list == null)
+ {
+ list = new ArrayList<ServiceReference>();
+ registry.put(clazz, list);
+ }
+ list.add(sref);
// 4. A service event of type ServiceEvent.REGISTERED is fired.
ServiceEventManager eventManager = framework.getServiceEventManager();
- eventManager.fireServiceEvent(new ServiceEvent(ServiceEvent.REGISTERED, serviceRef));
+ eventManager.fireServiceEvent(new ServiceEvent(ServiceEvent.REGISTERED, sref));
// 5. A ServiceRegistration object for this registration is returned.
- return new ServiceRegistrationImpl(serviceRef);
+ return new ServiceRegistrationImpl(sref);
}
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/testsuite/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/testsuite/pom.xml 2009-08-18 15:22:46 UTC (rev 92532)
+++ projects/jboss-osgi/trunk/testsuite/pom.xml 2009-08-18 16:13:49 UTC (rev 92533)
@@ -68,24 +68,64 @@
<artifactId>org.apache.felix.configadmin</artifactId>
<version>${version.apache.felix.configadmin}</version>
<scope>provided</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.http.jetty</artifactId>
<version>${version.apache.felix.http.jetty}</version>
<scope>provided</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.log</artifactId>
<version>${version.apache.felix.log}</version>
<scope>provided</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.metatype</artifactId>
<version>${version.apache.felix.metatype}</version>
<scope>provided</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>org.jboss.osgi.bundles</groupId>
@@ -105,7 +145,7 @@
<version>${version.jboss.osgi.common}</version>
<scope>provided</scope>
</dependency>
-
+
<!-- Test Dependencies -->
<dependency>
<groupId>junit</groupId>
@@ -150,18 +190,6 @@
<version>${version.jboss.osgi.runtime.felix}</version>
<scope>provided</scope>
</dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.osgi.core</artifactId>
- <version>${version.apache.felix.core}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.osgi.compendium</artifactId>
- <version>${version.apache.felix.core}</version>
- <scope>provided</scope>
- </dependency>
</dependencies>
</profile>
@@ -184,18 +212,6 @@
<version>${version.jboss.osgi.runtime.felix}</version>
<scope>provided</scope>
</dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.osgi.core</artifactId>
- <version>${version.apache.felix.core}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.osgi.compendium</artifactId>
- <version>${version.apache.felix.core}</version>
- <scope>provided</scope>
- </dependency>
</dependencies>
</profile>
16 years, 11 months
JBoss-OSGI SVN: r92532 - in projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src: main/java/org/jboss/osgi/jbossmc/framework and 2 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-08-18 11:22:46 -0400 (Tue, 18 Aug 2009)
New Revision: 92532
Added:
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/java/org/jboss/test/osgi/jbossmc/SystemContextTestCase.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/resources/tst.policy
Modified:
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleEventManager.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/FrameworkEventManager.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/ServiceEventManager.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/ServiceRegistry.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleContextImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleEventManagerImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleFactoryImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleRegistryImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleResolverImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkEventManagerImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceEventManagerImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceRegistryImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/SystemBundleContext.java
Log:
Basic event manager impl
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleEventManager.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleEventManager.java 2009-08-18 14:23:55 UTC (rev 92531)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleEventManager.java 2009-08-18 15:22:46 UTC (rev 92532)
@@ -22,6 +22,7 @@
package org.jboss.osgi.jbossmc.api;
import org.osgi.framework.BundleEvent;
+import org.osgi.framework.BundleListener;
//$Id: SystemBundleContext.java 91789 2009-07-29 20:49:03Z thomas.diesler(a)jboss.com $
@@ -34,4 +35,6 @@
public interface BundleEventManager
{
void fireBundleEvent(BundleEvent event);
+
+ void addBundleListener(BundleListener listener);
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/FrameworkEventManager.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/FrameworkEventManager.java 2009-08-18 14:23:55 UTC (rev 92531)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/FrameworkEventManager.java 2009-08-18 15:22:46 UTC (rev 92532)
@@ -22,6 +22,7 @@
package org.jboss.osgi.jbossmc.api;
import org.osgi.framework.FrameworkEvent;
+import org.osgi.framework.FrameworkListener;
//$Id: SystemBundleContext.java 91789 2009-07-29 20:49:03Z thomas.diesler(a)jboss.com $
@@ -34,4 +35,6 @@
public interface FrameworkEventManager
{
void fireFrameworkEvent(FrameworkEvent event);
+
+ void addFrameworkListener(FrameworkListener listener);
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/ServiceEventManager.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/ServiceEventManager.java 2009-08-18 14:23:55 UTC (rev 92531)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/ServiceEventManager.java 2009-08-18 15:22:46 UTC (rev 92532)
@@ -22,6 +22,7 @@
package org.jboss.osgi.jbossmc.api;
import org.osgi.framework.ServiceEvent;
+import org.osgi.framework.ServiceListener;
//$Id: SystemBundleContext.java 91789 2009-07-29 20:49:03Z thomas.diesler(a)jboss.com $
@@ -34,4 +35,6 @@
public interface ServiceEventManager
{
void fireServiceEvent(ServiceEvent event);
+
+ void addServiceListener(ServiceListener listener);
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/ServiceRegistry.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/ServiceRegistry.java 2009-08-18 14:23:55 UTC (rev 92531)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/ServiceRegistry.java 2009-08-18 15:22:46 UTC (rev 92532)
@@ -26,6 +26,7 @@
import java.util.Dictionary;
import org.osgi.framework.Bundle;
+import org.osgi.framework.ServiceReference;
import org.osgi.framework.ServiceRegistration;
/**
@@ -39,4 +40,8 @@
ServiceRegistration registerService(Bundle bundle, String[] clazzes, Object service, Dictionary properties);
ServiceRegistration registerService(Bundle bundle, String clazz, Object service, Dictionary properties);
+
+ ServiceReference getServiceReference(String clazz);
+
+ ServiceReference[] getServiceReferences(String clazz, String filter);
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleContextImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleContextImpl.java 2009-08-18 14:23:55 UTC (rev 92531)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleContextImpl.java 2009-08-18 15:22:46 UTC (rev 92532)
@@ -28,6 +28,11 @@
import java.util.Dictionary;
import org.jboss.logging.Logger;
+import org.jboss.osgi.jbossmc.api.BundleEventManager;
+import org.jboss.osgi.jbossmc.api.BundleFactory;
+import org.jboss.osgi.jbossmc.api.BundleRegistry;
+import org.jboss.osgi.jbossmc.api.FrameworkEventManager;
+import org.jboss.osgi.jbossmc.api.ServiceEventManager;
import org.jboss.osgi.jbossmc.api.ServiceRegistry;
import org.jboss.osgi.spi.NotImplementedException;
import org.osgi.framework.Bundle;
@@ -36,6 +41,7 @@
import org.osgi.framework.BundleListener;
import org.osgi.framework.Filter;
import org.osgi.framework.FrameworkListener;
+import org.osgi.framework.FrameworkUtil;
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceListener;
import org.osgi.framework.ServiceReference;
@@ -52,33 +58,36 @@
// Provide logging
final Logger log = Logger.getLogger(BundleContextImpl.class);
- private SystemBundleContext sysContext;
+ private FrameworkImpl framework;
private Bundle bundle;
- public BundleContextImpl(SystemBundleContext sysContext, Bundle bundle)
+ public BundleContextImpl(FrameworkImpl framework, Bundle bundle)
{
- this.sysContext = sysContext;
+ this.framework = framework;
this.bundle = bundle;
}
- SystemBundleContext getSystemContext()
+ public FrameworkImpl getFramework()
{
- return sysContext;
+ return framework;
}
-
+
public void addBundleListener(BundleListener listener)
{
- throw new NotImplementedException();
+ BundleEventManager eventManager = getFramework().getBundleEventManager();
+ eventManager.addBundleListener(listener);
}
public void addFrameworkListener(FrameworkListener listener)
{
- throw new NotImplementedException();
+ FrameworkEventManager eventManager = getFramework().getFrameworkEventManager();
+ eventManager.addFrameworkListener(listener);
}
public void addServiceListener(ServiceListener listener)
{
- throw new NotImplementedException();
+ ServiceEventManager eventManager = getFramework().getServiceEventManager();
+ eventManager.addServiceListener(listener);
}
public void addServiceListener(ServiceListener listener, String filter) throws InvalidSyntaxException
@@ -88,7 +97,7 @@
public Filter createFilter(String filter) throws InvalidSyntaxException
{
- throw new NotImplementedException();
+ return FrameworkUtil.createFilter(filter);
}
public ServiceReference[] getAllServiceReferences(String clazz, String filter) throws InvalidSyntaxException
@@ -118,7 +127,11 @@
public String getProperty(String key)
{
- throw new NotImplementedException();
+ String property = getFramework().getProperty(key);
+ if (property == null)
+ property = System.getProperty(key);
+
+ return property;
}
public Object getService(ServiceReference reference)
@@ -128,25 +141,25 @@
public ServiceReference getServiceReference(String clazz)
{
- // [TODO] getServiceReference
- return null;
+ ServiceRegistry serviceRegistry = getFramework().getServiceRegistry();
+ return serviceRegistry.getServiceReference(clazz);
}
public ServiceReference[] getServiceReferences(String clazz, String filter) throws InvalidSyntaxException
{
- // [TODO] getServiceReferences
- return null;
+ ServiceRegistry serviceRegistry = getFramework().getServiceRegistry();
+ return serviceRegistry.getServiceReferences(clazz, filter);
}
public Bundle installBundle(String location) throws BundleException
{
- SystemBundleContext sysContext = getSystemContext();
-
// Create the bundle from the location
- Bundle bundle = sysContext.getBundleFactory().createBundle(location);
+ BundleFactory bundleFactory = getFramework().getBundleFactory();
+ Bundle bundle = bundleFactory.createBundle(location);
// Register the bundle
- sysContext.getBundleRegistry().installBundle(bundle);
+ BundleRegistry bundleRegistry = getFramework().getBundleRegistry();
+ bundleRegistry.installBundle(bundle);
return bundle;
}
@@ -158,13 +171,13 @@
public ServiceRegistration registerService(String[] clazzes, Object service, Dictionary properties)
{
- ServiceRegistry registry = getSystemContext().getServiceRegistry();
+ ServiceRegistry registry = getFramework().getServiceRegistry();
return registry.registerService(getBundle(), clazzes, service, properties);
}
public ServiceRegistration registerService(String clazz, Object service, Dictionary properties)
{
- ServiceRegistry registry = getSystemContext().getServiceRegistry();
+ ServiceRegistry registry = getFramework().getServiceRegistry();
return registry.registerService(getBundle(), clazz, service, properties);
}
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleEventManagerImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleEventManagerImpl.java 2009-08-18 14:23:55 UTC (rev 92531)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleEventManagerImpl.java 2009-08-18 15:22:46 UTC (rev 92532)
@@ -23,12 +23,13 @@
//$Id: SystemBundleContext.java 91789 2009-07-29 20:49:03Z thomas.diesler(a)jboss.com $
+import java.util.ArrayList;
+import java.util.List;
+
import org.jboss.logging.Logger;
import org.jboss.osgi.jbossmc.api.BundleEventManager;
-import org.jboss.osgi.jbossmc.api.BundleResolver;
-import org.jboss.osgi.spi.NotImplementedException;
-import org.osgi.framework.Bundle;
import org.osgi.framework.BundleEvent;
+import org.osgi.framework.BundleListener;
/**
* A simple implementation of a BundleEventManager
@@ -41,15 +42,24 @@
// Provide logging
final Logger log = Logger.getLogger(BundleEventManagerImpl.class);
- private SystemBundleContext sysContext;
+ private FrameworkImpl framework;
+ private List<BundleListener> listeners = new ArrayList<BundleListener>();
- public BundleEventManagerImpl(SystemBundleContext sysContext)
+ public BundleEventManagerImpl(FrameworkImpl framework)
{
- this.sysContext = sysContext;
+ this.framework = framework;
}
public void fireBundleEvent(BundleEvent event)
{
- // [TODO] fire bundle event
+ // [TODO] When a BundleEvent is fired, it is asynchronously delivered to a BundleListener
+
+ for (BundleListener listener : listeners)
+ listener.bundleChanged(event);
}
+
+ public void addBundleListener(BundleListener listener)
+ {
+ listeners.add(listener);
+ }
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleFactoryImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleFactoryImpl.java 2009-08-18 14:23:55 UTC (rev 92531)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleFactoryImpl.java 2009-08-18 15:22:46 UTC (rev 92532)
@@ -43,11 +43,11 @@
// Provide logging
final Logger log = Logger.getLogger(BundleFactoryImpl.class);
- private SystemBundleContext sysContext;
+ private FrameworkImpl framework;
- public BundleFactoryImpl(SystemBundleContext sysContext)
+ public BundleFactoryImpl(FrameworkImpl framework)
{
- this.sysContext = sysContext;
+ this.framework = framework;
}
public Bundle createBundle(String location)
@@ -64,7 +64,7 @@
}
BundleImpl bundle = new BundleImpl(vfsRoot);
- bundle.setBundleContext(new BundleContextImpl(sysContext, bundle));
+ bundle.setBundleContext(new BundleContextImpl(framework, bundle));
return bundle;
}
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleImpl.java 2009-08-18 14:23:55 UTC (rev 92531)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleImpl.java 2009-08-18 15:22:46 UTC (rev 92532)
@@ -153,7 +153,7 @@
// If this bundle's state is not RESOLVED, an attempt is made to resolve this bundle.
if (state != Bundle.RESOLVED)
{
- BundleResolver resolver = getSystemContext().getBundleResolver();
+ BundleResolver resolver = getFramework().getBundleResolver();
resolver.resolveBundle(this);
}
@@ -163,7 +163,7 @@
state = Bundle.STARTING;
// A bundle event of type BundleEvent.STARTING is fired.
- BundleEventManager eventManager = getSystemContext().getBundleEventManager();
+ BundleEventManager eventManager = getFramework().getBundleEventManager();
eventManager.fireBundleEvent(new BundleEvent(BundleEvent.STARTING, this));
// The BundleActivator is called
@@ -341,7 +341,7 @@
// before attempting to load the class.
if (state == Bundle.INSTALLED)
{
- BundleResolver resolver = getSystemContext().getBundleResolver();
+ BundleResolver resolver = getFramework().getBundleResolver();
try
{
resolver.resolveBundle(this);
@@ -349,7 +349,7 @@
catch (BundleException ex)
{
// If this bundle cannot be resolved, a Framework event of type FrameworkEvent.ERROR is fired
- FrameworkEventManager eventManager = getSystemContext().getFrameworkEventManager();
+ FrameworkEventManager eventManager = getFramework().getFrameworkEventManager();
eventManager.fireFrameworkEvent(new FrameworkEvent(FrameworkEvent.ERROR, this, ex));
throw new ClassNotFoundException("Cannot load class: " + name, ex);
@@ -364,8 +364,8 @@
return (String)getHeaders().get(header);
}
- private SystemBundleContext getSystemContext()
+ private FrameworkImpl getFramework()
{
- return context.getSystemContext();
+ return context.getFramework();
}
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleRegistryImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleRegistryImpl.java 2009-08-18 14:23:55 UTC (rev 92531)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleRegistryImpl.java 2009-08-18 15:22:46 UTC (rev 92532)
@@ -41,12 +41,12 @@
final Logger log = Logger.getLogger(BundleRegistryImpl.class);
private long bundleId;
- private SystemBundleContext sysContext;
+ private FrameworkImpl framework;
private HashMap<String, Bundle> registry = new HashMap<String, Bundle>();
- public BundleRegistryImpl(SystemBundleContext sysContext)
+ public BundleRegistryImpl(FrameworkImpl framework)
{
- this.sysContext = sysContext;
+ this.framework = framework;
}
public long installBundle(Bundle bundle)
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleResolverImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleResolverImpl.java 2009-08-18 14:23:55 UTC (rev 92531)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleResolverImpl.java 2009-08-18 15:22:46 UTC (rev 92532)
@@ -40,8 +40,11 @@
// Provide logging
final Logger log = Logger.getLogger(BundleResolverImpl.class);
- public BundleResolverImpl(SystemBundleContext sysContext)
+ private FrameworkImpl framework;
+
+ public BundleResolverImpl(FrameworkImpl framework)
{
+ this.framework = framework;
}
public void resolveBundle(Bundle bundle) throws BundleException
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkEventManagerImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkEventManagerImpl.java 2009-08-18 14:23:55 UTC (rev 92531)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkEventManagerImpl.java 2009-08-18 15:22:46 UTC (rev 92532)
@@ -23,9 +23,13 @@
//$Id: SystemBundleContext.java 91789 2009-07-29 20:49:03Z thomas.diesler(a)jboss.com $
+import java.util.ArrayList;
+import java.util.List;
+
import org.jboss.logging.Logger;
import org.jboss.osgi.jbossmc.api.FrameworkEventManager;
import org.osgi.framework.FrameworkEvent;
+import org.osgi.framework.FrameworkListener;
/**
* A simple implementation of a FrameworkEventManager
@@ -38,12 +42,24 @@
// Provide logging
final Logger log = Logger.getLogger(FrameworkEventManagerImpl.class);
- public FrameworkEventManagerImpl(SystemBundleContext sysContext)
+ private FrameworkImpl framework;
+ private List<FrameworkListener> listeners = new ArrayList<FrameworkListener>();
+
+ public FrameworkEventManagerImpl(FrameworkImpl framework)
{
+ this.framework = framework;
}
public void fireFrameworkEvent(FrameworkEvent event)
{
- // [TODO] fire framework event
+ // [TODO] When a FrameworkEvent is fired, it is asynchronously delivered to a FrameworkListener.
+
+ for (FrameworkListener listener : listeners)
+ listener.frameworkEvent(event);
}
+
+ public void addFrameworkListener(FrameworkListener listener)
+ {
+ listeners.add(listener);
+ }
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkImpl.java 2009-08-18 14:23:55 UTC (rev 92531)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkImpl.java 2009-08-18 15:22:46 UTC (rev 92532)
@@ -25,10 +25,17 @@
import java.io.IOException;
import java.io.InputStream;
+import java.util.HashMap;
import java.util.Map;
import org.jboss.logging.Logger;
-import org.osgi.framework.BundleContext;
+import org.jboss.osgi.jbossmc.api.BundleEventManager;
+import org.jboss.osgi.jbossmc.api.BundleFactory;
+import org.jboss.osgi.jbossmc.api.BundleRegistry;
+import org.jboss.osgi.jbossmc.api.BundleResolver;
+import org.jboss.osgi.jbossmc.api.FrameworkEventManager;
+import org.jboss.osgi.jbossmc.api.ServiceEventManager;
+import org.jboss.osgi.jbossmc.api.ServiceRegistry;
import org.osgi.framework.BundleException;
import org.osgi.framework.FrameworkEvent;
import org.osgi.framework.launch.Framework;
@@ -44,13 +51,21 @@
// Provide logging
final Logger log = Logger.getLogger(FrameworkImpl.class);
- private Map configuration;
- private SystemBundleContext sysContext;
+ private Map<String, String> properties = new HashMap<String, String>();
private int startLevel;
+
+ private BundleRegistry bundleRegistry;
+ private BundleFactory bundleFactory;
+ private BundleResolver bundleResolver;
+ private BundleEventManager bundleEventManager;
+ private FrameworkEventManager frameworkEventManager;
+ private ServiceEventManager serviceEventManager;
+ private ServiceRegistry serviceRegistry;
- public FrameworkImpl(Map configuration)
+ public FrameworkImpl(Map props)
{
- this.configuration = configuration;
+ if (props != null)
+ properties.putAll(props);
}
/**
@@ -87,12 +102,11 @@
this.startLevel = startLevel;
}
- @Override
- public BundleContext getBundleContext()
+ public String getProperty(String key)
{
- return sysContext;
+ return properties.get(key);
}
-
+
public void init() throws BundleException
{
initInternal();
@@ -177,7 +191,15 @@
setState(STARTING);
// Have a valid Bundle Context
- sysContext = new SystemBundleContext(this);
+ setBundleContext(new SystemBundleContext(this));
+
+ bundleFactory = new BundleFactoryImpl(this);
+ bundleResolver = new BundleResolverImpl(this);
+ bundleRegistry = new BundleRegistryImpl(this);
+ serviceRegistry = new ServiceRegistryImpl(this);
+ bundleEventManager = new BundleEventManagerImpl(this);
+ frameworkEventManager = new FrameworkEventManagerImpl(this);
+ serviceEventManager = new ServiceEventManagerImpl(this);
// Be at start level 0
setStartLevel(0);
@@ -234,4 +256,39 @@
// [TODO] A Framework Event indicating the reason this method returned
return new FrameworkEvent(FrameworkEvent.STOPPED, this, null);
}
+
+ public BundleFactory getBundleFactory()
+ {
+ return bundleFactory;
+ }
+
+ public BundleRegistry getBundleRegistry()
+ {
+ return bundleRegistry;
+ }
+
+ public BundleResolver getBundleResolver()
+ {
+ return bundleResolver;
+ }
+
+ public ServiceRegistry getServiceRegistry()
+ {
+ return serviceRegistry;
+ }
+
+ public BundleEventManager getBundleEventManager()
+ {
+ return bundleEventManager;
+ }
+
+ public ServiceEventManager getServiceEventManager()
+ {
+ return serviceEventManager;
+ }
+
+ public FrameworkEventManager getFrameworkEventManager()
+ {
+ return frameworkEventManager;
+ }
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceEventManagerImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceEventManagerImpl.java 2009-08-18 14:23:55 UTC (rev 92531)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceEventManagerImpl.java 2009-08-18 15:22:46 UTC (rev 92532)
@@ -23,9 +23,13 @@
//$Id: SystemBundleContext.java 91789 2009-07-29 20:49:03Z thomas.diesler(a)jboss.com $
+import java.util.ArrayList;
+import java.util.List;
+
import org.jboss.logging.Logger;
import org.jboss.osgi.jbossmc.api.ServiceEventManager;
import org.osgi.framework.ServiceEvent;
+import org.osgi.framework.ServiceListener;
/**
* A simple implementation of a BundleEventManager
@@ -38,15 +42,25 @@
// Provide logging
final Logger log = Logger.getLogger(ServiceEventManagerImpl.class);
- private SystemBundleContext sysContext;
+ private FrameworkImpl framework;
+ private List<ServiceListener> listeners = new ArrayList<ServiceListener>();
- public ServiceEventManagerImpl(SystemBundleContext sysContext)
+ public ServiceEventManagerImpl(FrameworkImpl framework)
{
- this.sysContext = sysContext;
+ this.framework = framework;
}
-
+
public void fireServiceEvent(ServiceEvent event)
{
- // [TODO] fire service event
+ // When a ServiceEvent is fired, it is synchronously delivered to a ServiceListener.
+ for (ServiceListener listener : listeners)
+ listener.serviceChanged(event);
+
+ // [TODO] ServiceEvent object delivery to ServiceListener objects is filtered
}
+
+ public void addServiceListener(ServiceListener listener)
+ {
+ listeners.add(listener);
+ }
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceRegistryImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceRegistryImpl.java 2009-08-18 14:23:55 UTC (rev 92531)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceRegistryImpl.java 2009-08-18 15:22:46 UTC (rev 92532)
@@ -48,12 +48,12 @@
// Provide logging
final Logger log = Logger.getLogger(ServiceRegistryImpl.class);
- private SystemBundleContext sysContext;
private Map<String, ServiceReference> registry = new HashMap<String, ServiceReference>();
+ private FrameworkImpl framework;
- public ServiceRegistryImpl(SystemBundleContext sysContext)
+ public ServiceRegistryImpl(FrameworkImpl framework)
{
- this.sysContext = sysContext;
+ this.framework = framework;
}
public ServiceRegistration registerService(Bundle bundle, String clazz, Object service, Dictionary properties)
@@ -66,6 +66,20 @@
throw new NotImplementedException();
}
+ public ServiceReference getServiceReference(String clazz)
+ {
+ // [TODO] If multiple such services exist, the service with the highest ranking (as specified in its Constants.SERVICE_RANKING property) is returned.
+
+ // [TODO] If there is a tie in ranking, the service with the lowest service ID (as specified in its Constants.SERVICE_ID property); that is, the service that was registered first is returned.
+
+ return registry.get(clazz);
+ }
+
+ public ServiceReference[] getServiceReferences(String clazz, String filter)
+ {
+ throw new NotImplementedException();
+ }
+
private ServiceRegistration registerServiceInternal(Bundle bundle, String clazz, Object service, Dictionary properties)
{
// If service is not a ServiceFactory, an IllegalArgumentException is thrown if service
@@ -94,7 +108,7 @@
registry.put(clazz, serviceRef);
// 4. A service event of type ServiceEvent.REGISTERED is fired.
- ServiceEventManager eventManager = sysContext.getServiceEventManager();
+ ServiceEventManager eventManager = framework.getServiceEventManager();
eventManager.fireServiceEvent(new ServiceEvent(ServiceEvent.REGISTERED, serviceRef));
// 5. A ServiceRegistration object for this registration is returned.
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/SystemBundleContext.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/SystemBundleContext.java 2009-08-18 14:23:55 UTC (rev 92531)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/SystemBundleContext.java 2009-08-18 15:22:46 UTC (rev 92532)
@@ -24,14 +24,6 @@
//$Id$
import org.jboss.logging.Logger;
-import org.jboss.osgi.jbossmc.api.BundleEventManager;
-import org.jboss.osgi.jbossmc.api.BundleFactory;
-import org.jboss.osgi.jbossmc.api.BundleRegistry;
-import org.jboss.osgi.jbossmc.api.BundleResolver;
-import org.jboss.osgi.jbossmc.api.FrameworkEventManager;
-import org.jboss.osgi.jbossmc.api.ServiceEventManager;
-import org.jboss.osgi.jbossmc.api.ServiceRegistry;
-import org.osgi.framework.launch.Framework;
/**
* An implementation of the OSGi system BundleContext
@@ -44,65 +36,8 @@
// Provide logging
final Logger log = Logger.getLogger(SystemBundleContext.class);
- private BundleRegistry bundleRegistry;
- private BundleFactory bundleFactory;
- private BundleResolver bundleResolver;
- private BundleEventManager bundleEventManager;
- private FrameworkEventManager frameworkEventManager;
- private ServiceEventManager serviceEventManager;
- private ServiceRegistry serviceRegistry;
-
- public SystemBundleContext(Framework framework)
+ public SystemBundleContext(FrameworkImpl framework)
{
- super(null, framework);
-
- bundleFactory = new BundleFactoryImpl(this);
- bundleResolver = new BundleResolverImpl(this);
- bundleRegistry = new BundleRegistryImpl(this);
- serviceRegistry = new ServiceRegistryImpl(this);
- bundleEventManager = new BundleEventManagerImpl(this);
- frameworkEventManager = new FrameworkEventManagerImpl(this);
- serviceEventManager = new ServiceEventManagerImpl(this);
+ super(framework, framework);
}
-
- @Override
- SystemBundleContext getSystemContext()
- {
- return this;
- }
-
- public BundleFactory getBundleFactory()
- {
- return bundleFactory;
- }
-
- public BundleRegistry getBundleRegistry()
- {
- return bundleRegistry;
- }
-
- public BundleResolver getBundleResolver()
- {
- return bundleResolver;
- }
-
- public ServiceRegistry getServiceRegistry()
- {
- return serviceRegistry;
- }
-
- public BundleEventManager getBundleEventManager()
- {
- return bundleEventManager;
- }
-
- public ServiceEventManager getServiceEventManager()
- {
- return serviceEventManager;
- }
-
- public FrameworkEventManager getFrameworkEventManager()
- {
- return frameworkEventManager;
- }
}
\ No newline at end of file
Added: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/java/org/jboss/test/osgi/jbossmc/SystemContextTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/java/org/jboss/test/osgi/jbossmc/SystemContextTestCase.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/java/org/jboss/test/osgi/jbossmc/SystemContextTestCase.java 2009-08-18 15:22:46 UTC (rev 92532)
@@ -0,0 +1,73 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.jbossmc;
+
+//$Id: FrameworkLaunchTestCase.java 91789 2009-07-29 20:49:03Z thomas.diesler(a)jboss.com $
+
+import static org.junit.Assert.assertNotNull;
+
+import org.jboss.osgi.spi.util.ServiceLoader;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.Filter;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.launch.Framework;
+import org.osgi.framework.launch.FrameworkFactory;
+
+/**
+ * Test OSGi System bundle context
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 27-Jul-2009
+ */
+public class SystemContextTestCase
+{
+ private static Framework framework;
+ private static BundleContext context;
+
+ @BeforeClass
+ public static void beforeClass() throws BundleException
+ {
+ FrameworkFactory factory = ServiceLoader.loadService(FrameworkFactory.class);
+ framework = factory.newFramework(null);
+ framework.start();
+
+ context = framework.getBundleContext();
+ assertNotNull("System context not null", context);
+ }
+
+ @AfterClass
+ public static void afterClass() throws BundleException
+ {
+ framework.stop();
+ }
+
+ @Test
+ public void testCreateFilter() throws InvalidSyntaxException
+ {
+ Filter filter = context.createFilter("(foo=bar)");
+ assertNotNull("Filter not null", filter);
+ }
+}
\ No newline at end of file
Added: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/resources/tst.policy
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/resources/tst.policy (rev 0)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/resources/tst.policy 2009-08-18 15:22:46 UTC (rev 92532)
@@ -0,0 +1,4 @@
+grant {
+ permission java.security.AllPermission;
+};
+
16 years, 11 months
JBoss-OSGI SVN: r92529 - in projects/jboss-osgi/trunk: reactor/runtime/jbossmc/scripts and 10 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-08-18 09:45:40 -0400 (Tue, 18 Aug 2009)
New Revision: 92529
Added:
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/scripts/
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/scripts/antrun-test-jars.xml
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleClassLoader.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleEventManager.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleFactory.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleRegistry.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleResolver.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/FrameworkEventManager.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/ServiceEventManager.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/ServiceRegistry.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleClassLoaderImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleEventManagerImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleFactoryImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleRegistryImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleResolverImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkEventManagerImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceEventManagerImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceReferenceImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceRegistrationImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceRegistryImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/java/org/jboss/test/osgi/jbossmc/simple/
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/java/org/jboss/test/osgi/jbossmc/simple/BundleInstallTestCase.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/java/org/jboss/test/osgi/jbossmc/simple/bundle/
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/java/org/jboss/test/osgi/jbossmc/simple/bundle/SimpleActivator.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/java/org/jboss/test/osgi/jbossmc/simple/bundle/SimpleService.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/resources/jboss-osgi-jbossmc.properties
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/resources/org.jboss.osgi.spi.framework.OSGiBootstrapProvider
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/resources/simple/
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/resources/simple/simple.bnd
projects/jboss-osgi/trunk/testsuite/example/src/test/resources/jboss-osgi-jbossmc.properties
Removed:
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/java/org/jboss/test/osgi/felix/
Modified:
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/pom.xml
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleContextImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/SystemBundleContext.java
Log:
Initial bundle install
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/pom.xml 2009-08-18 13:38:52 UTC (rev 92528)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/pom.xml 2009-08-18 13:45:40 UTC (rev 92529)
@@ -37,6 +37,10 @@
<!-- Dependencies -->
<dependencies>
<dependency>
+ <groupId>biz.aQute</groupId>
+ <artifactId>bnd</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.jboss.osgi</groupId>
<artifactId>jboss-osgi-spi</artifactId>
<version>${version.jboss.osgi.spi}</version>
@@ -55,10 +59,48 @@
<!-- Build -->
<build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>build-test-jars</id>
+ <phase>test-compile</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <tasks>
+ <property name="maven.runtime.classpath" refid="maven.runtime.classpath" />
+ <property name="tests.output.dir" value="${project.build.directory}" />
+ <ant antfile="scripts/antrun-test-jars.xml" />
+ </tasks>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
</build>
<!-- Profiles -->
<profiles>
+
+ <!--
+ Name: framework-default
+ Descr: Setup for default framework integration testing
+ -->
+ <profile>
+ <id>framework-default</id>
+ <activation>
+ <property>
+ <name>!framework</name>
+ </property>
+ </activation>
+ <properties>
+ <jboss.osgi.framework.properties>jboss-osgi-jbossmc.properties</jboss.osgi.framework.properties>
+ </properties>
+ </profile>
+
</profiles>
</project>
Added: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/scripts/antrun-test-jars.xml
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/scripts/antrun-test-jars.xml (rev 0)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/scripts/antrun-test-jars.xml 2009-08-18 13:45:40 UTC (rev 92529)
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- ============================================================ -->
+<!-- JBoss, the OpenSource J2EE webOS -->
+<!-- Distributable under LGPL license. -->
+<!-- See terms of license at http://www.gnu.org. -->
+<!-- ============================================================ -->
+
+<!-- $Id: antrun-example-jars.xml 87329 2009-04-15 10:34:21Z thomas.diesler(a)jboss.com $ -->
+
+<project default="build-test-jars">
+
+ <description>OSGi test archive builder</description>
+
+ <!-- ================================================================== -->
+ <!-- Init -->
+ <!-- ================================================================== -->
+
+ <target name="init">
+
+ <!-- Property override when not called from maven -->
+ <property name="maven.runtime.classpath" value="/usr/java/bnd.jar" />
+ <property name="tests.output.dir" value="${basedir}/../target" />
+
+ <mkdir dir="${tests.output.dir}/test-libs" />
+ <property name="tests.classes.dir" value="${tests.output.dir}/test-classes" />
+ <property name="tests.resources.dir" value="${tests.output.dir}/test-classes" />
+
+ <taskdef resource="aQute/bnd/ant/taskdef.properties">
+ <classpath>
+ <pathelement path="${maven.runtime.classpath}" />
+ </classpath>
+ </taskdef>
+
+ </target>
+
+ <!-- ================================================================== -->
+ <!-- Building -->
+ <!-- ================================================================== -->
+
+ <target name="build-test-jars" depends="init" description="Build the test deployments">
+
+ <!-- Please add alphabetically -->
+
+ <!-- simple -->
+ <bnd classpath="${tests.classes.dir}" output="${tests.output.dir}/test-libs/simple-bundle.jar" files="${tests.resources.dir}/simple/simple.bnd" />
+
+ <!-- Please add alphabetically -->
+
+ </target>
+
+</project>
Added: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleClassLoader.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleClassLoader.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleClassLoader.java 2009-08-18 13:45:40 UTC (rev 92529)
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.jbossmc.api;
+
+//$Id: SystemBundleContext.java 91789 2009-07-29 20:49:03Z thomas.diesler(a)jboss.com $
+
+/**
+ * An abstraction of a bundle class loader.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 18-Aug-2009
+ */
+public interface BundleClassLoader
+{
+ Class loadClass(String name) throws ClassNotFoundException;
+}
\ No newline at end of file
Added: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleEventManager.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleEventManager.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleEventManager.java 2009-08-18 13:45:40 UTC (rev 92529)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.jbossmc.api;
+
+import org.osgi.framework.BundleEvent;
+
+//$Id: SystemBundleContext.java 91789 2009-07-29 20:49:03Z thomas.diesler(a)jboss.com $
+
+/**
+ * An abstraction of a bundle event manager.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 18-Aug-2009
+ */
+public interface BundleEventManager
+{
+ void fireBundleEvent(BundleEvent event);
+}
\ No newline at end of file
Added: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleFactory.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleFactory.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleFactory.java 2009-08-18 13:45:40 UTC (rev 92529)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.jbossmc.api;
+
+import org.osgi.framework.Bundle;
+
+//$Id: SystemBundleContext.java 91789 2009-07-29 20:49:03Z thomas.diesler(a)jboss.com $
+
+
+/**
+ * An abstraction of a bundle factory.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 18-Aug-2009
+ */
+public interface BundleFactory
+{
+ Bundle createBundle(String location);
+}
\ No newline at end of file
Added: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleRegistry.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleRegistry.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleRegistry.java 2009-08-18 13:45:40 UTC (rev 92529)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.jbossmc.api;
+
+import org.osgi.framework.Bundle;
+
+//$Id: SystemBundleContext.java 91789 2009-07-29 20:49:03Z thomas.diesler(a)jboss.com $
+
+
+/**
+ * An abstraction of a bundle registry.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 18-Aug-2009
+ */
+public interface BundleRegistry
+{
+ long installBundle(Bundle bundle);
+
+ void uninstallBundle(Bundle bundle);
+}
\ No newline at end of file
Added: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleResolver.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleResolver.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleResolver.java 2009-08-18 13:45:40 UTC (rev 92529)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.jbossmc.api;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleException;
+
+//$Id: SystemBundleContext.java 91789 2009-07-29 20:49:03Z thomas.diesler(a)jboss.com $
+
+
+/**
+ * An abstraction of a bundle resolver.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 18-Aug-2009
+ */
+public interface BundleResolver
+{
+ void resolveBundle(Bundle bundle) throws BundleException;
+}
\ No newline at end of file
Added: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/FrameworkEventManager.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/FrameworkEventManager.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/FrameworkEventManager.java 2009-08-18 13:45:40 UTC (rev 92529)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.jbossmc.api;
+
+import org.osgi.framework.FrameworkEvent;
+
+//$Id: SystemBundleContext.java 91789 2009-07-29 20:49:03Z thomas.diesler(a)jboss.com $
+
+/**
+ * An abstraction of a framework event manager.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 18-Aug-2009
+ */
+public interface FrameworkEventManager
+{
+ void fireFrameworkEvent(FrameworkEvent event);
+}
\ No newline at end of file
Added: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/ServiceEventManager.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/ServiceEventManager.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/ServiceEventManager.java 2009-08-18 13:45:40 UTC (rev 92529)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.jbossmc.api;
+
+import org.osgi.framework.ServiceEvent;
+
+//$Id: SystemBundleContext.java 91789 2009-07-29 20:49:03Z thomas.diesler(a)jboss.com $
+
+/**
+ * An abstraction of a service event manager.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 18-Aug-2009
+ */
+public interface ServiceEventManager
+{
+ void fireServiceEvent(ServiceEvent event);
+}
\ No newline at end of file
Added: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/ServiceRegistry.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/ServiceRegistry.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/ServiceRegistry.java 2009-08-18 13:45:40 UTC (rev 92529)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.jbossmc.api;
+
+//$Id: SystemBundleContext.java 91789 2009-07-29 20:49:03Z thomas.diesler(a)jboss.com $
+
+import java.util.Dictionary;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.ServiceRegistration;
+
+/**
+ * An abstraction of a service registry.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 18-Aug-2009
+ */
+public interface ServiceRegistry
+{
+ ServiceRegistration registerService(Bundle bundle, String[] clazzes, Object service, Dictionary properties);
+
+ ServiceRegistration registerService(Bundle bundle, String clazz, Object service, Dictionary properties);
+}
\ No newline at end of file
Added: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleClassLoaderImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleClassLoaderImpl.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleClassLoaderImpl.java 2009-08-18 13:45:40 UTC (rev 92529)
@@ -0,0 +1,74 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.jbossmc.framework;
+
+//$Id: SystemBundleContext.java 91789 2009-07-29 20:49:03Z thomas.diesler(a)jboss.com $
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.net.URLClassLoader;
+
+import org.jboss.logging.Logger;
+import org.jboss.osgi.jbossmc.api.BundleClassLoader;
+import org.jboss.osgi.jbossmc.api.BundleFactory;
+import org.jboss.virtual.VFS;
+import org.jboss.virtual.VirtualFile;
+import org.osgi.framework.Bundle;
+
+/**
+ * A simple implementation of a BundleClassLoader
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 18-Aug-2009
+ */
+public class BundleClassLoaderImpl implements BundleClassLoader
+{
+ // Provide logging
+ final Logger log = Logger.getLogger(BundleClassLoaderImpl.class);
+
+ private ClassLoader loader;
+
+ public BundleClassLoaderImpl(Bundle bundle)
+ {
+ BundleImpl bundleImpl = (BundleImpl)bundle;
+
+ URL location;
+ try
+ {
+ location = bundleImpl.getVirtualFile().toURL();
+ }
+ catch (Exception ex)
+ {
+ throw new IllegalStateException("Cannot obtain bundle location", ex);
+ }
+
+ loader = new URLClassLoader(new URL[]{ location });
+ }
+
+ public Class loadClass(String name) throws ClassNotFoundException
+ {
+ return loader.loadClass(name);
+ }
+
+}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleContextImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleContextImpl.java 2009-08-18 13:38:52 UTC (rev 92528)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleContextImpl.java 2009-08-18 13:45:40 UTC (rev 92529)
@@ -28,6 +28,7 @@
import java.util.Dictionary;
import org.jboss.logging.Logger;
+import org.jboss.osgi.jbossmc.api.ServiceRegistry;
import org.jboss.osgi.spi.NotImplementedException;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
@@ -51,16 +52,16 @@
// Provide logging
final Logger log = Logger.getLogger(BundleContextImpl.class);
- private BundleContext sysContext;
+ private SystemBundleContext sysContext;
private Bundle bundle;
- public BundleContextImpl(BundleContext sysContext, Bundle bundle)
+ public BundleContextImpl(SystemBundleContext sysContext, Bundle bundle)
{
this.sysContext = sysContext;
this.bundle = bundle;
}
- BundleContext getSystemContext()
+ SystemBundleContext getSystemContext()
{
return sysContext;
}
@@ -139,7 +140,15 @@
public Bundle installBundle(String location) throws BundleException
{
- throw new NotImplementedException();
+ SystemBundleContext sysContext = getSystemContext();
+
+ // Create the bundle from the location
+ Bundle bundle = sysContext.getBundleFactory().createBundle(location);
+
+ // Register the bundle
+ sysContext.getBundleRegistry().installBundle(bundle);
+
+ return bundle;
}
public Bundle installBundle(String location, InputStream input) throws BundleException
@@ -149,12 +158,14 @@
public ServiceRegistration registerService(String[] clazzes, Object service, Dictionary properties)
{
- throw new NotImplementedException();
+ ServiceRegistry registry = getSystemContext().getServiceRegistry();
+ return registry.registerService(getBundle(), clazzes, service, properties);
}
public ServiceRegistration registerService(String clazz, Object service, Dictionary properties)
{
- throw new NotImplementedException();
+ ServiceRegistry registry = getSystemContext().getServiceRegistry();
+ return registry.registerService(getBundle(), clazz, service, properties);
}
public void removeBundleListener(BundleListener listener)
Added: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleEventManagerImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleEventManagerImpl.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleEventManagerImpl.java 2009-08-18 13:45:40 UTC (rev 92529)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.jbossmc.framework;
+
+//$Id: SystemBundleContext.java 91789 2009-07-29 20:49:03Z thomas.diesler(a)jboss.com $
+
+import org.jboss.logging.Logger;
+import org.jboss.osgi.jbossmc.api.BundleEventManager;
+import org.jboss.osgi.jbossmc.api.BundleResolver;
+import org.jboss.osgi.spi.NotImplementedException;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleEvent;
+
+/**
+ * A simple implementation of a BundleEventManager
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 18-Aug-2009
+ */
+public class BundleEventManagerImpl implements BundleEventManager
+{
+ // Provide logging
+ final Logger log = Logger.getLogger(BundleEventManagerImpl.class);
+
+ private SystemBundleContext sysContext;
+
+ public BundleEventManagerImpl(SystemBundleContext sysContext)
+ {
+ this.sysContext = sysContext;
+ }
+
+ public void fireBundleEvent(BundleEvent event)
+ {
+ // [TODO] fire bundle event
+ }
+}
\ No newline at end of file
Added: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleFactoryImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleFactoryImpl.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleFactoryImpl.java 2009-08-18 13:45:40 UTC (rev 92529)
@@ -0,0 +1,70 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.jbossmc.framework;
+
+//$Id: SystemBundleContext.java 91789 2009-07-29 20:49:03Z thomas.diesler(a)jboss.com $
+
+import java.io.IOException;
+import java.net.URL;
+
+import org.jboss.logging.Logger;
+import org.jboss.osgi.jbossmc.api.BundleFactory;
+import org.jboss.virtual.VFS;
+import org.jboss.virtual.VirtualFile;
+import org.osgi.framework.Bundle;
+
+/**
+ * A simple implementation of a BundleFactory
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 18-Aug-2009
+ */
+public class BundleFactoryImpl implements BundleFactory
+{
+ // Provide logging
+ final Logger log = Logger.getLogger(BundleFactoryImpl.class);
+
+ private SystemBundleContext sysContext;
+
+ public BundleFactoryImpl(SystemBundleContext sysContext)
+ {
+ this.sysContext = sysContext;
+ }
+
+ public Bundle createBundle(String location)
+ {
+ VirtualFile vfsRoot;
+ try
+ {
+ URL locationURL = new URL(location);
+ vfsRoot = VFS.createNewRoot(locationURL);
+ }
+ catch (IOException ex)
+ {
+ throw new IllegalArgumentException("Invalid bundle location URL: " + location);
+ }
+
+ BundleImpl bundle = new BundleImpl(vfsRoot);
+ bundle.setBundleContext(new BundleContextImpl(sysContext, bundle));
+ return bundle;
+ }
+}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleImpl.java 2009-08-18 13:38:52 UTC (rev 92528)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleImpl.java 2009-08-18 13:45:40 UTC (rev 92529)
@@ -28,16 +28,29 @@
import java.net.URL;
import java.util.Dictionary;
import java.util.Enumeration;
+import java.util.Hashtable;
import java.util.Map;
+import java.util.jar.Attributes;
+import java.util.jar.Manifest;
import org.jboss.logging.Logger;
+import org.jboss.osgi.jbossmc.api.BundleClassLoader;
+import org.jboss.osgi.jbossmc.api.BundleEventManager;
+import org.jboss.osgi.jbossmc.api.BundleResolver;
+import org.jboss.osgi.jbossmc.api.FrameworkEventManager;
import org.jboss.osgi.spi.NotImplementedException;
+import org.jboss.virtual.VirtualFile;
import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleEvent;
import org.osgi.framework.BundleException;
+import org.osgi.framework.FrameworkEvent;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.Version;
+import aQute.lib.osgi.Constants;
+
/**
* An implementation of an OSGi Bundle
*
@@ -50,13 +63,38 @@
final Logger log = Logger.getLogger(BundleImpl.class);
private int state;
- private BundleContext bndContext;
+ private VirtualFile vFile;
+ private long bundleId;
+ private BundleContextImpl context;
+ private Dictionary<String, String> headers;
+ private BundleClassLoader classLoader;
+ public BundleImpl()
+ {
+ // ctor used by the framework
+ // [TODO] remove when we have a VFS root for the framework
+ }
+
+ public BundleImpl(VirtualFile vFile)
+ {
+ this.vFile = vFile;
+ }
+
+ public VirtualFile getVirtualFile()
+ {
+ return vFile;
+ }
+
public long getBundleId()
{
- throw new NotImplementedException();
+ return bundleId;
}
+ public void setBundleId(long bundleId)
+ {
+ this.bundleId = bundleId;
+ }
+
public int getState()
{
return state;
@@ -69,22 +107,110 @@
public String getLocation()
{
- throw new NotImplementedException();
+ try
+ {
+ return getVirtualFile().toURL().toExternalForm();
+ }
+ catch (Exception ex)
+ {
+ throw new IllegalStateException("Cannot obtain bundle location", ex);
+ }
}
public String getSymbolicName()
{
- throw new NotImplementedException();
+ return getHeader(Constants.BUNDLE_SYMBOLICNAME);
}
+ public BundleClassLoader getClassLoader()
+ {
+ return classLoader;
+ }
+
+ public void setClassLoader(BundleClassLoader classLoader)
+ {
+ this.classLoader = classLoader;
+ }
+
public void start() throws BundleException
{
- throw new NotImplementedException();
+ start(0);
}
public void start(int options) throws BundleException
{
- throw new NotImplementedException();
+ // If this bundle's state is UNINSTALLED then an IllegalStateException is thrown.
+ if (state == Bundle.UNINSTALLED)
+ throw new IllegalStateException("Bundle already uninstalled: " + this);
+
+ // [TODO] Implement the optional Start Level service
+
+ // [TODO] If this bundle is in the process of being activated or deactivated then this method must wait
+ // for activation or deactivation to complete before continuing.
+ if (state == Bundle.STARTING || state == Bundle.STARTING)
+ throw new IllegalStateException("Bundle already staring/stopping: " + this);
+
+ // If this bundle's state is not RESOLVED, an attempt is made to resolve this bundle.
+ if (state != Bundle.RESOLVED)
+ {
+ BundleResolver resolver = getSystemContext().getBundleResolver();
+ resolver.resolveBundle(this);
+ }
+
+ // [TODO] Lazy bundle activation
+
+ // This bundle's state is set to STARTING.
+ state = Bundle.STARTING;
+
+ // A bundle event of type BundleEvent.STARTING is fired.
+ BundleEventManager eventManager = getSystemContext().getBundleEventManager();
+ eventManager.fireBundleEvent(new BundleEvent(BundleEvent.STARTING, this));
+
+ // The BundleActivator is called
+ String activatorClass = getHeader(Constants.BUNDLE_ACTIVATOR);
+ if (activatorClass != null)
+ {
+ BundleActivator activator;
+ try
+ {
+ activator = (BundleActivator)loadClass(activatorClass).newInstance();
+ activator.start(context);
+ }
+ catch (Exception ex)
+ {
+ // This bundle's state is set to STOPPING.
+ state = Bundle.STOPPING;
+
+ // A bundle event of type BundleEvent.STOPPING is fired
+ eventManager.fireBundleEvent(new BundleEvent(BundleEvent.STOPPING, this));
+
+ // [TODO] Any services registered by this bundle must be unregistered.
+
+ // [TODO] Any services used by this bundle must be released.
+
+ // [TODO] Any listeners registered by this bundle must be removed.
+
+ // This bundle's state is set to RESOLVED.
+ state = Bundle.RESOLVED;
+
+ // A bundle event of type BundleEvent.STOPPED is fired.
+ eventManager.fireBundleEvent(new BundleEvent(BundleEvent.STOPPED, this));
+
+ // A BundleException is then thrown.
+ throw new BundleException("Cannot call BundleActivator: " + activatorClass, ex);
+ }
+ }
+
+ // If this bundle's state is UNINSTALLED, because this bundle was uninstalled while
+ // the BundleActivator.start was running
+ if (state == Bundle.UNINSTALLED)
+ throw new IllegalStateException("Bundle already uninstalled: " + this);
+
+ // This bundle's state is set to ACTIVE
+ state = Bundle.ACTIVE;
+
+ // A bundle event of type BundleEvent.STARTED is fired
+ eventManager.fireBundleEvent(new BundleEvent(BundleEvent.STARTED, this));
}
public void stop() throws BundleException
@@ -119,9 +245,14 @@
public BundleContext getBundleContext()
{
- return bndContext;
+ return context;
}
+ public void setBundleContext(BundleContextImpl bndContext)
+ {
+ this.context = bndContext;
+ }
+
public URL getEntry(String path)
{
throw new NotImplementedException();
@@ -134,7 +265,26 @@
public Dictionary getHeaders()
{
- throw new NotImplementedException();
+ if (headers == null)
+ {
+ headers = new Hashtable<String, String>();
+ try
+ {
+ VirtualFile child = vFile.getChild("META-INF/MANIFEST.MF");
+ Manifest manifest = new Manifest(child.openStream());
+ Attributes attribs = manifest.getMainAttributes();
+ for (Object key : attribs.keySet())
+ {
+ Object value = attribs.get(key);
+ headers.put(key.toString(), value.toString());
+ }
+ }
+ catch (IOException ex)
+ {
+ throw new IllegalStateException("Cannot read bundle manifest", ex);
+ }
+ }
+ return headers;
}
public Dictionary getHeaders(String locale)
@@ -183,8 +333,39 @@
throw new NotImplementedException();
}
- public Class loadClass(String name) throws ClassNotFoundException
+ public Class<?> loadClass(String name) throws ClassNotFoundException
{
- throw new NotImplementedException();
+ // [TODO] If this bundle is a fragment bundle then this method must throw a ClassNotFoundException
+
+ // If this bundle's state is INSTALLED, this method must attempt to resolve this bundle
+ // before attempting to load the class.
+ if (state == Bundle.INSTALLED)
+ {
+ BundleResolver resolver = getSystemContext().getBundleResolver();
+ try
+ {
+ resolver.resolveBundle(this);
+ }
+ catch (BundleException ex)
+ {
+ // If this bundle cannot be resolved, a Framework event of type FrameworkEvent.ERROR is fired
+ FrameworkEventManager eventManager = getSystemContext().getFrameworkEventManager();
+ eventManager.fireFrameworkEvent(new FrameworkEvent(FrameworkEvent.ERROR, this, ex));
+
+ throw new ClassNotFoundException("Cannot load class: " + name, ex);
+ }
+ }
+
+ return getClassLoader().loadClass(name);
}
+
+ private String getHeader(String header)
+ {
+ return (String)getHeaders().get(header);
+ }
+
+ private SystemBundleContext getSystemContext()
+ {
+ return context.getSystemContext();
+ }
}
\ No newline at end of file
Added: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleRegistryImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleRegistryImpl.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleRegistryImpl.java 2009-08-18 13:45:40 UTC (rev 92529)
@@ -0,0 +1,79 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.jbossmc.framework;
+
+//$Id: SystemBundleContext.java 91789 2009-07-29 20:49:03Z thomas.diesler(a)jboss.com $
+
+import java.util.HashMap;
+
+import org.jboss.logging.Logger;
+import org.jboss.osgi.jbossmc.api.BundleRegistry;
+import org.osgi.framework.Bundle;
+
+/**
+ * A simple implementation of a BundleRegistry
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 18-Aug-2009
+ */
+public class BundleRegistryImpl implements BundleRegistry
+{
+ // Provide logging
+ final Logger log = Logger.getLogger(BundleRegistryImpl.class);
+
+ private long bundleId;
+ private SystemBundleContext sysContext;
+ private HashMap<String, Bundle> registry = new HashMap<String, Bundle>();
+
+ public BundleRegistryImpl(SystemBundleContext sysContext)
+ {
+ this.sysContext = sysContext;
+ }
+
+ public long installBundle(Bundle bundle)
+ {
+ String location = getBundleLocation(bundle);
+ registry.put(location, bundle);
+
+ ((BundleImpl)bundle).setBundleId(bundleId++);
+ return bundle.getBundleId();
+ }
+
+ public void uninstallBundle(Bundle bundle)
+ {
+ String location = getBundleLocation(bundle);
+ if (registry.remove(location) == null)
+ throw new IllegalStateException("Cannot unregister bundle: " + bundle);
+ }
+
+ private String getBundleLocation(Bundle bundle)
+ {
+ if (bundle == null)
+ throw new IllegalArgumentException("Cannot unregister null bundle");
+
+ String location = bundle.getLocation();
+ if (location == null)
+ throw new IllegalArgumentException("Cannot obtain bundle location");
+
+ return location;
+ }
+}
\ No newline at end of file
Added: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleResolverImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleResolverImpl.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleResolverImpl.java 2009-08-18 13:45:40 UTC (rev 92529)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.jbossmc.framework;
+
+//$Id: SystemBundleContext.java 91789 2009-07-29 20:49:03Z thomas.diesler(a)jboss.com $
+
+import org.jboss.logging.Logger;
+import org.jboss.osgi.jbossmc.api.BundleClassLoader;
+import org.jboss.osgi.jbossmc.api.BundleResolver;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleException;
+
+/**
+ * A simple implementation of a BundleResolver
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 18-Aug-2009
+ */
+public class BundleResolverImpl implements BundleResolver
+{
+ // Provide logging
+ final Logger log = Logger.getLogger(BundleResolverImpl.class);
+
+ public BundleResolverImpl(SystemBundleContext sysContext)
+ {
+ }
+
+ public void resolveBundle(Bundle bundle) throws BundleException
+ {
+ // [TODO] resolve bundle properly
+
+ BundleImpl bundleImpl = (BundleImpl)bundle;
+ BundleClassLoader loader = new BundleClassLoaderImpl(bundleImpl);
+ bundleImpl.setClassLoader(loader);
+
+ bundleImpl.setState(Bundle.RESOLVED);
+ }
+}
\ No newline at end of file
Added: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkEventManagerImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkEventManagerImpl.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkEventManagerImpl.java 2009-08-18 13:45:40 UTC (rev 92529)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.jbossmc.framework;
+
+//$Id: SystemBundleContext.java 91789 2009-07-29 20:49:03Z thomas.diesler(a)jboss.com $
+
+import org.jboss.logging.Logger;
+import org.jboss.osgi.jbossmc.api.FrameworkEventManager;
+import org.osgi.framework.FrameworkEvent;
+
+/**
+ * A simple implementation of a FrameworkEventManager
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 18-Aug-2009
+ */
+public class FrameworkEventManagerImpl implements FrameworkEventManager
+{
+ // Provide logging
+ final Logger log = Logger.getLogger(FrameworkEventManagerImpl.class);
+
+ public FrameworkEventManagerImpl(SystemBundleContext sysContext)
+ {
+ }
+
+ public void fireFrameworkEvent(FrameworkEvent event)
+ {
+ // [TODO] fire framework event
+ }
+}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkImpl.java 2009-08-18 13:38:52 UTC (rev 92528)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkImpl.java 2009-08-18 13:45:40 UTC (rev 92529)
@@ -62,23 +62,19 @@
return 0;
}
- /**
- * Returns the symbolic name of this Framework.
- */
@Override
- public String getSymbolicName()
+ public String getLocation()
{
- return "org.jboss.osgi.jbossmc";
+ return "System Bundle";
}
/**
- * Returns the Framework location identifier. This Framework is assigned the unique location "<code>System Bundle</code>" since this Framework is also a
- * System Bundle.
+ * Returns the symbolic name of this Framework.
*/
@Override
- public String getLocation()
+ public String getSymbolicName()
{
- return "System Bundle";
+ return "org.jboss.osgi.jbossmc";
}
int getStartLevel()
Added: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceEventManagerImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceEventManagerImpl.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceEventManagerImpl.java 2009-08-18 13:45:40 UTC (rev 92529)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.jbossmc.framework;
+
+//$Id: SystemBundleContext.java 91789 2009-07-29 20:49:03Z thomas.diesler(a)jboss.com $
+
+import org.jboss.logging.Logger;
+import org.jboss.osgi.jbossmc.api.ServiceEventManager;
+import org.osgi.framework.ServiceEvent;
+
+/**
+ * A simple implementation of a BundleEventManager
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 18-Aug-2009
+ */
+public class ServiceEventManagerImpl implements ServiceEventManager
+{
+ // Provide logging
+ final Logger log = Logger.getLogger(ServiceEventManagerImpl.class);
+
+ private SystemBundleContext sysContext;
+
+ public ServiceEventManagerImpl(SystemBundleContext sysContext)
+ {
+ this.sysContext = sysContext;
+ }
+
+ public void fireServiceEvent(ServiceEvent event)
+ {
+ // [TODO] fire service event
+ }
+}
\ No newline at end of file
Added: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceReferenceImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceReferenceImpl.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceReferenceImpl.java 2009-08-18 13:45:40 UTC (rev 92529)
@@ -0,0 +1,93 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.jbossmc.framework;
+
+//$Id: SystemBundleContext.java 91789 2009-07-29 20:49:03Z thomas.diesler(a)jboss.com $
+
+import java.util.ArrayList;
+import java.util.Dictionary;
+import java.util.Enumeration;
+import java.util.List;
+
+import org.jboss.logging.Logger;
+import org.jboss.osgi.spi.NotImplementedException;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.ServiceReference;
+
+/**
+ * A simple implementation of a ServiceReference
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 18-Aug-2009
+ */
+public class ServiceReferenceImpl implements ServiceReference
+{
+ // Provide logging
+ final Logger log = Logger.getLogger(ServiceReferenceImpl.class);
+
+ private Bundle bundle;
+ private Dictionary<String, String> properties;
+
+ public ServiceReferenceImpl(Bundle bundle, Dictionary<String, String> properties)
+ {
+ this.bundle = bundle;
+ this.properties = properties;
+ }
+
+ public int compareTo(Object reference)
+ {
+ throw new NotImplementedException();
+ }
+
+ public Bundle getBundle()
+ {
+ return bundle;
+ }
+
+ public Object getProperty(String key)
+ {
+ return properties.get(key);
+ }
+
+ public String[] getPropertyKeys()
+ {
+ Enumeration<String> keysEnum = properties.keys();
+ List<String> keyList = new ArrayList<String>();
+ while (keysEnum.hasMoreElements())
+ keyList.add(keysEnum.nextElement());
+
+ String[] keys = new String[keyList.size()];
+ keyList.toArray(keys);
+
+ return keys;
+ }
+
+ public Bundle[] getUsingBundles()
+ {
+ throw new NotImplementedException();
+ }
+
+ public boolean isAssignableTo(Bundle bundle, String className)
+ {
+ throw new NotImplementedException();
+ }
+}
\ No newline at end of file
Added: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceRegistrationImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceRegistrationImpl.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceRegistrationImpl.java 2009-08-18 13:45:40 UTC (rev 92529)
@@ -0,0 +1,65 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.jbossmc.framework;
+
+//$Id: SystemBundleContext.java 91789 2009-07-29 20:49:03Z thomas.diesler(a)jboss.com $
+
+import java.util.Dictionary;
+
+import org.jboss.logging.Logger;
+import org.jboss.osgi.spi.NotImplementedException;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
+
+/**
+ * A simple implementation of a ServiceRegistration
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 18-Aug-2009
+ */
+public class ServiceRegistrationImpl implements ServiceRegistration
+{
+ // Provide logging
+ final Logger log = Logger.getLogger(ServiceRegistrationImpl.class);
+
+ private ServiceReferenceImpl serviceRef;
+
+ public ServiceRegistrationImpl(ServiceReferenceImpl serviceRef)
+ {
+ this.serviceRef = serviceRef;
+ }
+
+ public ServiceReference getReference()
+ {
+ return serviceRef;
+ }
+
+ public void setProperties(Dictionary properties)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void unregister()
+ {
+ throw new NotImplementedException();
+ }
+}
\ No newline at end of file
Added: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceRegistryImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceRegistryImpl.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceRegistryImpl.java 2009-08-18 13:45:40 UTC (rev 92529)
@@ -0,0 +1,103 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.jbossmc.framework;
+
+//$Id: SystemBundleContext.java 91789 2009-07-29 20:49:03Z thomas.diesler(a)jboss.com $
+
+import java.util.Dictionary;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.logging.Logger;
+import org.jboss.osgi.jbossmc.api.ServiceEventManager;
+import org.jboss.osgi.jbossmc.api.ServiceRegistry;
+import org.jboss.osgi.spi.NotImplementedException;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.ServiceEvent;
+import org.osgi.framework.ServiceFactory;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
+
+/**
+ * A simple implementation of a BundleRegistry
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 18-Aug-2009
+ */
+public class ServiceRegistryImpl implements ServiceRegistry
+{
+ // Provide logging
+ final Logger log = Logger.getLogger(ServiceRegistryImpl.class);
+
+ private SystemBundleContext sysContext;
+ private Map<String, ServiceReference> registry = new HashMap<String, ServiceReference>();
+
+ public ServiceRegistryImpl(SystemBundleContext sysContext)
+ {
+ this.sysContext = sysContext;
+ }
+
+ public ServiceRegistration registerService(Bundle bundle, String clazz, Object service, Dictionary properties)
+ {
+ return registerServiceInternal(bundle, clazz, service, properties);
+ }
+
+ public ServiceRegistration registerService(Bundle bundle, String[] clazzes, Object service, Dictionary properties)
+ {
+ throw new NotImplementedException();
+ }
+
+ private ServiceRegistration registerServiceInternal(Bundle bundle, String clazz, Object service, Dictionary properties)
+ {
+ // If service is not a ServiceFactory, an IllegalArgumentException is thrown if service
+ // is not an instanceof all the specified class names.
+ if ((service instanceof ServiceFactory) == false)
+ {
+ try
+ {
+ Class<?> interf = bundle.loadClass(clazz);
+ if (interf.isAssignableFrom(service.getClass()) == false)
+ throw new IllegalArgumentException("Service is not assignable to: " + clazz);
+ }
+ catch (ClassNotFoundException ex)
+ {
+ throw new IllegalArgumentException("Cannot load service interface: " + clazz, ex);
+ }
+ }
+
+ ServiceReferenceImpl serviceRef = new ServiceReferenceImpl(bundle, properties);
+
+ // 2. The Framework adds the following service properties to the service properties from the specified Dictionary (which may be null):
+ // A property named Constants.SERVICE_ID identifying the registration number of the service
+ // A property named Constants.OBJECTCLASS containing all the specified classes.
+
+ // 3. The service is added to the Framework service registry and may now be used by other bundles.
+ registry.put(clazz, serviceRef);
+
+ // 4. A service event of type ServiceEvent.REGISTERED is fired.
+ ServiceEventManager eventManager = sysContext.getServiceEventManager();
+ eventManager.fireServiceEvent(new ServiceEvent(ServiceEvent.REGISTERED, serviceRef));
+
+ // 5. A ServiceRegistration object for this registration is returned.
+ return new ServiceRegistrationImpl(serviceRef);
+ }
+}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/SystemBundleContext.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/SystemBundleContext.java 2009-08-18 13:38:52 UTC (rev 92528)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/SystemBundleContext.java 2009-08-18 13:45:40 UTC (rev 92529)
@@ -24,7 +24,13 @@
//$Id$
import org.jboss.logging.Logger;
-import org.osgi.framework.BundleContext;
+import org.jboss.osgi.jbossmc.api.BundleEventManager;
+import org.jboss.osgi.jbossmc.api.BundleFactory;
+import org.jboss.osgi.jbossmc.api.BundleRegistry;
+import org.jboss.osgi.jbossmc.api.BundleResolver;
+import org.jboss.osgi.jbossmc.api.FrameworkEventManager;
+import org.jboss.osgi.jbossmc.api.ServiceEventManager;
+import org.jboss.osgi.jbossmc.api.ServiceRegistry;
import org.osgi.framework.launch.Framework;
/**
@@ -38,14 +44,65 @@
// Provide logging
final Logger log = Logger.getLogger(SystemBundleContext.class);
+ private BundleRegistry bundleRegistry;
+ private BundleFactory bundleFactory;
+ private BundleResolver bundleResolver;
+ private BundleEventManager bundleEventManager;
+ private FrameworkEventManager frameworkEventManager;
+ private ServiceEventManager serviceEventManager;
+ private ServiceRegistry serviceRegistry;
+
public SystemBundleContext(Framework framework)
{
super(null, framework);
+
+ bundleFactory = new BundleFactoryImpl(this);
+ bundleResolver = new BundleResolverImpl(this);
+ bundleRegistry = new BundleRegistryImpl(this);
+ serviceRegistry = new ServiceRegistryImpl(this);
+ bundleEventManager = new BundleEventManagerImpl(this);
+ frameworkEventManager = new FrameworkEventManagerImpl(this);
+ serviceEventManager = new ServiceEventManagerImpl(this);
}
@Override
- BundleContext getSystemContext()
+ SystemBundleContext getSystemContext()
{
return this;
}
+
+ public BundleFactory getBundleFactory()
+ {
+ return bundleFactory;
+ }
+
+ public BundleRegistry getBundleRegistry()
+ {
+ return bundleRegistry;
+ }
+
+ public BundleResolver getBundleResolver()
+ {
+ return bundleResolver;
+ }
+
+ public ServiceRegistry getServiceRegistry()
+ {
+ return serviceRegistry;
+ }
+
+ public BundleEventManager getBundleEventManager()
+ {
+ return bundleEventManager;
+ }
+
+ public ServiceEventManager getServiceEventManager()
+ {
+ return serviceEventManager;
+ }
+
+ public FrameworkEventManager getFrameworkEventManager()
+ {
+ return frameworkEventManager;
+ }
}
\ No newline at end of file
Added: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/java/org/jboss/test/osgi/jbossmc/simple/BundleInstallTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/java/org/jboss/test/osgi/jbossmc/simple/BundleInstallTestCase.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/java/org/jboss/test/osgi/jbossmc/simple/BundleInstallTestCase.java 2009-08-18 13:45:40 UTC (rev 92529)
@@ -0,0 +1,83 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.jbossmc.simple;
+
+//$Id: SimpleTestCase.java 91196 2009-07-14 09:41:15Z thomas.diesler(a)jboss.com $
+
+import static org.junit.Assert.assertEquals;
+
+import org.jboss.osgi.spi.testing.OSGiTest;
+import org.jboss.osgi.spi.util.ServiceLoader;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.launch.Framework;
+import org.osgi.framework.launch.FrameworkFactory;
+
+/**
+ * A test that deployes a bundle and verifies its state
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 18-Aug-2009
+ */
+public class BundleInstallTestCase extends OSGiTest
+{
+ private static Framework framework;
+
+ @BeforeClass
+ public static void beforeClass() throws BundleException
+ {
+ FrameworkFactory factory = ServiceLoader.loadService(FrameworkFactory.class);
+ framework = factory.newFramework(null);
+ framework.start();
+ }
+
+ @AfterClass
+ public static void afterClass() throws BundleException
+ {
+ framework.stop();
+ }
+
+ @Test
+ public void testFrameworkBundle() throws Exception
+ {
+ assertEquals("BundleId", 0, framework.getBundleId());
+ assertEquals("Location", "System Bundle", framework.getLocation());
+ assertEquals("SymbolicName", "org.jboss.osgi.jbossmc", framework.getSymbolicName());
+ }
+
+ @Test
+ public void testSimpleBundle() throws Exception
+ {
+ BundleContext context = framework.getBundleContext();
+ String location = getTestArchiveURL("simple-bundle.jar").toString();
+ Bundle bundle = context.installBundle(location);
+
+ assertEquals("simple-bundle", bundle.getSymbolicName());
+
+ bundle.start();
+ assertEquals("Bundle active", Bundle.ACTIVE, bundle.getState());
+ }
+}
\ No newline at end of file
Added: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/java/org/jboss/test/osgi/jbossmc/simple/bundle/SimpleActivator.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/java/org/jboss/test/osgi/jbossmc/simple/bundle/SimpleActivator.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/java/org/jboss/test/osgi/jbossmc/simple/bundle/SimpleActivator.java 2009-08-18 13:45:40 UTC (rev 92529)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.jbossmc.simple.bundle;
+
+//$Id: SimpleActivator.java 91196 2009-07-14 09:41:15Z thomas.diesler(a)jboss.com $
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+/**
+ * A Service Activator
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 24-Apr-2009
+ */
+public class SimpleActivator implements BundleActivator
+{
+ public void start(BundleContext context)
+ {
+ // Register a service
+ SimpleService service = new SimpleService(context);
+ context.registerService(SimpleService.class.getName(), service, null);
+ }
+
+ public void stop(BundleContext context)
+ {
+ }
+}
\ No newline at end of file
Added: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/java/org/jboss/test/osgi/jbossmc/simple/bundle/SimpleService.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/java/org/jboss/test/osgi/jbossmc/simple/bundle/SimpleService.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/java/org/jboss/test/osgi/jbossmc/simple/bundle/SimpleService.java 2009-08-18 13:45:40 UTC (rev 92529)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.jbossmc.simple.bundle;
+
+//$Id: SimpleService.java 91196 2009-07-14 09:41:15Z thomas.diesler(a)jboss.com $
+
+import org.osgi.framework.BundleContext;
+import org.osgi.service.log.LogService;
+
+/**
+ * A SimpleService
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 24-Apr-2009
+ */
+public class SimpleService
+{
+ private LogService log;
+
+ public SimpleService(BundleContext context)
+ {
+ }
+
+ public String echo(String msg)
+ {
+ return msg;
+ }
+}
\ No newline at end of file
Added: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/resources/jboss-osgi-jbossmc.properties
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/resources/jboss-osgi-jbossmc.properties (rev 0)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/resources/jboss-osgi-jbossmc.properties 2009-08-18 13:45:40 UTC (rev 92529)
@@ -0,0 +1,22 @@
+#
+# Properties read by the org.jboss.osgi.spi.framework.PropertiesBootstrapProvider
+#
+# $Id: jboss-osgi-felix.properties 92430 2009-08-17 14:53:52Z thomas.diesler(a)jboss.com $
+#
+
+# Properties to configure the Framework
+org.osgi.framework.storage=${basedir}/target/osgi-store
+org.osgi.framework.storage.clean=onFirstInit
+
+# Extra System Packages
+org.osgi.framework.system.packages.extra=
+
+# Bundles that need to be installed with the Framework automatically
+org.jboss.osgi.spi.framework.autoInstall=\
+ file://${test.archive.directory}/bundles/org.osgi.compendium.jar
+
+
+# Bundles that need to be started automatically
+org.jboss.osgi.spi.framework.autoStart=\
+ file://${test.archive.directory}/bundles/org.apache.felix.log.jar \
+ file://${test.archive.directory}/bundles/jboss-osgi-common.jar
Added: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/resources/org.jboss.osgi.spi.framework.OSGiBootstrapProvider
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/resources/org.jboss.osgi.spi.framework.OSGiBootstrapProvider (rev 0)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/resources/org.jboss.osgi.spi.framework.OSGiBootstrapProvider 2009-08-18 13:45:40 UTC (rev 92529)
@@ -0,0 +1 @@
+org.jboss.osgi.spi.framework.PropertiesBootstrapProvider
\ No newline at end of file
Added: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/resources/simple/simple.bnd
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/resources/simple/simple.bnd (rev 0)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/resources/simple/simple.bnd 2009-08-18 13:45:40 UTC (rev 92529)
@@ -0,0 +1,6 @@
+# bnd build -classpath target/test-classes -output target/test-libs/simple-bundle.jar src/test/resources/example/simple/simple.bnd
+
+Bundle-SymbolicName: simple-bundle
+
+Bundle-Activator: org.jboss.test.osgi.jbossmc.simple.bundle.SimpleActivator
+Export-Package: org.jboss.test.osgi.jbossmc.simple.bundle
Added: projects/jboss-osgi/trunk/testsuite/example/src/test/resources/jboss-osgi-jbossmc.properties
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/resources/jboss-osgi-jbossmc.properties (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/resources/jboss-osgi-jbossmc.properties 2009-08-18 13:45:40 UTC (rev 92529)
@@ -0,0 +1,22 @@
+#
+# Properties read by the org.jboss.osgi.spi.framework.PropertiesBootstrapProvider
+#
+# $Id: jboss-osgi-felix.properties 92430 2009-08-17 14:53:52Z thomas.diesler(a)jboss.com $
+#
+
+# Properties to configure the Framework
+org.osgi.framework.storage=${basedir}/target/osgi-store
+org.osgi.framework.storage.clean=onFirstInit
+
+# Extra System Packages
+org.osgi.framework.system.packages.extra=
+
+# Bundles that need to be installed with the Framework automatically
+org.jboss.osgi.spi.framework.autoInstall=\
+ file://${test.archive.directory}/bundles/org.osgi.compendium.jar
+
+
+# Bundles that need to be started automatically
+org.jboss.osgi.spi.framework.autoStart=\
+ file://${test.archive.directory}/bundles/org.apache.felix.log.jar \
+ file://${test.archive.directory}/bundles/jboss-osgi-common.jar
16 years, 11 months
JBoss-OSGI SVN: r92501 - in projects/jboss-osgi/projects: runtime/felix/trunk/src/main/java/org/jboss/osgi/felix and 1 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-08-18 04:51:46 -0400 (Tue, 18 Aug 2009)
New Revision: 92501
Added:
projects/jboss-osgi/projects/runtime/equinox/trunk/src/main/java/org/jboss/osgi/equinox/EquinoxIntegration.java
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/FrameworkIntegration.java
Modified:
projects/jboss-osgi/projects/runtime/felix/trunk/src/main/java/org/jboss/osgi/felix/FelixIntegration.java
Log:
Add EqunioxIntegration
Added: projects/jboss-osgi/projects/runtime/equinox/trunk/src/main/java/org/jboss/osgi/equinox/EquinoxIntegration.java
===================================================================
--- projects/jboss-osgi/projects/runtime/equinox/trunk/src/main/java/org/jboss/osgi/equinox/EquinoxIntegration.java (rev 0)
+++ projects/jboss-osgi/projects/runtime/equinox/trunk/src/main/java/org/jboss/osgi/equinox/EquinoxIntegration.java 2009-08-18 08:51:46 UTC (rev 92501)
@@ -0,0 +1,51 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.equinox;
+
+//$Id: FelixIntegration.java 91762 2009-07-29 12:14:37Z thomas.diesler(a)jboss.com $
+
+import org.jboss.logging.Logger;
+import org.jboss.osgi.spi.framework.FrameworkIntegration;
+import org.jboss.osgi.spi.util.ServiceLoader;
+import org.osgi.framework.launch.FrameworkFactory;
+
+/**
+ * Equinox specific OSGi Framework integration.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 23-Jan-2009
+ */
+public class EquinoxIntegration extends FrameworkIntegration
+{
+ // Provide logging
+ final Logger log = Logger.getLogger(EquinoxIntegration.class);
+
+ public void create()
+ {
+ String implVersion = getClass().getPackage().getImplementationVersion();
+ log.info("OSGi Integration Equinox - " + implVersion);
+
+ // Load the framework instance
+ FrameworkFactory factory = ServiceLoader.loadService(FrameworkFactory.class);
+ framework = factory.newFramework(properties);
+ }
+}
\ No newline at end of file
Modified: projects/jboss-osgi/projects/runtime/felix/trunk/src/main/java/org/jboss/osgi/felix/FelixIntegration.java
===================================================================
--- projects/jboss-osgi/projects/runtime/felix/trunk/src/main/java/org/jboss/osgi/felix/FelixIntegration.java 2009-08-18 08:51:31 UTC (rev 92500)
+++ projects/jboss-osgi/projects/runtime/felix/trunk/src/main/java/org/jboss/osgi/felix/FelixIntegration.java 2009-08-18 08:51:46 UTC (rev 92501)
@@ -23,80 +23,23 @@
//$Id$
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
import org.jboss.logging.Logger;
-import org.jboss.osgi.spi.FrameworkException;
-import org.jboss.osgi.spi.logging.ExportedPackageHelper;
+import org.jboss.osgi.spi.framework.FrameworkIntegration;
import org.jboss.osgi.spi.util.ServiceLoader;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
-import org.osgi.framework.launch.Framework;
import org.osgi.framework.launch.FrameworkFactory;
/**
- * An abstraction of an OSGi Framework
+ * Felix specific OSGi Framework integration.
*
* @author thomas.diesler(a)jboss.com
* @since 23-Jan-2009
*/
-public class FelixIntegration
+public class FelixIntegration extends FrameworkIntegration
{
// Provide logging
final Logger log = Logger.getLogger(FelixIntegration.class);
-
- private Map<String, Object> properties = new HashMap<String, Object>();
- private List<URL> autoInstall = new ArrayList<URL>();
- private List<URL> autoStart = new ArrayList<URL>();
-
- private Framework framework;
-
- public Map<String, Object> getProperties()
- {
- return properties;
- }
-
- public void setProperties(Map<String, Object> props)
- {
- this.properties = props;
- }
-
- public List<URL> getAutoInstall()
- {
- return autoInstall;
- }
-
- public void setAutoInstall(List<URL> autoInstall)
- {
- this.autoInstall = autoInstall;
- }
-
- public List<URL> getAutoStart()
- {
- return autoStart;
- }
-
- public void setAutoStart(List<URL> autoStart)
- {
- this.autoStart = autoStart;
- }
-
- public Bundle getBundle()
- {
- assertFrameworkStart();
- return framework;
- }
-
- public BundleContext getBundleContext()
- {
- return getBundle().getBundleContext();
- }
-
+
public void create()
{
String implVersion = getClass().getPackage().getImplementationVersion();
@@ -114,76 +57,6 @@
framework = factory.newFramework(properties);
}
- public void start()
- {
- // Create the Felix instance
- assertFrameworkCreate();
-
- // Start the System Bundle
- try
- {
- framework.start();
- }
- catch (BundleException ex)
- {
- throw new FrameworkException("Cannot start system bundle", ex);
- }
-
- // Get system bundle context
- BundleContext context = framework.getBundleContext();
- if (context == null)
- throw new FrameworkException("Cannot obtain system context");
-
- // Log the the framework packages
- ExportedPackageHelper packageHelper = new ExportedPackageHelper(context);
- packageHelper.logExportedPackages(getBundle());
-
- Map<URL, Bundle> autoBundles = new HashMap<URL, Bundle>();
-
- // Add the autoStart bundles to autoInstall
- for (URL bundleURL : autoStart)
- {
- autoInstall.add(bundleURL);
- }
-
- // Install autoInstall bundles
- for (URL bundleURL : autoInstall)
- {
- try
- {
- Bundle bundle = context.installBundle(bundleURL.toString());
- long bundleId = bundle.getBundleId();
- log.info("Installed bundle [" + bundleId + "]: " + bundle.getSymbolicName());
- autoBundles.put(bundleURL, bundle);
- }
- catch (BundleException ex)
- {
- stop();
- throw new IllegalStateException("Cannot install bundle: " + bundleURL, ex);
- }
- }
-
- // Start autoStart bundles
- for (URL bundleURL : autoStart)
- {
- try
- {
- Bundle bundle = autoBundles.get(bundleURL);
- if (bundle != null)
- {
- bundle.start();
- packageHelper.logExportedPackages(bundle);
- log.info("Started bundle: " + bundle.getSymbolicName());
- }
- }
- catch (BundleException ex)
- {
- stop();
- throw new IllegalStateException("Cannot start bundle: " + bundleURL, ex);
- }
- }
- }
-
public void stop()
{
if (framework != null)
@@ -237,17 +110,4 @@
thread.interrupt();
}
}
-
- private void assertFrameworkCreate()
- {
- if (framework == null)
- create();
- }
-
- private void assertFrameworkStart()
- {
- assertFrameworkCreate();
- if ((framework.getState() & Bundle.ACTIVE) == 0)
- start();
- }
}
\ No newline at end of file
Copied: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/FrameworkIntegration.java (from rev 92485, projects/jboss-osgi/projects/runtime/felix/trunk/src/main/java/org/jboss/osgi/felix/FelixIntegration.java)
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/FrameworkIntegration.java (rev 0)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/FrameworkIntegration.java 2009-08-18 08:51:46 UTC (rev 92501)
@@ -0,0 +1,211 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.spi.framework;
+
+//$Id$
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.jboss.logging.Logger;
+import org.jboss.osgi.spi.FrameworkException;
+import org.jboss.osgi.spi.logging.ExportedPackageHelper;
+import org.jboss.osgi.spi.util.ServiceLoader;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.launch.Framework;
+import org.osgi.framework.launch.FrameworkFactory;
+
+/**
+ * An abstraction of an OSGi Framework
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 23-Jan-2009
+ */
+public class FrameworkIntegration
+{
+ // Provide logging
+ final Logger log = Logger.getLogger(FrameworkIntegration.class);
+
+ protected Map<String, Object> properties = new HashMap<String, Object>();
+ protected List<URL> autoInstall = new ArrayList<URL>();
+ protected List<URL> autoStart = new ArrayList<URL>();
+
+ protected Framework framework;
+
+ public Map<String, Object> getProperties()
+ {
+ return properties;
+ }
+
+ public void setProperties(Map<String, Object> props)
+ {
+ this.properties = props;
+ }
+
+ public List<URL> getAutoInstall()
+ {
+ return autoInstall;
+ }
+
+ public void setAutoInstall(List<URL> autoInstall)
+ {
+ this.autoInstall = autoInstall;
+ }
+
+ public List<URL> getAutoStart()
+ {
+ return autoStart;
+ }
+
+ public void setAutoStart(List<URL> autoStart)
+ {
+ this.autoStart = autoStart;
+ }
+
+ public Bundle getBundle()
+ {
+ assertFrameworkStart();
+ return framework;
+ }
+
+ public BundleContext getBundleContext()
+ {
+ return getBundle().getBundleContext();
+ }
+
+ public void create()
+ {
+ // Load the framework instance
+ FrameworkFactory factory = ServiceLoader.loadService(FrameworkFactory.class);
+ framework = factory.newFramework(properties);
+ }
+
+ public void start()
+ {
+ // Create the Framework instance
+ assertFrameworkCreate();
+
+ // Start the System Bundle
+ try
+ {
+ framework.start();
+ }
+ catch (BundleException ex)
+ {
+ throw new FrameworkException("Cannot start system bundle", ex);
+ }
+
+ // Get system bundle context
+ BundleContext context = framework.getBundleContext();
+ if (context == null)
+ throw new FrameworkException("Cannot obtain system context");
+
+ // Log the the framework packages
+ ExportedPackageHelper packageHelper = new ExportedPackageHelper(context);
+ packageHelper.logExportedPackages(getBundle());
+
+ Map<URL, Bundle> autoBundles = new HashMap<URL, Bundle>();
+
+ // Add the autoStart bundles to autoInstall
+ for (URL bundleURL : autoStart)
+ {
+ autoInstall.add(bundleURL);
+ }
+
+ // Install autoInstall bundles
+ for (URL bundleURL : autoInstall)
+ {
+ try
+ {
+ Bundle bundle = context.installBundle(bundleURL.toString());
+ long bundleId = bundle.getBundleId();
+ log.info("Installed bundle [" + bundleId + "]: " + bundle.getSymbolicName());
+ autoBundles.put(bundleURL, bundle);
+ }
+ catch (BundleException ex)
+ {
+ stop();
+ throw new IllegalStateException("Cannot install bundle: " + bundleURL, ex);
+ }
+ }
+
+ // Start autoStart bundles
+ for (URL bundleURL : autoStart)
+ {
+ try
+ {
+ Bundle bundle = autoBundles.get(bundleURL);
+ if (bundle != null)
+ {
+ bundle.start();
+ packageHelper.logExportedPackages(bundle);
+ log.info("Started bundle: " + bundle.getSymbolicName());
+ }
+ }
+ catch (BundleException ex)
+ {
+ stop();
+ throw new IllegalStateException("Cannot start bundle: " + bundleURL, ex);
+ }
+ }
+ }
+
+ public void stop()
+ {
+ if (framework != null)
+ {
+ try
+ {
+ framework.stop();
+ framework.waitForStop(5000);
+ framework = null;
+ log.debug("SystemBundle STOPPED");
+ }
+ catch (BundleException ex)
+ {
+ log.error("Cannot stop Framework", ex);
+ }
+ catch (InterruptedException ex)
+ {
+ log.error("Cannot stop Framework", ex);
+ }
+ }
+ }
+
+ private void assertFrameworkCreate()
+ {
+ if (framework == null)
+ create();
+ }
+
+ private void assertFrameworkStart()
+ {
+ assertFrameworkCreate();
+ if ((framework.getState() & Bundle.ACTIVE) == 0)
+ start();
+ }
+}
\ No newline at end of file
16 years, 11 months
JBoss-OSGI SVN: r92482 - in projects/jboss-osgi/trunk/testsuite: functional/src/test/java/org/jboss/test/osgi/framework and 1 other directory.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-08-18 03:35:20 -0400 (Tue, 18 Aug 2009)
New Revision: 92482
Modified:
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/framework/FrameworkTestCase.java
projects/jboss-osgi/trunk/testsuite/pom.xml
Log:
Be explicit about felix osgi core
Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/framework/FrameworkTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/framework/FrameworkTestCase.java 2009-08-18 07:09:09 UTC (rev 92481)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/framework/FrameworkTestCase.java 2009-08-18 07:35:20 UTC (rev 92482)
@@ -48,22 +48,9 @@
@BeforeClass
public static void beforeClass() throws BundleException
{
- try
- {
- OSGiBootstrapProvider bootProvider = OSGiBootstrap.getBootstrapProvider();
- framework = bootProvider.getFramework();
- framework.start();
- }
- catch (BundleException ex)
- {
- Throwable cause = ex;
- while(cause != null)
- {
- System.out.println("cause: " + cause.toString());
- cause = cause.getCause();
- }
- throw ex;
- }
+ OSGiBootstrapProvider bootProvider = OSGiBootstrap.getBootstrapProvider();
+ framework = bootProvider.getFramework();
+ framework.start();
}
@Test
Modified: projects/jboss-osgi/trunk/testsuite/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/testsuite/pom.xml 2009-08-18 07:09:09 UTC (rev 92481)
+++ projects/jboss-osgi/trunk/testsuite/pom.xml 2009-08-18 07:35:20 UTC (rev 92482)
@@ -148,9 +148,16 @@
<groupId>org.jboss.osgi</groupId>
<artifactId>jboss-osgi-runtime-felix</artifactId>
<version>${version.jboss.osgi.runtime.felix}</version>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ <version>${version.apache.felix.core}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
<artifactId>org.osgi.compendium</artifactId>
<version>${version.apache.felix.core}</version>
<scope>provided</scope>
@@ -179,6 +186,12 @@
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ <version>${version.apache.felix.core}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
<artifactId>org.osgi.compendium</artifactId>
<version>${version.apache.felix.core}</version>
<scope>provided</scope>
16 years, 11 months
JBoss-OSGI SVN: r92481 - in projects/jboss-osgi/trunk/hudson/hudson-home: jobs/JBoss-5.2.0 and 1 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-08-18 03:09:09 -0400 (Tue, 18 Aug 2009)
New Revision: 92481
Modified:
projects/jboss-osgi/trunk/hudson/hudson-home/command.sh
projects/jboss-osgi/trunk/hudson/hudson-home/jobs/JBoss-5.2.0/config.xml
projects/jboss-osgi/trunk/hudson/hudson-home/jobs/JBoss-6.0.0/config.xml
Log:
Fix AS60 hudson setup
Modified: projects/jboss-osgi/trunk/hudson/hudson-home/command.sh
===================================================================
--- projects/jboss-osgi/trunk/hudson/hudson-home/command.sh 2009-08-18 07:07:49 UTC (rev 92480)
+++ projects/jboss-osgi/trunk/hudson/hudson-home/command.sh 2009-08-18 07:09:09 UTC (rev 92481)
@@ -43,7 +43,7 @@
;;
'jboss600')
SERVER_NAME=default
- JBOSS_BUILD=jboss-6.0.0.Alpha1
+ JBOSS_BUILD=jboss-6.0.0-SNAPSHOT
JBOSS_ZIP=$HUDSON_HOME/../jboss/$JBOSS_BUILD.zip
RUNTIME_HOME=$WORKSPACE/$JBOSS_BUILD
RUNTIME_LOG=$RUNTIME_HOME/server/$SERVER_NAME/log/server.log
Modified: projects/jboss-osgi/trunk/hudson/hudson-home/jobs/JBoss-5.2.0/config.xml
===================================================================
--- projects/jboss-osgi/trunk/hudson/hudson-home/jobs/JBoss-5.2.0/config.xml 2009-08-18 07:07:49 UTC (rev 92480)
+++ projects/jboss-osgi/trunk/hudson/hudson-home/jobs/JBoss-5.2.0/config.xml 2009-08-18 07:09:09 UTC (rev 92481)
@@ -27,7 +27,7 @@
<jdk>jdk1.5</jdk>
<triggers class="vector">
<hudson.triggers.TimerTrigger>
- <spec>0 0 * * *</spec>
+ <spec>0 18 * * *</spec>
</hudson.triggers.TimerTrigger>
</triggers>
<builders>
Modified: projects/jboss-osgi/trunk/hudson/hudson-home/jobs/JBoss-6.0.0/config.xml
===================================================================
--- projects/jboss-osgi/trunk/hudson/hudson-home/jobs/JBoss-6.0.0/config.xml 2009-08-18 07:07:49 UTC (rev 92480)
+++ projects/jboss-osgi/trunk/hudson/hudson-home/jobs/JBoss-6.0.0/config.xml 2009-08-18 07:09:09 UTC (rev 92481)
@@ -27,7 +27,7 @@
<jdk>jdk1.5</jdk>
<triggers class="vector">
<hudson.triggers.TimerTrigger>
- <spec>0 1 * * *</spec>
+ <spec>0 19 * * *</spec>
</hudson.triggers.TimerTrigger>
</triggers>
<builders>
@@ -37,7 +37,7 @@
HUDSONDIR=$OSGIDIR/hudson
HUDSONBIN=$HUDSONDIR/hudson-home/bin
-JBOSS_VERSION=jboss-6.0.0.Alpha1
+JBOSS_VERSION=jboss-6.0.0-SNAPSHOT
SERVER_NAME=default
JBOSS_HOME=$WORKSPACE/jbossas/build/output/$JBOSS_VERSION
16 years, 11 months
JBoss-OSGI SVN: r92480 - projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-08-18 03:07:49 -0400 (Tue, 18 Aug 2009)
New Revision: 92480
Modified:
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/PropertiesBootstrapProvider.java
Log:
Don't wrap BundleException in RTE
Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/PropertiesBootstrapProvider.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/PropertiesBootstrapProvider.java 2009-08-18 06:55:44 UTC (rev 92479)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/PropertiesBootstrapProvider.java 2009-08-18 07:07:49 UTC (rev 92480)
@@ -97,7 +97,7 @@
{
// Provide logging
final Logger log = Logger.getLogger(PropertiesBootstrapProvider.class);
-
+
/** The default framework property: jboss.osgi.framework.properties */
public static final String OSGI_FRAMEWORK_CONFIG = "jboss.osgi.framework.properties";
/** The default framework config: jboss-osgi-framework.properties */
@@ -140,7 +140,7 @@
public void start() throws BundleException
{
super.start();
-
+
// Get system bundle context
BundleContext context = framework.getBundleContext();
if (context == null)
@@ -149,7 +149,7 @@
// Log the the framework packages
ExportedPackageHelper packageHelper = new ExportedPackageHelper(context);
packageHelper.logExportedPackages(frameworkImpl);
-
+
// Init the the autoInstall URLs
List<URL> autoInstall = getBundleURLs(props, PROP_OSGI_FRAMEWORK_AUTO_INSTALL);
@@ -167,43 +167,26 @@
// Install autoInstall bundles
for (URL bundleURL : autoInstall)
{
- try
- {
- Bundle bundle = context.installBundle(bundleURL.toString());
- long bundleId = bundle.getBundleId();
- log.info("Installed bundle [" + bundleId + "]: " + bundle.getSymbolicName());
- autoBundles.put(bundleURL, bundle);
- }
- catch (BundleException ex)
- {
- //framework.stop();
- throw new IllegalStateException("Cannot install bundle: " + bundleURL, ex);
- }
+ Bundle bundle = context.installBundle(bundleURL.toString());
+ long bundleId = bundle.getBundleId();
+ log.info("Installed bundle [" + bundleId + "]: " + bundle.getSymbolicName());
+ autoBundles.put(bundleURL, bundle);
}
// Start autoStart bundles
for (URL bundleURL : autoStart)
{
- try
+ Bundle bundle = autoBundles.get(bundleURL);
+ if (bundle != null)
{
- Bundle bundle = autoBundles.get(bundleURL);
- if (bundle != null)
- {
- bundle.start();
- packageHelper.logExportedPackages(bundle);
- log.info("Started bundle: " + bundle.getSymbolicName());
- }
+ bundle.start();
+ packageHelper.logExportedPackages(bundle);
+ log.info("Started bundle: " + bundle.getSymbolicName());
}
- catch (BundleException ex)
- {
- //framework.stop();
- throw new IllegalStateException("Cannot start bundle: " + bundleURL, ex);
- }
}
}
};
-
configured = true;
}
@@ -279,18 +262,18 @@
}
Map<String, Object> propMap = new HashMap<String, Object>();
-
+
// Process property list
Enumeration<String> keys = (Enumeration<String>)props.propertyNames();
while (keys.hasMoreElements())
{
String key = keys.nextElement();
String value = props.getProperty(key);
-
+
// Replace property variables
value = StringPropertyReplacer.replaceProperties(value);
propMap.put(key, value);
-
+
if (key.endsWith(".instance"))
{
try
@@ -498,6 +481,6 @@
{
return framework.waitForStop(timeout);
}
-
+
}
}
16 years, 11 months
JBoss-OSGI SVN: r92478 - projects/jboss-osgi/projects/runtime/equinox/trunk.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-08-18 02:55:37 -0400 (Tue, 18 Aug 2009)
New Revision: 92478
Modified:
projects/jboss-osgi/projects/runtime/equinox/trunk/pom.xml
Log:
Add dependency to org.eclipse.osgi.services
Modified: projects/jboss-osgi/projects/runtime/equinox/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/projects/runtime/equinox/trunk/pom.xml 2009-08-18 06:47:07 UTC (rev 92477)
+++ projects/jboss-osgi/projects/runtime/equinox/trunk/pom.xml 2009-08-18 06:55:37 UTC (rev 92478)
@@ -47,13 +47,11 @@
<artifactId>org.eclipse.osgi</artifactId>
<version>${version.eclipse.equinox}</version>
</dependency>
- <!--
<dependency>
<groupId>org.eclipse.equinox</groupId>
<artifactId>org.eclipse.osgi.services</artifactId>
<version>${version.eclipse.equinox}</version>
</dependency>
- -->
</dependencies>
<!-- Build -->
16 years, 11 months