X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=org.argeo.slc.launcher%2Fsrc%2Forg%2Fargeo%2Fslc%2Fcli%2FSlcMain.java;h=8717b503055cc8549ea2911d9efdf5c00762bb3f;hb=58b35f147f3c1c1a12a07c303105618f679c7161;hp=d7bd977f7de7ff7df7a0b18aa9363ceaa70e07d0;hpb=5ff5e6e4b4e0928b9bae0da27a502b6a1885079f;p=gpl%2Fargeo-slc.git diff --git a/org.argeo.slc.launcher/src/org/argeo/slc/cli/SlcMain.java b/org.argeo.slc.launcher/src/org/argeo/slc/cli/SlcMain.java index d7bd977f7..8717b5030 100644 --- a/org.argeo.slc.launcher/src/org/argeo/slc/cli/SlcMain.java +++ b/org.argeo.slc.launcher/src/org/argeo/slc/cli/SlcMain.java @@ -1,18 +1,3 @@ -/* - * 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. - */ package org.argeo.slc.cli; import java.io.File; @@ -72,14 +57,21 @@ public class SlcMain implements PrivilegedAction { 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.eclipse.equinox.cm"); + bundlesToStart.add("org.argeo.cms"); + bundlesToStart.add("org.eclipse.gemini.blueprint.extender"); 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.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"); } @@ -92,12 +84,10 @@ public class SlcMain implements PrivilegedAction { info("## Data : " + dataDir.getCanonicalPath()); // Start Equinox - ServiceLoader ff = ServiceLoader - .load(FrameworkFactory.class); + ServiceLoader ff = ServiceLoader.load(FrameworkFactory.class); FrameworkFactory frameworkFactory = ff.iterator().next(); Map configuration = new HashMap(); - configuration.put("osgi.configuration.area", - confDir.getCanonicalPath()); + configuration.put("osgi.configuration.area", confDir.getCanonicalPath()); configuration.put("osgi.instance.area", dataDir.getCanonicalPath()); // Do clean configuration.put("osgi.clean", "true"); @@ -117,16 +107,13 @@ public class SlcMain implements PrivilegedAction { // working copy modules if (modulesDir.exists()) - osgiBoot.installUrls(osgiBoot.getBundlesUrls(modulesDir - .getCanonicalPath() + ";in=*;ex=.gitignore")); + 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))); + osgiBoot.installUrls(osgiBoot.getBundlesUrls(System.getProperty(OsgiBoot.PROP_ARGEO_OSGI_BUNDLES))); else - osgiBoot.installUrls(osgiBoot.getBundlesUrls(System - .getProperty("user.home") + "/.slc/modules/;in=**")); + osgiBoot.installUrls(osgiBoot.getBundlesUrls(System.getProperty("user.home") + "/.slc/modules/;in=**")); // Start runtime osgiBoot.startBundles(bundlesToStart); @@ -134,8 +121,7 @@ public class SlcMain implements PrivilegedAction { // Find SLC Agent ServiceReference sr = null; while (sr == null) { - sr = bundleContext - .getServiceReference("org.argeo.slc.execution.SlcAgentCli"); + sr = bundleContext.getServiceReference("org.argeo.slc.execution.SlcAgentCli"); if (System.currentTimeMillis() - begin > timeout) throw new RuntimeException("Cannot find SLC agent CLI"); Thread.sleep(100); @@ -144,8 +130,7 @@ public class SlcMain implements PrivilegedAction { // Initialization completed long duration = System.currentTimeMillis() - begin; - info("[[ Initialized in " + (duration / 1000) + "s " - + (duration % 1000) + "ms ]]"); + info("[[ Initialized in " + (duration / 1000) + "s " + (duration % 1000) + "ms ]]"); if (args.length == 0) return null;// console mode @@ -153,8 +138,7 @@ public class SlcMain implements PrivilegedAction { // Subject.doAs(Subject.getSubject(AccessController.getContext()), // new AgentCliCall(agentCli)); Class[] parameterTypes = { String[].class }; - Method method = agentCli.getClass().getMethod("process", - parameterTypes); + Method method = agentCli.getClass().getMethod("process", parameterTypes); Object[] methodArgs = { args }; Object ret = method.invoke(agentCli, methodArgs); @@ -184,13 +168,10 @@ public class SlcMain implements PrivilegedAction { 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()); + 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"); + System.setProperty("argeo.node.repo.configuration", "osgibundle:repository-memory.xml"); } else { slcDir = findSlcDir(executionDir); if (slcDir == null) { @@ -211,28 +192,27 @@ public class SlcMain implements PrivilegedAction { 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()); + // 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()); + 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)); -SlcMain slcMain = new SlcMain(args, confDir, dataDir, - modulesDir); -slcMain.run(); + // LoginContext lc = new LoginContext(os); + // lc.login(); + // + // Subject subject = + // Subject.getSubject(AccessController.getContext()); + // Subject.doAs(subject, new SlcMain(args, confDir, dataDir, + // modulesDir)); + SlcMain slcMain = new SlcMain(args, confDir, dataDir, modulesDir); + slcMain.run(); if (args.length != 0) System.exit(0); } catch (Exception e) { @@ -277,8 +257,7 @@ slcMain.run(); output.write(buf, 0, length); } } catch (Exception e) { - throw new RuntimeException("Cannot write " + resource + " file to " - + targetFile, e); + throw new RuntimeException("Cannot write " + resource + " file to " + targetFile, e); } finally { try { input.close(); @@ -342,4 +321,3 @@ slcMain.run(); // } // // } -