http://www.springframework.org/schema/beans \r
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">\r
\r
- <beans:import resource="classpath:org/argeo/slc/osgi/manager.xml" />\r
+<!-- <beans:import resource="classpath:org/argeo/slc/osgi/manager.xml" /> -->\r
\r
<!-- REFERENCES -->\r
<list id="executionContexts" interface="org.argeo.slc.execution.ExecutionContext"\r
unbind-method="unregister" />\r
</list>\r
\r
+ <!-- No sets so that the equals methods are not called -->\r
+ <list id="executionFlowDescriptorConverters"\r
+ interface="org.argeo.slc.execution.ExecutionFlowDescriptorConverter"\r
+ cardinality="0..N">\r
+ <listener ref="modulesManager" />\r
+ </list>\r
+\r
<list id="slcExecutionListeners" interface="org.argeo.slc.process.SlcExecutionNotifier"\r
cardinality="0..N" />\r
\r
import org.argeo.slc.SlcException;
import org.argeo.slc.execution.ExecutionFlowDescriptor;
import org.argeo.slc.execution.ExecutionModulesManager;
-import org.argeo.slc.process.RealizedFlow;
+import org.argeo.slc.execution.RealizedFlow;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.Command;
import org.eclipse.core.commands.ExecutionEvent;
import org.argeo.slc.execution.ExecutionProcess;
import org.argeo.slc.execution.ExecutionProcessNotifier;
import org.argeo.slc.execution.ExecutionStep;
-import org.argeo.slc.process.RealizedFlow;
+import org.argeo.slc.execution.RealizedFlow;
import org.argeo.slc.process.SlcExecutionNotifier;
/** Provides the base feature of an execution module manager. */
import org.argeo.slc.SlcException;
import org.argeo.slc.execution.ExecutionFlowDescriptor;
import org.argeo.slc.execution.ExecutionStep;
-import org.argeo.slc.process.RealizedFlow;
+import org.argeo.slc.execution.RealizedFlow;
import org.springframework.security.Authentication;
import org.springframework.security.context.SecurityContextHolder;
import org.argeo.slc.execution.ExecutionModulesManager;
import org.argeo.slc.execution.ExecutionProcess;
import org.argeo.slc.execution.ExecutionStep;
-import org.argeo.slc.process.RealizedFlow;
+import org.argeo.slc.execution.RealizedFlow;
import org.argeo.slc.process.SlcExecution;
import org.springframework.security.Authentication;
import org.springframework.security.context.SecurityContextHolder;
*/
package org.argeo.slc.cli;
+import java.io.File;
import java.io.FileInputStream;
+import java.util.List;
import java.util.Properties;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import org.apache.commons.io.IOUtils;
+import org.argeo.osgi.boot.OsgiBoot;
import org.argeo.slc.SlcException;
+import org.argeo.slc.execution.ExecutionModulesManager;
+import org.eclipse.core.runtime.adaptor.EclipseStarter;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
@SuppressWarnings("static-access")
public class SlcMain {
private final static String commandName = "slc";
+ private static String bundlesToInstall = "/usr/share/osgi;in=*.jar";
+
+ private static String bundlesToStart = "org.springframework.osgi.extender,"
+ + "org.argeo.node.repofactory.jackrabbit,"
+ + "org.argeo.node.repo.jackrabbit," + "org.argeo.security.dao.os,"
+ + "org.argeo.slc.node.jackrabbit," + "org.argeo.slc.agent,"
+ + "org.argeo.slc.agent.jcr";
+
static {
options = new Options();
- options.addOption(typeOpt);
- options.addOption(moduleOpt);
- options.addOption(flowsOpt);
- options.addOption(propertyOpt);
- options.addOption(propertiesOpt);
- options.addOption(runtimeOpt);
+ // options.addOption(typeOpt);
+ // options.addOption(moduleOpt);
+ // options.addOption(flowsOpt);
+ // options.addOption(propertyOpt);
+ // options.addOption(propertiesOpt);
+ // options.addOption(runtimeOpt);
}
public static void main(String[] args) {
- Type type = null;
- Properties properties = new Properties();
+ // Type type = null;
+ // Properties properties = new Properties();
+ // String flows = null;
+ // String urlStr = null;
+
String module = null;
- String flows = null;
- String urlStr = null;
+ String moduleUrl = null;
+ String flow = null;
try {
CommandLineParser clParser = new GnuParser();
CommandLine cl = clParser.parse(options, args);
- // Mode
- String typeStr = cl.getOptionValue(typeOpt.getOpt());
- if (typeStr == null) {
- type = Type.standalone;
+ List<String> arguments = cl.getArgList();
+ if (arguments.size() == 0) {
+ // TODO default behaviour
} else {
- try {
- type = Type.valueOf(typeStr);
- } catch (IllegalArgumentException e) {
- throw new SlcException("Unrecognized mode '" + typeStr
- + "'", e);
+ module = arguments.get(0);
+ File moduleFile = new File(module);
+ if (moduleFile.exists()) {
+ if (moduleFile.isDirectory()) {
+ moduleUrl = "reference:file:"
+ + moduleFile.getCanonicalPath();
+ } else {
+ moduleUrl = "file:" + moduleFile.getCanonicalPath();
+ }
}
- }
- // Script
- if (type.equals(Type.standalone)) {
- if (!cl.hasOption(moduleOpt.getOpt()))
- throw new SlcException("Type " + Type.standalone
- + " requires option '" + moduleOpt.getLongOpt()
- + "'");
- module = cl.getOptionValue(moduleOpt.getOpt());
-
- // Targets
- if (cl.hasOption(flowsOpt.getOpt()))
- flows = cl.getOptionValue(flowsOpt.getOpt());
- }
-
- // Properties
- if (cl.hasOption(propertiesOpt.getOpt())) {
- for (String propertyFile : cl.getOptionValues(propertiesOpt
- .getOpt())) {
- loadPropertyFile(properties, propertyFile);
+ if (arguments.size() == 1) {
+ // TODO module info
+ } else {
+ flow = arguments.get(1);
}
}
- if (cl.hasOption(propertyOpt.getOpt())) {
- for (String property : cl.getOptionValues(propertyOpt.getOpt())) {
- addProperty(properties, property);
- }
+
+ // System.setProperty(
+ // ExecutionModulesManager.UNIQUE_LAUNCH_MODULE_PROPERTY,
+ // module);
+ // System.setProperty(
+ // ExecutionModulesManager.UNIQUE_LAUNCH_FLOW_PROPERTY, flow);
+
+ String executionDir = System.getProperty("user.dir");
+ File slcDir = new File(executionDir, ".slc");
+ File dataDir = new File(slcDir, "data");
+ if (!dataDir.exists())
+ dataDir.mkdirs();
+ File confDir = new File(slcDir, "conf");
+ if (!confDir.exists())
+ confDir.mkdirs();
+
+ BundleContext bundleContext = null;
+ try {
+ String[] osgiRuntimeArgs = { "-configuration",
+ confDir.getCanonicalPath(), "-data",
+ dataDir.getCanonicalPath(), "-console", "-clean" };
+ bundleContext = EclipseStarter.startup(osgiRuntimeArgs, null);
+ } catch (Exception e) {
+ throw new RuntimeException("Cannot start Equinox.", e);
}
- // Runtime
- if (cl.hasOption(runtimeOpt.getOpt())) {
- urlStr = cl.getOptionValue(runtimeOpt.getOpt());
+ // OSGi bootstrap
+ OsgiBoot osgiBoot = new OsgiBoot(bundleContext);
+ osgiBoot.installUrls(osgiBoot.getBundlesUrls(bundlesToInstall));
+ osgiBoot.startBundles(bundlesToStart);
+
+ if (moduleUrl != null) {
+ Bundle bundle = osgiBoot.installUrl(moduleUrl);
+ module = bundle.getSymbolicName();
+ // TODO deal with version
}
+
+ // retrieve modulesManager
+ ServiceReference sr = bundleContext
+ .getServiceReference(ExecutionModulesManager.class
+ .getName());
+ ExecutionModulesManager modulesManager = (ExecutionModulesManager) bundleContext
+ .getService(sr);
+
+
+ modulesManager.execute(null);
+
+ // osgiBoot.bootstrap();
+ // osgiBoot.bootstrap();
+
+ // Mode
+ // String typeStr = cl.getOptionValue(typeOpt.getOpt());
+ // if (typeStr == null) {
+ // type = Type.standalone;
+ // } else {
+ // try {
+ // type = Type.valueOf(typeStr);
+ // } catch (IllegalArgumentException e) {
+ // throw new SlcException("Unrecognized mode '" + typeStr
+ // + "'", e);
+ // }
+ // }
+ //
+ // // Script
+ // if (type.equals(Type.standalone)) {
+ // if (!cl.hasOption(moduleOpt.getOpt()))
+ // throw new SlcException("Type " + Type.standalone
+ // + " requires option '" + moduleOpt.getLongOpt()
+ // + "'");
+ // module = cl.getOptionValue(moduleOpt.getOpt());
+ //
+ // // Targets
+ // if (cl.hasOption(flowsOpt.getOpt()))
+ // flows = cl.getOptionValue(flowsOpt.getOpt());
+ // }
+ //
+ // // Properties
+ // if (cl.hasOption(propertiesOpt.getOpt())) {
+ // for (String propertyFile : cl.getOptionValues(propertiesOpt
+ // .getOpt())) {
+ // loadPropertyFile(properties, propertyFile);
+ // }
+ // }
+ // if (cl.hasOption(propertyOpt.getOpt())) {
+ // for (String property : cl.getOptionValues(propertyOpt.getOpt()))
+ // {
+ // addProperty(properties, property);
+ // }
+ // }
+ //
+ // // Runtime
+ // if (cl.hasOption(runtimeOpt.getOpt())) {
+ // urlStr = cl.getOptionValue(runtimeOpt.getOpt());
+ // }
} catch (ParseException e) {
System.err.println("Problem with command line arguments. "
+ e.getMessage());
badExit();
}
- if (debug) {
- debug("Mode: " + type);
- if (urlStr != null)
- debug("Runtime: " + urlStr);
- debug("User properties: " + properties);
- if (module != null)
- debug("Module: " + module);
- if (flows != null)
- debug("Flows: " + flows);
- }
-
- // Standalone
- if (type.equals(Type.standalone)) {
- }
- // Agent
- else if (type.equals(Type.agent)) {
- }
+ // if (debug) {
+ // debug("Mode: " + type);
+ // if (urlStr != null)
+ // debug("Runtime: " + urlStr);
+ // debug("User properties: " + properties);
+ // if (module != null)
+ // debug("Module: " + module);
+ // if (flows != null)
+ // debug("Flows: " + flows);
+ // }
+ //
+ // // Standalone
+ // if (type.equals(Type.standalone)) {
+ // }
+ // // Agent
+ // else if (type.equals(Type.agent)) {
+ // }
}
public static void printUsage() {
import java.util.Map;
import org.argeo.slc.deploy.ModulesManager;
-import org.argeo.slc.process.RealizedFlow;
/** Provides access to the execution modules */
public interface ExecutionModulesManager extends ModulesManager {
--- /dev/null
+/*
+ * Copyright (C) 2007-2012 Mathieu Baudier
+ *
+ * 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.
+ */
+package org.argeo.slc.execution;
+
+import java.io.Serializable;
+
+import org.argeo.slc.BasicNameVersion;
+import org.argeo.slc.NameVersion;
+
+/** A fully configured execution flow, ready to be executed. */
+public class RealizedFlow implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ private String moduleName;
+ private String moduleVersion;
+ private ExecutionFlowDescriptor flowDescriptor;
+
+ public String getModuleName() {
+ return moduleName;
+ }
+
+ public void setModuleName(String moduleName) {
+ this.moduleName = moduleName;
+ }
+
+ public NameVersion getModuleNameVersion() {
+ return new BasicNameVersion(getModuleName(), getModuleVersion());
+ }
+
+ public String getModuleVersion() {
+ return moduleVersion;
+ }
+
+ public void setModuleVersion(String moduleVersion) {
+ this.moduleVersion = moduleVersion;
+ }
+
+ public ExecutionFlowDescriptor getFlowDescriptor() {
+ return flowDescriptor;
+ }
+
+ public void setFlowDescriptor(ExecutionFlowDescriptor flowDescriptor) {
+ this.flowDescriptor = flowDescriptor;
+ }
+}
+++ /dev/null
-/*
- * Copyright (C) 2007-2012 Mathieu Baudier
- *
- * 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.
- */
-package org.argeo.slc.process;
-
-import java.io.Serializable;
-
-import org.argeo.slc.BasicNameVersion;
-import org.argeo.slc.NameVersion;
-import org.argeo.slc.execution.ExecutionFlowDescriptor;
-
-/** A fully configured execution flow, ready to be executed. */
-public class RealizedFlow implements Serializable {
- private static final long serialVersionUID = 1L;
-
- private String moduleName;
- private String moduleVersion;
- private ExecutionFlowDescriptor flowDescriptor;
-
- public String getModuleName() {
- return moduleName;
- }
-
- public void setModuleName(String moduleName) {
- this.moduleName = moduleName;
- }
-
- public NameVersion getModuleNameVersion() {
- return new BasicNameVersion(getModuleName(), getModuleVersion());
- }
-
- public String getModuleVersion() {
- return moduleVersion;
- }
-
- public void setModuleVersion(String moduleVersion) {
- this.moduleVersion = moduleVersion;
- }
-
- public ExecutionFlowDescriptor getFlowDescriptor() {
- return flowDescriptor;
- }
-
- public void setFlowDescriptor(ExecutionFlowDescriptor flowDescriptor) {
- this.flowDescriptor = flowDescriptor;
- }
-}
\r
import org.argeo.slc.execution.ExecutionProcess;\r
import org.argeo.slc.execution.ExecutionStep;\r
+import org.argeo.slc.execution.RealizedFlow;\r
\r
/** @deprecated use other implementations of {@link ExecutionProcess} */\r
public class SlcExecution implements ExecutionProcess, Serializable {\r
*/
package org.argeo.slc.process;
+@Deprecated
public interface SlcExecutionRelated {
public String getSlcExecutionUuid();
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.argeo.slc.SlcException;
+import org.argeo.slc.execution.RealizedFlow;
import org.argeo.slc.osgi.OsgiExecutionModulesManager;
-import org.argeo.slc.process.RealizedFlow;
import org.eclipse.osgi.framework.console.CommandInterpreter;
import org.eclipse.osgi.framework.console.CommandProvider;
}
protected void installBundles() throws Exception {
-// System.out.println("java.class.path="
-// + System.getProperty("java.class.path"));
+ // System.out.println("java.class.path="
+ // + System.getProperty("java.class.path"));
osgiBoot.installUrls(osgiBoot.getLocationsUrls(
- OsgiBoot.DEFAULT_BASE_URL, System
- .getProperty("java.class.path")));
- osgiBoot.installUrls(osgiBoot.getBundlesUrls(OsgiBoot.DEFAULT_BASE_URL,
- "src/test/bundles;in=*"));
+ OsgiBoot.DEFAULT_BASE_URL,
+ System.getProperty("java.class.path")));
+ osgiBoot.installUrls(osgiBoot.getBundlesUrls("src/test/bundles;in=*"));
// Map<String, String> sysProps = new TreeMap(System.getProperties());
// for (String key : sysProps.keySet()) {
import org.argeo.slc.execution.ExecutionModulesManager;
import org.argeo.slc.execution.ExecutionProcess;
import org.argeo.slc.execution.ExecutionSpecAttribute;
+import org.argeo.slc.execution.RealizedFlow;
import org.argeo.slc.jcr.SlcJcrUtils;
import org.argeo.slc.jcr.SlcNames;
import org.argeo.slc.jcr.SlcTypes;
-import org.argeo.slc.process.RealizedFlow;
/** Where the actual execution takes place */
public class JcrProcessThread extends ProcessThread implements SlcNames {
import org.argeo.slc.deploy.Module;
import org.argeo.slc.deploy.ModuleDescriptor;
import org.argeo.slc.deploy.TargetData;
-import org.argeo.slc.process.RealizedFlow;
+import org.argeo.slc.execution.RealizedFlow;
import org.osgi.framework.Bundle;
import org.osgi.framework.Constants;
import org.springframework.core.io.Resource;
import org.argeo.slc.execution.ExecutionFlowDescriptorConverter;
import org.argeo.slc.execution.ExecutionModuleDescriptor;
import org.argeo.slc.execution.ExecutionModulesListener;
-import org.argeo.slc.process.RealizedFlow;
+import org.argeo.slc.execution.RealizedFlow;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleEvent;
import org.osgi.framework.BundleException;
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<!--\r
-\r
- Copyright (C) 2007-2012 Mathieu Baudier\r
-\r
- Licensed under the Apache License, Version 2.0 (the "License");\r
- you may not use this file except in compliance with the License.\r
- You may obtain a copy of the License at\r
-\r
- http://www.apache.org/licenses/LICENSE-2.0\r
-\r
- Unless required by applicable law or agreed to in writing, software\r
- distributed under the License is distributed on an "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- See the License for the specific language governing permissions and\r
- limitations under the License.\r
-\r
--->\r
-<beans:beans xmlns="http://www.springframework.org/schema/osgi"\r
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"\r
- xsi:schemaLocation="http://www.springframework.org/schema/osgi \r
- 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
- <!-- No sets so that the equals methods are not called -->\r
- <list id="executionFlowDescriptorConverters"\r
- interface="org.argeo.slc.execution.ExecutionFlowDescriptorConverter"\r
- cardinality="0..N">\r
- <listener ref="modulesManager" />\r
- </list>\r
-\r
- <list id="executionContexts" interface="org.argeo.slc.execution.ExecutionContext"\r
- cardinality="0..N">\r
- <listener ref="modulesManager" />\r
- </list>\r
-\r
- <list id="executionFlows" interface="org.argeo.slc.execution.ExecutionFlow"\r
- cardinality="0..N">\r
- <listener ref="modulesManager" />\r
- </list>\r
-\r
-</beans:beans>
\ No newline at end of file
\r
import org.argeo.slc.execution.ExecutionFlowDescriptor;\r
import org.argeo.slc.execution.ExecutionStep;\r
-import org.argeo.slc.process.RealizedFlow;\r
+import org.argeo.slc.execution.RealizedFlow;\r
import org.argeo.slc.process.SlcExecution;\r
import org.argeo.slc.process.SlcExecutionStep;\r
import org.argeo.slc.unit.execution.ExecutionFlowDescriptorTestUtils;\r