SLC CLI
authorMathieu Baudier <mbaudier@argeo.org>
Tue, 12 Mar 2013 22:50:11 +0000 (22:50 +0000)
committerMathieu Baudier <mbaudier@argeo.org>
Tue, 12 Mar 2013 22:50:11 +0000 (22:50 +0000)
git-svn-id: https://svn.argeo.org/slc/trunk@6122 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

22 files changed:
dep/org.argeo.slc.dep.backend/pom.xml
dep/org.argeo.slc.dep.minimal/pom.xml
dist/slc/pom.xml
dist/slc/src/assembly/devel.xml
dist/slc/src/assembly/dist.xml
dist/slc/src/main/base/bin/slc [new file with mode: 0755]
dist/slc/src/main/base/work/server/conf/config.ini [deleted file]
dist/slc/src/main/rpm/etc/slc-cl/config.ini
dist/slc/src/main/rpm/usr/bin/slc
lib/org.argeo.slc.lib.repo/META-INF/spring/helloworld.xml [new file with mode: 0644]
runtime/org.argeo.slc.launcher/src/main/base/bin/slc [deleted file]
runtime/org.argeo.slc.launcher/src/main/java/org/argeo/slc/cli/SlcMain.java
runtime/org.argeo.slc.launcher/src/main/resources/org/argeo/slc/cli/bootstrapLog4j.properties [deleted file]
runtime/org.argeo.slc.launcher/src/main/resources/org/argeo/slc/cli/jaas.config [new file with mode: 0644]
runtime/org.argeo.slc.launcher/src/main/resources/org/argeo/slc/cli/log4j.properties [new file with mode: 0644]
runtime/org.argeo.slc.launcher/src/main/resources/org/argeo/slc/cli/spring.xml [deleted file]
runtime/org.argeo.slc.launcher/src/main/resources/org/argeo/slc/server/client/spring.xml [deleted file]
runtime/org.argeo.slc.support.equinox/META-INF/spring/commandProvider.xml [new file with mode: 0644]
runtime/org.argeo.slc.support.equinox/META-INF/spring/manager.xml [deleted file]
runtime/org.argeo.slc.support.equinox/META-INF/spring/osgi.xml
runtime/org.argeo.slc.support.equinox/src/main/java/org/argeo/slc/equinox/ExecutionCommandProvider.java
runtime/org.argeo.slc.unit/pom.xml

index 410031fa99787abac8417cd2bba9629968ad26a8..f2b4fc2dd619d38a3eca26ffd673a04081ce5339 100644 (file)
                        <artifactId>org.argeo.slc.server.repo.webapp</artifactId>
                        <version>1.1.12-SNAPSHOT</version>
                </dependency>
-
-               <!-- Launcher -->
-               <dependency>
-                       <groupId>org.argeo.slc</groupId>
-                       <artifactId>org.argeo.slc.launcher</artifactId>
-                       <version>1.1.12-SNAPSHOT</version>
-                       <type>tar.gz</type>
-                       <classifier>base</classifier>
-               </dependency>
-
+               
                <!-- Node -->
                <dependency>
                        <groupId>org.argeo.commons.security</groupId>
index 475f5c45cf4cb68ce3273ea7064eb76ae3b212c3..37118dbd6f7c568eecc4e8d114c54fa34e4eca4a 100644 (file)
                </dependency>
 
                <!-- CLI Agent -->
-               <dependency>
-                       <groupId>org.argeo.slc</groupId>
-                       <artifactId>org.argeo.slc.launcher</artifactId>
-                       <version>1.1.12-SNAPSHOT</version>
-               </dependency>
+<!--           <dependency> -->
+<!--                   <groupId>org.argeo.slc</groupId> -->
+<!--                   <artifactId>org.argeo.slc.launcher</artifactId> -->
+<!--                   <version>1.1.12-SNAPSHOT</version> -->
+<!--           </dependency> -->
                <dependency>
                        <groupId>org.argeo.slc</groupId>
                        <artifactId>org.argeo.slc.agent.cli</artifactId>
index 42647835265e4cff24fae306564a27a4dcad851f..aeed0b24ce1467d7ae74a0e4223ecc12df732d9c 100644 (file)
@@ -1,4 +1,5 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
        <modelVersion>4.0.0</modelVersion>
        <parent>
                <groupId>org.argeo.slc</groupId>
        </parent>
        <artifactId>slc</artifactId>
        <packaging>pom</packaging>
-       <name>SLC Node (RPM)</name>
+       <name>SLC Distribution</name>
        <profiles>
+               <profile>
+                       <id>dist</id>
+                       <build>
+                               <plugins>
+                                       <!-- <plugin> -->
+                                       <!-- <groupId>org.apache.maven.plugins</groupId> -->
+                                       <!-- <artifactId>maven-dependency-plugin</artifactId> -->
+                                       <!-- <executions> -->
+                                       <!-- <execution> -->
+                                       <!-- <id>copy-dependencies-dist</id> -->
+                                       <!-- <phase>package</phase> -->
+                                       <!-- <goals> -->
+                                       <!-- <goal>copy-dependencies</goal> -->
+                                       <!-- </goals> -->
+                                       <!-- <configuration> -->
+                                       <!-- <includeTypes>jar</includeTypes> -->
+                                       <!-- <useRepositoryLayout>true</useRepositoryLayout> -->
+                                       <!-- <outputDirectory>${project.build.directory}/modulest</outputDirectory> -->
+                                       <!-- </configuration> -->
+                                       <!-- </execution> -->
+                                       <!-- </executions> -->
+                                       <!-- </plugin> -->
+                                       <plugin>
+                                               <groupId>org.apache.maven.plugins</groupId>
+                                               <artifactId>maven-assembly-plugin</artifactId>
+                                               <configuration>
+                                                       <finalName>argeo-slc-${project.version}</finalName>
+                                                       <appendAssemblyId>false</appendAssemblyId>
+                                                       <descriptors>
+                                                               <descriptor>src/assembly/dist.xml</descriptor>
+                                                       </descriptors>
+                                               </configuration>
+                                               <executions>
+                                                       <execution>
+                                                               <id>assembly-base</id>
+                                                               <phase>package</phase>
+                                                               <goals>
+                                                                       <goal>single</goal>
+                                                               </goals>
+                                                       </execution>
+                                               </executions>
+                                       </plugin>
+                               </plugins>
+                       </build>
+                       <dependencies>
+                               <!-- Backend -->
+                               <dependency>
+                                       <groupId>org.argeo.slc</groupId>
+                                       <artifactId>org.argeo.slc.dep.backend</artifactId>
+                                       <version>1.1.12-SNAPSHOT</version>
+                                       <type>pom</type>
+                               </dependency>
+
+                               <!-- SLC Libs -->
+                               <dependency>
+                                       <groupId>org.argeo.slc</groupId>
+                                       <artifactId>org.argeo.slc.lib.jcr</artifactId>
+                                       <version>1.1.12-SNAPSHOT</version>
+                               </dependency>
+                               <dependency>
+                                       <groupId>org.argeo.slc</groupId>
+                                       <artifactId>org.argeo.slc.lib.repo</artifactId>
+                                       <version>1.1.12-SNAPSHOT</version>
+                               </dependency>
+
+                               <!-- Launcher -->
+                               <dependency>
+                                       <groupId>org.argeo.slc</groupId>
+                                       <artifactId>org.argeo.slc.launcher</artifactId>
+                                       <version>1.1.12-SNAPSHOT</version>
+                                       <!-- <type>tar.gz</type> -->
+                                       <!-- <classifier>base</classifier> -->
+                               </dependency>
+                       </dependencies>
+               </profile>
                <profile>
                        <id>rpmbuild</id>
                        <build>
                                <plugins>
