JBoss-OSGI SVN: r95995 - in projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi: internal and 1 other directory.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-11-04 08:14:13 -0500 (Wed, 04 Nov 2009)
New Revision: 95995
Added:
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/internal/OSGiBootstrapBean.java
Modified:
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/OSGiBootstrap.java
Log:
Hide bootstrap implemenation detail
Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/OSGiBootstrap.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/OSGiBootstrap.java 2009-11-04 10:54:33 UTC (rev 95994)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/OSGiBootstrap.java 2009-11-04 13:14:13 UTC (rev 95995)
@@ -23,31 +23,12 @@
//$Id$
-import static org.jboss.osgi.spi.OSGiConstants.OSGI_HOME;
-import static org.jboss.osgi.spi.OSGiConstants.OSGI_SERVER_HOME;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.Enumeration;
-import java.util.List;
-import java.util.Properties;
-
-import org.jboss.osgi.spi.util.ServiceLoader;
+import org.jboss.osgi.spi.internal.OSGiBootstrapBean;
import org.kohsuke.args4j.CmdLineException;
import org.kohsuke.args4j.CmdLineParser;
-import org.kohsuke.args4j.Option;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.launch.Framework;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
- * The OSGiBootstrap provides an {@link OSGiFramework} through a {@link OSGiBootstrapProvider}.
+ * The OSGiBootstrap is the entry point to obtain an {@link OSGiBootstrapProvider}.
*
* A OSGiBootstrapProvider is discovered in two stages.
*
@@ -63,27 +44,12 @@
*/
public class OSGiBootstrap
{
- private static Logger log;
-
- private static final String JAVA_PROTOCOL_HANDLERS = "java.protocol.handler.pkgs";
- private static final String JBOSS_BIND_ADDRESS = "jboss.bind.address";
- private static final String OSGI_SERVER_NAME = "osgi.server.name";
-
- @Option(name = "-c", aliases = { "--server-name" }, usage = "The runtime profile to start. (-c minimal)", required = false)
- public String serverName = "default";
-
- @Option(name = "-b", aliases = { "--bind-address" }, usage = "The network address various services can bind to (-b 127.0.0.1)", required = false)
- public String bindAddress = "localhost";
-
- private String osgiHome;
- private String osgiServerHome;
-
- /*
+ /**
* The main entry point
*/
public static void main(String[] args)
{
- OSGiBootstrap bean = new OSGiBootstrap();
+ OSGiBootstrapBean bean = new OSGiBootstrapBean();
CmdLineParser parser = new CmdLineParser(bean);
try
{
@@ -97,172 +63,11 @@
}
}
- public void run()
- {
- initBootstrap();
-
- OSGiBootstrapProvider bootProvider = getBootstrapProvider();
- Framework framework = bootProvider.getFramework();
-
- Runtime runtime = Runtime.getRuntime();
- runtime.addShutdownHook(new ShutdownThread(framework));
-
- Thread thread = new StartupThread(framework);
- thread.start();
- }
-
- private void initBootstrap()
- {
- osgiHome = System.getProperty(OSGI_HOME);
- if (osgiHome == null)
- throw new IllegalStateException("Cannot obtain system property: '" + OSGI_HOME + "'");
-
- osgiServerHome = osgiHome + "/server/" + serverName;
-
- // Replace the context class loader with one that contains the server conf dir
- File serverConfDir = new File(osgiServerHome + "/conf");
- if (serverConfDir.exists())
- {
- ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader();
- URLClassLoader confLoader = new URLClassLoader(new URL[] { toURL(serverConfDir) }, ctxLoader);
- Thread.currentThread().setContextClassLoader(confLoader);
- }
-
- // This property must be set before the logger is obtained
- System.setProperty(OSGI_SERVER_HOME, osgiServerHome);
- log = LoggerFactory.getLogger(OSGiBootstrap.class);
-
- Properties defaults = new Properties();
- defaults.setProperty(OSGI_SERVER_NAME, serverName);
- defaults.setProperty(OSGI_SERVER_HOME, osgiServerHome);
- defaults.setProperty(JBOSS_BIND_ADDRESS, bindAddress);
- defaults.setProperty(JAVA_PROTOCOL_HANDLERS, "org.jboss.net.protocol|org.jboss.virtual.protocol");
-
- log.debug("JBoss OSGi System Properties");
- log.debug(" " + OSGI_SERVER_HOME + "=" + osgiServerHome);
-
- Enumeration<?> defaultNames = defaults.propertyNames();
- while (defaultNames.hasMoreElements())
- {
- String propName = (String)defaultNames.nextElement();
- String sysValue = System.getProperty(propName);
- if (sysValue == null)
- {
- String propValue = defaults.getProperty(propName);
- System.setProperty(propName, propValue);
- log.debug(" " + propName + "=" + propValue);
- }
- }
- }
-
- /*
+ /**
* Get an instance of an OSGiBootstrapProvider.
*/
public static OSGiBootstrapProvider getBootstrapProvider()
{
- if (log == null)
- log = LoggerFactory.getLogger(OSGiBootstrap.class);
-
- OSGiBootstrapProvider provider = null;
-
- List<OSGiBootstrapProvider> providers = ServiceLoader.loadServices(OSGiBootstrapProvider.class);
- for (OSGiBootstrapProvider aux : providers)
- {
- try
- {
- aux.configure();
- provider = aux;
- break;
- }
- catch (Exception ex)
- {
- log.debug("Cannot configure [" + aux.getClass().getName() + "]", ex);
- }
- }
-
- if (provider == null)
- {
- provider = new PropertiesBootstrapProvider();
- log.debug("Using default: " + PropertiesBootstrapProvider.class.getName());
- }
-
- return provider;
+ return OSGiBootstrapBean.getBootstrapProvider();
}
-
- private URL toURL(File file)
- {
- try
- {
- return file.toURL();
- }
- catch (MalformedURLException e)
- {
- throw new IllegalArgumentException("Invalid file: " + file);
- }
- }
-
- class StartupThread extends Thread
- {
- private Framework framework;
-
- public StartupThread(Framework framework)
- {
- this.framework = framework;
- }
-
- public void run()
- {
- // Start the framework
- long beforeStart = System.currentTimeMillis();
- try
- {
- framework.start();
- }
- catch (BundleException ex)
- {
- throw new IllegalStateException("Cannot start framework", ex);
- }
-
- float diff = (System.currentTimeMillis() - beforeStart) / 1000f;
- log.info("JBossOSGi Runtime booted in " + diff + "sec");
-
- Reader br = new InputStreamReader(System.in);
- try
- {
- int inByte = br.read();
- while (inByte != 0)
- {
- inByte = br.read();
- }
- }
- catch (IOException ioe)
- {
- // ignore user input
- }
- }
- }
-
- class ShutdownThread extends Thread
- {
- private Framework framework;
-
- public ShutdownThread(Framework framework)
- {
- this.framework = framework;
- }
-
- public void run()
- {
- log.info("Initiating shutdown ...");
- try
- {
- framework.stop();
- }
- catch (BundleException ex)
- {
- log.error("Cannot stop framework", ex);
- }
- log.info("Shutdown complete");
- }
- }
}
\ No newline at end of file
Added: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/internal/OSGiBootstrapBean.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/internal/OSGiBootstrapBean.java (rev 0)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/internal/OSGiBootstrapBean.java 2009-11-04 13:14:13 UTC (rev 95995)
@@ -0,0 +1,238 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.spi.internal;
+
+//$Id$
+
+import static org.jboss.osgi.spi.OSGiConstants.OSGI_HOME;
+import static org.jboss.osgi.spi.OSGiConstants.OSGI_SERVER_HOME;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.Properties;
+
+import org.jboss.osgi.spi.framework.OSGiBootstrap;
+import org.jboss.osgi.spi.framework.OSGiBootstrapProvider;
+import org.jboss.osgi.spi.framework.PropertiesBootstrapProvider;
+import org.jboss.osgi.spi.util.ServiceLoader;
+import org.kohsuke.args4j.Option;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.launch.Framework;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * An internal bean that collabrates with {@link OSGiBootstrap}.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 04-Nov-2008
+ */
+public class OSGiBootstrapBean
+{
+ private static Logger log;
+
+ private static final String JAVA_PROTOCOL_HANDLERS = "java.protocol.handler.pkgs";
+ private static final String JBOSS_BIND_ADDRESS = "jboss.bind.address";
+ private static final String OSGI_SERVER_NAME = "osgi.server.name";
+
+ @Option(name = "-c", aliases = { "--server-name" }, usage = "The runtime profile to start. (-c minimal)", required = false)
+ public String serverName = "default";
+
+ @Option(name = "-b", aliases = { "--bind-address" }, usage = "The network address various services can bind to (-b 127.0.0.1)", required = false)
+ public String bindAddress = "localhost";
+
+ private String osgiHome;
+ private String osgiServerHome;
+
+ public void run()
+ {
+ initBootstrap();
+
+ OSGiBootstrapProvider bootProvider = getBootstrapProvider();
+ Framework framework = bootProvider.getFramework();
+
+ Runtime runtime = Runtime.getRuntime();
+ runtime.addShutdownHook(new ShutdownThread(framework));
+
+ Thread thread = new StartupThread(framework);
+ thread.start();
+ }
+
+ private void initBootstrap()
+ {
+ osgiHome = System.getProperty(OSGI_HOME);
+ if (osgiHome == null)
+ throw new IllegalStateException("Cannot obtain system property: '" + OSGI_HOME + "'");
+
+ osgiServerHome = osgiHome + "/server/" + serverName;
+
+ // Replace the context class loader with one that contains the server conf dir
+ File serverConfDir = new File(osgiServerHome + "/conf");
+ if (serverConfDir.exists())
+ {
+ ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader();
+ URLClassLoader confLoader = new URLClassLoader(new URL[] { toURL(serverConfDir) }, ctxLoader);
+ Thread.currentThread().setContextClassLoader(confLoader);
+ }
+
+ // This property must be set before the logger is obtained
+ System.setProperty(OSGI_SERVER_HOME, osgiServerHome);
+ log = LoggerFactory.getLogger(OSGiBootstrapBean.class);
+
+ Properties defaults = new Properties();
+ defaults.setProperty(OSGI_SERVER_NAME, serverName);
+ defaults.setProperty(OSGI_SERVER_HOME, osgiServerHome);
+ defaults.setProperty(JBOSS_BIND_ADDRESS, bindAddress);
+ defaults.setProperty(JAVA_PROTOCOL_HANDLERS, "org.jboss.net.protocol|org.jboss.virtual.protocol");
+
+ log.debug("JBoss OSGi System Properties");
+ log.debug(" " + OSGI_SERVER_HOME + "=" + osgiServerHome);
+
+ Enumeration<?> defaultNames = defaults.propertyNames();
+ while (defaultNames.hasMoreElements())
+ {
+ String propName = (String)defaultNames.nextElement();
+ String sysValue = System.getProperty(propName);
+ if (sysValue == null)
+ {
+ String propValue = defaults.getProperty(propName);
+ System.setProperty(propName, propValue);
+ log.debug(" " + propName + "=" + propValue);
+ }
+ }
+ }
+
+ public static OSGiBootstrapProvider getBootstrapProvider()
+ {
+ if (log == null)
+ log = LoggerFactory.getLogger(OSGiBootstrap.class);
+
+ OSGiBootstrapProvider provider = null;
+
+ List<OSGiBootstrapProvider> providers = ServiceLoader.loadServices(OSGiBootstrapProvider.class);
+ for (OSGiBootstrapProvider aux : providers)
+ {
+ try
+ {
+ aux.configure();
+ provider = aux;
+ break;
+ }
+ catch (Exception ex)
+ {
+ log.debug("Cannot configure [" + aux.getClass().getName() + "]", ex);
+ }
+ }
+
+ if (provider == null)
+ {
+ provider = new PropertiesBootstrapProvider();
+ log.debug("Using default: " + PropertiesBootstrapProvider.class.getName());
+ }
+
+ return provider;
+ }
+
+ private URL toURL(File file)
+ {
+ try
+ {
+ return file.toURL();
+ }
+ catch (MalformedURLException e)
+ {
+ throw new IllegalArgumentException("Invalid file: " + file);
+ }
+ }
+
+ class StartupThread extends Thread
+ {
+ private Framework framework;
+
+ public StartupThread(Framework framework)
+ {
+ this.framework = framework;
+ }
+
+ public void run()
+ {
+ // Start the framework
+ long beforeStart = System.currentTimeMillis();
+ try
+ {
+ framework.start();
+ }
+ catch (BundleException ex)
+ {
+ throw new IllegalStateException("Cannot start framework", ex);
+ }
+
+ float diff = (System.currentTimeMillis() - beforeStart) / 1000f;
+ log.info("JBossOSGi Runtime booted in " + diff + "sec");
+
+ Reader br = new InputStreamReader(System.in);
+ try
+ {
+ int inByte = br.read();
+ while (inByte != 0)
+ {
+ inByte = br.read();
+ }
+ }
+ catch (IOException ioe)
+ {
+ // ignore user input
+ }
+ }
+ }
+
+ class ShutdownThread extends Thread
+ {
+ private Framework framework;
+
+ public ShutdownThread(Framework framework)
+ {
+ this.framework = framework;
+ }
+
+ public void run()
+ {
+ log.info("Initiating shutdown ...");
+ try
+ {
+ framework.stop();
+ }
+ catch (BundleException ex)
+ {
+ log.error("Cannot stop framework", ex);
+ }
+ log.info("Shutdown complete");
+ }
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/internal/OSGiBootstrapBean.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
14 years, 7 months
JBoss-OSGI SVN: r95962 - projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-11-03 11:17:50 -0500 (Tue, 03 Nov 2009)
New Revision: 95962
Modified:
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/OSGiBootstrap.java
Log:
Fix typo
Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/OSGiBootstrap.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/OSGiBootstrap.java 2009-11-03 16:12:38 UTC (rev 95961)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/OSGiBootstrap.java 2009-11-03 16:17:50 UTC (rev 95962)
@@ -73,7 +73,7 @@
public String serverName = "default";
@Option(name = "-b", aliases = { "--bind-address" }, usage = "The network address various services can bind to (-b 127.0.0.1)", required = false)
- public String bindAdress = "localhost";
+ public String bindAddress = "localhost";
private String osgiHome;
private String osgiServerHome;
@@ -135,7 +135,7 @@
Properties defaults = new Properties();
defaults.setProperty(OSGI_SERVER_NAME, serverName);
defaults.setProperty(OSGI_SERVER_HOME, osgiServerHome);
- defaults.setProperty(JBOSS_BIND_ADDRESS, bindAdress);
+ defaults.setProperty(JBOSS_BIND_ADDRESS, bindAddress);
defaults.setProperty(JAVA_PROTOCOL_HANDLERS, "org.jboss.net.protocol|org.jboss.virtual.protocol");
log.debug("JBoss OSGi System Properties");
14 years, 7 months
JBoss-OSGI SVN: r95960 - in projects/jboss-osgi/trunk/reactor/framework: src/main and 3 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: adrian(a)jboss.org
Date: 2009-11-03 11:11:57 -0500 (Tue, 03 Nov 2009)
New Revision: 95960
Added:
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/metadata/internal/ManifestParser.java
Removed:
projects/jboss-osgi/trunk/reactor/framework/src/main/javacc/
Modified:
projects/jboss-osgi/trunk/reactor/framework/.classpath
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/metadata/internal/AbstractOSGiMetaData.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/metadata/internal/PackageAttributeListValueCreator.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/metadata/internal/PathAttributeListValueCreator.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/metadata/internal/QNameAttributeListValueCreator.java
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/bundle/metadata/HeaderValuesTestCase.java
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/classloader/test/ExportImportPackageUnitTestCase.java
Log:
[JBOSGI-137] [JBOSGI-153] - Fix the manifest parsing
Modified: projects/jboss-osgi/trunk/reactor/framework/.classpath
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/.classpath 2009-11-03 16:04:08 UTC (rev 95959)
+++ projects/jboss-osgi/trunk/reactor/framework/.classpath 2009-11-03 16:11:57 UTC (rev 95960)
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java"/>
- <classpathentry kind="src" path="target/generated-sources/javacc"/>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/>
Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/metadata/internal/AbstractOSGiMetaData.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/metadata/internal/AbstractOSGiMetaData.java 2009-11-03 16:04:08 UTC (rev 95959)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/metadata/internal/AbstractOSGiMetaData.java 2009-11-03 16:11:57 UTC (rev 95960)
@@ -176,10 +176,6 @@
ParameterizedAttribute parameters = parseSymbolicName();
if (parameters != null)
symbolicName = parameters.getAttribute();
-
- // [TODO] [JBOSGI-137] Cannot parse Bundle-SymbolicName
- if (symbolicName == null)
- symbolicName = getMainAttribute(Constants.BUNDLE_SYMBOLICNAME);
return symbolicName;
}
Added: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/metadata/internal/ManifestParser.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/metadata/internal/ManifestParser.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/metadata/internal/ManifestParser.java 2009-11-03 16:11:57 UTC (rev 95960)
@@ -0,0 +1,267 @@
+/*
+* 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.
+*/
+
+// This class is based on some original classes from
+// Apache Felix which is licensed as below
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.jboss.osgi.framework.metadata.internal;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.jboss.osgi.framework.metadata.PackageAttribute;
+import org.jboss.osgi.framework.metadata.Parameter;
+import org.jboss.osgi.framework.metadata.ParameterizedAttribute;
+
+/**
+ * ManifestParser.
+ *
+ * @author <a href="adrian(a)jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class ManifestParser
+{
+ /**
+ * Parse packages
+ *
+ * @param header the header
+ * @param list the list of packages to create
+ */
+ public static void parsePackages(String header, List<PackageAttribute> list)
+ {
+ parse(header, list, true);
+ }
+
+ /**
+ * Parse parameters
+ *
+ * @param header the header
+ * @param list the list of parameters to create
+ */
+ public static void parseParameters(String header, List<ParameterizedAttribute> list)
+ {
+ parse(header, list, false);
+ }
+
+ /**
+ * Parse paths
+ *
+ * @param header the header
+ * @param list the list of paths to create
+ */
+ public static void parsePaths(String header, List<ParameterizedAttribute> list)
+ {
+ parse(header, list, false);
+ }
+
+ /**
+ * Parse a header
+ *
+ * @param header the header
+ * @param list the list to create
+ * @param packages whether to create packages
+ */
+ @SuppressWarnings("unchecked")
+ public static void parse(String header, List list, boolean packages)
+ {
+ if (header == null)
+ return;
+ if (header.length() == 0)
+ throw new IllegalArgumentException("Empty header");
+
+ // Split the header into clauses using which are seperated by commas
+ // Like this: path; path; dir1:=dirval1; dir2:=dirval2; attr1=attrval1; attr2=attrval2,
+ // path; path; dir1:=dirval1; dir2:=dirval2; attr1=attrval1; attr2=attrval2
+ List<String> clauses = parseDelimitedString(header, ",");
+
+ // Now parse each clause
+ for (String clause : clauses)
+ {
+ // Split the cause into paths, directives and attributes using the semi-colon
+ // Like this: path; path; dir1:=dirval1; dir2:=dirval2; attr1=attrval1; attr2=attrval2
+ List<String> pieces = parseDelimitedString(clause, ";");
+
+ // Collect the paths they should be first
+ List<String> paths = new ArrayList<String>();
+ for (String piece : pieces)
+ {
+ if (piece.indexOf('=') >= 0)
+ break;
+ paths.add(unquote(piece));
+ }
+ if (paths.isEmpty())
+ throw new IllegalArgumentException("No paths for " + clause);
+
+ Map<String, Parameter> directives = null;
+ Map<String, Parameter> attributes = null;
+
+ for (int i = paths.size(); i < pieces.size(); ++i)
+ {
+ String piece = pieces.get(i);
+ int seperator = piece.indexOf(":=");
+ if (seperator >= 0)
+ {
+ String name = piece.substring(0, seperator);
+ String value = piece.substring(seperator + 2);
+ if (directives == null)
+ directives = new HashMap<String, Parameter>();
+ directives.put(unquote(name), new AbstractParameter(unquote(value)));
+ }
+ else
+ {
+ seperator = piece.indexOf("=");
+ if (seperator >= 0)
+ {
+ String name = piece.substring(0, seperator);
+ String value = piece.substring(seperator + 1);
+ if (attributes == null)
+ attributes = new HashMap<String, Parameter>();
+ attributes.put(unquote(name), new AbstractParameter(unquote(value)));
+ }
+ else
+ {
+ throw new IllegalArgumentException("Path " + piece + " should appear before attributes and directives in " + clause);
+ }
+ }
+ }
+
+ // TODO JBOSGI-200 replace with seperate attribute and directives in the metadata
+ if (attributes == null)
+ attributes = new HashMap<String, Parameter>();
+ if (directives != null)
+ attributes.putAll(directives);
+ // END JBOSGI-200
+
+ for (String path : paths)
+ {
+ ParameterizedAttribute metadata = null;
+ if (packages)
+ metadata = new AbstractPackageAttribute(path, attributes);
+ else
+ metadata = new AbstractParameterizedAttribute(path, attributes);
+
+ list.add(metadata);
+ }
+
+ }
+ }
+
+ /**
+ * Remove around quotes around a string
+ *
+ * @param string the string
+ * @return the unquoted string
+ */
+ private static String unquote(String string)
+ {
+ if (string.length() < 2)
+ return string;
+ if (string.charAt(0) == '\"' && string.charAt(string.length()-1) == '\"')
+ return string.substring(1, string.length()-1);
+ return string;
+ }
+
+ /**
+ * Parses delimited string and returns an array containing the tokens. This
+ * parser obeys quotes, so the delimiter character will be ignored if it is
+ * inside of a quote. This method assumes that the quote character is not
+ * included in the set of delimiter characters.
+ * @param value the delimited string to parse.
+ * @param delim the characters delimiting the tokens.
+ * @return an array of string tokens or null if there were no tokens.
+ **/
+ private static List<String> parseDelimitedString(String value, String delim)
+ {
+ if (value == null)
+ value = "";
+
+ List<String> list = new ArrayList<String>();
+
+ int CHAR = 1;
+ int DELIMITER = 2;
+ int STARTQUOTE = 4;
+ int ENDQUOTE = 8;
+
+ StringBuilder sb = new StringBuilder();
+
+ int expecting = (CHAR | DELIMITER | STARTQUOTE);
+
+ for (int i = 0; i < value.length(); i++)
+ {
+ char c = value.charAt(i);
+
+ boolean isDelimiter = (delim.indexOf(c) >= 0);
+ boolean isQuote = (c == '"');
+
+ if (isDelimiter && ((expecting & DELIMITER) > 0))
+ {
+ list.add(sb.toString().trim());
+ sb.delete(0, sb.length());
+ expecting = (CHAR | DELIMITER | STARTQUOTE);
+ }
+ else if (isQuote && ((expecting & STARTQUOTE) > 0))
+ {
+ sb.append(c);
+ expecting = CHAR | ENDQUOTE;
+ }
+ else if (isQuote && ((expecting & ENDQUOTE) > 0))
+ {
+ sb.append(c);
+ expecting = (CHAR | STARTQUOTE | DELIMITER);
+ }
+ else if ((expecting & CHAR) > 0)
+ {
+ sb.append(c);
+ }
+ else
+ {
+ throw new IllegalArgumentException("Invalid delimited string: '" + value + "' delimiter=" + delim);
+ }
+ }
+
+ if (sb.length() > 0)
+ list.add(sb.toString().trim());
+
+ return list;
+ }
+
+}
Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/metadata/internal/PackageAttributeListValueCreator.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/metadata/internal/PackageAttributeListValueCreator.java 2009-11-03 16:04:08 UTC (rev 95959)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/metadata/internal/PackageAttributeListValueCreator.java 2009-11-03 16:11:57 UTC (rev 95960)
@@ -36,14 +36,7 @@
public List<PackageAttribute> useString(String attibute)
{
List<PackageAttribute> list = new ArrayList<PackageAttribute>();
- try
- {
- HeaderValue.parsePackages(attibute, list, log.isTraceEnabled());
- }
- catch (ParseException e)
- {
- log.error("Exception parsing package headers.", e);
- }
+ ManifestParser.parsePackages(attibute, list);
return list;
}
}
Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/metadata/internal/PathAttributeListValueCreator.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/metadata/internal/PathAttributeListValueCreator.java 2009-11-03 16:04:08 UTC (rev 95959)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/metadata/internal/PathAttributeListValueCreator.java 2009-11-03 16:11:57 UTC (rev 95960)
@@ -34,13 +34,6 @@
{
protected void parseAttribute(String attribute, List<ParameterizedAttribute> list, boolean trace)
{
- try
- {
- HeaderValue.parsePaths(attribute, list, trace);
- }
- catch (ParseException e)
- {
- log.error("Exception parsing parameters.", e);
- }
+ ManifestParser.parsePaths(attribute, list);
}
}
Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/metadata/internal/QNameAttributeListValueCreator.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/metadata/internal/QNameAttributeListValueCreator.java 2009-11-03 16:04:08 UTC (rev 95959)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/metadata/internal/QNameAttributeListValueCreator.java 2009-11-03 16:11:57 UTC (rev 95960)
@@ -34,13 +34,6 @@
{
protected void parseAttribute(String attribute, List<ParameterizedAttribute> list, boolean trace)
{
- try
- {
- HeaderValue.parseParameters(attribute, list, trace);
- }
- catch (ParseException e)
- {
- log.debug("Exception parsing parameters.", e);
- }
+ ManifestParser.parseParameters(attribute, list);
}
}
Modified: projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/bundle/metadata/HeaderValuesTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/bundle/metadata/HeaderValuesTestCase.java 2009-11-03 16:04:08 UTC (rev 95959)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/bundle/metadata/HeaderValuesTestCase.java 2009-11-03 16:11:57 UTC (rev 95960)
@@ -149,7 +149,7 @@
exportPackages.add(new AbstractPackageAttribute("org.osgi.util.tracker", ep1));
exportPackages.add(new AbstractPackageAttribute("net.osgi.foo", ep1));
Map<String, Parameter> ep2 = new HashMap<String, Parameter>();
- ep2.put("version", new AbstractParameter("\"[1.0,2.0)\""));
+ ep2.put("version", new AbstractParameter("[1.0,2.0)"));
exportPackages.add(new AbstractPackageAttribute("org.jboss.test", ep2));
List<PackageAttribute> metadataExport = metaData.getExportPackages();
assertNotNull(metadataExport);
@@ -189,7 +189,7 @@
importPackages.add(new AbstractPackageAttribute("org.osgi.util.tracker", ip1));
importPackages.add(new AbstractPackageAttribute("org.osgi.service.io", ip1));
Map<String, Parameter> ip2 = new HashMap<String, Parameter>();
- ip2.put("version", new AbstractParameter("\"[2.0,3.0)\""));
+ ip2.put("version", new AbstractParameter("[2.0,3.0)"));
ip2.put("resolution", new AbstractParameter("osgi-int"));
importPackages.add(new AbstractPackageAttribute("org.jboss.test", ip2));
List<PackageAttribute> metadataImport = metaData.getImportPackages();
Modified: projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/classloader/test/ExportImportPackageUnitTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/classloader/test/ExportImportPackageUnitTestCase.java 2009-11-03 16:04:08 UTC (rev 95959)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/classloader/test/ExportImportPackageUnitTestCase.java 2009-11-03 16:11:57 UTC (rev 95960)
@@ -314,9 +314,7 @@
try
{
bundle2.start();
- System.out.println("FIXME [JBOSGI-153] Cannot parse Import-Package parameters");
- //assertLoadClass(bundle2, A.class, bundle1);
-
+ assertLoadClass(bundle2, A.class, bundle1);
assertLoadClass(bundle2, B.class, bundle2);
}
finally
14 years, 7 months
JBoss-OSGI SVN: r95951 - in projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework: deployers and 3 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: adrian(a)jboss.org
Date: 2009-11-03 08:51:24 -0500 (Tue, 03 Nov 2009)
New Revision: 95951
Modified:
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/deployers/OSGiDeployersWrapper.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/metadata/internal/AbstractOSGiMetaData.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/metadata/internal/OSGiParameters.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/plugins/internal/AutoInstallPluginImpl.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/BundleCapability.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/BundleResolver.java
Log:
[JBOSGI-199] - Use thread safe collections for mutable info
Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java 2009-11-03 13:50:39 UTC (rev 95950)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java 2009-11-03 13:51:24 UTC (rev 95951)
@@ -36,13 +36,13 @@
import java.util.Collections;
import java.util.Comparator;
import java.util.Dictionary;
-import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
+import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
@@ -151,10 +151,10 @@
private OSGiSystemState systemBundle;
/** The registered manager plugins */
- private Map<Class<?>, Plugin> plugins = new LinkedHashMap<Class<?>, Plugin>();
+ private Map<Class<?>, Plugin> plugins = Collections.synchronizedMap(new LinkedHashMap<Class<?>, Plugin>());
/** The frame work properties */
- private Map<String, Object> properties = new HashMap<String, Object>();
+ private Map<String, Object> properties = new ConcurrentHashMap<String, Object>();
static
{
Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/deployers/OSGiDeployersWrapper.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/deployers/OSGiDeployersWrapper.java 2009-11-03 13:50:39 UTC (rev 95950)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/deployers/OSGiDeployersWrapper.java 2009-11-03 13:51:24 UTC (rev 95951)
@@ -23,10 +23,10 @@
import static org.jboss.osgi.spi.OSGiConstants.PROPERTY_AUTO_START;
-import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
+import java.util.concurrent.CopyOnWriteArrayList;
import org.jboss.deployers.client.spi.Deployment;
import org.jboss.deployers.client.spi.main.MainDeployer;
@@ -63,7 +63,7 @@
private PackageAdmin packageAdmin;
/** The list of unresolved bundles */
- private List<OSGiBundleState> unresolvedBundles = new ArrayList<OSGiBundleState>();
+ private List<OSGiBundleState> unresolvedBundles = new CopyOnWriteArrayList<OSGiBundleState>();
public OSGiDeployersWrapper(MainDeployer mainDeployer, OSGiBundleManager bundleManager)
{
Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/metadata/internal/AbstractOSGiMetaData.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/metadata/internal/AbstractOSGiMetaData.java 2009-11-03 13:50:39 UTC (rev 95950)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/metadata/internal/AbstractOSGiMetaData.java 2009-11-03 13:51:24 UTC (rev 95951)
@@ -53,11 +53,11 @@
import java.net.URL;
import java.util.Arrays;
import java.util.Dictionary;
-import java.util.HashMap;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.concurrent.ConcurrentHashMap;
import java.util.jar.Manifest;
import java.util.jar.Attributes.Name;
@@ -90,7 +90,7 @@
registry.registerVersionComparator(Version.class, String.class, new OSGiVersionToStringComparator());
}
- protected transient Map<String, Object> cachedAttributes = new HashMap<String, Object>();
+ protected transient Map<String, Object> cachedAttributes = new ConcurrentHashMap<String, Object>();
protected transient ParameterizedAttribute parameters;
Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/metadata/internal/OSGiParameters.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/metadata/internal/OSGiParameters.java 2009-11-03 13:50:39 UTC (rev 95950)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/metadata/internal/OSGiParameters.java 2009-11-03 13:51:24 UTC (rev 95951)
@@ -21,17 +21,23 @@
*/
package org.jboss.osgi.framework.metadata.internal;
+import static org.osgi.framework.Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE;
+import static org.osgi.framework.Constants.BUNDLE_VERSION_ATTRIBUTE;
+import static org.osgi.framework.Constants.RESOLUTION_DIRECTIVE;
+import static org.osgi.framework.Constants.RESOLUTION_MANDATORY;
+import static org.osgi.framework.Constants.VERSION_ATTRIBUTE;
+import static org.osgi.framework.Constants.VISIBILITY_DIRECTIVE;
+import static org.osgi.framework.Constants.VISIBILITY_PRIVATE;
+
import java.util.Collection;
import java.util.Collections;
-import java.util.HashMap;
import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
import org.jboss.logging.Logger;
import org.jboss.osgi.framework.metadata.Parameter;
import org.jboss.osgi.framework.metadata.VersionRange;
-import static org.osgi.framework.Constants.*;
-
/**
* OSGi parameter values.
* Util for transforming parameter info to actual useful values.
@@ -48,7 +54,7 @@
public OSGiParameters(Map<String, Parameter> parameters)
{
this.parameters = Collections.unmodifiableMap(parameters);
- this.cachedAttributes = new HashMap<String, Object>();
+ this.cachedAttributes = new ConcurrentHashMap<String, Object>();
}
protected Map<String, Parameter> getParameters()
Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/plugins/internal/AutoInstallPluginImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/plugins/internal/AutoInstallPluginImpl.java 2009-11-03 13:50:39 UTC (rev 95950)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/plugins/internal/AutoInstallPluginImpl.java 2009-11-03 13:51:24 UTC (rev 95951)
@@ -24,9 +24,9 @@
//$Id$
import java.net.URL;
-import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
import org.jboss.logging.Logger;
import org.jboss.osgi.framework.bundle.OSGiBundleManager;
@@ -48,7 +48,7 @@
private List<URL> autoInstall;
private List<URL> autoStart;
- private Map<URL, Bundle> autoBundles = new HashMap<URL, Bundle>();
+ private Map<URL, Bundle> autoBundles = new ConcurrentHashMap<URL, Bundle>();
public AutoInstallPluginImpl(OSGiBundleManager bundleManager)
{
Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/BundleCapability.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/BundleCapability.java 2009-11-03 13:50:39 UTC (rev 95950)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/BundleCapability.java 2009-11-03 13:51:24 UTC (rev 95951)
@@ -21,9 +21,9 @@
*/
package org.jboss.osgi.framework.resolver;
-import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
import org.jboss.classloading.plugins.metadata.PackageCapability;
import org.jboss.classloading.spi.dependency.Module;
@@ -90,7 +90,7 @@
void wireRequirement(BundleRequirement bundleRequirement)
{
if (wires == null)
- wires = new ArrayList<BundleRequirement>();
+ wires = new CopyOnWriteArrayList<BundleRequirement>();
wires.add(bundleRequirement);
}
Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/BundleResolver.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/BundleResolver.java 2009-11-03 13:50:39 UTC (rev 95950)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/BundleResolver.java 2009-11-03 13:51:24 UTC (rev 95951)
@@ -23,10 +23,10 @@
import java.util.ArrayList;
import java.util.Collections;
-import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
import org.jboss.classloading.plugins.metadata.PackageCapability;
import org.jboss.classloading.plugins.metadata.PackageRequirement;
@@ -60,8 +60,8 @@
private static final Logger log = Logger.getLogger(BundleResolver.class);
private OSGiBundleManager bundleManager;
- private Map<OSGiBundleState, List<BundleCapability>> bundleCapabilitiesMap = new HashMap<OSGiBundleState, List<BundleCapability>>();
- private Map<OSGiBundleState, List<BundleRequirement>> bundleRequirementsMap = new HashMap<OSGiBundleState, List<BundleRequirement>>();
+ private Map<OSGiBundleState, List<BundleCapability>> bundleCapabilitiesMap = new ConcurrentHashMap<OSGiBundleState, List<BundleCapability>>();
+ private Map<OSGiBundleState, List<BundleRequirement>> bundleRequirementsMap = new ConcurrentHashMap<OSGiBundleState, List<BundleRequirement>>();
public BundleResolver(OSGiBundleManager bundleManager)
{
14 years, 7 months
JBoss-OSGI SVN: r95950 - projects/jboss-osgi/trunk/reactor/framework/src/test/resources.
by jboss-osgi-commits@lists.jboss.org
Author: adrian(a)jboss.org
Date: 2009-11-03 08:50:39 -0500 (Tue, 03 Nov 2009)
New Revision: 95950
Modified:
projects/jboss-osgi/trunk/reactor/framework/src/test/resources/log4j.xml
Log:
Broken log4j again
Modified: projects/jboss-osgi/trunk/reactor/framework/src/test/resources/log4j.xml
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/resources/log4j.xml 2009-11-03 13:10:12 UTC (rev 95949)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/resources/log4j.xml 2009-11-03 13:50:39 UTC (rev 95950)
@@ -8,7 +8,7 @@
<!-- ================================= -->
<appender name="FILE" class="org.apache.log4j.FileAppender">
- <param name="File" value="${log4j.output.dir}/test.log"/>
+ <param name="File" value="${java.io.tmpdir}/test.log"/>
<param name="Append" value="false"/>
<layout class="org.apache.log4j.PatternLayout">
<!-- The default pattern: Date Priority [Category] Message\n -->
@@ -22,7 +22,7 @@
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
<param name="Target" value="System.out" />
- <param name="Threshold" value="INFO" />
+ <param name="Threshold" value="DEBUG" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{HH:mm:ss,SSS} %-5p [%c{1}] %m%n" />
</layout>
@@ -43,7 +43,7 @@
<!-- ======================= -->
<root>
- <!--appender-ref ref="CONSOLE"/-->
+ <appender-ref ref="CONSOLE"/>
<appender-ref ref="FILE"/>
</root>
14 years, 7 months
JBoss-OSGI SVN: r95949 - projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/bundle/metadata.
by jboss-osgi-commits@lists.jboss.org
Author: adrian(a)jboss.org
Date: 2009-11-03 08:10:12 -0500 (Tue, 03 Nov 2009)
New Revision: 95949
Modified:
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/bundle/metadata/HeaderValuesTestCase.java
Log:
Source code tidyup and fix the eclipse build
Modified: projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/bundle/metadata/HeaderValuesTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/bundle/metadata/HeaderValuesTestCase.java 2009-11-03 13:09:52 UTC (rev 95948)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/bundle/metadata/HeaderValuesTestCase.java 2009-11-03 13:10:12 UTC (rev 95949)
@@ -21,6 +21,7 @@
*/
package org.jboss.test.bundle.metadata;
+import java.io.Serializable;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
@@ -28,10 +29,7 @@
import java.util.List;
import java.util.Map;
import java.util.jar.Manifest;
-import java.io.Serializable;
-import junit.framework.Test;
-
import org.jboss.osgi.framework.metadata.ActivationPolicyMetaData;
import org.jboss.osgi.framework.metadata.OSGiMetaData;
import org.jboss.osgi.framework.metadata.PackageAttribute;
14 years, 7 months
JBoss-OSGI SVN: r95948 - in projects/jboss-osgi/trunk/reactor/framework: src/main/java/org/jboss/osgi/framework/bundle and 8 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: adrian(a)jboss.org
Date: 2009-11-03 08:09:52 -0500 (Tue, 03 Nov 2009)
New Revision: 95948
Modified:
projects/jboss-osgi/trunk/reactor/framework/.classpath
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/classloading/OSGiPackageCapability.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/classloading/OSGiPackageRequirement.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/BundleResolver.java
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/bundle/metadata/VersionRangeTestCase.java
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/bundle/test/BundleEntriesUnitTestCase.java
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/bundle/test/SystemBundleUnitTestCase.java
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/classloader/test/RequireBundleUnitTestCase.java
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/filter/test/BundleContextFilterUnitTestCase.java
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/test/GetServiceReferencesUnitTestCase.java
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/test/GetUnGetServiceUnitTestCase.java
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/test/RegisterServiceUnitTestCase.java
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/test/ServiceRegistrationUnitTestCase.java
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/smoke/test/OSGiSmokeTestCase.java
Log:
Source code tidyup and fix the eclipse build
Modified: projects/jboss-osgi/trunk/reactor/framework/.classpath
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/.classpath 2009-11-03 12:17:22 UTC (rev 95947)
+++ projects/jboss-osgi/trunk/reactor/framework/.classpath 2009-11-03 13:09:52 UTC (rev 95948)
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java"/>
- <classpathentry kind="src" output="target/classes" path="target/generated-sources/javacc"/>
+ <classpathentry kind="src" path="target/generated-sources/javacc"/>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/>
Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java 2009-11-03 12:17:22 UTC (rev 95947)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java 2009-11-03 13:09:52 UTC (rev 95948)
@@ -226,6 +226,8 @@
/**
* Get the kernel
+ *
+ * @return the kernel
*/
public Kernel getKernel()
{
@@ -355,6 +357,8 @@
/**
* Get the bundle resolver
+ *
+ * @return the resolver
*/
public BundleResolver getBundleResolver()
{
@@ -791,6 +795,7 @@
/**
* Get the bundles with the given state
*
+ * @param state the bundle state
* @return the bundles
*/
public Collection<AbstractBundleState> getBundles(int state)
Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/classloading/OSGiPackageCapability.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/classloading/OSGiPackageCapability.java 2009-11-03 12:17:22 UTC (rev 95947)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/classloading/OSGiPackageCapability.java 2009-11-03 13:09:52 UTC (rev 95948)
@@ -68,7 +68,7 @@
/**
* Create a new OSGiPackageCapability.
*
- * @param metadata the osgi metadata
+ * @param bundleState the bundle state
* @param exportPackage the export package metadata
* @return the capability
* @throws IllegalArgumentException for null metadata
@@ -157,6 +157,8 @@
/**
* Get the Module associated with this capability
+ *
+ * @return the module
*/
public Module getModule()
{
Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/classloading/OSGiPackageRequirement.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/classloading/OSGiPackageRequirement.java 2009-11-03 12:17:22 UTC (rev 95947)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/classloading/OSGiPackageRequirement.java 2009-11-03 13:09:52 UTC (rev 95948)
@@ -56,6 +56,7 @@
/**
* Create a new OSGiPackageRequirement.
*
+ * @param bundleState the bundle state
* @param requirePackage the require package metadata
* @return the requirement
* @throws IllegalArgumentException for a null requirePackage
@@ -93,6 +94,7 @@
/**
* Create a new OSGiPackageRequirement.
*
+ * @param bundleState the bundleState
* @param name the name
* @param versionRange the version range - pass null for all versions
* @param requirePackage the require package metadata
@@ -124,6 +126,8 @@
/**
* Get the Module associated with this requirement
+ *
+ * @return the module
*/
public Module getModule()
{
Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/BundleResolver.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/BundleResolver.java 2009-11-03 12:17:22 UTC (rev 95947)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/BundleResolver.java 2009-11-03 13:09:52 UTC (rev 95948)
@@ -73,6 +73,7 @@
*
* This is an iterative process that tries to wire BundleRequirements to BundleCapabilities.
*
+ * @param bundles the bundles to resolve
* @return The list of resolved bundles in the resolve order or an empty list
*/
public List<OSGiBundleState> resolveBundles(List<Bundle> bundles)
Modified: projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/bundle/metadata/VersionRangeTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/bundle/metadata/VersionRangeTestCase.java 2009-11-03 12:17:22 UTC (rev 95947)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/bundle/metadata/VersionRangeTestCase.java 2009-11-03 13:09:52 UTC (rev 95948)
@@ -3,8 +3,6 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import junit.framework.Test;
-
import org.jboss.logging.Logger;
import org.jboss.osgi.framework.metadata.VersionRange;
import org.jboss.osgi.framework.metadata.internal.AbstractVersionRange;
Modified: projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/bundle/test/BundleEntriesUnitTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/bundle/test/BundleEntriesUnitTestCase.java 2009-11-03 12:17:22 UTC (rev 95947)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/bundle/test/BundleEntriesUnitTestCase.java 2009-11-03 13:09:52 UTC (rev 95948)
@@ -28,8 +28,6 @@
import java.util.HashSet;
import java.util.Set;
-import junit.framework.Test;
-
import org.jboss.test.osgi.OSGiTestCase;
import org.osgi.framework.Bundle;
Modified: projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/bundle/test/SystemBundleUnitTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/bundle/test/SystemBundleUnitTestCase.java 2009-11-03 12:17:22 UTC (rev 95947)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/bundle/test/SystemBundleUnitTestCase.java 2009-11-03 13:09:52 UTC (rev 95948)
@@ -24,8 +24,6 @@
import java.util.Dictionary;
import java.util.Hashtable;
-import junit.framework.Test;
-
import org.jboss.test.osgi.OSGiTestCase;
import org.jboss.test.osgi.OSGiTestDelegate;
import org.osgi.framework.Bundle;
Modified: projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/classloader/test/RequireBundleUnitTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/classloader/test/RequireBundleUnitTestCase.java 2009-11-03 12:17:22 UTC (rev 95947)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/classloader/test/RequireBundleUnitTestCase.java 2009-11-03 13:09:52 UTC (rev 95948)
@@ -21,7 +21,6 @@
*/
package org.jboss.test.osgi.classloader.test;
-import org.jboss.deployers.client.spi.IncompleteDeploymentException;
import org.jboss.test.osgi.OSGiTestCase;
import org.jboss.test.osgi.classloader.support.a.A;
import org.jboss.test.osgi.classloader.support.b.B;
Modified: projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/filter/test/BundleContextFilterUnitTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/filter/test/BundleContextFilterUnitTestCase.java 2009-11-03 12:17:22 UTC (rev 95947)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/filter/test/BundleContextFilterUnitTestCase.java 2009-11-03 13:09:52 UTC (rev 95948)
@@ -23,8 +23,6 @@
import java.util.Dictionary;
-import junit.framework.Test;
-
import org.jboss.test.osgi.OSGiTestDelegate;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
Modified: projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/test/GetServiceReferencesUnitTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/test/GetServiceReferencesUnitTestCase.java 2009-11-03 12:17:22 UTC (rev 95947)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/test/GetServiceReferencesUnitTestCase.java 2009-11-03 13:09:52 UTC (rev 95948)
@@ -24,8 +24,6 @@
import java.util.Dictionary;
import java.util.Hashtable;
-import junit.framework.Test;
-
import org.jboss.test.osgi.OSGiTestCase;
import org.jboss.test.osgi.service.support.a.A;
import org.jboss.test.osgi.service.support.b.B;
Modified: projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/test/GetUnGetServiceUnitTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/test/GetUnGetServiceUnitTestCase.java 2009-11-03 12:17:22 UTC (rev 95947)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/test/GetUnGetServiceUnitTestCase.java 2009-11-03 13:09:52 UTC (rev 95948)
@@ -21,8 +21,6 @@
*/
package org.jboss.test.osgi.service.test;
-import junit.framework.Test;
-
import org.jboss.test.osgi.OSGiTestCase;
import org.jboss.test.osgi.service.support.BrokenServiceFactory;
import org.osgi.framework.Bundle;
Modified: projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/test/RegisterServiceUnitTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/test/RegisterServiceUnitTestCase.java 2009-11-03 12:17:22 UTC (rev 95947)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/test/RegisterServiceUnitTestCase.java 2009-11-03 13:09:52 UTC (rev 95948)
@@ -24,8 +24,6 @@
import java.util.Dictionary;
import java.util.Hashtable;
-import junit.framework.Test;
-
import org.jboss.test.osgi.OSGiTestCase;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
Modified: projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/test/ServiceRegistrationUnitTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/test/ServiceRegistrationUnitTestCase.java 2009-11-03 12:17:22 UTC (rev 95947)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/test/ServiceRegistrationUnitTestCase.java 2009-11-03 13:09:52 UTC (rev 95948)
@@ -23,8 +23,6 @@
import java.util.Hashtable;
-import junit.framework.Test;
-
import org.jboss.test.osgi.OSGiTestCase;
import org.jboss.test.osgi.service.support.SimpleServiceFactory;
import org.osgi.framework.Bundle;
Modified: projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/smoke/test/OSGiSmokeTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/smoke/test/OSGiSmokeTestCase.java 2009-11-03 12:17:22 UTC (rev 95947)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/smoke/test/OSGiSmokeTestCase.java 2009-11-03 13:09:52 UTC (rev 95948)
@@ -24,8 +24,6 @@
import java.io.InputStream;
import java.net.URL;
-import junit.framework.Test;
-
import org.jboss.test.osgi.OSGiTestCase;
import org.jboss.test.osgi.smoke.support.a.A;
import org.jboss.test.osgi.smoke.support.a.b.B;
14 years, 7 months
JBoss-OSGI SVN: r95925 - in projects/jboss-osgi/projects/bundles/microcontainer/trunk/src/main/java/org/jboss/osgi/microcontainer: internal and 1 other directory.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-11-02 12:22:32 -0500 (Mon, 02 Nov 2009)
New Revision: 95925
Removed:
projects/jboss-osgi/projects/bundles/microcontainer/trunk/src/main/java/org/jboss/osgi/microcontainer/MicrocontainerCapabilityMarker.java
Modified:
projects/jboss-osgi/projects/bundles/microcontainer/trunk/src/main/java/org/jboss/osgi/microcontainer/internal/MicrocontainerServiceActivator.java
Log:
Remove capability marker
Deleted: projects/jboss-osgi/projects/bundles/microcontainer/trunk/src/main/java/org/jboss/osgi/microcontainer/MicrocontainerCapabilityMarker.java
===================================================================
--- projects/jboss-osgi/projects/bundles/microcontainer/trunk/src/main/java/org/jboss/osgi/microcontainer/MicrocontainerCapabilityMarker.java 2009-11-02 16:44:31 UTC (rev 95924)
+++ projects/jboss-osgi/projects/bundles/microcontainer/trunk/src/main/java/org/jboss/osgi/microcontainer/MicrocontainerCapabilityMarker.java 2009-11-02 17:22:32 UTC (rev 95925)
@@ -1,35 +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.microcontainer;
-
-//$Id$
-
-
-/**
- * A marker service for the jboss-osgi-microcontainer.jar
- *
- * @author thomas.diesler(a)jboss.com
- * @since 01-Nov-2009
- */
-public interface MicrocontainerCapabilityMarker
-{
-}
\ No newline at end of file
Modified: projects/jboss-osgi/projects/bundles/microcontainer/trunk/src/main/java/org/jboss/osgi/microcontainer/internal/MicrocontainerServiceActivator.java
===================================================================
--- projects/jboss-osgi/projects/bundles/microcontainer/trunk/src/main/java/org/jboss/osgi/microcontainer/internal/MicrocontainerServiceActivator.java 2009-11-02 16:44:31 UTC (rev 95924)
+++ projects/jboss-osgi/projects/bundles/microcontainer/trunk/src/main/java/org/jboss/osgi/microcontainer/internal/MicrocontainerServiceActivator.java 2009-11-02 17:22:32 UTC (rev 95925)
@@ -27,7 +27,6 @@
import org.jboss.deployers.client.spi.main.MainDeployer;
import org.jboss.osgi.deployment.deployer.DeployerService;
-import org.jboss.osgi.microcontainer.MicrocontainerCapabilityMarker;
import org.jboss.osgi.spi.service.MicrocontainerService;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
@@ -47,10 +46,6 @@
public void start(BundleContext context)
{
- // Always register the marker service
- MicrocontainerCapabilityMarker markerService = new MicrocontainerCapabilityMarker(){};
- context.registerService(MicrocontainerCapabilityMarker.class.getName(), markerService, null);
-
// Do nothing if this bundle gets installed on the jbossmc framework
String systemBundleName = context.getBundle(0).getSymbolicName();
if ("org.jboss.osgi.framework".equals(systemBundleName))
14 years, 7 months
JBoss-OSGI SVN: r95922 - in projects/jboss-osgi/projects: spi/trunk/src/main/java/org/jboss/osgi/spi/framework and 1 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-11-02 10:49:38 -0500 (Mon, 02 Nov 2009)
New Revision: 95922
Removed:
projects/jboss-osgi/projects/bundles/husky/trunk/testsuite/src/test/resources/META-INF/
Modified:
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/OSGiBootstrap.java
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/PropertiesBootstrapProvider.java
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/ServiceLoader.java
Log:
Support better bootstrap defaults
Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/OSGiBootstrap.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/OSGiBootstrap.java 2009-11-02 15:12:47 UTC (rev 95921)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/OSGiBootstrap.java 2009-11-02 15:49:38 UTC (rev 95922)
@@ -160,6 +160,9 @@
*/
public static OSGiBootstrapProvider getBootstrapProvider()
{
+ if (log == null)
+ log = LoggerFactory.getLogger(OSGiBootstrap.class);
+
OSGiBootstrapProvider provider = null;
List<OSGiBootstrapProvider> providers = ServiceLoader.loadServices(OSGiBootstrapProvider.class);
@@ -173,13 +176,15 @@
}
catch (Exception ex)
{
- Logger tmplog = LoggerFactory.getLogger(OSGiBootstrap.class);
- tmplog.debug("Cannot configure [" + aux.getClass().getName() + "]", ex);
+ log.debug("Cannot configure [" + aux.getClass().getName() + "]", ex);
}
}
if (provider == null)
- throw new IllegalStateException("Cannot obtain bootstrap provider");
+ {
+ provider = new PropertiesBootstrapProvider();
+ log.debug("Using default: " + PropertiesBootstrapProvider.class.getName());
+ }
return provider;
}
Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/PropertiesBootstrapProvider.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/PropertiesBootstrapProvider.java 2009-11-02 15:12:47 UTC (rev 95921)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/PropertiesBootstrapProvider.java 2009-11-02 15:49:38 UTC (rev 95922)
@@ -37,7 +37,6 @@
import java.util.Properties;
import java.util.Set;
-import org.jboss.osgi.spi.NotImplementedException;
import org.jboss.osgi.spi.internal.StringPropertyReplacer;
import org.jboss.osgi.spi.util.ExportedPackageHelper;
import org.jboss.osgi.spi.util.ServiceLoader;
@@ -57,6 +56,7 @@
* <ul>
* <li><b>org.jboss.osgi.spi.framework.autoInstall</b> - Bundles that need to be installed with the Framework automatically</li>
* <li><b>org.jboss.osgi.spi.framework.autoStart</b> - Bundles that need to be started automatically</li>
+ * <li><b>org.jboss.osgi.spi.framework.extra</b> - An URL to extra properties, which recursivly may conatin this property.</li>
* </ul>
*
* All other properties are passed on to configure the framework.
@@ -114,14 +114,57 @@
public void configure()
{
- configure(System.getProperty(OSGI_FRAMEWORK_CONFIG, DEFAULT_OSGI_FRAMEWORK_PROPERTIES));
+ configureInternal(System.getProperty(OSGI_FRAMEWORK_CONFIG, DEFAULT_OSGI_FRAMEWORK_PROPERTIES));
}
+ public void configure(String resourceConfig)
+ {
+ if (resourceConfig == null)
+ throw new IllegalArgumentException("Null resouce name");
+
+ URL urlConfig = Thread.currentThread().getContextClassLoader().getResource(resourceConfig);
+ if (urlConfig == null)
+ throw new IllegalStateException("Cannot find resource: " + resourceConfig);
+
+ configure(urlConfig);
+ }
+
public void configure(URL urlConfig)
{
- // Read the configuration properties
- final Map<String, Object> props = getBootstrapProperties(urlConfig);
+ if (urlConfig == null)
+ throw new IllegalArgumentException("Null config url");
+
+ Map<String, Object> props = getBootstrapProperties(urlConfig);
+ initFrameworkInstance(props);
+ }
+ public void configure(InputStream streamConfig)
+ {
+ Map<String, Object> props = getBootstrapProperties(streamConfig);
+ initFrameworkInstance(props);
+ }
+
+ private void configureInternal(String resourceConfig)
+ {
+ if (resourceConfig == null)
+ throw new IllegalArgumentException("Null resouce name");
+
+ Map<String, Object> props;
+ URL urlConfig = Thread.currentThread().getContextClassLoader().getResource(resourceConfig);
+ if (urlConfig != null)
+ {
+ props = getBootstrapProperties(urlConfig);
+ }
+ else
+ {
+ props = new HashMap<String, Object>();
+ log.debug("Bootstrap using framework defaults");
+ }
+ initFrameworkInstance(props);
+ }
+
+ private void initFrameworkInstance(final Map<String, Object> props)
+ {
// Load the framework instance
final Framework frameworkImpl = createFramework(props);
framework = new FrameworkWrapper(frameworkImpl)
@@ -156,7 +199,7 @@
// Register system services
registerSystemServices(context);
-
+
// Install autoInstall bundles
for (URL bundleURL : autoInstall)
{
@@ -184,11 +227,11 @@
{
// Unregister system services
unregisterSystemServices(getBundleContext());
-
+
super.stop();
}
};
-
+
configured = true;
}
@@ -199,7 +242,7 @@
Framework framework = factory.newFramework(properties);
return framework;
}
-
+
/**
* Overwrite to register system services before bundles get installed.
*/
@@ -207,7 +250,7 @@
{
// no default system services
}
-
+
/**
* Overwrite to unregister system services before bundles get installed.
*/
@@ -215,7 +258,7 @@
{
// no default system services
}
-
+
private List<URL> getBundleURLs(Map<String, Object> props, String key)
{
String bundleList = (String)props.get(key);
@@ -248,107 +291,107 @@
}
}
- public void configure(String resourceConfig)
- {
- URL urlConfig = Thread.currentThread().getContextClassLoader().getResource(resourceConfig);
- if (urlConfig == null)
- throw new IllegalStateException("Cannot find resource: " + resourceConfig);
-
- configure(urlConfig);
- }
-
- public void configure(InputStream streamConfig)
- {
- throw new NotImplementedException();
- }
-
public Framework getFramework()
{
if (configured == false)
- {
- String defaultFrameworkProps = System.getProperty(OSGI_FRAMEWORK_CONFIG, DEFAULT_OSGI_FRAMEWORK_PROPERTIES);
- configure(defaultFrameworkProps);
- }
+ configureInternal(System.getProperty(OSGI_FRAMEWORK_CONFIG, DEFAULT_OSGI_FRAMEWORK_PROPERTIES));
+
return framework;
}
- @SuppressWarnings("unchecked")
private Map<String, Object> getBootstrapProperties(URL urlConfig)
{
- Properties props = new Properties();
+ Map<String, Object> props = null;
try
{
- InputStream inStream = urlConfig.openStream();
- props.load(inStream);
- inStream.close();
+ InputStream propStream = urlConfig.openStream();
+ props = getBootstrapProperties(propStream);
+ propStream.close();
}
catch (IOException ex)
{
- throw new IllegalStateException("Cannot load properties from: " + urlConfig, ex);
+ throw new IllegalStateException("Cannot configure from: " + urlConfig, ex);
}
+ return props;
+ }
+ @SuppressWarnings("unchecked")
+ private Map<String, Object> getBootstrapProperties(InputStream propStream)
+ {
+ if (propStream == null)
+ throw new IllegalArgumentException("Null properties stream");
+
Map<String, Object> propMap = new HashMap<String, Object>();
-
- // Process property list
- Enumeration<String> keys = (Enumeration<String>)props.propertyNames();
- while (keys.hasMoreElements())
+ try
{
- String key = keys.nextElement();
- String value = props.getProperty(key);
+ Properties props = new Properties();
+ props.load(propStream);
+ propStream.close();
- // Replace property variables
- value = StringPropertyReplacer.replaceProperties(value);
- propMap.put(key, value);
+ // Process property list
+ Enumeration<String> keys = (Enumeration<String>)props.propertyNames();
+ while (keys.hasMoreElements())
+ {
+ String key = keys.nextElement();
+ String value = props.getProperty(key);
- if (key.endsWith(".instance"))
- {
- try
+ // Replace property variables
+ value = StringPropertyReplacer.replaceProperties(value);
+ propMap.put(key, value);
+
+ if (key.endsWith(".instance"))
{
- String subkey = key.substring(0, key.lastIndexOf(".instance"));
- Object instance = Class.forName(value).newInstance();
- propMap.put(subkey, instance);
+ try
+ {
+ String subkey = key.substring(0, key.lastIndexOf(".instance"));
+ Object instance = Class.forName(value).newInstance();
+ propMap.put(subkey, instance);
+ }
+ catch (Exception ex)
+ {
+ log.error("Cannot load " + key + "=" + value, ex);
+ }
}
- catch (Exception ex)
- {
- log.error("Cannot load " + key + "=" + value, ex);
- }
}
- }
- // Merge optional extra properties
- String extraPropsValue = (String)propMap.get(PROP_OSGI_FRAMEWORK_EXTRA);
- if (extraPropsValue != null)
- {
- URL extraPropsURL = null;
- try
+ // Merge optional extra properties
+ String extraPropsValue = (String)propMap.get(PROP_OSGI_FRAMEWORK_EXTRA);
+ if (extraPropsValue != null)
{
- extraPropsURL = new URL(extraPropsValue);
- }
- catch (MalformedURLException e)
- {
- // ignore;
- }
- if (extraPropsURL == null)
- {
- File propsFile = new File(extraPropsValue);
+ URL extraPropsURL = null;
try
{
- extraPropsURL = propsFile.toURL();
+ extraPropsURL = new URL(extraPropsValue);
}
catch (MalformedURLException e)
{
// ignore;
}
- }
+ if (extraPropsURL == null)
+ {
+ File propsFile = new File(extraPropsValue);
+ try
+ {
+ extraPropsURL = propsFile.toURL();
+ }
+ catch (MalformedURLException e)
+ {
+ // ignore;
+ }
+ }
- if (extraPropsURL == null)
- throw new IllegalStateException("Invalid properties URL: " + extraPropsValue);
+ if (extraPropsURL == null)
+ throw new IllegalStateException("Invalid properties URL: " + extraPropsValue);
- propMap.remove(PROP_OSGI_FRAMEWORK_EXTRA);
- Map<String, Object> extraProps = getBootstrapProperties(extraPropsURL);
- propMap.putAll(extraProps);
+ propMap.remove(PROP_OSGI_FRAMEWORK_EXTRA);
+ Map<String, Object> extraProps = getBootstrapProperties(extraPropsURL.openStream());
+ propMap.putAll(extraProps);
+ }
}
-
+ catch (IOException ex)
+ {
+ throw new IllegalStateException("Cannot load properties", ex);
+ }
return propMap;
}
}
Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/ServiceLoader.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/ServiceLoader.java 2009-11-02 15:12:47 UTC (rev 95921)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/ServiceLoader.java 2009-11-02 15:49:38 UTC (rev 95922)
@@ -94,9 +94,6 @@
}
}
- if (services.size() == 0)
- throw new IllegalStateException("Failed to load services from: META-INF/services/" + serviceClass.getName());
-
return services;
}
14 years, 7 months
JBoss-OSGI SVN: r95917 - projects/jboss-osgi/trunk/distribution/installer/src/main/resources/jbossas.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-11-02 09:21:11 -0500 (Mon, 02 Nov 2009)
New Revision: 95917
Modified:
projects/jboss-osgi/trunk/distribution/installer/src/main/resources/jbossas/jta-service-jboss-beans.xml
projects/jboss-osgi/trunk/distribution/installer/src/main/resources/jbossas/microcontainer-service-jboss-beans.xml
Log:
more xml service docu
Modified: projects/jboss-osgi/trunk/distribution/installer/src/main/resources/jbossas/jta-service-jboss-beans.xml
===================================================================
--- projects/jboss-osgi/trunk/distribution/installer/src/main/resources/jbossas/jta-service-jboss-beans.xml 2009-11-02 13:49:24 UTC (rev 95916)
+++ projects/jboss-osgi/trunk/distribution/installer/src/main/resources/jbossas/jta-service-jboss-beans.xml 2009-11-02 14:21:11 UTC (rev 95917)
@@ -6,7 +6,14 @@
<deployment xmlns="urn:jboss:bean-deployer:2.0">
- <!-- Transaction Service -->
+ <!--
+ A bean that registers
+
+ javax.transaction.TransactionManager
+ javax.transaction.UserTransaction
+
+ as OSGi services. Please see the OSGi Enterprise JTA spec for details.
+ -->
<bean name="jboss.osgi:service=Transaction" class="org.jboss.osgi.integration.jbossas.TransactionServiceBean">
<property name="bundleContext"><inject bean="jboss.osgi:service=Framework" property="bundleContext"/></property>
<property name="transactionManager"><inject bean="RealTransactionManager"/></property>
Modified: projects/jboss-osgi/trunk/distribution/installer/src/main/resources/jbossas/microcontainer-service-jboss-beans.xml
===================================================================
--- projects/jboss-osgi/trunk/distribution/installer/src/main/resources/jbossas/microcontainer-service-jboss-beans.xml 2009-11-02 13:49:24 UTC (rev 95916)
+++ projects/jboss-osgi/trunk/distribution/installer/src/main/resources/jbossas/microcontainer-service-jboss-beans.xml 2009-11-02 14:21:11 UTC (rev 95917)
@@ -6,7 +6,13 @@
<deployment xmlns="urn:jboss:bean-deployer:2.0">
- <!-- Microcontainer Service -->
+ <!--
+ A bean that registers
+
+ org.jboss.osgi.microcontainer.MicrocontainerService
+
+ as OSGi services. Please see the JBoss OSGi userguide for details.
+ -->
<bean name="jboss.osgi:service=Microcontainer" class="org.jboss.osgi.integration.jbossas.MicrocontainerServiceBean">
<property name="bundleContext"><inject bean="jboss.osgi:service=Framework" property="bundleContext"/></property>
<property name="mbeanServer"><inject bean="JMXKernel" property="mbeanServer"/></property>
14 years, 7 months