[jboss-cvs] JBossAS SVN: r92839 - in projects/jboss-osgi/projects/runtime/microcontainer/branches/tdiesler/src: main/java/org/jboss/osgi/plugins/facade/launch and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Aug 26 11:27:24 EDT 2009
Author: thomas.diesler at jboss.com
Date: 2009-08-26 11:27:23 -0400 (Wed, 26 Aug 2009)
New Revision: 92839
Modified:
projects/jboss-osgi/projects/runtime/microcontainer/branches/tdiesler/src/main/java/org/jboss/osgi/plugins/facade/bundle/OSGiBundleContextWrapper.java
projects/jboss-osgi/projects/runtime/microcontainer/branches/tdiesler/src/main/java/org/jboss/osgi/plugins/facade/bundle/OSGiBundleManager.java
projects/jboss-osgi/projects/runtime/microcontainer/branches/tdiesler/src/main/java/org/jboss/osgi/plugins/facade/bundle/OSGiBundleState.java
projects/jboss-osgi/projects/runtime/microcontainer/branches/tdiesler/src/main/java/org/jboss/osgi/plugins/facade/bundle/OSGiBundleWrapper.java
projects/jboss-osgi/projects/runtime/microcontainer/branches/tdiesler/src/main/java/org/jboss/osgi/plugins/facade/bundle/OSGiServiceState.java
projects/jboss-osgi/projects/runtime/microcontainer/branches/tdiesler/src/main/java/org/jboss/osgi/plugins/facade/bundle/OSGiSystemBundle.java
projects/jboss-osgi/projects/runtime/microcontainer/branches/tdiesler/src/main/java/org/jboss/osgi/plugins/facade/launch/OSGiFramework.java
projects/jboss-osgi/projects/runtime/microcontainer/branches/tdiesler/src/main/java/org/jboss/osgi/plugins/facade/launch/OSGiFrameworkFactory.java
projects/jboss-osgi/projects/runtime/microcontainer/branches/tdiesler/src/test/java/org/jboss/test/osgi/OSGiTestDelegate.java
Log:
WIP
Modified: projects/jboss-osgi/projects/runtime/microcontainer/branches/tdiesler/src/main/java/org/jboss/osgi/plugins/facade/bundle/OSGiBundleContextWrapper.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/branches/tdiesler/src/main/java/org/jboss/osgi/plugins/facade/bundle/OSGiBundleContextWrapper.java 2009-08-26 15:26:13 UTC (rev 92838)
+++ projects/jboss-osgi/projects/runtime/microcontainer/branches/tdiesler/src/main/java/org/jboss/osgi/plugins/facade/bundle/OSGiBundleContextWrapper.java 2009-08-26 15:27:23 UTC (rev 92839)
@@ -45,7 +45,7 @@
public class OSGiBundleContextWrapper implements BundleContext
{
/** The bundle state */
- private OSGiBundleState bundleState;
+ private AbstractBundleState bundleState;
/**
* Create a new OSGiBundleContextWrapper.
@@ -53,7 +53,7 @@
* @param bundleState the bundle state
* @throws IllegalArgumentException for a null parameter
*/
- public OSGiBundleContextWrapper(OSGiBundleState bundleState)
+ public OSGiBundleContextWrapper(AbstractBundleState bundleState)
{
if (bundleState == null)
throw new IllegalArgumentException("Null bundle state");
Modified: projects/jboss-osgi/projects/runtime/microcontainer/branches/tdiesler/src/main/java/org/jboss/osgi/plugins/facade/bundle/OSGiBundleManager.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/branches/tdiesler/src/main/java/org/jboss/osgi/plugins/facade/bundle/OSGiBundleManager.java 2009-08-26 15:26:13 UTC (rev 92838)
+++ projects/jboss-osgi/projects/runtime/microcontainer/branches/tdiesler/src/main/java/org/jboss/osgi/plugins/facade/bundle/OSGiBundleManager.java 2009-08-26 15:27:23 UTC (rev 92839)
@@ -99,7 +99,7 @@
private static String OSGi_FRAMEWORK_PROCESSOR;
/** The bundles by id */
- private Map<Long, OSGiBundleState> bundlesById = new ConcurrentHashMap<Long, OSGiBundleState>();
+ private Map<Long, AbstractBundleState> bundlesById = new ConcurrentHashMap<Long, AbstractBundleState>();
/** The registered services */
private Set<OSGiServiceState> registeredServices = new ConcurrentSet<OSGiServiceState>();
@@ -272,7 +272,7 @@
public boolean isActive()
{
// We are active if the system bundle is at least in the starting/stopping state
- OSGiBundleState bundleState = getSystemBundle();
+ AbstractBundleState bundleState = getSystemBundle();
return bundleState.getState() >= Bundle.STARTING;
}
@@ -358,7 +358,7 @@
public void uninstall(Bundle bundle) throws BundleException
{
long id = bundle.getBundleId();
- OSGiBundleState state = getBundle(id);
+ OSGiBundleState state = (OSGiBundleState)getBundle(id);
if (state == null)
throw new BundleException(bundle + " not installed");
uninstall(state);
@@ -448,7 +448,7 @@
* @param bundleState the bundle state
* @throws IllegalArgumentException for a null bundle state
*/
- public void addBundle(OSGiBundleState bundleState)
+ public void addBundle(AbstractBundleState bundleState)
{
if (bundleState == null)
throw new IllegalArgumentException("Null bundle state");
@@ -458,7 +458,7 @@
if (metaData.isSingleton())
{
String symbolicName = metaData.getBundleSymbolicName();
- for (OSGiBundleState bundle : getBundles())
+ for (AbstractBundleState bundle : getBundles())
{
OSGiMetaData other = bundle.getOSGiMetaData();
if (other.isSingleton() && symbolicName.equals(other.getBundleSymbolicName()))
@@ -494,7 +494,7 @@
* @param id the id of the bundle
* @return the bundle or null if there is no bundle with that id
*/
- public OSGiBundleState getBundle(long id)
+ public AbstractBundleState getBundle(long id)
{
return bundlesById.get(id);
}
@@ -517,9 +517,13 @@
*/
public DeploymentUnit getDeployment(long id)
{
- OSGiBundleState bundleState = getBundle(id);
+ if (id == 0)
+ throw new IllegalArgumentException("Cannot get deployment unit for system bundle");
+
+ OSGiBundleState bundleState = (OSGiBundleState)getBundle(id);
if (bundleState == null)
return null;
+
return bundleState.getDeploymentUnit();
}
@@ -528,7 +532,7 @@
*
* @return the bundles
*/
- public Collection<OSGiBundleState> getBundles()
+ public Collection<AbstractBundleState> getBundles()
{
return bundlesById.values();
}
@@ -567,12 +571,13 @@
* @param errorOnFail whether to throw an error if it cannot be resolved
* @return true when resolved
*/
- public boolean resolve(OSGiBundleState bundleState, boolean errorOnFail)
+ public boolean resolve(AbstractBundleState bundleState, boolean errorOnFail)
{
try
{
// [TODO] check actually changed state
- deployerClient.change(bundleState.getDeploymentUnit().getName(), DeploymentStages.CLASSLOADER);
+ DeploymentUnit unit = getDeployment(bundleState.getBundleId());
+ deployerClient.change(unit.getName(), DeploymentStages.CLASSLOADER);
return true;
}
catch (DeploymentException e)
@@ -589,11 +594,11 @@
* @param bundleState the bundle state
* @throws BundleException the bundle exception
*/
- public void start(OSGiBundleState bundleState) throws BundleException
+ public void start(AbstractBundleState bundleState) throws BundleException
{
try
{
- String name = bundleState.getDeploymentUnit().getName();
+ String name = getDeployment(bundleState.getBundleId()).getName();
deployerClient.change(name, DeploymentStages.INSTALLED);
deployerClient.checkComplete(name);
}
@@ -612,11 +617,12 @@
* @param bundleState the bundle state
* @throws BundleException the bundle exception
*/
- public void stop(OSGiBundleState bundleState) throws BundleException
+ public void stop(AbstractBundleState bundleState) throws BundleException
{
try
{
- deployerClient.change(bundleState.getDeploymentUnit().getName(), DeploymentStages.CLASSLOADER);
+ DeploymentUnit unit = getDeployment(bundleState.getBundleId());
+ deployerClient.change(unit.getName(), DeploymentStages.CLASSLOADER);
}
catch (DeploymentException e)
{
@@ -636,7 +642,7 @@
* @param checkAssignable whether to check isAssignable
* @return the services
*/
- Collection<OSGiServiceState> getServices(OSGiBundleState bundleState, String clazz, Filter filter, boolean checkAssignable)
+ Collection<OSGiServiceState> getServices(AbstractBundleState bundleState, String clazz, Filter filter, boolean checkAssignable)
{
if (filter == null)
filter = NoFilter.INSTANCE;
@@ -671,7 +677,7 @@
* @param clazz any class
* @return the reference
*/
- ServiceReference getServiceReference(OSGiBundleState bundleState, String clazz)
+ ServiceReference getServiceReference(AbstractBundleState bundleState, String clazz)
{
// Ignore isAssignable for the system context
boolean checkAssignable = (bundleState.getBundleId() != 0);
@@ -693,7 +699,7 @@
* @param checkAssignable whether to check isAssignable
* @return the services
*/
- ServiceReference[] getServiceReferences(OSGiBundleState bundleState, String clazz, Filter filter, boolean checkAssignable)
+ ServiceReference[] getServiceReferences(AbstractBundleState bundleState, String clazz, Filter filter, boolean checkAssignable)
{
Collection<OSGiServiceState> services = getServices(bundleState, clazz, filter, checkAssignable);
if (services == null || services.isEmpty())
@@ -715,7 +721,7 @@
* @return the services
* @throws InvalidSyntaxException when the filter is invalid
*/
- ServiceReference[] getServiceReferences(OSGiBundleState bundleState, String clazz, String filter, boolean checkAssignable) throws InvalidSyntaxException
+ ServiceReference[] getServiceReferences(AbstractBundleState bundleState, String clazz, String filter, boolean checkAssignable) throws InvalidSyntaxException
{
Filter f = NoFilter.INSTANCE;
if (filter != null)
@@ -733,7 +739,7 @@
* @return the service state
*/
@SuppressWarnings("unchecked")
- OSGiServiceState registerService(OSGiBundleState bundleState, String[] clazzes, Object service, Dictionary properties)
+ OSGiServiceState registerService(AbstractBundleState bundleState, String[] clazzes, Object service, Dictionary properties)
{
OSGiServiceState result = new OSGiServiceState(bundleState, clazzes, service, properties);
result.internalRegister();
@@ -763,7 +769,7 @@
* @param reference the service reference
* @return the service
*/
- Object getService(OSGiBundleState bundleState, ServiceReference reference)
+ Object getService(AbstractBundleState bundleState, ServiceReference reference)
{
OSGiServiceReferenceWrapper serviceReference = (OSGiServiceReferenceWrapper) reference;
OSGiServiceState serviceState = serviceReference.getServiceState();
@@ -780,7 +786,7 @@
* @param reference the service reference
* @return true when the service is still in use by the bundle
*/
- boolean ungetService(OSGiBundleState bundleState, ServiceReference reference)
+ boolean ungetService(AbstractBundleState bundleState, ServiceReference reference)
{
if (reference == null)
throw new IllegalArgumentException("Null reference");
@@ -870,12 +876,12 @@
*/
public void stopFramework()
{
- OSGiBundleState systemBundle = getSystemBundle();
+ AbstractBundleState systemBundle = getSystemBundle();
if (systemBundle.getState() != Bundle.ACTIVE)
return;
systemBundle.changeState(Bundle.STOPPING);
- for (OSGiBundleState bundle : getBundles())
+ for (AbstractBundleState bundle : getBundles())
{
if (bundle != systemBundle)
{
@@ -898,11 +904,11 @@
*/
public void restartFramework()
{
- OSGiBundleState systemBundle = getSystemBundle();
+ AbstractBundleState systemBundle = getSystemBundle();
if (systemBundle.getState() != Bundle.ACTIVE)
return;
- for (OSGiBundleState bundle : getBundles())
+ for (AbstractBundleState bundle : getBundles())
{
if (bundle != systemBundle && bundle.getState() == Bundle.ACTIVE)
{
@@ -932,7 +938,7 @@
*
* @param t the throwable
*/
- void fireError(OSGiBundleState bundleState, String context, Throwable t)
+ void fireError(AbstractBundleState bundleState, String context, Throwable t)
{
OSGiSystemBundle systemBundle = getSystemBundle();
if (t instanceof BundleException)
@@ -948,7 +954,7 @@
*
* @param t the throwable
*/
- void fireWarning(OSGiBundleState bundleState, String context, Throwable t)
+ void fireWarning(AbstractBundleState bundleState, String context, Throwable t)
{
OSGiSystemBundle systemBundle = getSystemBundle();
if (t instanceof BundleException)
Modified: projects/jboss-osgi/projects/runtime/microcontainer/branches/tdiesler/src/main/java/org/jboss/osgi/plugins/facade/bundle/OSGiBundleState.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/branches/tdiesler/src/main/java/org/jboss/osgi/plugins/facade/bundle/OSGiBundleState.java 2009-08-26 15:26:13 UTC (rev 92838)
+++ projects/jboss-osgi/projects/runtime/microcontainer/branches/tdiesler/src/main/java/org/jboss/osgi/plugins/facade/bundle/OSGiBundleState.java 2009-08-26 15:27:23 UTC (rev 92839)
@@ -21,26 +21,10 @@
*/
package org.jboss.osgi.plugins.facade.bundle;
-import java.io.File;
import java.io.IOException;
-import java.io.InputStream;
-import java.net.MalformedURLException;
import java.net.URL;
-import java.security.AccessControlContext;
-import java.security.AccessController;
-import java.security.Permission;
-import java.security.cert.X509Certificate;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Dictionary;
import java.util.Enumeration;
-import java.util.HashSet;
-import java.util.List;
import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.CopyOnWriteArrayList;
-import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import org.jboss.beans.info.spi.BeanInfo;
@@ -50,30 +34,13 @@
import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
import org.jboss.kernel.spi.dependency.KernelController;
import org.jboss.logging.Logger;
-import org.jboss.osgi.plugins.facade.api.BundleStoragePlugin;
-import org.jboss.osgi.plugins.filter.NoFilter;
-import org.jboss.osgi.spi.NotImplementedException;
import org.jboss.osgi.spi.metadata.OSGiMetaData;
-import org.jboss.util.collection.ConcurrentSet;
import org.jboss.virtual.VirtualFile;
import org.osgi.framework.AdminPermission;
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.BundleListener;
-import org.osgi.framework.Filter;
-import org.osgi.framework.FrameworkEvent;
-import org.osgi.framework.FrameworkListener;
-import org.osgi.framework.FrameworkUtil;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceEvent;
-import org.osgi.framework.ServiceListener;
-import org.osgi.framework.ServiceReference;
-import org.osgi.framework.ServiceRegistration;
-import org.osgi.framework.SynchronousBundleListener;
-import org.osgi.framework.Version;
/**
* BundleState.
@@ -81,189 +48,43 @@
* @author <a href="adrian at jboss.com">Adrian Brock</a>
* @version $Revision: 1.1 $
*/
-public class OSGiBundleState implements Bundle, BundleContext
+public class OSGiBundleState extends AbstractBundleState
{
/** The log */
private static final Logger log = Logger.getLogger(OSGiBundleState.class);
-
+
/** Used to generate a unique id */
private static final AtomicLong bundleIDGenerator = new AtomicLong();
/** The bundle id */
private long bundleId;
- /** The last modified time stamp */
- private long lastModified = System.currentTimeMillis();
-
- /** The bundle manager */
- private OSGiBundleManager bundleManager;
-
- /** The osgi metadata */
- private OSGiMetaData osgiMetaData;
-
/** The deployment unit */
private DeploymentUnit unit;
- /** The bundle context */
- private BundleContext bundleContext;
-
- /** The bundle */
- private Bundle bundle;
-
- /** The bundle state */
- private AtomicInteger state = new AtomicInteger(Bundle.UNINSTALLED);
-
- /** The registered services in use */
- private Set<OSGiServiceState> registeredServices = new ConcurrentSet<OSGiServiceState>();
-
- /** The services in use */
- private Map<OSGiServiceState, Integer> servicesInUse = new ConcurrentHashMap<OSGiServiceState, Integer>();
-
- /** The bundle listeners */
- private List<BundleListener> bundleListeners = new CopyOnWriteArrayList<BundleListener>();
-
- /** The framework listeners */
- private List<FrameworkListener> frameworkListeners = new CopyOnWriteArrayList<FrameworkListener>();
-
- /** The service listeners */
- private Map<ServiceListener, ServiceListenerRegistration> serviceListeners = new ConcurrentHashMap<ServiceListener, ServiceListenerRegistration>();
-
- /**
- * Create a new BundleState.
- *
- * @param osgiMetaData the osgi metadata
- * @param unit the deployment unit
- * @throws IllegalArgumentException for a null parameter
- */
public OSGiBundleState(OSGiMetaData osgiMetaData, DeploymentUnit unit)
{
- if (osgiMetaData == null)
- throw new IllegalArgumentException("Null osgi metadata");
- if (unit == null)
- throw new IllegalArgumentException("Null deployment unit");
- this.osgiMetaData = osgiMetaData;
+ super(osgiMetaData);
this.unit = unit;
this.bundleId = bundleIDGenerator.incrementAndGet();
unit.getMutableMetaData().addMetaData(unit, DeploymentUnit.class);
changeState(Bundle.INSTALLED);
}
- /**
- * Create a new BundleState for the system bundle.
- *
- * @param osgiMetaData the osgi metadata
- * @throws IllegalArgumentException for a null parameter
- */
- OSGiBundleState(OSGiMetaData osgiMetaData)
+ public long getBundleId()
{
- if (osgiMetaData == null)
- throw new IllegalArgumentException("Null osgi metadata");
- this.osgiMetaData = osgiMetaData;
- this.bundleId = 0;
- changeState(Bundle.INSTALLED);
+ return bundleId;
}
-
+
/**
- * Get the bundleManager.
- *
- * @return the bundleManager.
+ * Get the unit.
+ * @return the unit.
*/
- public OSGiBundleManager getBundleManager()
+ DeploymentUnit getDeploymentUnit()
{
- return bundleManager;
+ return unit;
}
- public long getBundleId()
- {
- return bundleId;
- }
-
- public String getSymbolicName()
- {
- return osgiMetaData.getBundleSymbolicName();
- }
-
- public Version getVersion()
- {
- return osgiMetaData.getBundleVersion();
- }
-
- public int getState()
- {
- return state.get();
- }
-
- public Map<X509Certificate, List<X509Certificate>> getSignerCertificates(int signersType)
- {
- throw new NotImplementedException();
- }
-
- public synchronized BundleContext getBundleContext()
- {
- checkAdminPermission(AdminPermission.CONTEXT);
- return bundleContext;
- }
-
- public synchronized BundleContext createBundleContext()
- {
- if (bundleContext == null)
- bundleContext = new OSGiBundleContextWrapper(this);
- return bundleContext;
- }
-
- public synchronized Bundle getBundle()
- {
- checkValidBundleContext();
- return getBundleInternal();
- }
-
- public synchronized Bundle getBundleInternal()
- {
- if (bundle == null)
- bundle = new OSGiBundleWrapper(this);
- return bundle;
- }
-
- public Bundle getBundle(long id)
- {
- checkValidBundleContext();
- OSGiBundleManager bundleManager = getBundleManager();
- if (bundleManager == null)
- return null;
-
- OSGiBundleState bundleState = bundleManager.getBundle(id);
- if (bundleState == null)
- return null;
- return bundleState.getBundleInternal();
- }
-
- public Bundle[] getBundles()
- {
- checkValidBundleContext();
- OSGiBundleManager bundleManager = getBundleManager();
- if (bundleManager == null)
- return null;
-
- Collection<OSGiBundleState> bundleStates = bundleManager.getBundles();
- if (bundleStates.isEmpty())
- return new Bundle[0];
-
- List<Bundle> bundles = new ArrayList<Bundle>(bundleStates.size());
- for (OSGiBundleState bundleState : bundleStates)
- bundles.add(bundleState.getBundleInternal());
- return bundles.toArray(new Bundle[bundles.size()]);
- }
-
- public long getLastModified()
- {
- return lastModified;
- }
-
- public void modified()
- {
- lastModified = System.currentTimeMillis();
- }
-
public String getLocation()
{
checkAdminPermission(AdminPermission.METADATA);
@@ -282,43 +103,7 @@
return null;
}
-
- /**
- * Get the osgiMetaData.
- *
- * @return the osgiMetaData.
- */
- public OSGiMetaData getOSGiMetaData()
- {
- return osgiMetaData;
- }
-
- @SuppressWarnings("unchecked")
- public Dictionary getHeaders()
- {
- return getHeaders(null);
- }
-
- @SuppressWarnings("unchecked")
- public Dictionary getHeaders(String locale)
- {
- checkAdminPermission(AdminPermission.METADATA);
- return getOSGiMetaData().getHeaders(locale);
- }
-
- public String getProperty(String key)
- {
- checkValidBundleContext();
- return bundleManager.getProperty(key);
- }
-
- public File getDataFile(String filename)
- {
- checkValidBundleContext();
- BundleStoragePlugin storagePlugin = bundleManager.getOptionalPlugin(BundleStoragePlugin.class);
- return storagePlugin != null ? storagePlugin.getDataFile(this, filename) : null;
- }
-
+
public URL getEntry(String path)
{
checkInstalled();
@@ -448,296 +233,7 @@
return getDeploymentUnit().getClassLoader().getResources(name);
}
- public boolean hasPermission(Object permission)
- {
- if (permission == null || permission instanceof Permission == false)
- return false;
-
- SecurityManager sm = System.getSecurityManager();
- if (sm == null)
- return true;
-
- // [TODO] hasPermission
- return true;
- }
-
- public Filter createFilter(String filter) throws InvalidSyntaxException
- {
- checkValidBundleContext();
- return FrameworkUtil.createFilter(filter);
- }
-
- public void addServiceListener(ServiceListener listener)
- {
- addServiceListenerInternal(listener, null);
- }
-
- public void addServiceListener(ServiceListener listener, String filter) throws InvalidSyntaxException
- {
- Filter theFilter = null;
- if (filter != null)
- theFilter = createFilter(filter);
- addServiceListenerInternal(listener, theFilter);
- }
-
- public void addServiceListenerInternal(ServiceListener listener, Filter filter)
- {
- if (listener == null)
- throw new IllegalArgumentException("Null listener");
- if (filter == null)
- filter = NoFilter.INSTANCE;
- checkValidBundleContext();
-
- serviceListeners.put(listener, new ServiceListenerRegistration(filter));
- }
-
- public void removeServiceListener(ServiceListener listener)
- {
- if (listener == null)
- throw new IllegalArgumentException("Null listener");
-
- checkValidBundleContext();
-
- serviceListeners.remove(listener);
- }
-
/**
- * Add a registered service
- *
- * @param serviceState the service
- */
- void addRegisteredService(OSGiServiceState serviceState)
- {
- registeredServices.add(serviceState);
- }
-
- /**
- * Remove a registered service
- *
- * @param serviceState the service
- */
- void removeRegisteredService(OSGiServiceState serviceState)
- {
- registeredServices.remove(serviceState);
- }
-
- public ServiceReference[] getRegisteredServices()
- {
- checkInstalled();
-
- if (registeredServices.isEmpty())
- return null;
-
- Set<ServiceReference> result = new HashSet<ServiceReference>(registeredServices.size());
- for (OSGiServiceState service : registeredServices)
- {
- if (service.hasPermission())
- result.add(service.getReferenceInternal());
- }
- if (result.isEmpty())
- return null;
- return result.toArray(new ServiceReference[result.size()]);
- }
-
- /**
- * Increment the use count of a service for this bundle
- *
- * @param serviceState the service
- */
- void addServiceInUse(OSGiServiceState serviceState)
- {
- synchronized (servicesInUse)
- {
- Integer count = servicesInUse.get(serviceState);
- if (count == null)
- servicesInUse.put(serviceState, 1);
- else
- servicesInUse.put(serviceState, ++count);
- }
- serviceState.addUsingBundle(this);
- }
-
- /**
- * Decrement the use count of a service for this bundle
- *
- * @param serviceState the service
- * @return true when the service is still in use by the bundle
- */
- boolean removeServiceInUse(OSGiServiceState serviceState)
- {
- synchronized (servicesInUse)
- {
- Integer count = servicesInUse.get(serviceState);
- if (count == null)
- {
- return false;
- }
- else if (count == 1)
- {
- servicesInUse.remove(serviceState);
- serviceState.removeUsingBundle(this);
- return false;
- }
- else
- {
- servicesInUse.put(serviceState, --count);
- }
- }
- return true;
- }
-
- public ServiceReference[] getServicesInUse()
- {
- checkInstalled();
-
- synchronized (servicesInUse)
- {
- Collection<OSGiServiceState> inUse = servicesInUse.keySet();
- if (inUse.isEmpty())
- return null;
-
- Set<ServiceReference> result = new HashSet<ServiceReference>(inUse.size());
- for (OSGiServiceState service : inUse)
- {
- if (service.hasPermission())
- result.add(service.getReferenceInternal());
- }
- if (result.isEmpty())
- return null;
- return result.toArray(new ServiceReference[result.size()]);
- }
- }
-
- public ServiceReference[] getAllServiceReferences(String clazz, String filter) throws InvalidSyntaxException
- {
- checkValidBundleContext();
- return getBundleManager().getServiceReferences(this, clazz, filter, false);
- }
-
- public Object getService(ServiceReference reference)
- {
- checkValidBundleContext();
-
- if (reference == null)
- throw new IllegalArgumentException("Null reference");
-
- return getBundleManager().getService(this, reference);
- }
-
- public ServiceReference getServiceReference(String clazz)
- {
- checkValidBundleContext();
- if (clazz == null)
- throw new IllegalArgumentException("Null clazz");
- return getBundleManager().getServiceReference(this, clazz);
- }
-
- public ServiceReference[] getServiceReferences(String clazz, String filter) throws InvalidSyntaxException
- {
- checkValidBundleContext();
- return getBundleManager().getServiceReferences(this, clazz, filter, true);
- }
-
- @SuppressWarnings("unchecked")
- public ServiceRegistration registerService(String clazz, Object service, Dictionary properties)
- {
- if (clazz == null)
- throw new IllegalArgumentException("Null class");
- return registerService(new String[] { clazz }, service, properties);
- }
-
- @SuppressWarnings("unchecked")
- public ServiceRegistration registerService(String[] clazzes, Object service, Dictionary properties)
- {
- checkValidBundleContext();
-
- OSGiServiceState serviceState = getBundleManager().registerService(this, clazzes, service, properties);
- return serviceState.getRegistration();
- }
-
- /**
- * Unregister a service
- *
- * @param serviceState the service state
- */
- void unregisterService(OSGiServiceState serviceState)
- {
- getBundleManager().unregisterService(serviceState);
- }
-
- public boolean ungetService(ServiceReference reference)
- {
- checkValidBundleContext();
-
- return getBundleManager().ungetService(this, reference);
- }
-
- boolean ungetService(OSGiServiceState state)
- {
- return getBundleManager().ungetService(this, state);
- }
-
- public void addBundleListener(BundleListener listener)
- {
- if (listener == null)
- throw new IllegalArgumentException("Null listener");
-
- checkValidBundleContext();
-
- if (listener instanceof SynchronousBundleListener)
- checkAdminPermission(AdminPermission.LISTENER);
-
- if (bundleListeners.contains(listener))
- return;
-
- bundleListeners.add(listener);
- }
-
- public void removeBundleListener(BundleListener listener)
- {
- if (listener == null)
- throw new IllegalArgumentException("Null listener");
-
- checkValidBundleContext();
-
- if (listener instanceof SynchronousBundleListener)
- checkAdminPermission(AdminPermission.LISTENER);
-
- bundleListeners.remove(listener);
- }
-
- /**
- * Try to resolve the bundle
- *
- * @param errorOnFail whether to throw an error when not installed
- * @return true when resolved
- */
- boolean resolve(boolean errorOnFail)
- {
- if (getState() != INSTALLED)
- return true;
-
- return getBundleManager().resolve(this, errorOnFail);
- }
-
- public void start() throws BundleException
- {
- start(0);
- }
-
- // [TODO] options
- public void start(int options) throws BundleException
- {
- checkInstalled();
- checkAdminPermission(AdminPermission.EXECUTE);
-
- if (getState() == ACTIVE)
- return;
-
- getBundleManager().start(this);
- }
-
- /**
* Start internal
*
* [TODO] Start Level Service & START_TRANSIENT? [TODO] START_ACTIVATION_POLICY [TODO] LAZY_ACTIVATION [TODO] locks [TODO] options
@@ -747,7 +243,7 @@
public void startInternal() throws Throwable
{
changeState(STARTING);
- bundleContext = createBundleContext();
+ createBundleContext();
try
{
OSGiMetaData metaData = getOSGiMetaData();
@@ -772,12 +268,12 @@
BundleActivator bundleActivator = (BundleActivator)result;
getDeploymentUnit().addAttachment(BundleActivator.class, bundleActivator);
- bundleActivator.start(bundleContext);
+ bundleActivator.start(getBundleContext());
}
}
if (getState() != STARTING)
- throw new BundleException("Bundle has been uninstalled: " + bundle);
+ throw new BundleException("Bundle has been uninstalled: " + this);
changeState(ACTIVE);
}
@@ -785,29 +281,12 @@
{
changeState(STOPPING);
// TODO stop the bundle
- this.bundleContext = null;
+ destroyBundleContext();
changeState(RESOLVED);
throw t;
}
}
- public void stop() throws BundleException
- {
- stop(0);
- }
-
- // [TODO] options
- public void stop(int options) throws BundleException
- {
- checkInstalled();
- checkAdminPermission(AdminPermission.EXECUTE);
-
- if (getState() != ACTIVE)
- return;
-
- getBundleManager().stop(this);
- }
-
/**
* Stop Internal
*
@@ -823,7 +302,7 @@
try
{
BundleActivator bundleActivator = getDeploymentUnit().getAttachment(BundleActivator.class);
- BundleContext bundleContext = this.bundleContext;
+ BundleContext bundleContext = getBundleContext();
if (bundleActivator != null && bundleContext != null)
{
try
@@ -872,459 +351,11 @@
{
if (getState() == STOPPING)
changeState(RESOLVED);
- bundleContext = null;
+ destroyBundleContext();
getDeploymentUnit().removeAttachment(BundleActivator.class);
}
if (rethrow != null)
throw rethrow;
}
-
- public void update() throws BundleException
- {
- checkAdminPermission(AdminPermission.LIFECYCLE); // [TODO] extension bundles
- // [TODO] update
- throw new UnsupportedOperationException("update");
- }
-
- public void update(InputStream in) throws BundleException
- {
- checkAdminPermission(AdminPermission.LIFECYCLE); // [TODO] extension bundles
- // [TODO] update
- throw new UnsupportedOperationException("update");
- }
-
- public void uninstall() throws BundleException
- {
- checkAdminPermission(AdminPermission.LIFECYCLE); // [TODO] extension bundles
-
- OSGiBundleManager bundleManager = getBundleManager();
- if (bundleManager == null)
- return;
-
- bundleManager.uninstall(this);
- }
-
- void uninstallInternal()
- {
- changeState(Bundle.UNINSTALLED);
-
- frameworkListeners.clear();
- bundleListeners.clear();
- serviceListeners.clear();
- }
-
- public void addFrameworkListener(FrameworkListener listener)
- {
- if (listener == null)
- throw new IllegalArgumentException("Null listener");
-
- checkValidBundleContext();
-
- if (frameworkListeners.contains(listener))
- return;
-
- frameworkListeners.add(listener);
- }
-
- public void removeFrameworkListener(FrameworkListener listener)
- {
- if (listener == null)
- throw new IllegalArgumentException("Null listener");
-
- checkValidBundleContext();
-
- frameworkListeners.remove(listener);
- }
-
- public Bundle installBundle(String location, InputStream input) throws BundleException
- {
- checkValidBundleContext();
- checkAdminPermission(AdminPermission.LIFECYCLE); // [TODO] extension bundles
- // [TODO] installBundle
- throw new UnsupportedOperationException("installBundle");
- }
-
- public Bundle installBundle(String location) throws BundleException
- {
- checkValidBundleContext();
- checkAdminPermission(AdminPermission.LIFECYCLE); // [TODO] extension bundles
-
- OSGiBundleManager bundleManager = getBundleManager();
- if (bundleManager == null)
- throw new IllegalStateException("Bundle " + getCanonicalName() + " is not valid");
-
- URL url = getLocationURL(location);
- OSGiBundleState bundleState = bundleManager.install(url);
- return bundleState.getBundleInternal();
- }
-
- private URL getLocationURL(String location) throws BundleException
- {
- // Try location as URL
- URL url = null;
- try
- {
- url = new URL(location);
- }
- catch (MalformedURLException e)
- {
- // ignore
- }
-
- // Try location as File
- if (url == null)
- {
- try
- {
- File file = new File(location);
- if (file.exists())
- url = file.toURL();
- }
- catch (MalformedURLException e)
- {
- // ignore
- }
- }
-
- if (url == null)
- throw new BundleException("Unable to handle location=" + location);
-
- return url;
- }
-
- @Override
- public String toString()
- {
- return "Bundle{" + getCanonicalName() + "}";
- }
-
- /**
- * Get the canonical name of the bundle
- *
- * @return the canonical name
- */
- String getCanonicalName()
- {
- return getSymbolicName() + ":" + osgiMetaData.getBundleVersion();
- }
-
- /**
- * Set the bundle manager
- *
- * @param bundleManager the bundle manager or null to uninstall the bundle
- */
- void setBundleManager(OSGiBundleManager bundleManager)
- {
- if (bundleManager != null && this.bundleManager != null)
- throw new IllegalStateException("Bundle " + this + " is already installed");
- this.bundleManager = bundleManager;
- if (bundleManager == null)
- changeState(Bundle.UNINSTALLED);
- }
-
- /**
- * Get the unit.
- *
- * @return the unit.
- */
- DeploymentUnit getDeploymentUnit()
- {
- return unit;
- }
-
- /**
- * Get the source of a class for ServiceReference.isAssignable()
- *
- * @param className the class name
- * @return the source or null if no source
- */
- Object getSource(String className)
- {
- // [TODO] some more efficient way than using the class?
- try
- {
- return loadClass(className);
- }
- catch (ClassNotFoundException e)
- {
- return null;
- }
- }
-
- /**
- * Change the state of the bundle
- *
- * @param state the new state
- */
- public void changeState(int state)
- {
- int previous = getState();
- int type = 0;
- switch (state)
- {
- case Bundle.STARTING:
- type = BundleEvent.STARTING;
- break;
- case Bundle.ACTIVE:
- type = BundleEvent.STARTED;
- break;
- case Bundle.STOPPING:
- type = BundleEvent.STOPPING;
- break;
- case Bundle.UNINSTALLED:
- type = BundleEvent.UNINSTALLED;
- break;
- case Bundle.INSTALLED:
- {
- if (previous == Bundle.RESOLVED)
- type = BundleEvent.UNRESOLVED;
- else
- type = BundleEvent.INSTALLED;
- break;
- }
- case Bundle.RESOLVED:
- {
- if (previous == Bundle.STOPPING)
- type = BundleEvent.STOPPED;
- else
- type = BundleEvent.RESOLVED;
- break;
- }
- default:
- throw new IllegalArgumentException("Unknown bundle state: " + state);
- }
- this.state.set(state);
- log.debug(this + " change state=" + toHumanReadableStateString(state));
- BundleEvent event = new BundleEvent(type, getBundleInternal());
- fireBundleEvent(event);
- }
-
- /**
- * Fire a bundle event
- *
- * @param event the event
- */
- void fireBundleEvent(BundleEvent event)
- {
- // Nobody is interested
- if (bundleListeners.isEmpty())
- return;
-
- // Are we active?
- if (getBundleManager().isActive() == false)
- return;
-
- // Synchronous listeners first
- for (BundleListener listener : bundleListeners)
- {
- try
- {
- if (listener instanceof SynchronousBundleListener)
- listener.bundleChanged(event);
- }
- catch (Throwable t)
- {
- log.warn("Error while firing bundle event: " + event.getType() + " for bundle " + getCanonicalName(), t);
- }
- }
- // Normal listeners after, if required
- int type = event.getType();
- if (type != BundleEvent.STARTING && type != BundleEvent.STOPPING && type != BundleEvent.LAZY_ACTIVATION)
- {
- for (BundleListener listener : bundleListeners)
- {
- try
- {
- if (listener instanceof SynchronousBundleListener == false)
- listener.bundleChanged(event);
- }
- catch (Throwable t)
- {
- log.warn("Error while firing bundle event: " + event.getType() + " for bundle " + this, t);
- }
- }
- }
- }
-
- /**
- * Fire a framework event
- *
- * @param type the type of event
- * @param throwable any throwable
- */
- void fireFrameworkEvent(int type, Throwable throwable)
- {
- // Nobody is interested
- if (frameworkListeners.isEmpty())
- return;
-
- // Are we active?
- if (getBundleManager().isActive() == false)
- return;
-
- // Call the listeners
- FrameworkEvent event = new FrameworkEvent(type, getBundleInternal(), throwable);
- for (FrameworkListener listener : frameworkListeners)
- {
- try
- {
- listener.frameworkEvent(event);
- }
- catch (Throwable t)
- {
- log.warn("Error while firing framework event: " + event.getType() + " for bundle " + getCanonicalName(), t);
- }
- }
- }
-
- /**
- * Fire a service event
- *
- * @param type the type
- * @param service the service
- */
- void fireServiceEvent(int type, OSGiServiceState service)
- {
- if (service == null)
- throw new IllegalArgumentException("No serviceReference");
-
- // Nobody is interested
- if (serviceListeners.isEmpty())
- return;
-
- // Are we active?
- if (getBundleManager().isActive() == false)
- return;
-
- ServiceEvent event = new ServiceEvent(type, service.getReferenceInternal());
-
- // Call the listeners
- for (Map.Entry<ServiceListener, ServiceListenerRegistration> entry : serviceListeners.entrySet())
- {
- ServiceListener listener = entry.getKey();
- ServiceListenerRegistration registration = entry.getValue();
- try
- {
- if (registration.filter.match(service))
- {
- AccessControlContext accessControlContext = registration.accessControlContext;
- if (accessControlContext == null || service.hasPermission(accessControlContext))
- listener.serviceChanged(event);
- }
- }
- catch (Throwable t)
- {
- log.warn("Error while firing service event: " + type + " for service " + service, t);
- }
- }
- }
-
- /**
- * Check the bundle is installed
- *
- * @throws IllegalStateException when the bundle is not installed
- */
- protected void checkInstalled()
- {
- if ((getState() & Bundle.UNINSTALLED) != 0)
- throw new IllegalStateException("Bundle " + getCanonicalName() + " is not installed");
- }
-
- /**
- * Check a bundle context is still valid
- *
- * @return the bundle context
- * @throws IllegalArgumentException when the context is no longer valid
- */
- protected synchronized BundleContext checkValidBundleContext()
- {
- BundleContext result = this.bundleContext;
- if (result == null)
- throw new IllegalStateException("Bundle context is no longer valid");
- return result;
- }
-
- /**
- * Check the admin permission
- *
- * @param what what permission to check
- * @throws SecurityException when the caller does not have the AdminPermission and a security manager is installed
- */
- protected void checkAdminPermission(String what)
- {
- SecurityManager sm = System.getSecurityManager();
- if (sm != null)
- sm.checkPermission(new AdminPermission(this, what));
- }
-
- /**
- * Checks if we have the admin permission
- *
- * @param what the permission to check
- * @return true if the caller doesn't have the permission
- */
- private boolean noAdminPermission(String what)
- {
- try
- {
- checkAdminPermission(what);
- return false;
- }
- catch (SecurityException e)
- {
- return true;
- }
- }
-
- /**
- * Get a human readable version of the state
- *
- * @param state the state
- * @return the human readable form
- */
- private static String toHumanReadableStateString(int state)
- {
- switch (state)
- {
- case Bundle.INSTALLED:
- return "INSTALLED";
- case Bundle.RESOLVED:
- return "RESOLVED";
- case Bundle.STARTING:
- return "STARTING";
- case Bundle.ACTIVE:
- return "ACTIVE";
- case Bundle.STOPPING:
- return "STOPPING";
- case Bundle.UNINSTALLED:
- return "UNINSTALLED";
- }
- return "???" + state;
- }
-
- /**
- * ServiceListenerRegistration.
- */
- private static class ServiceListenerRegistration
- {
- // Any filter
- Filter filter;
-
- // Any access control context
- AccessControlContext accessControlContext;
-
- /**
- * Create a new ServiceListenerRegistration.
- *
- * @param filter the filter
- */
- public ServiceListenerRegistration(Filter filter)
- {
- this.filter = filter;
-
- if (System.getSecurityManager() != null)
- accessControlContext = AccessController.getContext();
- }
- }
}
Modified: projects/jboss-osgi/projects/runtime/microcontainer/branches/tdiesler/src/main/java/org/jboss/osgi/plugins/facade/bundle/OSGiBundleWrapper.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/branches/tdiesler/src/main/java/org/jboss/osgi/plugins/facade/bundle/OSGiBundleWrapper.java 2009-08-26 15:26:13 UTC (rev 92838)
+++ projects/jboss-osgi/projects/runtime/microcontainer/branches/tdiesler/src/main/java/org/jboss/osgi/plugins/facade/bundle/OSGiBundleWrapper.java 2009-08-26 15:27:23 UTC (rev 92839)
@@ -45,7 +45,7 @@
public class OSGiBundleWrapper implements Bundle
{
/** The bundle state */
- private OSGiBundleState bundleState;
+ private AbstractBundleState bundleState;
/**
* Create a new OSGiBundleImpl.
@@ -53,7 +53,7 @@
* @param bundleState the bundle state
* @throws IllegalArgumentException for a null parameter
*/
- public OSGiBundleWrapper(OSGiBundleState bundleState)
+ public OSGiBundleWrapper(AbstractBundleState bundleState)
{
if (bundleState == null)
throw new IllegalArgumentException("Null bundle state");
@@ -65,7 +65,7 @@
*
* @return the bundle state
*/
- OSGiBundleState getBundleState()
+ AbstractBundleState getBundleState()
{
return bundleState;
}
Modified: projects/jboss-osgi/projects/runtime/microcontainer/branches/tdiesler/src/main/java/org/jboss/osgi/plugins/facade/bundle/OSGiServiceState.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/branches/tdiesler/src/main/java/org/jboss/osgi/plugins/facade/bundle/OSGiServiceState.java 2009-08-26 15:26:13 UTC (rev 92838)
+++ projects/jboss-osgi/projects/runtime/microcontainer/branches/tdiesler/src/main/java/org/jboss/osgi/plugins/facade/bundle/OSGiServiceState.java 2009-08-26 15:27:23 UTC (rev 92839)
@@ -58,7 +58,7 @@
private static final AtomicLong serviceIDGenerator = new AtomicLong();
/** The bundle state */
- private OSGiBundleState bundleState;
+ private AbstractBundleState bundleState;
/** The service reference */
private OSGiServiceReferenceWrapper serviceReference;
@@ -82,7 +82,7 @@
private CaseInsensitiveDictionary properties;
/** The using bundles */
- private Set<OSGiBundleState> usingBundles = new ConcurrentSet<OSGiBundleState>();
+ private Set<AbstractBundleState> usingBundles = new ConcurrentSet<AbstractBundleState>();
/**
* Create a new OSGiServiceState.
@@ -94,7 +94,7 @@
* @throws IllegalArgumentException for a null parameter
*/
@SuppressWarnings("unchecked")
- public OSGiServiceState(OSGiBundleState bundleState, String[] clazzes, Object service, Dictionary properties)
+ public OSGiServiceState(AbstractBundleState bundleState, String[] clazzes, Object service, Dictionary properties)
{
if (bundleState == null)
throw new IllegalArgumentException("Null bundle state");
@@ -226,7 +226,7 @@
*
* @return the bundleState.
*/
- public OSGiBundleState getBundleState()
+ public AbstractBundleState getBundleState()
{
return bundleState;
}
@@ -275,7 +275,7 @@
*
* @param bundleState the bundle
*/
- void addUsingBundle(OSGiBundleState bundleState)
+ void addUsingBundle(AbstractBundleState bundleState)
{
usingBundles.add(bundleState);
}
@@ -285,7 +285,7 @@
*
* @param bundleState the bundle
*/
- void removeUsingBundle(OSGiBundleState bundleState)
+ void removeUsingBundle(AbstractBundleState bundleState)
{
usingBundles.remove(bundleState);
}
@@ -296,7 +296,7 @@
return null;
Set<Bundle> result = new HashSet<Bundle>();
- for (OSGiBundleState bundleState : usingBundles)
+ for (AbstractBundleState bundleState : usingBundles)
result.add(bundleState.getBundleInternal());
return result.toArray(new Bundle[result.size()]);
}
@@ -311,7 +311,7 @@
throw new IllegalArgumentException("Unknown bundle: " + bundle);
OSGiBundleWrapper wrapper = (OSGiBundleWrapper) bundle;
- OSGiBundleState other = wrapper.getBundleState();
+ AbstractBundleState other = wrapper.getBundleState();
return isAssignableTo(other, className);
}
@@ -360,7 +360,7 @@
* @param other the bundle state
* @return true when assignable
*/
- boolean isAssignable(OSGiBundleState other)
+ boolean isAssignable(AbstractBundleState other)
{
if (other == bundleState)
return true;
@@ -382,7 +382,7 @@
* @param className the class name
* @return true when the class name matches
*/
- boolean matchClass(OSGiBundleState other, String className)
+ boolean matchClass(AbstractBundleState other, String className)
{
if (clazzes == null || clazzes.length == 0)
return false;
@@ -511,7 +511,7 @@
{
if (usingBundles.isEmpty() == false)
{
- for (OSGiBundleState using : usingBundles)
+ for (AbstractBundleState using : usingBundles)
using.ungetService(this);
}
Modified: projects/jboss-osgi/projects/runtime/microcontainer/branches/tdiesler/src/main/java/org/jboss/osgi/plugins/facade/bundle/OSGiSystemBundle.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/branches/tdiesler/src/main/java/org/jboss/osgi/plugins/facade/bundle/OSGiSystemBundle.java 2009-08-26 15:26:13 UTC (rev 92838)
+++ projects/jboss-osgi/projects/runtime/microcontainer/branches/tdiesler/src/main/java/org/jboss/osgi/plugins/facade/bundle/OSGiSystemBundle.java 2009-08-26 15:27:23 UTC (rev 92839)
@@ -21,11 +21,14 @@
*/
package org.jboss.osgi.plugins.facade.bundle;
+import java.io.IOException;
import java.io.InputStream;
+import java.net.URL;
+import java.util.Enumeration;
import org.jboss.osgi.spi.NotImplementedException;
import org.jboss.osgi.spi.metadata.OSGiMetaData;
-import org.osgi.framework.AdminPermission;
+import org.osgi.framework.Bundle;
import org.osgi.framework.BundleException;
import org.osgi.framework.Constants;
@@ -35,7 +38,7 @@
* @author <a href="adrian at jboss.com">Adrian Brock</a>
* @version $Revision: 1.1 $
*/
-class OSGiSystemBundle extends OSGiBundleState
+public class OSGiSystemBundle extends AbstractBundleState
{
/**
* Create a new OSGiSystemBundle.
@@ -45,20 +48,20 @@
public OSGiSystemBundle(OSGiMetaData osgiMetaData)
{
super(osgiMetaData);
+ changeState(Bundle.INSTALLED);
}
+ public long getBundleId()
+ {
+ return 0;
+ }
+
@Override
public String getLocation()
{
return Constants.SYSTEM_BUNDLE_LOCATION;
}
- public Class<?> loadClass(String name) throws ClassNotFoundException
- {
- // [JBOSGI-138] Proper system BundleContext implementation
- throw new NotImplementedException();
- }
-
@Override
public void stop(int options) throws BundleException
{
@@ -96,4 +99,48 @@
{
throw new BundleException("The system bundle cannot be uninstalled");
}
+
+ public Class<?> loadClass(String name) throws ClassNotFoundException
+ {
+ // [JBOSGI-138] Proper system BundleContext implementation
+ throw new NotImplementedException();
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public Enumeration findEntries(String path, String filePattern, boolean recurse)
+ {
+ // [JBOSGI-138] Proper system BundleContext implementation
+ throw new NotImplementedException();
+ }
+
+ @Override
+ public URL getEntry(String path)
+ {
+ // [JBOSGI-138] Proper system BundleContext implementation
+ throw new NotImplementedException();
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public Enumeration getEntryPaths(String path)
+ {
+ // [JBOSGI-138] Proper system BundleContext implementation
+ throw new NotImplementedException();
+ }
+
+ @Override
+ public URL getResource(String name)
+ {
+ // [JBOSGI-138] Proper system BundleContext implementation
+ throw new NotImplementedException();
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public Enumeration getResources(String name) throws IOException
+ {
+ // [JBOSGI-138] Proper system BundleContext implementation
+ throw new NotImplementedException();
+ }
}
Modified: projects/jboss-osgi/projects/runtime/microcontainer/branches/tdiesler/src/main/java/org/jboss/osgi/plugins/facade/launch/OSGiFramework.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/branches/tdiesler/src/main/java/org/jboss/osgi/plugins/facade/launch/OSGiFramework.java 2009-08-26 15:26:13 UTC (rev 92838)
+++ projects/jboss-osgi/projects/runtime/microcontainer/branches/tdiesler/src/main/java/org/jboss/osgi/plugins/facade/launch/OSGiFramework.java 2009-08-26 15:27:23 UTC (rev 92839)
@@ -28,8 +28,8 @@
import org.jboss.logging.Logger;
import org.jboss.osgi.plugins.facade.bundle.OSGiBundleManager;
-import org.jboss.osgi.plugins.facade.bundle.OSGiBundleState;
import org.jboss.osgi.plugins.facade.bundle.OSGiBundleWrapper;
+import org.jboss.osgi.plugins.facade.bundle.OSGiSystemBundle;
import org.osgi.framework.BundleException;
import org.osgi.framework.FrameworkEvent;
import org.osgi.framework.launch.Framework;
@@ -47,7 +47,7 @@
private OSGiBundleManager bundleManager;
- public OSGiFramework(OSGiBundleManager bundleManager, OSGiBundleState bundleState)
+ public OSGiFramework(OSGiBundleManager bundleManager, OSGiSystemBundle bundleState)
{
super(bundleState);
this.bundleManager = bundleManager;
Modified: projects/jboss-osgi/projects/runtime/microcontainer/branches/tdiesler/src/main/java/org/jboss/osgi/plugins/facade/launch/OSGiFrameworkFactory.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/branches/tdiesler/src/main/java/org/jboss/osgi/plugins/facade/launch/OSGiFrameworkFactory.java 2009-08-26 15:26:13 UTC (rev 92838)
+++ projects/jboss-osgi/projects/runtime/microcontainer/branches/tdiesler/src/main/java/org/jboss/osgi/plugins/facade/launch/OSGiFrameworkFactory.java 2009-08-26 15:27:23 UTC (rev 92839)
@@ -35,7 +35,7 @@
import org.jboss.kernel.plugins.deployment.xml.BasicXMLDeployer;
import org.jboss.logging.Logger;
import org.jboss.osgi.plugins.facade.bundle.OSGiBundleManager;
-import org.jboss.osgi.plugins.facade.bundle.OSGiBundleState;
+import org.jboss.osgi.plugins.facade.bundle.OSGiSystemBundle;
import org.osgi.framework.launch.Framework;
import org.osgi.framework.launch.FrameworkFactory;
@@ -86,7 +86,7 @@
throw new IllegalStateException("Cannot obtain installed bean: " + OSGiBundleManager.BEAN_BUNDLE_MANAGER);
OSGiBundleManager manager = (OSGiBundleManager)managerContext.getTarget();
- OSGiBundleState sysBundle = manager.getBundle(0);
+ OSGiSystemBundle sysBundle = (OSGiSystemBundle)manager.getBundle(0);
return new OSGiFramework(manager, sysBundle);
}
Modified: projects/jboss-osgi/projects/runtime/microcontainer/branches/tdiesler/src/test/java/org/jboss/test/osgi/OSGiTestDelegate.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/branches/tdiesler/src/test/java/org/jboss/test/osgi/OSGiTestDelegate.java 2009-08-26 15:26:13 UTC (rev 92838)
+++ projects/jboss-osgi/projects/runtime/microcontainer/branches/tdiesler/src/test/java/org/jboss/test/osgi/OSGiTestDelegate.java 2009-08-26 15:27:23 UTC (rev 92839)
@@ -32,6 +32,7 @@
import org.jboss.dependency.spi.ControllerState;
import org.jboss.deployers.plugins.main.MainDeployerImpl;
import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.osgi.plugins.facade.bundle.AbstractBundleState;
import org.jboss.osgi.plugins.facade.bundle.OSGiBundleManager;
import org.jboss.osgi.plugins.facade.bundle.OSGiBundleState;
import org.jboss.test.kernel.junit.MicrocontainerTestDelegate;
@@ -125,8 +126,8 @@
protected void undeployBundles()
{
OSGiBundleManager bundleManager = getBundleManager();
- Collection<OSGiBundleState> bundles = bundleManager.getBundles();
- for (OSGiBundleState bundleState : bundles)
+ Collection<AbstractBundleState> bundles = bundleManager.getBundles();
+ for (AbstractBundleState bundleState : bundles)
{
try
{
More information about the jboss-cvs-commits
mailing list