+                                       <plugin>
+                                               <groupId>org.apache.maven.plugins</groupId>
+                                               <artifactId>maven-dependency-plugin</artifactId>
+                                               <executions>
+                                                       <execution>
+                                                               <id>copy-dependencies-rpm</id>
+                                                               <phase>package</phase>
+                                                               <goals>
+                                                                       <goal>copy</goal>
+                                                               </goals>
+                                                               <configuration>
+                                                                       <includeTypes>jar</includeTypes>
+                                                                       <stripVersion>true</stripVersion>
+                                                                       <outputDirectory>${project.build.directory}/boot</outputDirectory>
+                                                                       <artifactItems>
+                                                                               <artifactItem>
+                                                                                       <groupId>org.argeo.slc</groupId>
+                                                                                       <artifactId>org.argeo.slc.launcher</artifactId>
+                                                                                       <version>${project.version}</version>
+                                                                               </artifactItem>
+                                                                       </artifactItems>
+                                                               </configuration>
+                                                       </execution>
+                                               </executions>
+                                       </plugin>
                                        <plugin>
                                                <groupId>org.codehaus.mojo</groupId>
                                                <artifactId>rpm-maven-plugin</artifactId>
                                                                                                </source>
                                                                                        </sources>
                                                                                </mapping>
+                                                                               <mapping>
+                                                                                       <directory>/usr/share/osgi/boot</directory>
+                                                                                       <username>root</username>
+                                                                                       <groupname>root</groupname>
+                                                                                       <filemode>644</filemode>
+                                                                                       <directoryIncluded>false</directoryIncluded>
+                                                                                       <sources>
+                                                                                               <source>
+                                                                                                       <location>${project.build.directory}/boot</location>
+                                                                                                       <includes>
+                                                                                                               <include>org.argeo.slc.launcher.jar</include>
+                                                                                                       </includes>
+                                                                                               </source>
+                                                                                       </sources>
+                                                                               </mapping>
                                                                                <!-- Maven (even if not installed) -->
                                                                                <mapping>
                                                                                        <directory>/var/lib/slc/.m2</directory>
index ffbc98feda97349e2c7138ab41c4fb8228bdb86c..6164817cb5280f0634c428eba29df8b3e842528b 100644 (file)
@@ -20,7 +20,7 @@
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
        <id>devel</id>
-       <baseDirectory>slc</baseDirectory>
+       <baseDirectory>argeo-slc-${project.version}</baseDirectory>
        <formats>
                <format>zip</format>
        </formats>
index 4fdab1ad11caa8f7ebcb9dad3d52ccf24731a380..c101a9d6f2b13ec2497e282795dbb36474557ae8 100644 (file)
@@ -1,54 +1,59 @@
-<!--
-
-    Copyright (C) 2007-2012 Argeo GmbH
-
-    Licensed 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.
-
--->
+<!-- Copyright (C) 2007-2012 Argeo GmbH Licensed 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. -->
 <assembly
        xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
        <id>dist</id>
-       <baseDirectory>slc</baseDirectory>
+       <baseDirectory>argeo-slc-${project.version}</baseDirectory>
        <formats>
-               <format>zip</format>
+               <format>tar.gz</format>
        </formats>
        <fileSets>
                <fileSet>
-                       <directory>target/base</directory>
-                       <outputDirectory></outputDirectory>
+                       <directory>src/main/base/bin</directory>
+                       <outputDirectory>bin</outputDirectory>
+                       <fileMode>0755</fileMode>
                        <includes>
-                               <include>**</include>
+                               <include>slc</include>
                        </includes>
                </fileSet>
        </fileSets>
        <dependencySets>
                <dependencySet>
                        <unpack>false</unpack>
-                       <outputFileNameMapping>${artifact.artifactId}-${artifact.baseVersion}.${artifact.extension}
-                       </outputFileNameMapping>
-                       <outputDirectory>lib</outputDirectory>
+                       <outputFileNameMapping>${artifact.artifactId}-${artifact.baseVersion}.${artifact.extension}</outputFileNameMapping>
+                       <outputDirectory>modules</outputDirectory>
                        <includes>
                                <include>*:jar</include>
                        </includes>
+                       <excludes>
+                               <exclude>org.argeo.tp:org.eclipse.osgi</exclude>
+                               <exclude>org.argeo.commons.base:org.argeo.osgi.boot</exclude>
+                               <exclude>org.argeo.slc:org.argeo.slc.launcher</exclude>
+                       </excludes>
                </dependencySet>
                <dependencySet>
-                       <unpack>true</unpack>
+                       <unpack>false</unpack>
+                       <outputFileNameMapping>${artifact.artifactId}-${artifact.baseVersion}.${artifact.extension}</outputFileNameMapping>
+                       <outputDirectory>boot</outputDirectory>
                        <includes>
-                               <include>org.argeo.slc.runtime:org.argeo.slc.launcher:tar.gz:base
-                               </include>
+                               <include>org.argeo.tp:org.eclipse.osgi</include>
+                               <include>org.argeo.commons.base:org.argeo.osgi.boot</include>
+                               <include>org.argeo.slc:org.argeo.slc.launcher</include>
                        </includes>
                </dependencySet>
