[jboss-cvs] JBossAS SVN: r85293 - in projects/jboss-osgi/trunk: build/distribution and 9 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Mar 5 08:45:47 EST 2009
Author: thomas.diesler at jboss.com
Date: 2009-03-05 08:45:47 -0500 (Thu, 05 Mar 2009)
New Revision: 85293
Added:
projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi41/bundleA/ServiceB.java
Modified:
projects/jboss-osgi/trunk/build/distribution/pom.xml
projects/jboss-osgi/trunk/build/distribution/src/main/resources/installer/install-definition.xml
projects/jboss-osgi/trunk/pom.xml
projects/jboss-osgi/trunk/runtime/deployer/src/main/java/org/jboss/osgi/deployer/BundleClassLoaderDeployer.java
projects/jboss-osgi/trunk/runtime/deployer/src/main/java/org/jboss/osgi/deployer/BundleStartStopDeployer.java
projects/jboss-osgi/trunk/runtime/deployer/src/main/resources/osgi-deployers-jboss-beans.xml
projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/Constants.java
projects/jboss-osgi/trunk/testsuite/pom.xml
projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi38/bundleA/ServiceA.java
projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi41/OSGI41DeployerTestCase.java
projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi41/bundleA/ServiceActivator.java
projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/http/junit/EndpointServiceTestCase.java
Log:
Add Http Service, Config Admin Service
Modified: projects/jboss-osgi/trunk/build/distribution/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/build/distribution/pom.xml 2009-03-05 13:25:59 UTC (rev 85292)
+++ projects/jboss-osgi/trunk/build/distribution/pom.xml 2009-03-05 13:45:47 UTC (rev 85293)
@@ -77,6 +77,10 @@
<artifactId>org.apache.felix.configadmin</artifactId>
</dependency>
<dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.http.jetty</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.codehaus.izpack</groupId>
<artifactId>izpack-standalone-compiler</artifactId>
<version>${izpack.version}</version>
Modified: projects/jboss-osgi/trunk/build/distribution/src/main/resources/installer/install-definition.xml
===================================================================
--- projects/jboss-osgi/trunk/build/distribution/src/main/resources/installer/install-definition.xml 2009-03-05 13:25:59 UTC (rev 85292)
+++ projects/jboss-osgi/trunk/build/distribution/src/main/resources/installer/install-definition.xml 2009-03-05 13:45:47 UTC (rev 85293)
@@ -86,9 +86,9 @@
<!-- deploy/osgi -->
<fileset dir="@{deploy.artifacts.dir}/lib" targetdir="${jbossInstallPath}/server/${jbossTargetServer}/deploy/osgi" override="true">
- <!-- include name="jboss-osgi-service-http.jar" /-->
<include name="org.apache.felix.configadmin.jar" />
- <include name="jboss-osgi-service-webconsole.jar" />
+ <include name="org.apache.felix.http.jetty.jar" />
+ <!-- include name="jboss-osgi-service-webconsole.jar" /-->
</fileset>
</pack>
Modified: projects/jboss-osgi/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/pom.xml 2009-03-05 13:25:59 UTC (rev 85292)
+++ projects/jboss-osgi/trunk/pom.xml 2009-03-05 13:45:47 UTC (rev 85293)
@@ -36,6 +36,7 @@
<version.aqute.bnd>0.0.249</version.aqute.bnd>
<version.felix.configadmin>1.0.10</version.felix.configadmin>
<version.felix.framework>1.4.1</version.felix.framework>
+ <version.felix.http.jetty>0.9.0-20090218-R745505</version.felix.http.jetty>
<version.felix.javax.servlet>1.0.0</version.felix.javax.servlet>
<version.felix.osgi.core>1.2.0</version.felix.osgi.core>
<version.jbossas>5.0.1.GA</version.jbossas>
@@ -191,6 +192,11 @@
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.http.jetty</artifactId>
+ <version>${version.felix.http.jetty}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.framework</artifactId>
<version>${version.felix.framework}</version>
</dependency>
Modified: projects/jboss-osgi/trunk/runtime/deployer/src/main/java/org/jboss/osgi/deployer/BundleClassLoaderDeployer.java
===================================================================
--- projects/jboss-osgi/trunk/runtime/deployer/src/main/java/org/jboss/osgi/deployer/BundleClassLoaderDeployer.java 2009-03-05 13:25:59 UTC (rev 85292)
+++ projects/jboss-osgi/trunk/runtime/deployer/src/main/java/org/jboss/osgi/deployer/BundleClassLoaderDeployer.java 2009-03-05 13:45:47 UTC (rev 85293)
@@ -30,6 +30,7 @@
import org.jboss.osgi.deployer.helpers.BundleClassLoader;
import org.jboss.osgi.deployer.helpers.BundleDeploymentUnitFilter;
import org.jboss.osgi.deployer.helpers.PackageAdminDependencyItem;
+import org.jboss.osgi.spi.Constants;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
@@ -63,7 +64,9 @@
unit.addAttachment(ClassLoaderFactory.class, factory);
// create dependency items
- //unit.addIDependOn(new PackageAdminDependencyItem(systemContext, bundle));
+ String propStart = systemContext.getProperty(Constants.PROPERTY_DEFERRED_START);
+ if (Boolean.parseBoolean(propStart != null ? propStart : "true") == false)
+ unit.addIDependOn(new PackageAdminDependencyItem(systemContext, bundle));
// skip annotations scanning, if filter is set
if (filter != null)
Modified: projects/jboss-osgi/trunk/runtime/deployer/src/main/java/org/jboss/osgi/deployer/BundleStartStopDeployer.java
===================================================================
--- projects/jboss-osgi/trunk/runtime/deployer/src/main/java/org/jboss/osgi/deployer/BundleStartStopDeployer.java 2009-03-05 13:25:59 UTC (rev 85292)
+++ projects/jboss-osgi/trunk/runtime/deployer/src/main/java/org/jboss/osgi/deployer/BundleStartStopDeployer.java 2009-03-05 13:45:47 UTC (rev 85293)
@@ -30,6 +30,7 @@
import org.jboss.deployers.spi.DeploymentException;
import org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer;
import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.osgi.spi.Constants;
import org.jboss.osgi.spi.framework.StateFormat;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
@@ -51,7 +52,6 @@
// The list of unresolved bundles
private List<Bundle> unresolvedBundles = new ArrayList<Bundle>();
- private boolean simpleStart;
public BundleStartStopDeployer()
{
@@ -63,20 +63,16 @@
this.systemContext = systemContext;
}
- public void setSimpleStart(boolean simpleStartStop)
- {
- this.simpleStart = simpleStartStop;
- }
-
public void deploy(DeploymentUnit unit, Bundle bundle) throws DeploymentException
{
- if (simpleStart)
+ String propStart = systemContext.getProperty(Constants.PROPERTY_DEFERRED_START);
+ if (Boolean.parseBoolean(propStart != null ? propStart : "true") == true)
{
- simpleStart(unit, bundle);
+ deferredStart(unit, bundle);
}
else
{
- deferredStart(unit, bundle);
+ simpleStart(unit, bundle);
}
}
Modified: projects/jboss-osgi/trunk/runtime/deployer/src/main/resources/osgi-deployers-jboss-beans.xml
===================================================================
--- projects/jboss-osgi/trunk/runtime/deployer/src/main/resources/osgi-deployers-jboss-beans.xml 2009-03-05 13:25:59 UTC (rev 85292)
+++ projects/jboss-osgi/trunk/runtime/deployer/src/main/resources/osgi-deployers-jboss-beans.xml 2009-03-05 13:45:47 UTC (rev 85293)
@@ -8,48 +8,23 @@
<map keyClass="java.lang.String" valueClass="java.lang.String">
<entry><key>org.osgi.framework.storage</key><value>${jboss.server.data.dir}/osgi-store</value></entry>
<entry><key>org.osgi.framework.storage.clean</key><value>onFirstInit</value></entry>
+ <entry><key>org.osgi.service.http.port</key><value>8090</value></entry>
+ <entry><key>felix.cm.dir</key><value>${jboss.server.data.dir}/osgi-configadmin</value></entry>
<entry>
<key>org.osgi.framework.system.packages</key>
<value>
- javax.servlet,
- javax.servlet.http,
javax.management,
- javax.security.jacc,
- javax.xml.parsers,
- org.jboss.classloading.spi,
- org.jboss.dependency.spi,
- org.jboss.deployers.client.plugins.deployment,
- org.jboss.deployers.client.spi,
- org.jboss.deployers.spi.attachments,
- org.jboss.deployers.spi.structure,
- org.jboss.deployers.structure.spi,
- org.jboss.kernel,
- org.jboss.kernel.spi.dependency,
- org.jboss.metadata.javaee.spec,
- org.jboss.metadata.javaee.support,
- org.jboss.metadata.web.jboss,
- org.jboss.metadata.web.spec,
- org.jboss.mx.util,
org.jboss.osgi.service,
- org.jboss.osgi.spi,
- org.jboss.osgi.spi.framework,
org.jboss.osgi.spi.management,
- org.jboss.system.server.jmx,
- org.jboss.web,
- org.jboss.virtual,
org.osgi.framework; version=1.4,
- org.osgi.service.cm,
- org.osgi.service.deploymentadmin,
- org.osgi.service.event,
- org.osgi.service.http; version=1.2,
- org.osgi.service.log,
- org.osgi.service.metatype,
- org.osgi.service.packageadmin,
- org.osgi.service.prefs,
- org.osgi.service.startlevel,
- org.xml.sax
+ org.osgi.service.startlevel
</value>
</entry>
+ <!--
+ If set to 'true' bundles can be deployed in any order. Deployed bundle will get started when their dependencies can be resolved.
+ If set to 'false' bundles must be deployed in the order that is required to start them.
+ -->
+ <entry><key>org.jboss.osgi.deferred.start</key><value>true</value></entry>
</map>
</property>
<property name="autoStart">
Modified: projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/Constants.java
===================================================================
--- projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/Constants.java 2009-03-05 13:25:59 UTC (rev 85292)
+++ projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/Constants.java 2009-03-05 13:45:47 UTC (rev 85293)
@@ -29,8 +29,16 @@
* @author thomas.diesler at jboss.com
* @since 04-Mar-2009
*/
-public abstract class Constants
+public interface Constants
{
/** The JBossOSGi domain 'jboss.osgi' */
- public static final String DOMAIN_NAME = "jboss.osgi";
+ final String DOMAIN_NAME = "jboss.osgi";
+
+ /**
+ * If set to 'true' bundles can be deployed in any order. Deployed bundle will get started when their dependencies can be resolved.
+ * If set to 'false' bundles must be deployed in the order that is required to start them.
+ *
+ * The default is 'true'
+ */
+ final String PROPERTY_DEFERRED_START = "org.jboss.osgi.deferred.start";
}
Modified: projects/jboss-osgi/trunk/testsuite/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/testsuite/pom.xml 2009-03-05 13:25:59 UTC (rev 85292)
+++ projects/jboss-osgi/trunk/testsuite/pom.xml 2009-03-05 13:45:47 UTC (rev 85293)
@@ -158,7 +158,6 @@
<excludes>
<!-- [JBOSGI-40] Cannot run embedded tests with SecurityManager -->
<exclude>org/jboss/test/osgi/**/*EmbeddedTestCase.java</exclude>
- <exclude>org/jboss/test/osgi/service/http/junit/EndpointServiceTestCase.java</exclude>
<!-- [JBOSGI-39] Bundle gets wired to an already uninstalled bundle -->
<exclude>org/jboss/test/osgi/jbosgi39/*TestCase.java</exclude>
</excludes>
Modified: projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi38/bundleA/ServiceA.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi38/bundleA/ServiceA.java 2009-03-05 13:25:59 UTC (rev 85292)
+++ projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi38/bundleA/ServiceA.java 2009-03-05 13:45:47 UTC (rev 85293)
@@ -48,12 +48,6 @@
serviceB.doStuffInB(new SomePojo("hello"));
return serviceB;
}
-
- @Override
- public void removedService(ServiceReference reference, Object service)
- {
- super.removedService(reference, service);
- }
};
tracker.open();
}
Modified: projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi41/OSGI41DeployerTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi41/OSGI41DeployerTestCase.java 2009-03-05 13:25:59 UTC (rev 85292)
+++ projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi41/OSGI41DeployerTestCase.java 2009-03-05 13:45:47 UTC (rev 85293)
@@ -46,10 +46,7 @@
ManagedBundleMBean bundleA = deployBundle("jbosgi41-bundleA");
assertEquals("Bundle active", Bundle.ACTIVE, bundleA.getState());
- String rootDir = bundleA.getProperty("org.osgi.framework.storage");
- assertNotNull("Storage dir not null", rootDir);
-
- File dataFile = new File(rootDir + "/bundle" + bundleA.getBundleId() + "/data/config/jbosgi41.txt");
+ File dataFile = getBundleDataFile(bundleA, "config/jbosgi41.txt");
assertTrue("File exists: " + dataFile, dataFile.exists());
BufferedReader br = new BufferedReader(new FileReader(dataFile));
@@ -58,4 +55,13 @@
undeployBundle("jbosgi41-bundleA");
}
+
+ private File getBundleDataFile(ManagedBundleMBean bundleA, String filename)
+ {
+ String storageRoot = bundleA.getProperty("org.osgi.framework.storage");
+ assertNotNull("Storage dir not null", storageRoot);
+
+ File dataFile = new File(storageRoot + "/bundle" + bundleA.getBundleId() + "/data/" + filename);
+ return dataFile;
+ }
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi41/bundleA/ServiceActivator.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi41/bundleA/ServiceActivator.java 2009-03-05 13:25:59 UTC (rev 85292)
+++ projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi41/bundleA/ServiceActivator.java 2009-03-05 13:45:47 UTC (rev 85293)
@@ -23,26 +23,43 @@
//$Id$
+import java.util.Dictionary;
+import java.util.Hashtable;
+
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
public class ServiceActivator implements BundleActivator
{
- private ServiceRegistration registration;
+ private ServiceRegistration regA, regB;
public void start(BundleContext context)
{
- ServiceA service = new ServiceA(context);
- registration = context.registerService(ServiceA.class.getName(), service, null);
+ ServiceA serviceA = new ServiceA(context);
+ regA = context.registerService(ServiceA.class.getName(), serviceA, null);
+
+ Dictionary<String, String> props = new Hashtable<String, String>();
+ props.put("service.pid", ServiceB.class.getName());
+
+ ServiceB serviceB = new ServiceB(context);
+ regB = context.registerService(ServiceB.class.getName(), serviceB, props);
+
+ serviceB.updateConfig("xxx", "yyy");
+ serviceB.updateConfig("xxx", "zzz");
}
public void stop(BundleContext context)
{
- if (registration != null)
+ if (regA != null)
{
- registration.unregister();
- registration = null;
+ regA.unregister();
+ regA = null;
}
+ if (regB != null)
+ {
+ regB.unregister();
+ regB = null;
+ }
}
}
\ No newline at end of file
Added: projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi41/bundleA/ServiceB.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi41/bundleA/ServiceB.java (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi41/bundleA/ServiceB.java 2009-03-05 13:45:47 UTC (rev 85293)
@@ -0,0 +1,98 @@
+/*
+ * 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.jbosgi41.bundleA;
+
+//$Id$
+
+import java.util.Arrays;
+import java.util.Dictionary;
+import java.util.Hashtable;
+
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.cm.Configuration;
+import org.osgi.service.cm.ConfigurationAdmin;
+import org.osgi.service.cm.ConfigurationException;
+import org.osgi.service.cm.ManagedService;
+import org.osgi.util.tracker.ServiceTracker;
+
+/**
+ * ServiceB is a ManagedService
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 05-Mar-2009
+ */
+public class ServiceB implements ManagedService
+{
+ private ConfigurationAdmin configAdmin;
+
+ ServiceB(BundleContext context)
+ {
+ System.out.println("ServiceB");
+
+ ServiceTracker tracker = new ServiceTracker(context, ConfigurationAdmin.class.getName(), null)
+ {
+ @Override
+ public Object addingService(ServiceReference sref)
+ {
+ System.out.println("addingService");
+ configAdmin = (ConfigurationAdmin)super.addingService(sref);
+ return configAdmin;
+ }
+ };
+ tracker.open();
+ }
+
+ @SuppressWarnings("unchecked")
+ public void updateConfig(String key, String value)
+ {
+ System.out.println("updateConfig");
+ if (configAdmin != null)
+ {
+ try
+ {
+ Configuration config = configAdmin.getConfiguration(ServiceB.class.getName());
+ Dictionary props = config.getProperties();
+
+ if (props == null)
+ props = new Hashtable<String, String>();
+
+ props.put(key, value);
+
+ config.update(props);
+
+ Configuration[] configs = configAdmin.listConfigurations(null);
+ System.out.println(Arrays.asList(configs));
+ }
+ catch (Exception ex)
+ {
+ throw new RuntimeException("Cannot access ConfigurationAdmin", ex);
+ }
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public void updated(Dictionary props) throws ConfigurationException
+ {
+ System.out.println("updated: " + props);
+ }
+}
Property changes on: projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi41/bundleA/ServiceB.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/http/junit/EndpointServiceTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/http/junit/EndpointServiceTestCase.java 2009-03-05 13:25:59 UTC (rev 85292)
+++ projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/http/junit/EndpointServiceTestCase.java 2009-03-05 13:45:47 UTC (rev 85293)
@@ -48,35 +48,35 @@
public void testServletAccess() throws Exception
{
- URL url = new URL("http://" + getServerHost() + ":8080/servlet?test=plain");
+ URL url = new URL("http://" + getServerHost() + ":8090/servlet?test=plain");
BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream()));
assertEquals("Hello from Servlet", br.readLine());
}
public void testServletInitProps() throws Exception
{
- URL url = new URL("http://" + getServerHost() + ":8080/servlet?test=initProp");
+ URL url = new URL("http://" + getServerHost() + ":8090/servlet?test=initProp");
BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream()));
assertEquals("initProp=SomeValue", br.readLine());
}
public void testServletBundleContext() throws Exception
{
- URL url = new URL("http://" + getServerHost() + ":8080/servlet?test=context");
+ URL url = new URL("http://" + getServerHost() + ":8090/servlet?test=context");
BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream()));
assertEquals("http-service-test", br.readLine());
}
public void testServletStartLevel() throws Exception
{
- URL url = new URL("http://" + getServerHost() + ":8080/servlet?test=startLevel");
+ URL url = new URL("http://" + getServerHost() + ":8090/servlet?test=startLevel");
BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream()));
assertEquals("startLevel=1", br.readLine());
}
public void testResourceAccess() throws Exception
{
- URL url = new URL("http://" + getServerHost() + ":8080/file/message.txt");
+ URL url = new URL("http://" + getServerHost() + ":8090/file/message.txt");
BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream()));
assertEquals("Hello from Resource", br.readLine());
}
More information about the jboss-cvs-commits
mailing list