[jboss-osgi-commits] JBoss-OSGI SVN: r100969 - in projects/jboss-osgi/projects/runtime/framework/branches/alesj_service-mix: src/etc/osgitck and 5 other directories.
jboss-osgi-commits at lists.jboss.org
jboss-osgi-commits at lists.jboss.org
Mon Feb 15 09:54:13 EST 2010
Author: alesj
Date: 2010-02-15 09:54:11 -0500 (Mon, 15 Feb 2010)
New Revision: 100969
Added:
projects/jboss-osgi/projects/runtime/framework/branches/alesj_service-mix/src/main/java/org/jboss/osgi/framework/bundle/MetaDataRetrievalService.java
Removed:
projects/jboss-osgi/projects/runtime/framework/branches/alesj_service-mix/src/main/java/org/jboss/osgi/framework/plugins/StartLevelPlugin.java
Modified:
projects/jboss-osgi/projects/runtime/framework/branches/alesj_service-mix/pom.xml
projects/jboss-osgi/projects/runtime/framework/branches/alesj_service-mix/src/etc/osgitck/jboss-osgi-bootstrap.xml
projects/jboss-osgi/projects/runtime/framework/branches/alesj_service-mix/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java
projects/jboss-osgi/projects/runtime/framework/branches/alesj_service-mix/src/main/java/org/jboss/osgi/framework/bundle/ServiceManagerPluginImpl.java
projects/jboss-osgi/projects/runtime/framework/branches/alesj_service-mix/src/main/java/org/jboss/osgi/framework/plugins/PackageAdminPlugin.java
projects/jboss-osgi/projects/runtime/framework/branches/alesj_service-mix/src/main/java/org/jboss/osgi/framework/service/internal/LifecycleInterceptorServiceImpl.java
projects/jboss-osgi/projects/runtime/framework/branches/alesj_service-mix/src/main/java/org/jboss/osgi/framework/service/internal/MicrocontainerServiceImpl.java
projects/jboss-osgi/projects/runtime/framework/branches/alesj_service-mix/src/main/java/org/jboss/osgi/framework/service/internal/PackageAdminImpl.java
projects/jboss-osgi/projects/runtime/framework/branches/alesj_service-mix/src/main/java/org/jboss/osgi/framework/service/internal/StartLevelImpl.java
projects/jboss-osgi/projects/runtime/framework/branches/alesj_service-mix/src/test/java/org/jboss/test/osgi/fragments/subA/SubBeanA.java
projects/jboss-osgi/projects/runtime/framework/branches/alesj_service-mix/src/test/resources/bootstrap/jboss-osgi-bootstrap.xml
Log:
Fix MDR usage. Remove duplicate service registry.
Modified: projects/jboss-osgi/projects/runtime/framework/branches/alesj_service-mix/pom.xml
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/branches/alesj_service-mix/pom.xml 2010-02-15 14:20:10 UTC (rev 100968)
+++ projects/jboss-osgi/projects/runtime/framework/branches/alesj_service-mix/pom.xml 2010-02-15 14:54:11 UTC (rev 100969)
@@ -46,9 +46,9 @@
<version.apache.felix.configadmin>1.0.10</version.apache.felix.configadmin>
<version.apache.felix.log>1.0.0</version.apache.felix.log>
<version.apache.felix.metatype>1.0.2</version.apache.felix.metatype>
- <version.jboss.classloading>2.2.0.Alpha1</version.jboss.classloading>
+ <version.jboss.classloading>2.2.0.Alpha2</version.jboss.classloading>
<version.jboss.deployers>2.2.0.Alpha1</version.jboss.deployers>
- <version.jboss.kernel>2.2.0-SNAPSHOT</version.jboss.kernel>
+ <version.jboss.kernel>2.2.0.Alpha6</version.jboss.kernel>
<version.jboss.logging>2.1.0.GA</version.jboss.logging>
<version.jboss.mdr>2.2.0.Alpha1</version.jboss.mdr>
<version.jboss.osgi.apache.xerces>2.9.1.SP3</version.jboss.osgi.apache.xerces>
Modified: projects/jboss-osgi/projects/runtime/framework/branches/alesj_service-mix/src/etc/osgitck/jboss-osgi-bootstrap.xml
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/branches/alesj_service-mix/src/etc/osgitck/jboss-osgi-bootstrap.xml 2010-02-15 14:20:10 UTC (rev 100968)
+++ projects/jboss-osgi/projects/runtime/framework/branches/alesj_service-mix/src/etc/osgitck/jboss-osgi-bootstrap.xml 2010-02-15 14:54:11 UTC (rev 100969)
@@ -45,7 +45,33 @@
<uncallback method="removePlugin" />
</bean>
- <!--
+ <!--
+ ********************************
+ * *
+ * OSGi Framework MDR usage *
+ * *
+ ********************************
+ -->
+
+ <bean name="MDRService" class="org.jboss.osgi.framework.bundle.MetaDataRetrievalService">
+ <constructor>
+ <parameter><inject bean="jboss.kernel:service=Kernel"/></parameter>
+ <parameter><inject bean="OSGiBundleManager" property="systemBundle"/></parameter>
+ </constructor>
+ </bean>
+ <bean name="InstanceMDRFactory" class="org.jboss.osgi.framework.bundle.InstanceMetaDataRetrievalFactory">
+ <constructor><parameter><inject bean="jboss.kernel:service=Kernel"/></parameter></constructor>
+ <incallback method="addFactory"/>
+ <uncallback method="removeFactory"/>
+ </bean>
+ <bean name="OSGiDictionaryFactory" class="org.jboss.osgi.framework.bundle.OSGiServiceStateDictionaryFactory"/>
+ <bean name="KernelDictionaryFactory" class="org.jboss.osgi.framework.bundle.KernelDictionaryFactory">
+ <constructor>
+ <parameter><inject bean="jboss.kernel:service=KernelConfigurator"/></parameter>
+ </constructor>
+ </bean>
+
+ <!--
********************************
* *
* OSGi Framework Plugins *
@@ -58,6 +84,7 @@
<parameter><inject bean="OSGiBundleManager" /></parameter>
<parameter><inject bean="DeploymentRegistry" /></parameter>
</constructor>
+ <property name="factory"><inject bean="InstanceMDRFactory"/></property>
</bean>
<bean name="OSGiFrameworkEventsPlugin" class="org.jboss.osgi.framework.plugins.internal.FrameworkEventsPluginImpl">
<constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
@@ -71,8 +98,8 @@
<bean name="OSGiSystemPackages" class="org.jboss.osgi.framework.plugins.internal.SystemPackagesPluginImpl">
<constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
</bean>
-
- <!--
+
+ <!--
********************************
* *
* OSGi Service Plugins *
@@ -82,14 +109,20 @@
<bean name="MicrocontainerService" class="org.jboss.osgi.framework.service.internal.MicrocontainerServiceImpl">
<constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
+ <related-class name="org.jboss.osgi.spi.service.MicrocontainerService">OSGi</related-class>
+ <demand state="PreInstall">MDRService</demand>
</bean>
<bean name="StartLevelService" class="org.jboss.osgi.framework.service.internal.StartLevelImpl">
<constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
+ <related-class name="org.osgi.service.startlevel.StartLevel">OSGi</related-class>
+ <demand state="PreInstall">MDRService</demand>
</bean>
<bean name="PackageAdminService" class="org.jboss.osgi.framework.service.internal.PackageAdminImpl">
<constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
+ <related-class name="org.osgi.service.packageadmin.PackageAdmin">OSGi</related-class>
+ <demand state="PreInstall">MDRService</demand>
</bean>
-
+
<!--
********************************
* *
Copied: projects/jboss-osgi/projects/runtime/framework/branches/alesj_service-mix/src/main/java/org/jboss/osgi/framework/bundle/MetaDataRetrievalService.java (from rev 100962, projects/jboss-osgi/projects/runtime/framework/branches/alesj_service-mix/src/main/java/org/jboss/osgi/framework/bundle/InstanceMetaDataRetrievalFactory.java)
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/branches/alesj_service-mix/src/main/java/org/jboss/osgi/framework/bundle/MetaDataRetrievalService.java (rev 0)
+++ projects/jboss-osgi/projects/runtime/framework/branches/alesj_service-mix/src/main/java/org/jboss/osgi/framework/bundle/MetaDataRetrievalService.java 2010-02-15 14:54:11 UTC (rev 100969)
@@ -0,0 +1,155 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.osgi.framework.bundle;
+
+import org.jboss.dependency.plugins.tracker.NoopContextTracker;
+import org.jboss.dependency.spi.tracker.ContextTracker;
+import org.jboss.kernel.Kernel;
+import org.jboss.kernel.spi.qualifier.QualifierMatchers;
+import org.jboss.metadata.plugins.loader.memory.MemoryMetaDataLoader;
+import org.jboss.metadata.spi.MutableMetaData;
+import org.jboss.metadata.spi.repository.MutableMetaDataRepository;
+import org.jboss.metadata.spi.retrieval.MetaDataRetrieval;
+import org.jboss.metadata.spi.retrieval.MetaDataRetrievalFactory;
+import org.jboss.metadata.spi.scope.CommonLevels;
+import org.jboss.metadata.spi.scope.ScopeKey;
+
+/**
+ * Apply MDR usage.
+ *
+ * @author <a href="ales.justin at jboss.org">Ales Justin</a>
+ */
+public class MetaDataRetrievalService
+{
+ /** The kernel */
+ private Kernel kernel;
+ /** The system tracker */
+ private ContextTracker systemTracker;
+ /** The mdr factory */
+ private MetaDataRetrievalFactory factory;
+ /** The previous context tracker */
+ private ContextTracker previousTracker;
+
+ public MetaDataRetrievalService(Kernel kernel, ContextTracker systemTracker)
+ {
+ if (kernel == null)
+ throw new IllegalArgumentException("Null kernel");
+ if (systemTracker == null)
+ throw new IllegalArgumentException("Null system tracker");
+
+ this.kernel = kernel;
+ this.systemTracker = systemTracker;
+ }
+
+ public void start()
+ {
+ applyMDRUsage(true);
+ }
+
+ public void stop()
+ {
+ applyMDRUsage(false);
+ }
+
+ /**
+ * Apply OSGi's MDR usage:
+ * - add/remove system bundle as default context tracker
+ * - add/remove instance metadata retrieval factory
+ *
+ * @param register do we register or unregister
+ */
+ private void applyMDRUsage(boolean register)
+ {
+ MutableMetaDataRepository repository = kernel.getMetaDataRepository().getMetaDataRepository();
+ MetaDataRetrieval retrieval = repository.getMetaDataRetrieval(ScopeKey.DEFAULT_SCOPE);
+ if (register && retrieval == null)
+ {
+ retrieval = new MemoryMetaDataLoader(ScopeKey.DEFAULT_SCOPE);
+ repository.addMetaDataRetrieval(retrieval);
+ }
+ if (retrieval != null && retrieval instanceof MutableMetaData)
+ {
+ MutableMetaData mmd = (MutableMetaData)retrieval;
+ if (register)
+ {
+ previousTracker = mmd.addMetaData(systemTracker, ContextTracker.class);
+ }
+ else
+ {
+ if (previousTracker == null)
+ {
+ mmd.removeMetaData(ContextTracker.class);
+ if (retrieval.isEmpty())
+ repository.removeMetaDataRetrieval(retrieval.getScope());
+ }
+ else
+ {
+ mmd.addMetaData(previousTracker, ContextTracker.class);
+ }
+ }
+ }
+
+ // osgi ldap filter parsing and matching
+ FilterParserAndMatcher fpm = FilterParserAndMatcher.INSTANCE;
+ QualifierMatchers matchers = QualifierMatchers.getInstance();
+
+ if (register)
+ {
+ matchers.addParser(fpm);
+ matchers.addMatcher(fpm);
+
+ MetaDataRetrievalFactory mdrFactory = getMetaDataRetrievalFactory();
+ repository.addMetaDataRetrievalFactory(CommonLevels.INSTANCE, mdrFactory);
+ }
+ else
+ {
+ repository.removeMetaDataRetrievalFactory(CommonLevels.INSTANCE);
+
+ matchers.removeParser(fpm.getHandledContent());
+ matchers.removeMatcher(fpm.getHandledType());
+ }
+ }
+
+ private MetaDataRetrievalFactory getMetaDataRetrievalFactory()
+ {
+ MetaDataRetrievalFactory mdrFactory = factory;
+ if (mdrFactory == null)
+ {
+ InstanceMetaDataRetrievalFactory imdrf = new InstanceMetaDataRetrievalFactory(kernel);
+ imdrf.addFactory(new OSGiServiceStateDictionaryFactory());
+ imdrf.addFactory(new KernelDictionaryFactory(kernel.getConfigurator()));
+ // add JMX via configuration, as we don't wanna depend on JMX code
+ mdrFactory = imdrf;
+ }
+ return mdrFactory;
+ }
+
+ /**
+ * Set mdr factory.
+ *
+ * @param factory the factory
+ */
+ public void setFactory(MetaDataRetrievalFactory factory)
+ {
+ this.factory = factory;
+ }
+}
\ No newline at end of file
Modified: projects/jboss-osgi/projects/runtime/framework/branches/alesj_service-mix/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/branches/alesj_service-mix/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java 2010-02-15 14:20:10 UTC (rev 100968)
+++ projects/jboss-osgi/projects/runtime/framework/branches/alesj_service-mix/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java 2010-02-15 14:54:11 UTC (rev 100969)
@@ -47,6 +47,7 @@
import org.jboss.dependency.spi.ControllerContext;
import org.jboss.dependency.spi.ControllerState;
+import org.jboss.dependency.spi.tracker.ContextTracker;
import org.jboss.deployers.client.spi.DeployerClient;
import org.jboss.deployers.client.spi.IncompleteDeploymentException;
import org.jboss.deployers.client.spi.IncompleteDeployments;
@@ -60,7 +61,15 @@
import org.jboss.deployers.vfs.spi.client.VFSDeployment;
import org.jboss.deployers.vfs.spi.client.VFSDeploymentFactory;
import org.jboss.kernel.Kernel;
+import org.jboss.kernel.spi.qualifier.QualifierMatchers;
import org.jboss.logging.Logger;
+import org.jboss.metadata.plugins.loader.memory.MemoryMetaDataLoader;
+import org.jboss.metadata.spi.MutableMetaData;
+import org.jboss.metadata.spi.repository.MutableMetaDataRepository;
+import org.jboss.metadata.spi.retrieval.MetaDataRetrieval;
+import org.jboss.metadata.spi.retrieval.MetaDataRetrievalFactory;
+import org.jboss.metadata.spi.scope.CommonLevels;
+import org.jboss.metadata.spi.scope.ScopeKey;
import org.jboss.osgi.deployment.deployer.Deployment;
import org.jboss.osgi.deployment.deployer.DeploymentFactory;
import org.jboss.osgi.framework.deployers.OSGiBundleActivatorDeployer;
@@ -165,7 +174,6 @@
*
* @param kernel the kernel
* @param deployerClient the deployer client
- * @param registry the deployment registry
* @throws IllegalArgumentException for a null parameter
*/
public OSGiBundleManager(Kernel kernel, DeployerClient deployerClient)
@@ -178,7 +186,6 @@
*
* @param kernel the kernel
* @param deployerClient the deployer client
- * @param registry the deployment registry
* @param executor the executor
* @throws IllegalArgumentException for a null parameter
*/
@@ -236,7 +243,7 @@
/**
* Set the framework properties
*
- * @param properties the properties
+ * @param props the properties
*/
public void setProperties(Map<String, Object> props)
{
Modified: projects/jboss-osgi/projects/runtime/framework/branches/alesj_service-mix/src/main/java/org/jboss/osgi/framework/bundle/ServiceManagerPluginImpl.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/branches/alesj_service-mix/src/main/java/org/jboss/osgi/framework/bundle/ServiceManagerPluginImpl.java 2010-02-15 14:20:10 UTC (rev 100968)
+++ projects/jboss-osgi/projects/runtime/framework/branches/alesj_service-mix/src/main/java/org/jboss/osgi/framework/bundle/ServiceManagerPluginImpl.java 2010-02-15 14:54:11 UTC (rev 100969)
@@ -23,41 +23,21 @@
//$Id$
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Dictionary;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
import org.jboss.dependency.spi.Controller;
import org.jboss.dependency.spi.ControllerContext;
import org.jboss.dependency.spi.ControllerState;
-import org.jboss.dependency.spi.tracker.ContextTracker;
import org.jboss.kernel.Kernel;
import org.jboss.kernel.spi.dependency.KernelController;
-import org.jboss.kernel.spi.qualifier.QualifierMatchers;
-import org.jboss.logging.Logger;
-import org.jboss.metadata.plugins.loader.memory.MemoryMetaDataLoader;
-import org.jboss.metadata.spi.MutableMetaData;
-import org.jboss.metadata.spi.repository.MutableMetaDataRepository;
-import org.jboss.metadata.spi.retrieval.MetaDataRetrieval;
-import org.jboss.metadata.spi.retrieval.MetaDataRetrievalFactory;
-import org.jboss.metadata.spi.scope.CommonLevels;
-import org.jboss.metadata.spi.scope.ScopeKey;
import org.jboss.osgi.framework.plugins.ControllerContextPlugin;
import org.jboss.osgi.framework.plugins.FrameworkEventsPlugin;
import org.jboss.osgi.framework.plugins.ServiceManagerPlugin;
import org.jboss.osgi.framework.plugins.internal.AbstractPlugin;
import org.jboss.osgi.framework.util.KernelUtils;
import org.jboss.osgi.framework.util.NoFilter;
-import org.osgi.framework.Filter;
-import org.osgi.framework.FrameworkUtil;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceEvent;
-import org.osgi.framework.ServiceReference;
+import org.osgi.framework.*;
+import java.util.*;
+
/**
* A plugin that manages OSGi services.
*
@@ -71,15 +51,8 @@
*/
public class ServiceManagerPluginImpl extends AbstractPlugin implements ServiceManagerPlugin
{
- // Provide logging
- private final Logger log = Logger.getLogger(ServiceManagerPluginImpl.class);
-
/** The kernel */
private Kernel kernel;
- /** The mdr factory */
- private MetaDataRetrievalFactory factory;
- /** The previous context tracker */
- private ContextTracker previousTracker;
public ServiceManagerPluginImpl(OSGiBundleManager bundleManager)
{
@@ -89,14 +62,8 @@
public void start()
{
kernel = getBundleManager().getKernel();
- applyMDRUsage(true);
}
- public void stop()
- {
- applyMDRUsage(false);
- }
-
public ServiceReference[] getRegisteredServices(AbstractBundleState bundleState)
{
ControllerContextPlugin plugin = getBundleManager().getPlugin(ControllerContextPlugin.class);
@@ -259,80 +226,6 @@
plugin.unregisterContexts(bundleState);
}
- /**
- * Apply OSGi's MDR usage:
- * - add/remove system bundle as default context tracker
- * - add/remove instance metadata retrieval factory
- *
- * @param register do we register or unregister
- */
- private void applyMDRUsage(boolean register)
- {
- MutableMetaDataRepository repository = kernel.getMetaDataRepository().getMetaDataRepository();
- MetaDataRetrieval retrieval = repository.getMetaDataRetrieval(ScopeKey.DEFAULT_SCOPE);
- if (register && retrieval == null)
- {
- retrieval = new MemoryMetaDataLoader(ScopeKey.DEFAULT_SCOPE);
- repository.addMetaDataRetrieval(retrieval);
- }
- if (retrieval != null && retrieval instanceof MutableMetaData)
- {
- MutableMetaData mmd = (MutableMetaData)retrieval;
- if (register)
- {
- OSGiSystemState systemBundle = getBundleManager().getSystemBundle();
- previousTracker = mmd.addMetaData(systemBundle, ContextTracker.class);
- }
- else
- {
- if (previousTracker == null)
- {
- mmd.removeMetaData(ContextTracker.class);
- if (retrieval.isEmpty())
- repository.removeMetaDataRetrieval(retrieval.getScope());
- }
- else
- {
- mmd.addMetaData(previousTracker, ContextTracker.class);
- }
- }
- }
-
- // osgi ldap filter parsing and matching
- FilterParserAndMatcher fpm = FilterParserAndMatcher.INSTANCE;
- QualifierMatchers matchers = QualifierMatchers.getInstance();
-
- if (register)
- {
- matchers.addParser(fpm);
- matchers.addMatcher(fpm);
-
- MetaDataRetrievalFactory mdrFactory = getMetaDataRetrievalFactory();
- repository.addMetaDataRetrievalFactory(CommonLevels.INSTANCE, mdrFactory);
- }
- else
- {
- repository.removeMetaDataRetrievalFactory(CommonLevels.INSTANCE);
-
- matchers.removeParser(fpm.getHandledContent());
- matchers.removeMatcher(fpm.getHandledType());
- }
- }
-
- private MetaDataRetrievalFactory getMetaDataRetrievalFactory()
- {
- MetaDataRetrievalFactory mdrFactory = factory;
- if (mdrFactory == null)
- {
- InstanceMetaDataRetrievalFactory imdrf = new InstanceMetaDataRetrievalFactory(kernel);
- imdrf.addFactory(new OSGiServiceStateDictionaryFactory());
- imdrf.addFactory(new KernelDictionaryFactory(kernel.getConfigurator()));
- // add JMX via configuration, as we don't wanna depend on JMX code
- mdrFactory = imdrf;
- }
- return mdrFactory;
- }
-
private Collection<ServiceReference> getServices(AbstractBundleState bundle, String clazz, Filter filter, boolean checkAssignable)
{
Set<ControllerContext> contexts;
@@ -422,14 +315,4 @@
}
return true;
}
-
- /**
- * Set mdr factory.
- *
- * @param factory the factory
- */
- public void setFactory(MetaDataRetrievalFactory factory)
- {
- this.factory = factory;
- }
}
\ No newline at end of file
Modified: projects/jboss-osgi/projects/runtime/framework/branches/alesj_service-mix/src/main/java/org/jboss/osgi/framework/plugins/PackageAdminPlugin.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/branches/alesj_service-mix/src/main/java/org/jboss/osgi/framework/plugins/PackageAdminPlugin.java 2010-02-15 14:20:10 UTC (rev 100968)
+++ projects/jboss-osgi/projects/runtime/framework/branches/alesj_service-mix/src/main/java/org/jboss/osgi/framework/plugins/PackageAdminPlugin.java 2010-02-15 14:54:11 UTC (rev 100969)
@@ -31,6 +31,6 @@
* @author thomas.diesler at jboss.com
* @since 07-Sep-2009
*/
-public interface PackageAdminPlugin extends ServicePlugin, PackageAdmin
+public interface PackageAdminPlugin extends Plugin, PackageAdmin
{
}
\ No newline at end of file
Deleted: projects/jboss-osgi/projects/runtime/framework/branches/alesj_service-mix/src/main/java/org/jboss/osgi/framework/plugins/StartLevelPlugin.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/branches/alesj_service-mix/src/main/java/org/jboss/osgi/framework/plugins/StartLevelPlugin.java 2010-02-15 14:20:10 UTC (rev 100968)
+++ projects/jboss-osgi/projects/runtime/framework/branches/alesj_service-mix/src/main/java/org/jboss/osgi/framework/plugins/StartLevelPlugin.java 2010-02-15 14:54:11 UTC (rev 100969)
@@ -1,34 +0,0 @@
-/*
- * 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.framework.plugins;
-
-import org.osgi.service.startlevel.StartLevel;
-
-/**
- * The StartLevel service plugin
- *
- * @author thomas.diesler at jboss.com
- * @since 07-Sep-2009
- */
-public interface StartLevelPlugin extends ServicePlugin, StartLevel
-{
-}
\ No newline at end of file
Modified: projects/jboss-osgi/projects/runtime/framework/branches/alesj_service-mix/src/main/java/org/jboss/osgi/framework/service/internal/LifecycleInterceptorServiceImpl.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/branches/alesj_service-mix/src/main/java/org/jboss/osgi/framework/service/internal/LifecycleInterceptorServiceImpl.java 2010-02-15 14:20:10 UTC (rev 100968)
+++ projects/jboss-osgi/projects/runtime/framework/branches/alesj_service-mix/src/main/java/org/jboss/osgi/framework/service/internal/LifecycleInterceptorServiceImpl.java 2010-02-15 14:54:11 UTC (rev 100969)
@@ -27,7 +27,6 @@
import org.jboss.logging.Logger;
import org.jboss.osgi.deployment.interceptor.AbstractLifecycleInterceptorService;
import org.jboss.osgi.deployment.interceptor.InvocationContext;
-import org.jboss.osgi.deployment.interceptor.LifecycleInterceptorService;
import org.jboss.osgi.deployment.internal.InvocationContextImpl;
import org.jboss.osgi.framework.bundle.AbstractDeployedBundleState;
import org.jboss.osgi.framework.bundle.OSGiBundleManager;
@@ -36,7 +35,6 @@
import org.jboss.osgi.framework.util.DeploymentUnitAttachments;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceRegistration;
/**
* A plugin that manages bundle lifecycle interceptors.
@@ -50,7 +48,6 @@
final Logger log = Logger.getLogger(LifecycleInterceptorServiceImpl.class);
private AbstractLifecycleInterceptorService delegate;
- private ServiceRegistration registration;
public LifecycleInterceptorServiceImpl(final OSGiBundleManager bundleManager)
{
@@ -82,18 +79,11 @@
return inv;
}
};
-
- registration = sysContext.registerService(LifecycleInterceptorService.class.getName(), delegate, null);
}
public void stopService()
{
- if (registration != null)
- {
- registration.unregister();
- registration = null;
- delegate = null;
- }
+ delegate = null;
}
public void handleStateChange(int state, Bundle bundle)
Modified: projects/jboss-osgi/projects/runtime/framework/branches/alesj_service-mix/src/main/java/org/jboss/osgi/framework/service/internal/MicrocontainerServiceImpl.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/branches/alesj_service-mix/src/main/java/org/jboss/osgi/framework/service/internal/MicrocontainerServiceImpl.java 2010-02-15 14:20:10 UTC (rev 100968)
+++ projects/jboss-osgi/projects/runtime/framework/branches/alesj_service-mix/src/main/java/org/jboss/osgi/framework/service/internal/MicrocontainerServiceImpl.java 2010-02-15 14:54:11 UTC (rev 100969)
@@ -23,13 +23,6 @@
//$Id$
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-
-import javax.management.MBeanServer;
-import javax.management.StandardMBean;
-
import org.jboss.dependency.plugins.AbstractController;
import org.jboss.dependency.plugins.AbstractControllerContext;
import org.jboss.dependency.plugins.AbstractControllerContextActions;
@@ -46,13 +39,14 @@
import org.jboss.osgi.framework.plugins.internal.AbstractServicePlugin;
import org.jboss.osgi.spi.management.MicrocontainerServiceMBean;
import org.jboss.osgi.spi.service.MicrocontainerService;
-import org.osgi.framework.Constants;
-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.*;
+import javax.management.MBeanServer;
+import javax.management.StandardMBean;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
/**
* An implementation of the {@link MicrocontainerService}.
*
@@ -65,7 +59,7 @@
private static final Logger log = Logger.getLogger(MicrocontainerServiceImpl.class);
private Kernel kernel;
- private ServiceRegistration registration;
+ private JMXServiceListener listener;
public MicrocontainerServiceImpl(OSGiBundleManager bundleManager)
{
@@ -77,13 +71,13 @@
public void startService()
{
installKernelBean(BEAN_BUNDLE_CONTEXT, getSystemContext());
- registration = getSystemContext().registerService(MicrocontainerService.class.getName(), this, null);
// Track the MBeanServer and register this service as an MBean
try
{
String filter = "(" + Constants.OBJECTCLASS + "=" + MBeanServer.class.getName() + ")";
- getSystemContext().addServiceListener(new JMXServiceListener(this), filter);
+ listener = new JMXServiceListener(this);
+ getSystemContext().addServiceListener(listener, filter);
}
catch (InvalidSyntaxException ex)
{
@@ -93,11 +87,7 @@
public void stopService()
{
- if (registration != null)
- {
- registration.unregister();
- registration = null;
- }
+ getSystemContext().removeServiceListener(listener);
}
public Object getRegisteredBean(String beanName)
Modified: projects/jboss-osgi/projects/runtime/framework/branches/alesj_service-mix/src/main/java/org/jboss/osgi/framework/service/internal/PackageAdminImpl.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/branches/alesj_service-mix/src/main/java/org/jboss/osgi/framework/service/internal/PackageAdminImpl.java 2010-02-15 14:20:10 UTC (rev 100968)
+++ projects/jboss-osgi/projects/runtime/framework/branches/alesj_service-mix/src/main/java/org/jboss/osgi/framework/service/internal/PackageAdminImpl.java 2010-02-15 14:54:11 UTC (rev 100969)
@@ -23,10 +23,6 @@
//$Id: StartLevelImpl.java 93118 2009-09-02 08:24:44Z thomas.diesler at jboss.com $
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
import org.jboss.classloading.plugins.metadata.PackageCapability;
import org.jboss.classloading.spi.dependency.ClassLoading;
import org.jboss.classloading.spi.dependency.Module;
@@ -36,26 +32,25 @@
import org.jboss.deployers.plugins.classloading.AbstractDeploymentClassLoaderPolicyModule;
import org.jboss.deployers.structure.spi.DeploymentUnit;
import org.jboss.logging.Logger;
-import org.jboss.osgi.framework.bundle.AbstractBundleState;
-import org.jboss.osgi.framework.bundle.AbstractDeployedBundleState;
-import org.jboss.osgi.framework.bundle.OSGiBundleManager;
-import org.jboss.osgi.framework.bundle.OSGiBundleState;
-import org.jboss.osgi.framework.bundle.OSGiFragmentState;
+import org.jboss.osgi.framework.bundle.*;
import org.jboss.osgi.framework.plugins.PackageAdminPlugin;
+import org.jboss.osgi.framework.plugins.Plugin;
import org.jboss.osgi.framework.plugins.ResolverPlugin;
-import org.jboss.osgi.framework.plugins.internal.AbstractServicePlugin;
+import org.jboss.osgi.framework.plugins.internal.AbstractPlugin;
import org.jboss.osgi.framework.resolver.Resolver;
import org.jboss.osgi.framework.resolver.ResolverBundle;
import org.jboss.osgi.spi.NotImplementedException;
import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
-import org.osgi.framework.ServiceRegistration;
import org.osgi.framework.Version;
import org.osgi.service.packageadmin.ExportedPackage;
import org.osgi.service.packageadmin.PackageAdmin;
import org.osgi.service.packageadmin.RequiredBundle;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
/**
* An implementation of the {@link PackageAdmin}.
*
@@ -64,33 +59,16 @@
* @author thomas.diesler at jboss.com
* @since 03-Sep-2009
*/
-public class PackageAdminImpl extends AbstractServicePlugin implements PackageAdminPlugin
+public class PackageAdminImpl extends AbstractPlugin implements PackageAdminPlugin
{
/** The log */
private static final Logger log = Logger.getLogger(PackageAdminImpl.class);
- private ServiceRegistration registration;
-
public PackageAdminImpl(OSGiBundleManager bundleManager)
{
super(bundleManager);
}
- public void startService()
- {
- BundleContext sysContext = getSystemContext();
- registration = sysContext.registerService(PackageAdmin.class.getName(), this, null);
- }
-
- public void stopService()
- {
- if (registration != null)
- {
- registration.unregister();
- registration = null;
- }
- }
-
@SuppressWarnings("rawtypes")
public Bundle getBundle(Class clazz)
{
Modified: projects/jboss-osgi/projects/runtime/framework/branches/alesj_service-mix/src/main/java/org/jboss/osgi/framework/service/internal/StartLevelImpl.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/branches/alesj_service-mix/src/main/java/org/jboss/osgi/framework/service/internal/StartLevelImpl.java 2010-02-15 14:20:10 UTC (rev 100968)
+++ projects/jboss-osgi/projects/runtime/framework/branches/alesj_service-mix/src/main/java/org/jboss/osgi/framework/service/internal/StartLevelImpl.java 2010-02-15 14:54:11 UTC (rev 100969)
@@ -25,10 +25,9 @@
import org.jboss.logging.Logger;
import org.jboss.osgi.framework.bundle.OSGiBundleManager;
-import org.jboss.osgi.framework.plugins.StartLevelPlugin;
-import org.jboss.osgi.framework.plugins.internal.AbstractServicePlugin;
+import org.jboss.osgi.framework.plugins.Plugin;
+import org.jboss.osgi.framework.plugins.internal.AbstractPlugin;
import org.osgi.framework.Bundle;
-import org.osgi.framework.ServiceRegistration;
import org.osgi.service.startlevel.StartLevel;
/**
@@ -39,32 +38,16 @@
* @author thomas.diesler at jboss.com
* @since 31-Aug-2009
*/
-public class StartLevelImpl extends AbstractServicePlugin implements StartLevelPlugin
+public class StartLevelImpl extends AbstractPlugin implements StartLevel, Plugin
{
/** The log */
private static final Logger log = Logger.getLogger(StartLevelImpl.class);
- private ServiceRegistration registration;
-
public StartLevelImpl(OSGiBundleManager bundleManager)
{
super(bundleManager);
}
- public void startService()
- {
- registration = getSystemContext().registerService(StartLevel.class.getName(), this, null);
- }
-
- public void stopService()
- {
- if (registration != null)
- {
- registration.unregister();
- registration = null;
- }
- }
-
public int getBundleStartLevel(Bundle bundle)
{
return 1;
Modified: projects/jboss-osgi/projects/runtime/framework/branches/alesj_service-mix/src/test/java/org/jboss/test/osgi/fragments/subA/SubBeanA.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/branches/alesj_service-mix/src/test/java/org/jboss/test/osgi/fragments/subA/SubBeanA.java 2010-02-15 14:20:10 UTC (rev 100968)
+++ projects/jboss-osgi/projects/runtime/framework/branches/alesj_service-mix/src/test/java/org/jboss/test/osgi/fragments/subA/SubBeanA.java 2010-02-15 14:54:11 UTC (rev 100969)
@@ -34,8 +34,6 @@
{
ServiceReference sref = context.getServiceReference(PackageAdmin.class.getName());
PackageAdmin packageAdmin = (PackageAdmin)context.getService(sref);
- Bundle provider = packageAdmin.getBundle(getClass());
- return provider;
+ return packageAdmin.getBundle(getClass());
}
-
}
Modified: projects/jboss-osgi/projects/runtime/framework/branches/alesj_service-mix/src/test/resources/bootstrap/jboss-osgi-bootstrap.xml
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/branches/alesj_service-mix/src/test/resources/bootstrap/jboss-osgi-bootstrap.xml 2010-02-15 14:20:10 UTC (rev 100968)
+++ projects/jboss-osgi/projects/runtime/framework/branches/alesj_service-mix/src/test/resources/bootstrap/jboss-osgi-bootstrap.xml 2010-02-15 14:54:11 UTC (rev 100969)
@@ -38,8 +38,35 @@
<uncallback method="removePlugin" />
</bean>
- <!--
+ <!--
********************************
+ * *
+ * OSGi Framework MDR usage *
+ * *
+ ********************************
+ -->
+
+ <bean name="MDRService" class="org.jboss.osgi.framework.bundle.MetaDataRetrievalService">
+ <constructor>
+ <parameter><inject bean="jboss.kernel:service=Kernel"/></parameter>
+ <parameter><inject bean="OSGiBundleManager" property="systemBundle"/></parameter>
+ </constructor>
+ <property name="factory"><inject bean="InstanceMDRFactory"/></property>
+ </bean>
+ <bean name="InstanceMDRFactory" class="org.jboss.osgi.framework.bundle.InstanceMetaDataRetrievalFactory">
+ <constructor><parameter><inject bean="jboss.kernel:service=Kernel"/></parameter></constructor>
+ <incallback method="addFactory"/>
+ <uncallback method="removeFactory"/>
+ </bean>
+ <bean name="OSGiDictionaryFactory" class="org.jboss.osgi.framework.bundle.OSGiServiceStateDictionaryFactory"/>
+ <bean name="KernelDictionaryFactory" class="org.jboss.osgi.framework.bundle.KernelDictionaryFactory">
+ <constructor>
+ <parameter><inject bean="jboss.kernel:service=KernelConfigurator"/></parameter>
+ </constructor>
+ </bean>
+
+ <!--
+ ********************************
* *
* OSGi Framework Plugins *
* *
@@ -62,7 +89,6 @@
</bean>
<bean name="OSGiServiceManagerPlugin" class="org.jboss.osgi.framework.bundle.ServiceManagerPluginImpl">
<constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
- <property name="factory"><inject bean="InstanceMDRFactory"/></property>
</bean>
<bean name="OSGiStoragePlugin" class="org.jboss.osgi.framework.plugins.internal.BundleStoragePluginImpl">
<constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
@@ -71,19 +97,7 @@
<constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
</bean>
- <bean name="InstanceMDRFactory" class="org.jboss.osgi.framework.bundle.InstanceMetaDataRetrievalFactory">
- <constructor><parameter><inject bean="jboss.kernel:service=Kernel"/></parameter></constructor>
- <incallback method="addFactory"/>
- <uncallback method="removeFactory"/>
- </bean>
- <bean name="OSGiDictionaryFactory" class="org.jboss.osgi.framework.bundle.OSGiServiceStateDictionaryFactory"/>
- <bean name="KernelDictionaryFactory" class="org.jboss.osgi.framework.bundle.KernelDictionaryFactory">
- <constructor>
- <parameter><inject bean="jboss.kernel:service=KernelConfigurator"/></parameter>
- </constructor>
- </bean>
-
- <!--
+ <!--
********************************
* *
* OSGi Service Plugins *
@@ -93,18 +107,29 @@
<bean name="MicrocontainerService" class="org.jboss.osgi.framework.service.internal.MicrocontainerServiceImpl">
<constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
+ <related-class name="org.jboss.osgi.spi.service.MicrocontainerService">OSGi</related-class>
+ <demand state="PreInstall">MDRService</demand>
</bean>
<bean name="StartLevelService" class="org.jboss.osgi.framework.service.internal.StartLevelImpl">
<constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
+ <related-class name="org.osgi.service.startlevel.StartLevel">OSGi</related-class>
+ <demand state="PreInstall">MDRService</demand>
</bean>
<bean name="PackageAdminService" class="org.jboss.osgi.framework.service.internal.PackageAdminImpl">
<constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
+ <related-class name="org.osgi.service.packageadmin.PackageAdmin">OSGi</related-class>
+ <demand state="PreInstall">MDRService</demand>
</bean>
<bean name="DeployerService" class="org.jboss.osgi.framework.service.internal.DeployerServiceImpl">
<constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
+ <!-- only expose full impl class; TODO on POJOs and properties -->
+ <related-class name="org.jboss.osgi.framework.service.internal.DeployerServiceImpl">OSGi</related-class>
+ <demand state="PreInstall">MDRService</demand>
</bean>
<bean name="LifecycleInterceptorService" class="org.jboss.osgi.framework.service.internal.LifecycleInterceptorServiceImpl">
<constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
+ <related-class name="org.jboss.osgi.deployment.interceptor.LifecycleInterceptorService">OSGi</related-class>
+ <demand state="PreInstall">MDRService</demand>
</bean>
<!--
More information about the jboss-osgi-commits
mailing list