+               <!-- <dependencySet> -->
+               <!-- <unpack>true</unpack> -->
+               <!-- <includes> -->
+               <!-- <include>org.argeo.slc.runtime:org.argeo.slc.launcher:tar.gz:base -->
+               <!-- </include> -->
+               <!-- </includes> -->
+               <!-- </dependencySet> -->
        </dependencySets>
 </assembly>
\ No newline at end of file
diff --git a/dist/slc/src/main/base/bin/slc b/dist/slc/src/main/base/bin/slc
new file mode 100755 (executable)
index 0000000..b85869d
--- /dev/null
@@ -0,0 +1,44 @@
+#!/bin/sh
+
+JAVA_CMD=java
+JAVA_OPTS="-client -Xmx128m"
+
+SLC_HOME_DIR=${HOME}/.slc/
+if [ -f $SLC_HOME_DIR/settings.sh ];then
+       . $SLC_HOME_DIR/settings.sh
+fi
+
+# Find home
+if [ -z "$ARGEO_SLC_HOME" -o ! -d "$ARGEO_SLC_HOME" ] ; then
+  ## resolve links - $0 may be a link to home
+  PRG="$0"
+  progname=`basename "$0"`
+
+  # need this for relative symlinks
+  while [ -h "$PRG" ] ; do
+    ls=`ls -ld "$PRG"`
+    link=`expr "$ls" : '.*-> \(.*\)$'`
+    if expr "$link" : '/.*' > /dev/null; then
+    PRG="$link"
+    else
+    PRG=`dirname "$PRG"`"/$link"
+    fi
+  done
+
+  ARGEO_SLC_HOME=`dirname "$PRG"`/..
+
+  # make it fully qualified
+  ARGEO_SLC_HOME=`cd "$ARGEO_SLC_HOME" && pwd`
+fi
+
+for i in "${ARGEO_SLC_HOME}"/boot/*.jar
+       do
+       CLASSPATH="$CLASSPATH:$i"
+       done
+
+ARGEO_OSGI_BUNDLES="$SLC_HOME_DIR/modules;in=**;ex=**/.git/**;ex=**/.svn/**,$ARGEO_SLC_HOME/modules;in=**;ex=**/.git/**;ex=**/.svn/**"
+
+$JAVA_CMD $JAVA_OPTS \
+ "-Dargeo.osgi.bundles=$ARGEO_OSGI_BUNDLES" \
+ -cp "$CLASSPATH" \
+ org.argeo.slc.cli.SlcMain "$@"
\ No newline at end of file
diff --git a/dist/slc/src/main/base/work/server/conf/config.ini b/dist/slc/src/main/base/work/server/conf/config.ini
deleted file mode 100644 (file)
index 30d4ab2..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-osgi.bundles=org.argeo.osgi.boot-${version.argeo-commons}.jar@start
-argeo.osgi.bundles=${osgi.install.area};in=*.jar
-argeo.osgi.start=org.springframework.osgi.extender,\
-       org.argeo.server.ads.server,\
-       org.argeo.slc.server.hsqldb,\
-       org.argeo.slc.server.main,\
-       org.argeo.slc.ria
index 37bd5af3127f57b412694a391438dc236272a791..8da7f7d8d0c3b64f3fcad8b9a6f8bb903b47d954 100644 (file)
@@ -7,13 +7,7 @@ org.argeo.slc.node.jackrabbit,\
 org.argeo.slc.agent,\
 org.argeo.slc.agent.jcr
 
-argeo.node.repo.configuration=osgibundle:repository-memory.xml
-
-## LOGGING
-log4j.configuration=file:/etc/slc-cl/log4j.properties
-
 # DO NOT CHANGE BELOW UNLESS YOU KNOW WHAT YOU ARE DOING
-osgi.bundles=org.argeo.osgi.boot.jar@start
 
 argeo.osgi.bundles=\
 ${user.home}/.slc/modules;in=**;ex=**/.git/**;ex=**/.svn/**,\
index 6dd87d33b9284b745ca2a1fb6b2c9cfb10ad55b4..9487c63771fe7191e94c2917e9748d1292bdf863 100644 (file)
@@ -1,30 +1,22 @@
 #!/bin/sh
 
-OSGI_INSTALL_AREA=/usr/share/osgi/boot
-OSGI_FRAMEWORK=$OSGI_INSTALL_AREA/org.eclipse.osgi.jar
-
-CL_DIR=~/.slc/cl
-DATA_DIR=$CL_DIR/data
-CONF_DIR=$CL_DIR/conf
-
-MODULE=$1
-FLOW=$2
+JAVA_CMD=/usr/lib/jvm/java-1.6.0/bin/java
+JAVA_OPTS="-client -Xmx256m"
 
-if [ ! -f $CONF_DIR/config.ini ];
-then
-       mkdir -p $CONF_DIR
-    cp /etc/slc-cl/config.ini $CONF_DIR
+SLC_HOME_DIR=${HOME}/.slc/
+if [ -f $SLC_HOME_DIR/settings.sh ];then
+       . $SLC_HOME_DIR/settings.sh
 fi
 
-# WORKAROUND: Clean up workspace directories
-rmdir $DATA_DIR/node/workspaces/*
+OSGI_INSTALL_AREA=/usr/share/osgi/boot
+OSGI_FRAMEWORK=$OSGI_INSTALL_AREA/org.eclipse.osgi.jar
+OSGI_BOOT=$OSGI_INSTALL_AREA/org.argeo.osgi.boot.jar
+SLC_LAUNCHER=$OSGI_INSTALL_AREA/org.argeo.slc.launcher.jar
+
+ARGEO_OSGI_BUNDLES="$SLC_HOME_DIR/modules;in=**;ex=**/.git/**;ex=**/.svn/**,/etc/slc-cl/modules;in=**;ex=**/.git/**;ex=**/.svn/**,/usr/share/osgi;in=*.jar"
 
-java \
- -Dslc.launch.module="$MODULE" \
- -Dslc.launch.flow="$FLOW" \
- -jar $OSGI_FRAMEWORK \
- -configuration $CONF_DIR \
- -data $DATA_DIR \
- -console \
- -clean
+$JAVA_CMD $JAVA_OPTS \
+ "-Dargeo.osgi.bundle=$ARGEO_OSGI_BUNDLES" \
+ -cp $OSGI_FRAMEWORK:$OSGI_BOOT \
+ -jar $SLC_LAUNCHER "$@"
  
\ No newline at end of file
diff --git a/lib/org.argeo.slc.lib.repo/META-INF/spring/helloworld.xml b/lib/org.argeo.slc.lib.repo/META-INF/spring/helloworld.xml
new file mode 100644 (file)
index 0000000..8e04d7e
--- /dev/null
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<beans xmlns:flow="http://www.argeo.org/schema/slc-flow" xmlns="http://www.springframework.org/schema/beans"\r
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
+       xsi:schemaLocation="\r
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
+       http://www.argeo.org/schema/slc-flow http://www.argeo.org/schema/slc-flow-1.2.xsd">\r
+\r
+       <!-- Hello world -->\r
+       <flow:flow name="hello">\r
+               <description>Print Hello World!</description>\r
+               <bean p:message="Hello World!" class="org.argeo.slc.core.execution.tasks.Echo" />\r
+       </flow:flow>\r
+\r
+\r
+       <flow:flow name="hello-with-var">\r
+               <description>Print Hello World! with variable</description>\r
+               <flow:spec>\r
+                       <flow:primitive name="testKey" value="777" />\r
+               </flow:spec>\r
+               <bean p:message="Hello World! @{testKey}" class="org.argeo.slc.core.execution.tasks.Echo">\r
+                       <flow:variable proxy-target-class="false" />\r
+               </bean>\r
+       </flow:flow>\r
+\r
+</beans>
\ No newline at end of file
diff --git a/runtime/org.argeo.slc.launcher/src/main/base/bin/slc b/runtime/org.argeo.slc.launcher/src/main/base/bin/slc
deleted file mode 100755 (executable)
index ca8ef49..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-#!/bin/sh
-
-# Find home
-if [ -z "$ARGEO_SLC_HOME" -o ! -d "$ARGEO_SLC_HOME" ] ; then
-  ## resolve links - $0 may be a link to home
-  PRG="$0"
-  progname=`basename "$0"`
-
-  # need this for relative symlinks
-  while [ -h "$PRG" ] ; do
-    ls=`ls -ld "$PRG"`
-    link=`expr "$ls" : '.*-> \(.*\)$'`
-    if expr "$link" : '/.*' > /dev/null; then
-    PRG="$link"
-    else
-    PRG=`dirname "$PRG"`"/$link"
-    fi
-  done
-
-  ARGEO_SLC_HOME=`dirname "$PRG"`/..
-
-  # make it fully qualified
-  ARGEO_SLC_HOME=`cd "$ARGEO_SLC_HOME" && pwd`
-fi
-
-echo ARGEO_SLC_HOME=$ARGEO_SLC_HOME
-
-for i in "${ARGEO_SLC_HOME}"/lib/*.jar
-       do
-       CLASSPATH="$CLASSPATH:$i"
-       done
-
-#echo CLASSPATH=$CLASSPATH
-
-java -cp $CLASSPATH org.argeo.slc.cli.SlcMain "$@"
index 4c5c82dd136f65493791e61941ec908136ebd8c2..606748279a0a57fc398b6ac340a1ca0ade276f5f 100644 (file)
 package org.argeo.slc.cli;
 
 import java.io.File;
+import java.io.FileOutputStream;
+import java.io.InputStream;
 import java.lang.reflect.Method;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
 import java.util.ArrayList;
-import java.util.Arrays;
+import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -37,12 +39,13 @@ import org.osgi.framework.launch.Framework;
 import org.osgi.framework.launch.FrameworkFactory;
 
 /** Configures an SLC runtime and runs a process. */
