[jboss-cvs] JBossAS SVN: r87853 - in projects/jboss-osgi/trunk: bundle/blueprint/src/main/java/org/jboss/osgi/blueprint and 10 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Apr 27 05:32:49 EDT 2009
Author: thomas.diesler at jboss.com
Date: 2009-04-27 05:32:49 -0400 (Mon, 27 Apr 2009)
New Revision: 87853
Modified:
projects/jboss-osgi/trunk/bundle/blueprint/scripts/assembly-bundles.xml
projects/jboss-osgi/trunk/bundle/blueprint/src/main/java/org/jboss/osgi/blueprint/PropertiesBootstrapProvider.java
projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/bootstrap/SystemBundleTestCase.java
projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/jmx/JMXTestCase.java
projects/jboss-osgi/trunk/bundle/blueprint/src/test/resources/jboss-osgi-framework.properties
projects/jboss-osgi/trunk/bundle/jmx/pom.xml
projects/jboss-osgi/trunk/bundle/jmx/src/main/java/org/jboss/osgi/jmx/ServiceActivator.java
projects/jboss-osgi/trunk/bundle/microcontainer/pom.xml
projects/jboss-osgi/trunk/bundle/webconsole/pom.xml
projects/jboss-osgi/trunk/runtime/felix/src/main/java/org/jboss/osgi/felix/framework/FelixIntegration.java
projects/jboss-osgi/trunk/runtime/microcontainer/
projects/jboss-osgi/trunk/runtime/microcontainer/osgi-int/
Log:
Add proper logging to jmx bundle.
DEfine private imports for microcontainer bundle.
Modified: projects/jboss-osgi/trunk/bundle/blueprint/scripts/assembly-bundles.xml
===================================================================
--- projects/jboss-osgi/trunk/bundle/blueprint/scripts/assembly-bundles.xml 2009-04-27 09:29:34 UTC (rev 87852)
+++ projects/jboss-osgi/trunk/bundle/blueprint/scripts/assembly-bundles.xml 2009-04-27 09:32:49 UTC (rev 87853)
@@ -16,6 +16,7 @@
<outputFileNameMapping>${artifact.artifactId}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
<includes>
<include>*:org.apache.felix.log:jar</include>
+ <include>*:org.osgi.compendium:jar</include>
<include>*:jboss-osgi-common:jar</include>
<include>*:jboss-osgi-logging:jar</include>
<include>*:jboss-osgi-jmx:jar</include>
Modified: projects/jboss-osgi/trunk/bundle/blueprint/src/main/java/org/jboss/osgi/blueprint/PropertiesBootstrapProvider.java
===================================================================
--- projects/jboss-osgi/trunk/bundle/blueprint/src/main/java/org/jboss/osgi/blueprint/PropertiesBootstrapProvider.java 2009-04-27 09:29:34 UTC (rev 87852)
+++ projects/jboss-osgi/trunk/bundle/blueprint/src/main/java/org/jboss/osgi/blueprint/PropertiesBootstrapProvider.java 2009-04-27 09:32:49 UTC (rev 87853)
@@ -25,15 +25,19 @@
import java.io.IOException;
import java.io.InputStream;
+import java.net.MalformedURLException;
import java.net.URL;
+import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import java.util.Properties;
import org.jboss.osgi.spi.NotImplementedException;
import org.jboss.osgi.spi.framework.OSGiBootstrapProvider;
import org.jboss.osgi.spi.framework.OSGiFramework;
+import org.jboss.util.StringPropertyReplacer;
/**
* A simple properties based bootstrap provider
@@ -66,52 +70,53 @@
public void configure(URL urlConfig)
{
// Read the configuration properties
- Properties props = new Properties();
- try
- {
- InputStream inStream = urlConfig.openStream();
- props.load(inStream);
- inStream.close();
- }
- catch (IOException ex)
- {
- throw new IllegalStateException("Cannot load properties from: " + urlConfig, ex);
- }
+ Properties props = getBootstrapProperties(urlConfig);
- String frameworkImpl = props.getProperty(PROP_OSGI_FRAMEWORK_IMPL);
- if (frameworkImpl == null)
- throw new IllegalStateException("Cannot get : " + urlConfig);
-
// Load the framework instance
- try
- {
- ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader();
- Class<?> frameworkClass = ctxLoader.loadClass(frameworkImpl);
- framework = (OSGiFramework)frameworkClass.newInstance();
- }
- catch (Exception ex)
- {
- throw new IllegalStateException("Cannot load framework: " + frameworkImpl, ex);
- }
+ framework = loadFrameworkImpl(urlConfig, props);
// Process Framework props
- String prefix = "framework.prop.";
- Map<String,Object> frameworkProps = new HashMap<String,Object>();
- Enumeration<?> keys = props.propertyNames();
- while(keys.hasMoreElements())
+ initFrameworkProperties(props);
+
+ // Init the the autoInstall URLs
+ List<URL> installURLs = getBundleURLs(props, "framework.autoInstall");
+ framework.setAutoInstall(installURLs);
+
+ // Init the the autoStart URLs
+ List<URL> startURLs = getBundleURLs(props, "framework.autoStart");
+ framework.setAutoStart(startURLs);
+ }
+
+ private List<URL> getBundleURLs(Properties props, String key)
+ {
+ String bundleList = props.getProperty(key);
+ if (bundleList == null)
+ bundleList = "";
+
+ List<URL> bundleURLs = new ArrayList<URL>();
+ for (String bundle : bundleList.split("[, ]"))
{
- String key = (String)keys.nextElement();
- if (key.startsWith(prefix))
+ if (bundle.trim().length() > 0)
{
- String value = props.getProperty(key);
- key = key.substring(prefix.length());
- frameworkProps.put(key, value);
+ URL installURL = toURL(bundle);
+ bundleURLs.add(installURL);
}
}
- framework.setProperties(frameworkProps);
+ return bundleURLs;
+ }
- // Start the Framework
- framework.start();
+ private URL toURL(String path)
+ {
+ String realPath = StringPropertyReplacer.replaceProperties(path);
+ try
+ {
+ URL pathURL = new URL(realPath);
+ return pathURL;
+ }
+ catch (MalformedURLException ex)
+ {
+ throw new IllegalStateException("Invalid path: " + path, ex);
+ }
}
public void configure(String resourceConfig)
@@ -152,4 +157,58 @@
{
throw new NotImplementedException();
}
+
+ private void initFrameworkProperties(Properties props)
+ {
+ String prefix = "framework.prop.";
+ Map<String,Object> frameworkProps = new HashMap<String,Object>();
+ Enumeration<?> keys = props.propertyNames();
+ while(keys.hasMoreElements())
+ {
+ String key = (String)keys.nextElement();
+ if (key.startsWith(prefix))
+ {
+ String value = props.getProperty(key);
+ key = key.substring(prefix.length());
+ frameworkProps.put(key, value);
+ }
+ }
+ framework.setProperties(frameworkProps);
+ }
+
+ private OSGiFramework loadFrameworkImpl(URL urlConfig, Properties props)
+ {
+ String frameworkImpl = props.getProperty(PROP_OSGI_FRAMEWORK_IMPL);
+ if (frameworkImpl == null)
+ throw new IllegalStateException("Cannot get : " + urlConfig);
+
+ OSGiFramework framework;
+ try
+ {
+ ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader();
+ Class<?> frameworkClass = ctxLoader.loadClass(frameworkImpl);
+ framework = (OSGiFramework)frameworkClass.newInstance();
+ }
+ catch (Exception ex)
+ {
+ throw new IllegalStateException("Cannot load framework: " + frameworkImpl, ex);
+ }
+ return framework;
+ }
+
+ private Properties getBootstrapProperties(URL urlConfig)
+ {
+ Properties props = new Properties();
+ try
+ {
+ InputStream inStream = urlConfig.openStream();
+ props.load(inStream);
+ inStream.close();
+ }
+ catch (IOException ex)
+ {
+ throw new IllegalStateException("Cannot load properties from: " + urlConfig, ex);
+ }
+ return props;
+ }
}
Modified: projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/bootstrap/SystemBundleTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/bootstrap/SystemBundleTestCase.java 2009-04-27 09:29:34 UTC (rev 87852)
+++ projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/bootstrap/SystemBundleTestCase.java 2009-04-27 09:32:49 UTC (rev 87853)
@@ -42,6 +42,7 @@
{
OSGiBootstrapProvider configProvider = OSGiBootstrap.getBootstrapProvider();
OSGiFramework framework = configProvider.getFramework();
+
Bundle bundle = framework.getSystemBundle();
assertEquals("BundleId == 0", 0, bundle.getBundleId());
Modified: projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/jmx/JMXTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/jmx/JMXTestCase.java 2009-04-27 09:29:34 UTC (rev 87852)
+++ projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/jmx/JMXTestCase.java 2009-04-27 09:32:49 UTC (rev 87853)
@@ -42,11 +42,11 @@
public void testMBeanAccess() throws Exception
{
OSGiFramework framework = getBootstrapProvider().getFramework();
+
try
{
BundleContext sysContext = framework.getSystemBundleContext();
- installBundle(sysContext, "bundles/jboss-osgi-jmx.jar", true);
installBundle(sysContext, "jmx-test.jar", true);
ObjectName oname = new ObjectName("jboss.osgi:service=mbean-test-service");
Modified: projects/jboss-osgi/trunk/bundle/blueprint/src/test/resources/jboss-osgi-framework.properties
===================================================================
--- projects/jboss-osgi/trunk/bundle/blueprint/src/test/resources/jboss-osgi-framework.properties 2009-04-27 09:29:34 UTC (rev 87852)
+++ projects/jboss-osgi/trunk/bundle/blueprint/src/test/resources/jboss-osgi-framework.properties 2009-04-27 09:32:49 UTC (rev 87853)
@@ -3,7 +3,23 @@
#
# $Id: $
#
+
+# The OSGiFramework implementation
framework.impl=org.jboss.osgi.felix.framework.FelixIntegration
-# properties passed on to the framework start with: 'framework.prop'
-framework.prop.org.osgi.framework.storage.clean=onFirstInit
\ No newline at end of file
+# Properties to configure the Framework
+# All props start with 'framework.prop'
+framework.prop.org.osgi.framework.storage.clean=onFirstInit
+framework.prop.org.osgi.framework.system.packages=org.jboss.logging, \
+ org.osgi.framework; version=1.4, \
+ javax.management
+
+# Bundles that need to be installed with the Framework automatically
+framework.autoInstall=file://${test.archive.directory}/bundles/org.osgi.compendium.jar
+
+# Bundles that need to be started automatically
+framework.autoStart=file://${test.archive.directory}/bundles/jboss-osgi-common.jar \
+ file://${test.archive.directory}/bundles/org.apache.felix.log.jar \
+ file://${test.archive.directory}/bundles/jboss-osgi-logging.jar \
+ file://${test.archive.directory}/bundles/jboss-osgi-jmx.jar
+
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/bundle/jmx/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/bundle/jmx/pom.xml 2009-04-27 09:29:34 UTC (rev 87852)
+++ projects/jboss-osgi/trunk/bundle/jmx/pom.xml 2009-04-27 09:32:49 UTC (rev 87853)
@@ -19,6 +19,11 @@
<dependencies>
<dependency>
<groupId>org.jboss.osgi</groupId>
+ <artifactId>jboss-osgi-common</artifactId>
+ <version>${version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.osgi</groupId>
<artifactId>jboss-osgi-spi</artifactId>
<version>${version}</version>
</dependency>
@@ -53,7 +58,9 @@
<Bundle-SymbolicName>jboss-osgi-jmx</Bundle-SymbolicName>
<Bundle-Activator>org.jboss.osgi.jmx.ServiceActivator</Bundle-Activator>
<Import-Package>
+ org.jboss.osgi.common.log,
org.osgi.framework;version=1.4,
+ org.osgi.service.log,
javax.management,
</Import-Package>
</instructions>
Modified: projects/jboss-osgi/trunk/bundle/jmx/src/main/java/org/jboss/osgi/jmx/ServiceActivator.java
===================================================================
--- projects/jboss-osgi/trunk/bundle/jmx/src/main/java/org/jboss/osgi/jmx/ServiceActivator.java 2009-04-27 09:29:34 UTC (rev 87852)
+++ projects/jboss-osgi/trunk/bundle/jmx/src/main/java/org/jboss/osgi/jmx/ServiceActivator.java 2009-04-27 09:32:49 UTC (rev 87853)
@@ -28,10 +28,12 @@
import javax.management.MBeanServer;
import javax.management.MBeanServerFactory;
+import org.jboss.osgi.common.log.LogServiceTracker;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.log.LogService;
/**
* A Service Activator that registers an MBeanServer
@@ -42,10 +44,12 @@
public class ServiceActivator implements BundleActivator
{
private ServiceRegistration registration;
+ private LogService log;
@SuppressWarnings("unchecked")
public void start(BundleContext context)
{
+ log = new LogServiceTracker(context);
ServiceReference sref = context.getServiceReference(MBeanServer.class.getName());
if (sref == null)
{
@@ -60,7 +64,7 @@
if (mbeanServer == null)
mbeanServer = MBeanServerFactory.createMBeanServer();
- System.out.println("Register MBeanServer");
+ log.log(LogService.LOG_DEBUG, "Register MBeanServer");
registration = context.registerService(MBeanServer.class.getName(), mbeanServer, null);
}
}
@@ -69,7 +73,7 @@
{
if (registration != null)
{
- System.out.println("Unregister MBeanServer");
+ log.log(LogService.LOG_DEBUG, "Unregister MBeanServer");
registration.unregister();
registration = null;
}
Modified: projects/jboss-osgi/trunk/bundle/microcontainer/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/bundle/microcontainer/pom.xml 2009-04-27 09:29:34 UTC (rev 87852)
+++ projects/jboss-osgi/trunk/bundle/microcontainer/pom.xml 2009-04-27 09:32:49 UTC (rev 87853)
@@ -6,7 +6,7 @@
<groupId>org.jboss.osgi</groupId>
<artifactId>jboss-osgi-microcontainer</artifactId>
- <packaging>jar</packaging>
+ <packaging>bundle</packaging>
<!-- Parent -->
<parent>
@@ -52,13 +52,38 @@
<Bundle-SymbolicName>jboss-osgi-microcontainer</Bundle-SymbolicName>
<Bundle-Activator>jboss-osgi-microcontainer.internal.ServiceActivator</Bundle-Activator>
<Export-Package>
- org.jboss.osgi.microcontainer;version=${version.felix.webconsole}
+ org.jboss.osgi.microcontainer;version=${version.jboss.microcontainer}
</Export-Package>
<Private-Package>
</Private-Package>
<Import-Package>
+ jboss-osgi-microcontainer.internal,
+
+ javassist*,
+ javax.naming,
+ javax.xml.bind.*,
+ org.jboss.annotation.*,
+ org.jboss.beans.*,
+ org.jboss.classadapter.spi,
+ org.jboss.classloader.*,
+ org.jboss.classloading.*,
+ org.jboss.config.*,
+ org.jboss.dependency.*,
+ org.jboss.deployers.*,
+ org.jboss.joinpoint.*,
+ org.jboss.logging,
+ org.jboss.managed.*,
+ org.jboss.metadata.*,
+ org.jboss.metatype.*,
+ org.jboss.reflect.*,
+ org.jboss.test,
+ org.jboss.util*,
+ org.jboss.virtual*,
+ org.jboss.xb.*,
+ org.xml.sax
</Import-Package>
<Embed-Dependency>
+ javassist,
jboss-deployers-client-spi,
jboss-deployers-vfs,
jboss-kernel,
Modified: projects/jboss-osgi/trunk/bundle/webconsole/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/bundle/webconsole/pom.xml 2009-04-27 09:29:34 UTC (rev 87852)
+++ projects/jboss-osgi/trunk/bundle/webconsole/pom.xml 2009-04-27 09:32:49 UTC (rev 87853)
@@ -68,7 +68,7 @@
<optional>true</optional>
</dependency>
</dependencies>
-
+
<!-- Build -->
<build>
<plugins>
@@ -87,18 +87,18 @@
<goals>
<goal>unpack</goal>
</goals>
- <configuration>
- <artifactItems>
- <artifactItem>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.webconsole</artifactId>
- <type>jar</type>
- <outputDirectory>target/classes</outputDirectory>
- </artifactItem>
- </artifactItems>
- </configuration>
</execution>
</executions>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.webconsole</artifactId>
+ <type>jar</type>
+ <outputDirectory>target/classes</outputDirectory>
+ </artifactItem>
+ </artifactItems>
+ </configuration>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
@@ -107,7 +107,8 @@
<configuration>
<instructions>
<Bundle-SymbolicName>org.jboss.osgi.service.webconsole</Bundle-SymbolicName>
- <Bundle-Activator>org.jboss.osgi.service.webconsole.internal.WebConsoleActivator</Bundle-Activator>
+ <Bundle-Activator>org.jboss.osgi.service.webconsole.internal.WebConsoleActivator
+ </Bundle-Activator>
<Export-Package>
org.apache.felix.webconsole;version=${version.felix.webconsole},
org.osgi.service.obr
@@ -126,11 +127,11 @@
</Import-Package>
<Embed-Dependency>
<!-- Import/Export-Package parsing, OBR -->
- org.apache.felix.bundlerepository,
+
<!-- Required for JSON data transfer -->
- json,
+
<!-- File Upload functionality -->
- commons-fileupload,
+
<!-- Required by FileUpload and Util -->
commons-io
</Embed-Dependency>
Modified: projects/jboss-osgi/trunk/runtime/felix/src/main/java/org/jboss/osgi/felix/framework/FelixIntegration.java
===================================================================
--- projects/jboss-osgi/trunk/runtime/felix/src/main/java/org/jboss/osgi/felix/framework/FelixIntegration.java 2009-04-27 09:29:34 UTC (rev 87852)
+++ projects/jboss-osgi/trunk/runtime/felix/src/main/java/org/jboss/osgi/felix/framework/FelixIntegration.java 2009-04-27 09:32:49 UTC (rev 87853)
@@ -86,11 +86,13 @@
public Bundle getSystemBundle()
{
+ assertFrameworkStart();
return framework;
}
public BundleContext getSystemBundleContext()
{
+ assertFrameworkStart();
return getSystemBundle().getBundleContext();
}
@@ -113,8 +115,7 @@
public void start()
{
// Create the Felix instance
- if (framework == null)
- create();
+ assertFrameworkCreate();
// Start the System Bundle
try
@@ -170,6 +171,19 @@
}
}
+ private void assertFrameworkCreate()
+ {
+ if (framework == null)
+ create();
+ }
+
+ private void assertFrameworkStart()
+ {
+ assertFrameworkCreate();
+ if ((framework.getState() & Bundle.ACTIVE) == 0)
+ start();
+ }
+
public void stop()
{
if (framework != null)
@@ -178,6 +192,7 @@
{
framework.stop();
framework.waitForStop(5000);
+ framework = null;
log.debug("SystemBundle STOPPED");
}
catch (BundleException ex)
Property changes on: projects/jboss-osgi/trunk/runtime/microcontainer
___________________________________________________________________
Name: svn:ignore
+ target
Property changes on: projects/jboss-osgi/trunk/runtime/microcontainer/osgi-int
___________________________________________________________________
Name: svn:ignore
+ target
More information about the jboss-cvs-commits
mailing list