X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;ds=sidebyside;f=runtime%2Forg.argeo.slc.support.osgi%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fslc%2Fosgi%2FOsgiExecutionModulesManager.java;h=2cfad6683cdc7404daaa076b945ac1c6902b3b44;hb=649ed86fb73062b5773770fb1892eded24b74038;hp=9fd9c09f419bb7b2bfe43c40a66868b91ed98dd4;hpb=9d38eeed9b5571a26a9e4d1844dc42a57699dd13;p=gpl%2Fargeo-slc.git diff --git a/runtime/org.argeo.slc.support.osgi/src/main/java/org/argeo/slc/osgi/OsgiExecutionModulesManager.java b/runtime/org.argeo.slc.support.osgi/src/main/java/org/argeo/slc/osgi/OsgiExecutionModulesManager.java index 9fd9c09f4..2cfad6683 100644 --- a/runtime/org.argeo.slc.support.osgi/src/main/java/org/argeo/slc/osgi/OsgiExecutionModulesManager.java +++ b/runtime/org.argeo.slc.support.osgi/src/main/java/org/argeo/slc/osgi/OsgiExecutionModulesManager.java @@ -1,3 +1,19 @@ +/* + * Copyright (C) 2010 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.osgi; import java.util.ArrayList; @@ -14,6 +30,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.argeo.slc.SlcException; import org.argeo.slc.build.BasicNameVersion; +import org.argeo.slc.build.NameVersion; import org.argeo.slc.core.execution.AbstractExecutionModulesManager; import org.argeo.slc.core.execution.DefaultExecutionFlowDescriptorConverter; import org.argeo.slc.deploy.ModuleDescriptor; @@ -37,26 +54,26 @@ public class OsgiExecutionModulesManager extends AbstractExecutionModulesManager implements InitializingBean, DisposableBean, OsgiServiceLifecycleListener { - static { - // Force usage of vanilla Xalan when in OSGi - // We would like to do it in a cleaner way - // but the integration of Xalan and Xerces in the JRE - // makes it very difficult - // Suggestions welcome! - Properties systemProperties = System.getProperties(); - // if (!systemProperties - // .containsKey("javax.xml.parsers.DocumentBuilderFactory")) - // System.setProperty("javax.xml.parsers.DocumentBuilderFactory", - // "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl"); - // if - // (!systemProperties.containsKey("javax.xml.parsers.SAXParserFactory")) - // System.setProperty("javax.xml.parsers.SAXParserFactory", - // "org.apache.xerces.jaxp.SAXParserFactoryImpl"); - if (!systemProperties - .containsKey("javax.xml.transform.TransformerFactory")) - System.setProperty("javax.xml.transform.TransformerFactory", - "org.apache.xalan.processor.TransformerFactoryImpl"); - } +// static { +// // Force usage of vanilla Xalan when in OSGi +// // We would like to do it in a cleaner way +// // but the integration of Xalan and Xerces in the JRE +// // makes it very difficult +// // Suggestions welcome! +// Properties systemProperties = System.getProperties(); +// // if (!systemProperties +// // .containsKey("javax.xml.parsers.DocumentBuilderFactory")) +// // System.setProperty("javax.xml.parsers.DocumentBuilderFactory", +// // "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl"); +// // if +// // (!systemProperties.containsKey("javax.xml.parsers.SAXParserFactory")) +// // System.setProperty("javax.xml.parsers.SAXParserFactory", +// // "org.apache.xerces.jaxp.SAXParserFactoryImpl"); +// if (!systemProperties +// .containsKey("javax.xml.transform.TransformerFactory")) +// System.setProperty("javax.xml.transform.TransformerFactory", +// "org.apache.xalan.processor.TransformerFactoryImpl"); +// } private final static String PROPERTY_CACHE_SERVICES = "slc.osgi.execution.cacheServices"; @@ -146,8 +163,11 @@ public class OsgiExecutionModulesManager extends Map flows = new HashMap(); if (useCachedServices) { - Set flowsT = executionFlows.get(new OsgiBundle( - moduleName, moduleVersion)); + OsgiBundle key = new OsgiBundle( + moduleName, moduleVersion); + if(!executionFlows.containsKey(key)) + return flows; + Set flowsT = executionFlows.get(key); for (ExecutionFlow flow : flowsT) flows.put(flow.getName(), flow); } else { @@ -258,10 +278,9 @@ public class OsgiExecutionModulesManager extends } } - public void updateAndExecute(RealizedFlow realizedFlow) { - OsgiBundle osgiBundle = new OsgiBundle(realizedFlow); + public void upgrade(NameVersion nameVersion) { + OsgiBundle osgiBundle = new OsgiBundle(nameVersion); bundlesManager.upgradeSynchronous(osgiBundle); - execute(realizedFlow); } protected synchronized ExecutionFlowDescriptorConverter getExecutionFlowDescriptorConverter( @@ -283,33 +302,6 @@ public class OsgiExecutionModulesManager extends } } - public void execute(RealizedFlow realizedFlow) { - if (log.isTraceEnabled()) - log.trace("Executing " + realizedFlow); - - String moduleName = realizedFlow.getModuleName(); - String moduleVersion = realizedFlow.getModuleVersion(); - - Map variablesToAdd = getExecutionFlowDescriptorConverter( - moduleName, moduleVersion).convertValues( - realizedFlow.getFlowDescriptor()); - ExecutionContext executionContext = findExecutionContext(moduleName, - moduleVersion); - for (String key : variablesToAdd.keySet()) - executionContext.setVariable(key, variablesToAdd.get(key)); - - ExecutionFlow flow = findExecutionFlow(moduleName, moduleVersion, - realizedFlow.getFlowDescriptor().getName()); - - // - // Actually runs the flow, IN THIS THREAD - // - flow.run(); - // - // - // - } - public ModuleDescriptor getModuleDescriptor(String moduleName, String version) { return getExecutionModuleDescriptor(moduleName, version);