-public class SlcMain implements Runnable {
+public class SlcMain implements PrivilegedAction<String> {
        public final static String NIX = "NIX";
        public final static String WINDOWS = "WINDOWS";
        public final static String SOLARIS = "SOLARIS";
 
        public final static String os;
+       public final static String slcDirName = ".slc";
        static {
                String osName = System.getProperty("os.name");
                if (osName.startsWith("Win"))
@@ -53,63 +56,36 @@ public class SlcMain implements Runnable {
                        os = NIX;
        }
 
-       // private final DateFormat dateFormat = new
-       // SimpleDateFormat("HH:mm:ss,SSS");
        private Long timeout = 30 * 1000l;
        private final String[] args;
-
-       // private static String bundlesToInstall = "/usr/share/osgi;in=*.jar";
-       private String bundlesToInstall = System.getProperty("user.home")
-                       + "/dev/src/slc/dep/org.argeo.slc.dep.minimal/target/dependency;in=*.jar,"
-                       + System.getProperty("user.home")
-                       + "/dev/src/slc/demo/modules;in=*;ex=pom.xml;ex=.svn";
+       private final File confDir;
+       private final File dataDir;
+       private final File modulesDir;
 
        private final List<String> bundlesToStart = new ArrayList<String>();
 
-       public SlcMain(String[] args) {
+       public SlcMain(String[] args, File confDir, File dataDir, File modulesDir) {
                this.args = args;
+               this.confDir = confDir;
+               this.dataDir = dataDir;
+               this.modulesDir = modulesDir;
                bundlesToStart.add("org.springframework.osgi.extender");
                bundlesToStart.add("org.argeo.node.repo.jackrabbit");
                bundlesToStart.add("org.argeo.security.dao.os");
                bundlesToStart.add("org.argeo.slc.node.jackrabbit");
                bundlesToStart.add("org.argeo.slc.agent");
                bundlesToStart.add("org.argeo.slc.agent.jcr");
+               if (args.length == 0)
+                       bundlesToStart.add("org.argeo.slc.support.equinox");
                // bundlesToStart.add("org.argeo.slc.agent.cli");
        }
 
-       public void run() {
+       public String run() {
                long begin = System.currentTimeMillis();
-               // System.out.println(dateFormat.format(new Date()));
 
-               Boolean isTransient = false;
-               File dataDir = null;
-               final LoginContext lc;
                try {
-                       // Authenticate
-                       lc = new LoginContext(os);
-                       lc.login();
-
-                       // Prepare directories
-                       String executionDir = System.getProperty("user.dir");
-                       File slcDir = new File(executionDir, ".slc");
-                       File tempDir = new File(System.getProperty("java.io.tmpdir"));
-
-                       if (isTransient)
-                               dataDir = new File(tempDir, "slc-data-"
-                                               + UUID.randomUUID().toString());
-                       else
-                               dataDir = new File(slcDir, "data");
-                       if (!dataDir.exists())
-                               dataDir.mkdirs();
-
-                       File confDir = new File(slcDir, "conf");
-                       if (!confDir.exists())
-                               confDir.mkdirs();
-
-                       System.setProperty("log4j.configuration", "file:./log4j.properties");
-                       if (isTransient)
-                               System.setProperty("argeo.node.repo.configuration",
-                                               "osgibundle:repository-memory.xml");
+                       info("## Date : " + new Date());
+                       info("## Data : " + dataDir.getCanonicalPath());
 
                        // Start Equinox
                        ServiceLoader<FrameworkFactory> ff = ServiceLoader
@@ -119,8 +95,10 @@ public class SlcMain implements Runnable {
                        configuration.put("osgi.configuration.area",
                                        confDir.getCanonicalPath());
                        configuration.put("osgi.instance.area", dataDir.getCanonicalPath());
-                       // configuration.put("osgi.clean", "true");
-                       // configuration.put("osgi.console", "");
+                       if (args.length == 0) {
+                               // configuration.put("osgi.clean", "true");
+                               configuration.put("osgi.console", "");
+                       }
 
                        // Spring configs currently require System properties
                        System.getProperties().putAll(configuration);
@@ -128,15 +106,22 @@ public class SlcMain implements Runnable {
                        Framework framework = frameworkFactory.newFramework(configuration);
                        framework.start();
                        BundleContext bundleContext = framework.getBundleContext();
-                       // String[] osgiRuntimeArgs = { "-configuration",
-                       // confDir.getCanonicalPath(), "-data",
-                       // dataDir.getCanonicalPath(), "-clean" };
-                       // BundleContext bundleContext = EclipseStarter.startup(
-                       // osgiRuntimeArgs, null);
 
                        // OSGi bootstrap
                        OsgiBoot osgiBoot = new OsgiBoot(bundleContext);
-                       osgiBoot.installUrls(osgiBoot.getBundlesUrls(bundlesToInstall));
+
+                       // working copy modules
+                       if (modulesDir.exists())
+                               osgiBoot.installUrls(osgiBoot.getBundlesUrls(modulesDir
+                                               .getCanonicalPath() + ";in=*;ex=.gitignore"));
+
+                       // system modules
+                       if (System.getProperty(OsgiBoot.PROP_ARGEO_OSGI_BUNDLES) != null)
+                               osgiBoot.installUrls(osgiBoot.getBundlesUrls(System
+                                               .getProperty(OsgiBoot.PROP_ARGEO_OSGI_BUNDLES)));
+                       else
+                               osgiBoot.installUrls(osgiBoot.getBundlesUrls(System
+                                               .getProperty("user.home") + "/.slc/modules/**"));
 
                        // Start runtime
                        osgiBoot.startBundles(bundlesToStart);
@@ -150,66 +135,186 @@ public class SlcMain implements Runnable {
                                        throw new RuntimeException("Cannot find SLC agent CLI");
                                Thread.sleep(100);
                        }
-                       final Object agentCli = bundleContext.getService(sr);
-
-                       // ServiceTracker agentTracker = new ServiceTracker(bundleContext,
-                       // "org.argeo.slc.execution.SlcAgentCli", null);
-                       // agentTracker.open();
-                       // final Object agentCli = agentTracker.waitForService(30 * 1000);
-                       // if (agentCli == null)
-                       // throw new RuntimeException("Cannot find SLC agent CLI");
+                       Object agentCli = bundleContext.getService(sr);
 
+                       // Initialization completed
                        long duration = System.currentTimeMillis() - begin;
-                       System.out.println("Initialized in " + (duration / 1000) + "s "
-                                       + (duration % 1000) + "ms");
-                       // Run as a privileged action
-                       Subject.doAs(Subject.getSubject(AccessController.getContext()),
-                                       new PrivilegedAction<String>() {
-
-                                               public String run() {
-                                                       try {
-                                                               Class<?>[] parameterTypes = { String[].class };
-                                                               Method method = agentCli.getClass().getMethod(
-                                                                               "process", parameterTypes);
-                                                               Object[] methodArgs = { args };
-                                                               Object ret = method
-                                                                               .invoke(agentCli, methodArgs);
-                                                               return ret.toString();
-                                                       } catch (Exception e) {
-                                                               throw new RuntimeException("Cannot run "
-                                                                               + Arrays.toString(args) + " on "
-                                                                               + agentCli, e);
-                                                       }
-                                               }
-
-                                       });
+                       info("[[ Initialized in " + (duration / 1000) + "s "
+                                       + (duration % 1000) + "ms ]]");
+
+                       if (args.length == 0)
+                               return null;// console mode
+
+                       // Subject.doAs(Subject.getSubject(AccessController.getContext()),
+                       // new AgentCliCall(agentCli));
+                       Class<?>[] parameterTypes = { String[].class };
+                       Method method = agentCli.getClass().getMethod("process",
+                                       parameterTypes);
+                       Object[] methodArgs = { args };
+                       Object ret = method.invoke(agentCli, methodArgs);
 
                        // Shutdown OSGi runtime
                        framework.stop();
                        framework.waitForStop(60 * 1000);
 
-                       System.exit(0);
+                       return ret.toString();
+               } catch (Exception e) {
+                       throw new RuntimeException("Cannot run SLC command line", e);
+               }
+       }
+
+       public static void main(String[] args) {
+               try {
+                       // Prepare directories
+                       File executionDir = new File(System.getProperty("user.dir"));
+                       File slcDir;
+                       Boolean isTransient = false;
+                       if (isTransient) {
+                               File tempDir = new File(System.getProperty("java.io.tmpdir")
+                                               + "/" + System.getProperty("user.name"));
+                               slcDir = new File(tempDir, "slc-"
+                                               + UUID.randomUUID().toString());
+                               slcDir.mkdirs();
+                               System.setProperty("argeo.node.repo.configuration",
+                                               "osgibundle:repository-memory.xml");
+                       } else {
+                               slcDir = findSlcDir(executionDir);
+                               if (slcDir == null) {
+                                       slcDir = new File(executionDir, slcDirName);
+                                       slcDir.mkdirs();
+                               }
+                       }
+
+                       File dataDir = new File(slcDir, "data");
+                       if (!dataDir.exists())
+                               dataDir.mkdirs();
+
+                       File confDir = new File(slcDir, "conf");
+                       if (!confDir.exists())
+                               confDir.mkdirs();
+
+                       File modulesDir = new File(slcDir, "modules");
+
+                       // JAAS
+                       File jaasFile = new File(confDir, "jaas.config");
+                       if (!jaasFile.exists())
+                               copyResource("/org/argeo/slc/cli/jaas.config", jaasFile);
+                       System.setProperty("java.security.auth.login.config",
+                                       jaasFile.getCanonicalPath());
+
+                       // log4j
+                       File log4jFile = new File(confDir, "log4j.properties");
+                       if (!log4jFile.exists())
+                               copyResource("/org/argeo/slc/cli/log4j.properties", log4jFile);
+                       System.setProperty("log4j.configuration",
+                                       "file://" + log4jFile.getCanonicalPath());
+                       // Run as a privileged action
+                       LoginContext lc = new LoginContext(os);
+                       lc.login();
+
+                       Subject subject = Subject.getSubject(AccessController.getContext());
+                       Subject.doAs(subject, new SlcMain(args, confDir, dataDir,
+                                       modulesDir));
+
+                       if (args.length != 0)
+                               System.exit(0);
                } catch (Exception e) {
                        e.printStackTrace();
                        System.exit(1);
+               }
+       }
+
+       /**
+        * Recursively look in parent directories for a directory named
+        * {@link #slcDirName}
+        */
+       protected static File findSlcDir(File currentDir) {
+               File slcDir = new File(currentDir, slcDirName);
+               if (slcDir.exists() && slcDir.isDirectory())
+                       return slcDir;
+               File parentDir = currentDir.getParentFile();
+               if (parentDir == null)
+                       return null;
+               return findSlcDir(parentDir);
+       }
+
+       protected static void copyResource(String resource, File targetFile) {
+               InputStream input = null;
+               FileOutputStream output = null;
+               try {
+                       input = SlcMain.class.getResourceAsStream(resource);
+                       output = new FileOutputStream(targetFile);
+                       byte[] buf = new byte[8192];
+                       while (true) {
+                               int length = input.read(buf);
+                               if (length < 0)
+                                       break;
+                               output.write(buf, 0, length);
+                       }
+               } catch (Exception e) {
+                       throw new RuntimeException("Cannot write " + resource + " file to "
+                                       + targetFile, e);
                } finally {
-                       if (isTransient && dataDir != null && dataDir.exists()) {
-                               // TODO clean up transient data dir
+                       try {
+                               input.close();
+                       } catch (Exception ignore) {
+                       }
+                       try {
+                               output.close();
+                       } catch (Exception ignore) {
                        }
-
                }
-       }
 
-       public static void main(String[] args) {
-               new SlcMain(args).run();
        }
 
        protected static void info(Object msg) {
                System.out.println(msg);
        }
 
+       protected static void err(Object msg) {
+               System.err.println(msg);
+       }
+
        protected static void debug(Object msg) {
                System.out.println(msg);
        }
 
 }
+
+// private String bundlesToInstall = System.getProperty("user.home")
+// +
+// "/dev/src/slc/dep/org.argeo.slc.dep.minimal/target/dependency;in=*.jar,"
+// + System.getProperty("user.home")
+// + "/dev/src/slc/demo/modules;in=*;ex=pom.xml;ex=.svn";
+
+// ServiceTracker agentTracker = new ServiceTracker(bundleContext,
+// "org.argeo.slc.execution.SlcAgentCli", null);
+// agentTracker.open();
+// final Object agentCli = agentTracker.waitForService(30 * 1000);
+// if (agentCli == null)
+// throw new RuntimeException("Cannot find SLC agent CLI");
+
+// protected class AgentCliCall implements PrivilegedAction<String> {
+// private final Object agentCli;
+//
+// public AgentCliCall(Object agentCli) {
+// super();
+// this.agentCli = agentCli;
+// }
+//
+// public String run() {
+// try {
+// Class<?>[] parameterTypes = { String[].class };
+// Method method = agentCli.getClass().getMethod("process",
+// parameterTypes);
+// Object[] methodArgs = { args };
+// Object ret = method.invoke(agentCli, methodArgs);
+// return ret.toString();
+// } catch (Exception e) {
+// throw new RuntimeException("Cannot run "
+// + Arrays.toString(args) + " on " + agentCli, e);
+// }
+// }
+//
+// }
+
diff --git a/runtime/org.argeo.slc.launcher/src/main/resources/org/argeo/slc/cli/bootstrapLog4j.properties b/runtime/org.argeo.slc.launcher/src/main/resources/org/argeo/slc/cli/bootstrapLog4j.properties
deleted file mode 100644 (file)
index 7dcc3fd..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-log4j.rootLogger=WARN, console\r
-\r
-## Levels\r
-log4j.logger.org.argeo=INFO\r
-\r
-## Appenders\r
-# console is set to be a ConsoleAppender.\r
-log4j.appender.console=org.apache.log4j.ConsoleAppender\r
-\r
-# console uses PatternLayout.\r
-log4j.appender.console.layout=org.apache.log4j.PatternLayout\r
-log4j.appender.console.layout.ConversionPattern= %-5p %d{ISO8601} %m - %c%n\r
-\r
diff --git a/runtime/org.argeo.slc.launcher/src/main/resources/org/argeo/slc/cli/jaas.config b/runtime/org.argeo.slc.launcher/src/main/resources/org/argeo/slc/cli/jaas.config
new file mode 100644 (file)
index 0000000..2fc1198
--- /dev/null
@@ -0,0 +1,7 @@
+NIX {
+   com.sun.security.auth.module.UnixLoginModule required;
+};
+
+WINDOWS {
+   com.sun.security.auth.module.NTLoginModule required;
+};
diff --git a/runtime/org.argeo.slc.launcher/src/main/resources/org/argeo/slc/cli/log4j.properties b/runtime/org.argeo.slc.launcher/src/main/resources/org/argeo/slc/cli/log4j.properties
new file mode 100644 (file)
index 0000000..6770d0a
--- /dev/null
@@ -0,0 +1,20 @@
+log4j.rootLogger=WARN, console
+#log4j.rootLogger=DEBUG, development
+
+## Levels
+log4j.logger.org.argeo=INFO
+
+log4j.logger.org.apache.jackrabbit.core.query.lucene=ERROR
+log4j.logger.org.apache.jackrabbit.core.config.ConfigurationErrorHandler=ERROR
+log4j.logger.org.apache.jackrabbit.core.util.db.DbUtility=FATAL
+
+## Appenders
+# default appender
+log4j.appender.console=org.apache.log4j.ConsoleAppender
+log4j.appender.console.layout=org.apache.log4j.PatternLayout
+log4j.appender.console.layout.ConversionPattern=%d{HH:mm:ss,SSS} %m%n
+
+# development appender
+log4j.appender.development=org.apache.log4j.ConsoleAppender
+log4j.appender.development.layout=org.apache.log4j.PatternLayout
+log4j.appender.development.layout.ConversionPattern=%d{HH:mm:ss,SSS} %5p %m [%16.16t] %c%n
diff --git a/runtime/org.argeo.slc.launcher/src/main/resources/org/argeo/slc/cli/spring.xml b/runtime/org.argeo.slc.launcher/src/main/resources/org/argeo/slc/cli/spring.xml
deleted file mode 100644 (file)
index ad77822..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
-    Copyright (C) 2007-2012 Argeo GmbH
-
-    Licensed 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.
-
--->
-<beans xmlns="http://www.springframework.org/schema/beans"
-       xmlns:amq="http://activemq.apache.org/schema/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
-       http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd"
-       default-lazy-init="false">
-
-
-       <bean
-               class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
-               lazy-init="false">
-               <property name="properties">
-                       <props>
-                               <prop key="org.apache.activemq.brokerURL">
-                                       tcp://localhost:61616
-                </prop>
-                       </props>
-               </property>
-               <property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />
-               <property name="ignoreUnresolvablePlaceholders" value="true" />
-       </bean>
-
-       <import resource="classpath:org/argeo/slc/activemq/spring-agent.xml" />
-
-       <bean id="slcDefault.cli.slcApplication" class="org.argeo.slc.ant.AntSlcApplication"
-               init-method="initFromSlcRootFile">
-               <property name="slcRootFile" value="${slc.rootFile}" />
-       </bean>
-
-</beans>
\ No newline at end of file
diff --git a/runtime/org.argeo.slc.launcher/src/main/resources/org/argeo/slc/server/client/spring.xml b/runtime/org.argeo.slc.launcher/src/main/resources/org/argeo/slc/server/client/spring.xml
deleted file mode 100644 (file)
index f13d118..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
-    Copyright (C) 2007-2012 Argeo GmbH
-
-    Licensed 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.
-
--->
-<beans xmlns="http://www.springframework.org/schema/beans"
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
-       xmlns:tx="http://www.springframework.org/schema/tx"
-       xsi:schemaLocation="
-        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"
-       default-lazy-init="true">
-
-       <import resource="classpath:org/argeo/slc/castor/spring.xml" />
-
-       <!-- Http client -->
-       <bean id="slcTemplate.serverHttpClient"
-               class="org.argeo.slc.server.client.impl.SlcServerHttpClientImpl"
-               init-method="init" abstract="true">
-               <property name="user" value="demo" />
-               <property name="password" value="demo" />
-               <property name="unmarshaller" ref="slcDefault.castor.marshaller" />
-               <property name="marshaller" ref="slcDefault.castor.marshaller" />
-               <property name="baseUrl" value="http://localhost:7070/org.argeo.slc.webapp/" />
-       </bean>
-</beans>
\ No newline at end of file
diff --git a/runtime/org.argeo.slc.support.equinox/META-INF/spring/commandProvider.xml b/runtime/org.argeo.slc.support.equinox/META-INF/spring/commandProvider.xml
new file mode 100644 (file)
index 0000000..92b5e0e
--- /dev/null
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<!-- Copyright (C) 2010 Mathieu Baudier <mbaudier@argeo.org> Licensed under \r
+       the Apache License, Version 2.0 (the "License"); you may not use this file \r
+       except in compliance with the License. You may obtain a copy of the License \r
+       at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable \r
+       law or agreed to in writing, software distributed under the License is distributed \r
+       on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either \r
+       express or implied. See the License for the specific language governing permissions \r
+       and limitations under the License. -->\r
+\r
+<beans xmlns="http://www.springframework.org/schema/beans"\r
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
+       xmlns:aop="http://www.springframework.org/schema/aop"\r
+       xsi:schemaLocation="\r
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
+       http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd\r
+       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
+\r
+<!--   <bean -->\r
+<!--           class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> -->\r
+<!--           <property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" /> -->\r
+<!--           <property name="ignoreUnresolvablePlaceholders" value="false" /> -->\r
+<!--           <property name="locations"> -->\r
+<!--                   <value>osgibundle:equinox.properties</value> -->\r
+<!--           </property> -->\r
+<!--   </bean> -->\r
+\r
+       <bean id="commandProvider" class="org.argeo.slc.equinox.ExecutionCommandProvider">\r
+               <property name="agentCli" ref="agentCli" />\r
+       </bean>\r
+\r
+<!--   <bean id="modulesManager" class="org.argeo.slc.osgi.OsgiExecutionModulesManager"> -->\r
+<!--           <property name="bundlesManager" ref="bundlesManager" /> -->\r
+<!--   </bean> -->\r
+\r
+<!--   <bean id="bundlesManager" class="org.argeo.slc.osgi.BundlesManager"> -->\r
+<!--           <property name="defaultTimeout" value="${slc.equinox.commandTimeout}" /> -->\r
+<!--           <property name="pollingPeriod" value="${slc.equinox.commandPollingPeriod}" /> -->\r
+<!--   </bean> -->\r
+\r
+</beans>
\ No newline at end of file
diff --git a/runtime/org.argeo.slc.support.equinox/META-INF/spring/manager.xml b/runtime/org.argeo.slc.support.equinox/META-INF/spring/manager.xml
deleted file mode 100644 (file)
index ecd64eb..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>\r
-<!-- Copyright (C) 2010 Mathieu Baudier <mbaudier@argeo.org> Licensed under \r
-       the Apache License, Version 2.0 (the "License"); you may not use this file \r
-       except in compliance with the License. You may obtain a copy of the License \r
-       at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable \r
-       law or agreed to in writing, software distributed under the License is distributed \r
-       on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either \r
-       express or implied. See the License for the specific language governing permissions \r
-       and limitations under the License. -->\r
-\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
-       xmlns:aop="http://www.springframework.org/schema/aop"\r
-       xsi:schemaLocation="\r
-       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
-       http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd\r
-       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
-\r
-       <bean\r
-               class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">\r
-               <property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />\r
-               <property name="ignoreUnresolvablePlaceholders" value="false" />\r
-               <property name="locations">\r
-                       <value>osgibundle:equinox.properties</value>\r
-               </property>\r
-       </bean>\r
-\r
-       <bean id="commandProvider" class="org.argeo.slc.equinox.ExecutionCommandProvider">\r
-               <property name="modulesManager" ref="modulesManager" />\r
-       </bean>\r
-\r
-       <bean id="modulesManager" class="org.argeo.slc.osgi.OsgiExecutionModulesManager">\r
-               <property name="bundlesManager" ref="bundlesManager" />\r
-       </bean>\r
-\r
-       <bean id="bundlesManager" class="org.argeo.slc.osgi.BundlesManager">\r
-               <property name="defaultTimeout" value="${slc.equinox.commandTimeout}" />\r
-               <property name="pollingPeriod" value="${slc.equinox.commandPollingPeriod}" />\r
-       </bean>\r
-\r
-</beans>
\ No newline at end of file
index 08d00045afee954b8e2f3e88d170e60232190f81..cb7f0ae4b65e8aa7a9d8e3cdc4e1fbfd55ba0345 100644 (file)
        http://www.springframework.org/schema/osgi/spring-osgi-1.1.xsd\r
        http://www.springframework.org/schema/beans   \r
        http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">\r
+\r
+       <!-- REFERENCES -->\r
+       <reference id="agentCli" interface="org.argeo.slc.execution.SlcAgentCli" />\r
+\r
        <!-- SERVICES -->\r
        <service interface="org.eclipse.osgi.framework.console.CommandProvider"\r
                ref="commandProvider" />\r
index 25de1868d92dc7b27ea1dc60642f9c1cd477814e..94ccf2649d54349d9c801edc827b29efccaed8ad 100644 (file)
  */
 package org.argeo.slc.equinox;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import java.util.ArrayList;
+import java.util.List;
+
 import org.argeo.slc.SlcException;
-import org.argeo.slc.execution.RealizedFlow;
-import org.argeo.slc.osgi.OsgiExecutionModulesManager;
+import org.argeo.slc.execution.SlcAgentCli;
 import org.eclipse.osgi.framework.console.CommandInterpreter;
 import org.eclipse.osgi.framework.console.CommandProvider;
 
 public class ExecutionCommandProvider implements CommandProvider {
-       private final static Log log = LogFactory
-                       .getLog(ExecutionCommandProvider.class);
-
-       private final static String SLC_WITH_REFRESH = "slc";
-       private final static String SLC_NO_REFRESH = "slcnr";
-
-       private OsgiExecutionModulesManager modulesManager;
+       private SlcAgentCli agentCli;
 
-       private RealizedFlow lastLaunch = null;
+       private String lastProcessUuid;
 
        public Object _slc(CommandInterpreter ci) {
-               return exec(SLC_WITH_REFRESH, ci);
-       }
-
-       public Object _slcnr(CommandInterpreter ci) {
-               return exec(SLC_NO_REFRESH, ci);
-       }
-
-       protected Object exec(String slcCommand, CommandInterpreter ci) {
-               // TODO: check version
-               String firstArg = ci.nextArgument();
-               if (firstArg == null) {
-                       if (lastLaunch != null) {
-                               String cmd = slcCommand + " " + lastLaunch.getModuleName()
-                                               + " " + lastLaunch.getFlowDescriptor().getName();
-                               if (log.isDebugEnabled())
-                                       log.debug("Execute again last command: " + cmd);
-                               return ci.execute(cmd);
-                       } else {
-                               ci.execute("help");
-                               throw new SlcException("Command not properly formatted");
-                       }
+               List<String> args = new ArrayList<String>();
+               String arg = null;
+               while ((arg = ci.nextArgument()) != null)
+                       args.add(arg);
+               if (args.size() == 0) {
+                       // TODO relaunch last process
+                       ci.execute("help");
+                       throw new SlcException("Command not properly formatted");
                }
-               String executionName = ci.nextArgument();
-               
-
-               launch(slcCommand, firstArg, executionName);
-               return "COMMAND COMPLETED";
-       }
-
-       protected void launch(String slcCommand, String firstArg,
-                       String executionName) {
-               lastLaunch = modulesManager.findRealizedFlow(firstArg, executionName);
-               if (lastLaunch == null)
-                       throw new SlcException("Cannot find launch for " + firstArg + " "
-                                       + executionName);
 
-               // Execute
-               if (SLC_WITH_REFRESH.equals(slcCommand)) {
-                       modulesManager.upgrade(lastLaunch.getModuleNameVersion());
-                       modulesManager.execute(lastLaunch);
-               } else if (SLC_NO_REFRESH.equals(slcCommand))
-                       modulesManager.execute(lastLaunch);
-               else
-                       throw new SlcException("Unrecognized SLC command " + slcCommand);
+               lastProcessUuid = agentCli
+                               .process(args.toArray(new String[args.size()]));
+               return lastProcessUuid;
        }
 
        public String getHelp() {
                StringBuffer buf = new StringBuffer();
                buf.append("---SLC Execution Commands---\n");
-               buf
-                               .append("\tslc (<id>|<segment of bsn>) <execution bean>"
-                                               + "  - refresh the bundle, execute an execution flow (without arg, execute last)\n");
-               buf
-                               .append("\tslcnr (<id>|<segment of bsn>) <execution bean>"
-                                               + "  - execute an execution flow (without arg, execute last)\n");
+               buf.append("\tslc <module> <flow> [[ --arg value | --booleanArg ]]"
+                               + "  - executes an execution flow\n");
                return buf.toString();
 
        }
 
-       public void setModulesManager(OsgiExecutionModulesManager osgiModulesManager) {
-               this.modulesManager = osgiModulesManager;
+       public void setAgentCli(SlcAgentCli agentCli) {
+               this.agentCli = agentCli;
        }
 
 }
index 08710b804fa57c08d113ca9fa47c227efda62e44..5bc7c0ae468aaaf118fc4f29dafe23562faea94d 100644 (file)
                        <artifactId>org.springframework.osgi.core</artifactId>
                </dependency>
 
-               <!-- Client -->
-               <dependency>
-                       <groupId>org.argeo.slc</groupId>
-                       <artifactId>org.argeo.slc.launcher</artifactId>
-                       <version>1.1.12-SNAPSHOT</version>
-               </dependency>
-
                <!-- OXM -->
                <dependency>
                        <groupId>org.argeo.tp</groupId>