[jboss-cvs] JBossAS SVN: r89527 - in projects/jboss-osgi/trunk: distribution and 5 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri May 29 07:53:49 EDT 2009
Author: thomas.diesler at jboss.com
Date: 2009-05-29 07:53:48 -0400 (Fri, 29 May 2009)
New Revision: 89527
Modified:
projects/jboss-osgi/trunk/distribution/pom.xml
projects/jboss-osgi/trunk/distribution/runtime/bin/run.sh
projects/jboss-osgi/trunk/distribution/runtime/conf/jboss-osgi-felix.properties
projects/jboss-osgi/trunk/distribution/runtime/conf/log4j.xml
projects/jboss-osgi/trunk/distribution/src/main/resources/installer/install-definition.xml
projects/jboss-osgi/trunk/pom.xml
projects/jboss-osgi/trunk/spi/pom.xml
projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/framework/OSGiBootstrap.java
Log:
Add args4j command line option handling
Modified: projects/jboss-osgi/trunk/distribution/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/distribution/pom.xml 2009-05-29 11:14:38 UTC (rev 89526)
+++ projects/jboss-osgi/trunk/distribution/pom.xml 2009-05-29 11:53:48 UTC (rev 89527)
@@ -29,6 +29,10 @@
<!-- Dependencies -->
<dependencies>
<dependency>
+ <groupId>args4j</groupId>
+ <artifactId>args4j</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.jboss.osgi</groupId>
<artifactId>jboss-osgi-deployers</artifactId>
</dependency>
Modified: projects/jboss-osgi/trunk/distribution/runtime/bin/run.sh
===================================================================
--- projects/jboss-osgi/trunk/distribution/runtime/bin/run.sh 2009-05-29 11:14:38 UTC (rev 89526)
+++ projects/jboss-osgi/trunk/distribution/runtime/bin/run.sh 2009-05-29 11:53:48 UTC (rev 89527)
@@ -142,7 +142,7 @@
# Execute the JVM in the foreground
"$JAVA" $JAVA_OPTS \
-classpath "$OSGI_CLASSPATH" \
- org.jboss.osgi.spi.framework.OSGiBootstrap "$@" &
+ -Dmainclass=org.jboss.osgi.spi.framework.OSGiBootstrap org.kohsuke.args4j.Starter "$@" &
OSGI_PID=$!
echo $OSGI_PID > $OSGI_HOME/bin/pid.txt
Modified: projects/jboss-osgi/trunk/distribution/runtime/conf/jboss-osgi-felix.properties
===================================================================
--- projects/jboss-osgi/trunk/distribution/runtime/conf/jboss-osgi-felix.properties 2009-05-29 11:14:38 UTC (rev 89526)
+++ projects/jboss-osgi/trunk/distribution/runtime/conf/jboss-osgi-felix.properties 2009-05-29 11:53:48 UTC (rev 89527)
@@ -8,17 +8,17 @@
org.jboss.osgi.spi.framework.impl=org.jboss.osgi.felix.framework.FelixIntegration
# Properties to configure the Framework
-org.osgi.framework.storage=${osgi.home}/data/osgi-store
+org.osgi.framework.storage=${osgi.home}/server/${jboss.server.name}/data/osgi-store
org.osgi.framework.storage.clean=onFirstInit
# Hot Deployement
-org.jboss.osgi.hotdeploy.scandir=${osgi.home}/bundles
+org.jboss.osgi.hotdeploy.scandir=${osgi.home}/server/${jboss.server.name}/bundles
# HTTP Service Port
org.osgi.service.http.port=8090
# Config Admin Service
-felix.cm.dir=${osgi.home}/data/osgi-configadmin
+felix.cm.dir=${osgi.home}/server/${jboss.server.name}/data/osgi-configadmin
# JMX bundle properties
org.jboss.osgi.jmx.host=${jboss.bind.address}
@@ -67,16 +67,10 @@
# Bundles that need to be installed with the Framework automatically
org.jboss.osgi.spi.framework.autoInstall=\
- file://${osgi.home}/bundles/org.osgi.compendium.jar
+ file://${osgi.home}/server/minimal/bundles/org.osgi.compendium.jar
# Bundles that need to be started automatically
org.jboss.osgi.spi.framework.autoStart=\
- file://${osgi.home}/bundles/org.apache.felix.log.jar \
- file://${osgi.home}/bundles/jboss-osgi-common.jar \
- file://${osgi.home}/bundles/jboss-osgi-common-core.jar \
- file://${osgi.home}/bundles/jboss-osgi-jmx.jar \
- file://${osgi.home}/bundles/jboss-osgi-jaxb.jar \
- file://${osgi.home}/bundles/jboss-osgi-apache-xerces.jar \
- file://${osgi.home}/bundles/jboss-osgi-xml-binding.jar \
- file://${osgi.home}/bundles/jboss-osgi-microcontainer.jar \
- file://${osgi.home}/bundles/jboss-osgi-hotdeploy.jar
\ No newline at end of file
+ file://${osgi.home}/server/minimal/bundles/org.apache.felix.log.jar \
+ file://${osgi.home}/server/minimal/bundles/jboss-osgi-common.jar \
+ file://${osgi.home}/server/minimal/bundles/jboss-osgi-hotdeploy.jar
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/distribution/runtime/conf/log4j.xml
===================================================================
--- projects/jboss-osgi/trunk/distribution/runtime/conf/log4j.xml 2009-05-29 11:14:38 UTC (rev 89526)
+++ projects/jboss-osgi/trunk/distribution/runtime/conf/log4j.xml 2009-05-29 11:53:48 UTC (rev 89527)
@@ -8,7 +8,7 @@
<!-- ================================= -->
<appender name="FILE" class="org.apache.log4j.FileAppender">
- <param name="File" value="${osgi.home}/log/server.log"/>
+ <param name="File" value="${osgi.home}/server/${jboss.server.name}/log/server.log"/>
<param name="Append" value="false"/>
<layout class="org.apache.log4j.PatternLayout">
<!-- The default pattern: Date Priority [Category] Message\n -->
Modified: projects/jboss-osgi/trunk/distribution/src/main/resources/installer/install-definition.xml
===================================================================
--- projects/jboss-osgi/trunk/distribution/src/main/resources/installer/install-definition.xml 2009-05-29 11:14:38 UTC (rev 89526)
+++ projects/jboss-osgi/trunk/distribution/src/main/resources/installer/install-definition.xml 2009-05-29 11:53:48 UTC (rev 89527)
@@ -166,6 +166,7 @@
<!-- JBossOSGi Lib -->
<fileset dir="@{deploy.artifacts.dir}/lib" targetdir="$INSTALL_PATH/runtime/lib" override="true">
+ <include name="args4j.jar" />
<include name="jboss-common-core.jar" />
<include name="jboss-logging-spi.jar" />
<include name="jboss-logging-log4j.jar" />
@@ -174,13 +175,24 @@
<include name="log4j.jar" />
</fileset>
- <!-- JBossOSGi Bundles -->
- <fileset dir="@{deploy.artifacts.dir}/lib" targetdir="$INSTALL_PATH/runtime/bundles" override="true">
+ <!-- JBossOSGi Minimal -->
+ <fileset dir="@{deploy.artifacts.dir}/lib" targetdir="$INSTALL_PATH/runtime/server/minimal/bundles" override="true">
+ <include name="org.apache.felix.log.jar" />
+ <include name="jboss-osgi-common.jar" />
+ <include name="jboss-osgi-hotdeploy.jar" />
+ </fileset>
+
+ <fileset dir="@{deploy.artifacts.dir}/lib" targetdir="$INSTALL_PATH/runtime/server/default/bundles" override="true">
+ <include name="jboss-osgi-webconsole.jar" />
+ <include name="org.apache.felix.configadmin.jar" />
+ <include name="org.apache.felix.http.jetty.jar" />
+ <include name="org.apache.felix.metatype.jar" />
+ </fileset>
+
+ <fileset dir="@{deploy.artifacts.dir}/lib" targetdir="$INSTALL_PATH/runtime/server/all/bundles" override="true">
<include name="jboss-osgi-apache-xerces.jar" />
<include name="jboss-osgi-jaxb.jar" />
<include name="jboss-osgi-common-core.jar" />
- <include name="jboss-osgi-common.jar" />
- <include name="jboss-osgi-hotdeploy.jar" />
<include name="jboss-osgi-jndi.jar" />
<include name="jboss-osgi-jmx.jar" />
<include name="jboss-osgi-microcontainer.jar" />
@@ -188,7 +200,6 @@
<include name="jboss-osgi-xml-binding.jar" />
<include name="org.apache.felix.configadmin.jar" />
<include name="org.apache.felix.http.jetty.jar" />
- <include name="org.apache.felix.log.jar" />
<include name="org.apache.felix.metatype.jar" />
</fileset>
@@ -200,7 +211,7 @@
<include name="jboss-osgi-runtime-felix.jar" />
<include name="org.apache.felix.framework.jar" />
</fileset>
- <fileset dir="@{deploy.artifacts.dir}/lib" targetdir="$INSTALL_PATH/runtime/bundles" override="true">
+ <fileset dir="@{deploy.artifacts.dir}/lib" targetdir="$INSTALL_PATH/runtime/server/minimal/bundles" override="true">
<include name="org.osgi.compendium.jar" />
</fileset>
@@ -211,7 +222,7 @@
<include name="jboss-osgi-runtime-equinox.jar" />
<include name="org.eclipse.osgi.jar" />
</fileset>
- <fileset condition="isEquinox" dir="@{deploy.artifacts.dir}/lib" targetdir="$INSTALL_PATH/runtime/bundles" override="true">
+ <fileset condition="isEquinox" dir="@{deploy.artifacts.dir}/lib" targetdir="$INSTALL_PATH/runtime/server/minimal/bundles" override="true">
<include name="org.eclipse.osgi.services.jar" />
</fileset>
-->
@@ -223,7 +234,7 @@
<include name="jboss-osgi-runtime-knopflerfish.jar" />
<include name="org.knopflerfish.framework.jar" />
</fileset>
- <fileset condition="isKnopflerfish" dir="@{deploy.artifacts.dir}/lib" targetdir="$INSTALL_PATH/runtime/bundles" override="true">
+ <fileset condition="isKnopflerfish" dir="@{deploy.artifacts.dir}/lib" targetdir="$INSTALL_PATH/runtime/server/minimal/bundles" override="true">
<include name="org.osgi.compendium.jar" />
</fileset>
-->
Modified: projects/jboss-osgi/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/pom.xml 2009-05-29 11:14:38 UTC (rev 89526)
+++ projects/jboss-osgi/trunk/pom.xml 2009-05-29 11:53:48 UTC (rev 89527)
@@ -34,7 +34,8 @@
<!-- Properties -->
<properties>
<surefire.security.args>-Djava.security.manager -Djava.security.policy=src/test/resources/tst.policy</surefire.security.args>
-
+
+ <version.args4j>2.0.12</version.args4j>
<version.aqute.bnd>0.0.323</version.aqute.bnd>
<version.equinox>3.4.2</version.equinox>
<version.felix.bundlerepository>1.0.3</version.felix.bundlerepository>
@@ -173,6 +174,11 @@
<!-- 3rd Party Dependencies -->
<dependency>
+ <groupId>args4j</groupId>
+ <artifactId>args4j</artifactId>
+ <version>${version.args4j}</version>
+ </dependency>
+ <dependency>
<groupId>biz.aQute</groupId>
<artifactId>bnd</artifactId>
<version>${version.aqute.bnd}</version>
Modified: projects/jboss-osgi/trunk/spi/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/spi/pom.xml 2009-05-29 11:14:38 UTC (rev 89526)
+++ projects/jboss-osgi/trunk/spi/pom.xml 2009-05-29 11:53:48 UTC (rev 89527)
@@ -22,6 +22,10 @@
<!-- Compile Dependencies -->
<dependency>
+ <groupId>args4j</groupId>
+ <artifactId>args4j</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging-spi</artifactId>
</dependency>
Modified: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/framework/OSGiBootstrap.java
===================================================================
--- projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/framework/OSGiBootstrap.java 2009-05-29 11:14:38 UTC (rev 89526)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/framework/OSGiBootstrap.java 2009-05-29 11:53:48 UTC (rev 89527)
@@ -32,6 +32,9 @@
import java.util.Properties;
import org.jboss.logging.Logger;
+import org.kohsuke.args4j.CmdLineException;
+import org.kohsuke.args4j.CmdLineParser;
+import org.kohsuke.args4j.Option;
/**
* The OSGiBootstrap provides an {@link OSGiFramework} through a {@link OSGiBootstrapProvider}.
@@ -48,18 +51,88 @@
* @author thomas.diesler at jboss.com
* @since 18-Jun-2008
*/
-public final class OSGiBootstrap
+public class OSGiBootstrap
{
- // Provide logging
- final static Logger log = Logger.getLogger(OSGiBootstrap.class);
-
- // Hide the ctor
- private 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 JBOSS_SERVER_NAME = "jboss.server.name";
+
+ @Option(name = "-c", usage = "Sets the server config (must )")
+ public String serverName = "default";
+
+ @Option(name = "-b", usage = "Sets the bind address")
+ public String bindAdress = "localhost";
+
+ /*
+ * The main entry point
+ */
+ public static void main(String[] args)
{
+ OSGiBootstrap bean = new OSGiBootstrap();
+ CmdLineParser parser = new CmdLineParser(bean);
+ try
+ {
+ parser.parseArgument(args);
+ bean.run();
+ }
+ catch (CmdLineException ex)
+ {
+ System.err.println("Invalid OSGiBootstrap options");
+ parser.printUsage(System.err);
+ }
}
- /**
- * Get an instance of an OSGiBootstrapProvider.
+ public void run()
+ {
+ initSystemProperties();
+
+ OSGiBootstrapProvider bootProvider = getBootstrapProvider();
+ OSGiFramework framework = bootProvider.getFramework();
+
+ Runtime runtime = Runtime.getRuntime();
+ runtime.addShutdownHook(new ShutdownThread(framework));
+
+ Thread thread = new StartupThread(framework);
+ thread.start();
+ }
+
+ private void initSystemProperties()
+ {
+ Properties defaults = new Properties();
+ defaults.setProperty(JBOSS_SERVER_NAME, serverName);
+ defaults.setProperty(JBOSS_BIND_ADDRESS, bindAdress);
+ defaults.setProperty(JAVA_PROTOCOL_HANDLERS, "org.jboss.net.protocol|org.jboss.virtual.protocol");
+
+ getLogger().info("JBoss OSGi System Properties");
+
+ 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);
+ getLogger().info(" " + propName + "=" + propValue);
+ }
+ }
+ }
+
+ private Logger getLogger()
+ {
+ if (log == null)
+ {
+ System.setProperty(JBOSS_SERVER_NAME, serverName);
+ log = Logger.getLogger(OSGiBootstrap.class);
+ }
+ return log;
+ }
+
+ /*
+ * * Get an instance of an OSGiBootstrapProvider.
*/
public static OSGiBootstrapProvider getBootstrapProvider()
{
@@ -105,50 +178,8 @@
return provider;
}
- public static void main(String[] args)
+ class StartupThread extends Thread
{
- initSystemProperties(args);
-
- OSGiBootstrapProvider bootProvider = getBootstrapProvider();
- OSGiFramework framework = bootProvider.getFramework();
-
- Runtime runtime = Runtime.getRuntime();
- runtime.addShutdownHook(new ShutdownThread(framework));
-
- Thread thread = new StartupThread(framework);
- thread.start();
- }
-
- private static void initSystemProperties(String[] args)
- {
- log.debug("initSystemProperties");
-
- Properties defaults = new Properties();
- defaults.setProperty("jboss.bind.address", "localhost");
- defaults.setProperty("java.protocol.handler.pkgs", "org.jboss.net.protocol|org.jboss.virtual.protocol");
-
- // [TODO] use args4j
- if (args != null && args.length == 2 && args[0].equals("-b"))
- {
- defaults.setProperty("jboss.bind.address", args[1]);
- }
-
- 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);
- }
- }
- }
-
- static class StartupThread extends Thread
- {
private OSGiFramework framework;
public StartupThread(OSGiFramework framework)
@@ -162,9 +193,9 @@
long start = System.currentTimeMillis();
framework.start();
long end = System.currentTimeMillis();
-
+
float diff = (end - start) / 1000f;
- log.info("JBossOSGi Runtime started in " + diff + "sec");
+ getLogger().info("JBossOSGi Runtime started in " + diff + "sec");
Reader br = new InputStreamReader(System.in);
try
@@ -182,7 +213,7 @@
}
}
- static class ShutdownThread extends Thread
+ class ShutdownThread extends Thread
{
private OSGiFramework framework;
@@ -193,9 +224,9 @@
public void run()
{
- log.info("Initiating shutdown ...");
+ getLogger().info("Initiating shutdown ...");
framework.stop();
- log.info("Shutdown complete");
+ getLogger().info("Shutdown complete");
}
}
}
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list