You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by ch...@apache.org on 2007/12/05 16:47:38 UTC
svn commit: r601373 - in /servicemix/branches/servicemix-4.0/runtime:
gshell/gshell-core/
gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/spring/
gshell/gshell-core/src/main/resources/META-INF/spring/ main/
main/src/main/java/org/apache/ser...
Author: chirino
Date: Wed Dec 5 07:47:34 2007
New Revision: 601373
URL: http://svn.apache.org/viewvc?rev=601373&view=rev
Log:
- The main boot strap now registers a MainService object so that other bundles can find out
what the command line arguments were.
- The GShell service now uses that to execute the gshell command specified via those
arguments.
Added:
servicemix/branches/servicemix-4.0/runtime/main/src/main/java/org/apache/servicemix/main/spi/
servicemix/branches/servicemix-4.0/runtime/main/src/main/java/org/apache/servicemix/main/spi/MainService.java
Modified:
servicemix/branches/servicemix-4.0/runtime/gshell/gshell-core/pom.xml
servicemix/branches/servicemix-4.0/runtime/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/spring/GShell.java
servicemix/branches/servicemix-4.0/runtime/gshell/gshell-core/src/main/resources/META-INF/spring/gshell-local.xml
servicemix/branches/servicemix-4.0/runtime/main/pom.xml
servicemix/branches/servicemix-4.0/runtime/main/src/main/java/org/apache/servicemix/main/Main.java
servicemix/branches/servicemix-4.0/runtime/minimum/src/main/release/bin/servicemix.bat
servicemix/branches/servicemix-4.0/runtime/minimum/src/main/release/bin/servicemix.sh
servicemix/branches/servicemix-4.0/runtime/minimum/src/main/release/etc/config.properties
Modified: servicemix/branches/servicemix-4.0/runtime/gshell/gshell-core/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/branches/servicemix-4.0/runtime/gshell/gshell-core/pom.xml?rev=601373&r1=601372&r2=601373&view=diff
==============================================================================
--- servicemix/branches/servicemix-4.0/runtime/gshell/gshell-core/pom.xml (original)
+++ servicemix/branches/servicemix-4.0/runtime/gshell/gshell-core/pom.xml Wed Dec 5 07:47:34 2007
@@ -39,6 +39,7 @@
<properties>
<gshell.osgi.import>
+ org.apache.servicemix.main.spi.*;resolution:=optional,
com.thoughtworks.xstream*;resolution:=optional,
javax.xml.stream*;resolution:=optional,
junit.framework*;resolution:=optional,
@@ -66,6 +67,11 @@
</properties>
<dependencies>
+ <dependency>
+ <groupId>org.apache.servicemix</groupId>
+ <artifactId>org.apache.servicemix.main</artifactId>
+ <version>4.0-SNAPSHOT</version>
+ </dependency>
<dependency>
<groupId>org.apache.geronimo.gshell</groupId>
<artifactId>gshell-core</artifactId>
Modified: servicemix/branches/servicemix-4.0/runtime/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/spring/GShell.java
URL: http://svn.apache.org/viewvc/servicemix/branches/servicemix-4.0/runtime/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/spring/GShell.java?rev=601373&r1=601372&r2=601373&view=diff
==============================================================================
--- servicemix/branches/servicemix-4.0/runtime/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/spring/GShell.java (original)
+++ servicemix/branches/servicemix-4.0/runtime/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/spring/GShell.java Wed Dec 5 07:47:34 2007
@@ -20,6 +20,7 @@
import org.apache.geronimo.gshell.command.IO;
import org.apache.geronimo.gshell.shell.Environment;
import org.apache.geronimo.gshell.shell.InteractiveShell;
+import org.apache.servicemix.main.spi.MainService;
/**
* Created by IntelliJ IDEA.
@@ -35,6 +36,7 @@
private IO io;
private Environment env;
private boolean start;
+ private MainService mainService;
public GShell(InteractiveShell shell) {
this.shell = shell;
@@ -62,13 +64,38 @@
}
public void run() {
- IOTargetSource.setIO(io);
- EnvironmentTargetSource.setEnvironment(env);
try {
- shell.run();
+ IOTargetSource.setIO(io);
+ EnvironmentTargetSource.setEnvironment(env);
+
+ String[] args=null;
+ if( mainService != null ) {
+ args = mainService.getArgs();
+ }
+
+ // If a command was specified on the command line, then just execute that command.
+ if( args!=null && args.length > 0 ) {
+ System.out.println("Executing 1 command:");
+ shell.execute((Object[])args);
+ }
+// For now we don't know how to shutdown after executing the command so go into a shell loop
+// else {
+ System.out.println("going int interactive loop:");
+ // Otherwise go into a command shell.
+ shell.run();
+// }
+
} catch (Exception e) {
e.printStackTrace();
}
}
+
+ public MainService getMainService() {
+ return mainService;
+ }
+
+ public void setMainService(MainService main) {
+ this.mainService = main;
+ }
}
Modified: servicemix/branches/servicemix-4.0/runtime/gshell/gshell-core/src/main/resources/META-INF/spring/gshell-local.xml
URL: http://svn.apache.org/viewvc/servicemix/branches/servicemix-4.0/runtime/gshell/gshell-core/src/main/resources/META-INF/spring/gshell-local.xml?rev=601373&r1=601372&r2=601373&view=diff
==============================================================================
--- servicemix/branches/servicemix-4.0/runtime/gshell/gshell-core/src/main/resources/META-INF/spring/gshell-local.xml (original)
+++ servicemix/branches/servicemix-4.0/runtime/gshell/gshell-core/src/main/resources/META-INF/spring/gshell-local.xml Wed Dec 5 07:47:34 2007
@@ -19,17 +19,24 @@
-->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:util="http://www.springframework.org/schema/util"
+ xmlns:util="http://www.springframework.org/schema/util"
+ xmlns:osgi="http://www.springframework.org/schema/osgi"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/util
- http://www.springframework.org/schema/util/spring-util.xsd">
+ http://www.springframework.org/schema/util/spring-util.xsd
+ http://www.springframework.org/schema/osgi
+ http://www.springframework.org/schema/osgi/spring-osgi.xsd">
+
+
+ <osgi:reference id="mainService" interface="org.apache.servicemix.main.spi.MainService" />
<bean id="gshell" class="org.apache.geronimo.gshell.spring.GShell"
init-method="start" destroy-method="stop">
<constructor-arg ref="interactiveShell" />
<property name="start" value="${startLocalConsole}" />
+ <property name="mainService" ref="mainService" />
</bean>
Modified: servicemix/branches/servicemix-4.0/runtime/main/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/branches/servicemix-4.0/runtime/main/pom.xml?rev=601373&r1=601372&r2=601373&view=diff
==============================================================================
--- servicemix/branches/servicemix-4.0/runtime/main/pom.xml (original)
+++ servicemix/branches/servicemix-4.0/runtime/main/pom.xml Wed Dec 5 07:47:34 2007
@@ -80,9 +80,18 @@
<_donotcopy>(CVS|.svn|config.properties)</_donotcopy>
<Main-Class>org.apache.servicemix.main.Main</Main-Class>
<Bundle-Name>Apache ServiceMix</Bundle-Name>
- <Bundle-Description>OSGi R4 framework.</Bundle-Description>
+ <Bundle-Description>OSGi R4 framework.</Bundle-Description>
+ <Export-Package>org.apache.servicemix.main.spi.*</Export-Package>
<Private-Package>
- org.apache.servicemix.main.*,org.apache.felix.moduleloader.*,org.apache.felix.framework.*,org.osgi.framework,org.osgi.service.packageadmin,org.osgi.service.startlevel,org.osgi.service.event,org.osgi.service.url,org.osgi.util.tracker
+ org.apache.servicemix.main,
+ org.apache.felix.moduleloader.*,
+ org.apache.felix.framework.*,
+ org.osgi.framework,
+ org.osgi.service.packageadmin,
+ org.osgi.service.startlevel,
+ org.osgi.service.event,
+ org.osgi.service.url,
+ org.osgi.util.tracker
</Private-Package>
<Import-Package>!*</Import-Package>
<Include-Resource>{src/main/resources/}</Include-Resource>
Modified: servicemix/branches/servicemix-4.0/runtime/main/src/main/java/org/apache/servicemix/main/Main.java
URL: http://svn.apache.org/viewvc/servicemix/branches/servicemix-4.0/runtime/main/src/main/java/org/apache/servicemix/main/Main.java?rev=601373&r1=601372&r2=601373&view=diff
==============================================================================
--- servicemix/branches/servicemix-4.0/runtime/main/src/main/java/org/apache/servicemix/main/Main.java (original)
+++ servicemix/branches/servicemix-4.0/runtime/main/src/main/java/org/apache/servicemix/main/Main.java Wed Dec 5 07:47:34 2007
@@ -26,6 +26,10 @@
import org.apache.felix.framework.Felix;
import org.apache.felix.framework.cache.BundleCache;
import org.apache.felix.framework.util.StringMap;
+import org.apache.servicemix.main.spi.MainService;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
/**
* <p>
@@ -38,7 +42,7 @@
* the framework.
* </p>
**/
-public class Main
+public class Main implements MainService
{
/**
* The system property name used to specify an URL to the system
@@ -64,8 +68,13 @@
public static final String PROPERTY_AUTO_START = "felix.auto.start";
private static Felix m_felix = null;
+ private final String[] args;
- /**
+ public Main(String[] args) {
+ this.args = args;
+ }
+
+ /**
* <p>
* This method performs the main task of constructing an framework instance
* and starting its execution. The following functions are performed
@@ -191,11 +200,29 @@
System.err.println("You must specify a profile name or directory.");
System.exit(-1);
}
+
+ // Register the Main class so that other bundles can inspect the command line args.
+ final MainService main = new Main(argv);
+ BundleActivator activator = new BundleActivator() {
+ private ServiceRegistration registration;
+ public void start(BundleContext context)
+ {
+ registration = context.registerService(MainService.class.getName(), main, null);
+ }
+ public void stop(BundleContext context)
+ {
+ registration.unregister();
+ }
+ };
+ List<BundleActivator> activations = new ArrayList<BundleActivator>();
+ activations.add(activator);
+
try
{
// Now create an instance of the framework.
- m_felix = new Felix(new StringMap(configProps, false), null);
+
+ m_felix = new Felix(new StringMap(configProps, false), activations);
m_felix.start();
}
catch (Exception ex)
@@ -284,7 +311,7 @@
is = propURL.openConnection().getInputStream();
props.load(is);
is.close();
- }
+ }
catch (FileNotFoundException ex)
{
// Ignore file not found.
@@ -499,14 +526,14 @@
* property placeholder syntax or a recursive variable reference.
**/
public static String substVars(String val, String currentKey,
- Map cycleMap, Properties configProps)
+ Map<String, String> cycleMap, Properties configProps)
throws IllegalArgumentException
{
// If there is currently no cycle map, then create
// one for detecting cycles for this invocation.
if (cycleMap == null)
{
- cycleMap = new HashMap();
+ cycleMap = new HashMap<String, String>();
}
// Put the current key in the cycle map.
@@ -597,4 +624,11 @@
// Return the value.
return val;
}
+
+ /* (non-Javadoc)
+ * @see org.apache.servicemix.main.MainService#getArgs()
+ */
+ public String[] getArgs() {
+ return args;
+ }
}
Added: servicemix/branches/servicemix-4.0/runtime/main/src/main/java/org/apache/servicemix/main/spi/MainService.java
URL: http://svn.apache.org/viewvc/servicemix/branches/servicemix-4.0/runtime/main/src/main/java/org/apache/servicemix/main/spi/MainService.java?rev=601373&view=auto
==============================================================================
--- servicemix/branches/servicemix-4.0/runtime/main/src/main/java/org/apache/servicemix/main/spi/MainService.java (added)
+++ servicemix/branches/servicemix-4.0/runtime/main/src/main/java/org/apache/servicemix/main/spi/MainService.java Wed Dec 5 07:47:34 2007
@@ -0,0 +1,25 @@
+/*
+ * 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.apache.servicemix.main.spi;
+
+public interface MainService {
+
+ public abstract String[] getArgs();
+
+}
\ No newline at end of file
Modified: servicemix/branches/servicemix-4.0/runtime/minimum/src/main/release/bin/servicemix.bat
URL: http://svn.apache.org/viewvc/servicemix/branches/servicemix-4.0/runtime/minimum/src/main/release/bin/servicemix.bat?rev=601373&r1=601372&r2=601373&view=diff
==============================================================================
--- servicemix/branches/servicemix-4.0/runtime/minimum/src/main/release/bin/servicemix.bat (original)
+++ servicemix/branches/servicemix-4.0/runtime/minimum/src/main/release/bin/servicemix.bat Wed Dec 5 07:47:34 2007
@@ -73,7 +73,7 @@
if "%JAVA_HOME%" == "" call :warn JAVA_HOME not set; results may vary
if not "%JAVA_HOME%" == "" set JAVA=%JAVA_HOME%\bin\java
if not exist "%JAVA_HOME%" (
- call :warn JAVA_HOME is not valid: %JAVA_HOME%
+ call :warn JAVA_HOME is not valid: "%JAVA_HOME%"
goto END
)
:Check_JAVA_END
@@ -114,7 +114,7 @@
:EXECUTE
rem Execute the Java Virtual Machine
cd "%SERVICEMIX_HOME%"
- "%JAVA%" %JAVA_OPTS% -Dservicemix.home="%SERVICEMIX_HOME%" -Dbundles.configuration.location="%SERVICEMIX_HOME%/conf" -jar "%SERVICEMIX_HOME%\bin\bootstrapper.jar" "%SERVICEMIX_HOME%" start
+ "%JAVA%" %JAVA_OPTS% -Dservicemix.home="%SERVICEMIX_HOME%" -Dbundles.configuration.location="%SERVICEMIX_HOME%/conf" -jar "%SERVICEMIX_HOME%\bin\servicemix.jar" %*
rem # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Modified: servicemix/branches/servicemix-4.0/runtime/minimum/src/main/release/bin/servicemix.sh
URL: http://svn.apache.org/viewvc/servicemix/branches/servicemix-4.0/runtime/minimum/src/main/release/bin/servicemix.sh?rev=601373&r1=601372&r2=601373&view=diff
==============================================================================
--- servicemix/branches/servicemix-4.0/runtime/minimum/src/main/release/bin/servicemix.sh (original)
+++ servicemix/branches/servicemix-4.0/runtime/minimum/src/main/release/bin/servicemix.sh Wed Dec 5 07:47:34 2007
@@ -245,7 +245,7 @@
SERVICEMIX_HOME=`cygpath --path --windows "$SERVICEMIX_HOME"`
fi
cd "$SERVICEMIX_HOME"
- exec $JAVA $JAVA_OPTS -Dservicemix.home="$SERVICEMIX_HOME" -Dbundles.configuration.location="$SERVICEMIX_HOME/etc" -jar "$JAR" "$1"
+ exec $JAVA $JAVA_OPTS -Dservicemix.home="$SERVICEMIX_HOME" -Dbundles.configuration.location="$SERVICEMIX_HOME/etc" -jar "$JAR" "$*"
}
main() {
Modified: servicemix/branches/servicemix-4.0/runtime/minimum/src/main/release/etc/config.properties
URL: http://svn.apache.org/viewvc/servicemix/branches/servicemix-4.0/runtime/minimum/src/main/release/etc/config.properties?rev=601373&r1=601372&r2=601373&view=diff
==============================================================================
--- servicemix/branches/servicemix-4.0/runtime/minimum/src/main/release/etc/config.properties (original)
+++ servicemix/branches/servicemix-4.0/runtime/minimum/src/main/release/etc/config.properties Wed Dec 5 07:47:34 2007
@@ -24,6 +24,7 @@
org.osgi.service.packageadmin; version=1.2.0, \
org.osgi.service.startlevel; version=1.0.0, \
org.osgi.service.url; version=1.0.0, \
+ org.apache.servicemix.main.spi; version=1.0.0, \
${jre-${java.specification.version}}
#org.osgi.framework.bootdelegation=sun.*,com.sun.*
felix.auto.start=true