<artifactId>org.argeo.slc.osgiboot</artifactId>
</dependency>
- <dependency>
- <groupId>org.argeo.slc.dep</groupId>
- <artifactId>org.argeo.slc.dep.agent</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <!-- Unit Tests -->
- <dependency>
- <groupId>org.argeo.slc.runtime</groupId>
- <artifactId>org.argeo.slc.unit</artifactId>
- <scope>test</scope>
- </dependency>
+ <!--
+ Unit Tests <dependency> <groupId>org.argeo.slc.runtime</groupId>
+ <artifactId>org.argeo.slc.unit</artifactId> <scope>test</scope>
+ </dependency>
+ -->
</dependencies>
</dependency>
</dependencies>
</profile>
+ <profile>
+ <id>detached</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.argeo.maven.plugins</groupId>
+ <artifactId>maven-argeo-osgi-plugin</artifactId>
+ <configuration>
+ <execDir>target/exec/detached</execDir>
+ <fork>false</fork>
+ <systemProperties>
+ <slc.osgi.start>
+ org.springframework.osgi.extender,
+ org.argeo.slc.detached,
+ org.argeo.slc.demo.det
+ </slc.osgi.start>
+ <slc.osgi.bundles>
+ ${basedir}/site;in=org.argeo.slc.demo.det;ex=pom.xml;ex=target,
+ ${basedir}/site;in=org.argeo.slc.demo.log4j;ex=pom.xml;ex=target,
+ </slc.osgi.bundles>
+ <javax.xml.parsers.DocumentBuilderFactory>org.apache.xerces.jaxp.DocumentBuilderFactoryImpl</javax.xml.parsers.DocumentBuilderFactory>
+ </systemProperties>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>org.argeo.slc.dep</groupId>
+ <artifactId>org.argeo.slc.dep.detached</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>net.sourceforge.mx4j</groupId>
+ <artifactId>com.springsource.mx4j</artifactId>
+ <version>3.0.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.xerces</groupId>
+ <artifactId>com.springsource.org.apache.xerces</artifactId>
+ <version>2.8.1</version>
+ </dependency>
+ </dependencies>
+ </profile>
<profile>
<id>standalone</id>
<build>
<bundle id="minimal" symbolic-name="org.argeo.slc.demo.minimal"
action="start" />
<bundle id="ant" symbolic-name="org.argeo.slc.demo.ant" action="start" />
+ <bundle id="detached" symbolic-name="org.argeo.slc.demo.detached"
+ action="start" />
+ <!-- <bundle id="det" symbolic-name="org.argeo.slc.demo.det" action="start" /> -->
</beans:beans>
\ No newline at end of file
Bundle-Description: Test of basic features\r
Spring-Context: conf/*,conf/testCases/*\r
Import-Package: \r
- org.argeo.slc.core.test,\r
+ net.sf.cglib.core,\r
+ net.sf.cglib.proxy,\r
+ net.sf.cglib.reflect,\r
+ org.aopalliance.aop,\r
org.argeo.slc.core.attachment,\r
org.argeo.slc.core.execution,\r
org.argeo.slc.core.execution.tasks,\r
+ org.argeo.slc.core.structure.tree,\r
+ org.argeo.slc.core.test,\r
org.argeo.slc.core.test.context,\r
org.argeo.slc.core.test.tree,\r
- org.argeo.slc.core.structure.tree,\r
- org.argeo.slc.test,\r
org.argeo.slc.execution,\r
org.argeo.slc.osgi,\r
org.argeo.slc.structure,\r
- net.sf.cglib.core,\r
- net.sf.cglib.proxy,\r
- net.sf.cglib.reflect,\r
- org.aopalliance.aop,\r
+ org.argeo.slc.test,\r
org.springframework.aop,\r
org.springframework.aop.framework,\r
org.springframework.aop.scope,\r
--- /dev/null
+Manifest-Version: 1.0\r
+Bundle-SymbolicName: org.argeo.slc.demo.det\r
+Bundle-Version: 0.11.4.SNAPSHOT\r
+Bundle-Name: SLC Demo Detached (Detached Bundle)\r
+Bundle-Description: Detached Bundle\r
+Import-Package: org.argeo.slc.detached,\r
+ org.argeo.slc.detached.admin,\r
+ org.springframework.beans.factory.config,\r
+ org.argeo.slc.detached.drivers,\r
+ org.apache.xerces.jaxp,\r
+ org.w3c.dom;version="0.0.0"\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+ 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">
+
+ <import resource="classpath:/org/argeo/slc/detached/spring.xml" />
+
+ <bean id="propertyConfigurer"
+ class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
+ <property name="systemPropertiesModeName">
+ <value>SYSTEM_PROPERTIES_MODE_OVERRIDE</value>
+ </property>
+ </bean>
+
+ <!-- Steps -->
+ <bean id="step.mirror" class="org.argeo.slc.detached.MirrorStep">
+ </bean>
+
+ <!-- Runtime -->
+ <bean id="driver.detached" parent="slcTemplate.detached.fileDriver"
+ init-method="start" destroy-method="stop">
+ <property name="baseDir" value="${user.dir}/local/detached" />
+ <property name="xmlConverter" ref="slcDefault.detached.xmlConverterCompat" />
+ <property name="executionServer" ref="executionServer.serviceref" />
+ </bean>
+
+</beans>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<beans:beans xmlns="http://www.springframework.org/schema/osgi"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"
+ xsi:schemaLocation="http://www.springframework.org/schema/osgi
+ http://www.springframework.org/schema/osgi/spring-osgi.xsd
+ http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd">
+
+<!--
+ <reference id="slcDetached.driver" interface="org.argeo.slc.detached.DetachedDriver" />
+-->
+ <reference id="executionServer.serviceref" interface="org.argeo.slc.detached.DetachedExecutionServer" />
+
+</beans:beans>
\ No newline at end of file
--- /dev/null
+Manifest-Version: 1.0\r
+Bundle-SymbolicName: org.argeo.slc.demo.detached\r
+Bundle-Version: 0.11.4.SNAPSHOT\r
+Bundle-Name: SLC Demo Detached (Test)\r
+Import-Package: \r
+ net.sf.cglib.core,\r
+ net.sf.cglib.proxy,\r
+ net.sf.cglib.reflect,\r
+ org.aopalliance.aop,\r
+ org.argeo.slc.core.attachment,\r
+ org.argeo.slc.core.execution,\r
+ org.argeo.slc.core.execution.tasks,\r
+ org.argeo.slc.core.structure.tree,\r
+ org.argeo.slc.core.test,\r
+ org.argeo.slc.core.test.context,\r
+ org.argeo.slc.core.test.tree,\r
+ org.argeo.slc.detached,\r
+ org.argeo.slc.detached.drivers,\r
+ org.argeo.slc.execution,\r
+ org.argeo.slc.lib.detached,\r
+ org.argeo.slc.osgi,\r
+ org.argeo.slc.structure,\r
+ org.argeo.slc.test,\r
+ org.springframework.aop,\r
+ org.springframework.aop.framework,\r
+ org.springframework.aop.scope,\r
+ org.springframework.beans.factory.config,\r
+ org.springframework.core.io,\r
+ org.springframework.oxm.castor\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
+ xmlns:aop="http://www.springframework.org/schema/aop"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+ http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd
+ http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
+
+ <bean id="detachedTest" parent="slcTemplate.simpleFlow">
+ <property name="path" value="/autoui/testcases" />
+ <property name="executables">
+ <list>
+ <bean parent="task.echo" scope="execution">
+ <property name="message" value="Executing step" />
+ <aop:scoped-proxy />
+ </bean>
+
+ <bean parent="detachedAdminTask">
+ <property name="action" value="slcDefault.detached.admin.openSession" />
+ <property name="properties">
+ <props>
+ <prop key="slc.detached.refreshedBundles">org.argeo.slc.demo.det
+ </prop>
+ </props>
+ </property>
+ </bean>
+
+ <bean parent="stepTestRun">
+ <property name="testDefinition">
+ <bean parent="detachedTestDef">
+ <property name="stepRef" value="step.mirror" />
+ </bean>
+ </property>
+ <property name="testData" ref="detached.data.dummy" />
+ </bean>
+
+
+ <bean parent="detachedAdminTask">
+ <property name="action" value="slcDefault.detached.admin.closeSession" />
+ </bean>
+ </list>
+ </property>
+ </bean>
+
+ <bean id="stepTestRun" class="org.argeo.slc.core.test.SimpleTestRun">
+ <property name="testResult">
+ <bean parent="slcDefault.test.basicTreeTestResult">
+ <property name="listeners">
+ <list>
+ <bean class="org.argeo.slc.core.test.tree.TreeTestResultLogger" />
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+
+
+ <bean id="detachedTestDef" parent="slcTemplate.detached.testDefinition"
+ scope="prototype">
+ <property name="client" ref="driver.runtime" />
+ </bean>
+
+ <bean id="detachedAdminTask" class="org.argeo.slc.lib.detached.DetachedAdminTask"
+ abstract="true">
+ <property name="client" ref="driver.runtime" />
+ </bean>
+
+ <bean id="driver.runtime" class="org.argeo.slc.detached.drivers.FileDriver"
+ init-method="cleanPreviousRuns">
+ <property name="baseDir" value="${user.dir}/local/detached" />
+ <property name="xmlConverter" ref="slcDefault.detached.xmlConverterCastor" />
+ </bean>
+
+ <bean id="detached.data.dummy" class="org.argeo.slc.lib.detached.DetachedTestData"
+ scope="prototype">
+ <property name="values">
+ <map>
+ <entry key="label" value="tata" />
+ </map>
+ </property>
+ <property name="expectedValues">
+ <map>
+ <entry key="label" value="tata" />
+ </map>
+ </property>
+ </bean>
+</beans>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+ 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">
+
+ <import resource="classpath:org/argeo/slc/core/execution/spring.xml" />
+
+ <import resource="classpath:/org/argeo/slc/core/test/spring.xml" />
+ <import resource="classpath:/org/argeo/slc/lib/detached/spring.xml" />
+
+</beans>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\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
+ <beans:import resource="classpath:org/argeo/slc/osgi/execution.xml" />\r
+\r
+</beans:beans>
\ No newline at end of file
Bundle-Version: 0.11.4.SNAPSHOT\r
Bundle-Name: Log4j Configuration\r
Bundle-SymbolicName: org.argeo.slc.demo.log4j\r
-\r
package org.argeo.slc.demo;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.argeo.slc.equinox.unit.AbstractOsgiRuntimeTestCase;
-import org.argeo.slc.osgiboot.OsgiBoot;
-
-public class StartStopDemoTest extends AbstractOsgiRuntimeTestCase {
+public class StartStopDemoTest {//extends AbstractOsgiRuntimeTestCase {
+/*
public void testStartStop() throws Exception {
assertBundleApplicationContext("org.argeo.slc.agent");
assertStartedBundlesApplicationContext("org.argeo.slc.demo");
bundlesToStart.add("org.argeo.slc.agent");
bundlesToStart.add("org.argeo.slc.demo.basic");
return bundlesToStart;
- }
+ }*/
}
package org.argeo.slc.demo.minimal;
-import junit.framework.TestCase;
-import org.argeo.slc.execution.ExecutionFlow;
-import org.springframework.beans.factory.generic.GenericBeanFactoryAccessor;
-import org.springframework.context.ConfigurableApplicationContext;
-import org.springframework.context.support.FileSystemXmlApplicationContext;
-
-public class HelloWorldTest extends TestCase {
- public void testHelloWorld() throws Exception {
+public class HelloWorldTest {// extends TestCase {
+/* public void testHelloWorld() throws Exception {
GenericBeanFactoryAccessor context = new GenericBeanFactoryAccessor(
createContext());
ExecutionFlow flow = context.getBean("main");
locations);
return context;
}
-
+*/
}
<groupId>org.argeo.slc.runtime</groupId>
<artifactId>org.argeo.slc.support.castor</artifactId>
</dependency>
+
+ <!-- Additional -->
<dependency>
<groupId>org.argeo.slc.runtime</groupId>
<artifactId>org.argeo.slc.support.ant</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.argeo.slc.runtime</groupId>
+ <artifactId>org.argeo.slc.lib.detached</artifactId>
+ </dependency>
</dependencies>
</project>
\ No newline at end of file
--- /dev/null
+Bundle-SymbolicName: org.argeo.slc.dep.detached
+Bundle-Version: 0.11.4.SNAPSHOT
--- /dev/null
+<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>
+ <artifactId>dep</artifactId>
+ <version>0.11.4-SNAPSHOT</version>
+ <relativePath>..</relativePath>
+ </parent>
+ <groupId>org.argeo.slc.dep</groupId>
+ <artifactId>org.argeo.slc.dep.detached</artifactId>
+ <packaging>jar</packaging>
+ <name>Argeo SLC Dependencies Detached</name>
+ <dependencies>
+
+ <dependency>
+ <groupId>org.argeo.slc.runtime</groupId>
+ <artifactId>org.argeo.slc.detached</artifactId>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
<modules>
<module>org.argeo.slc.dep.server</module>
<module>org.argeo.slc.dep.agent</module>
+ <module>org.argeo.slc.dep.detached</module>
</modules>
<build>
<resources>
<artifactId>org.argeo.slc.detached</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.argeo.slc.runtime</groupId>
+ <artifactId>org.argeo.slc.lib.detached</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<dependency>
<groupId>org.argeo.slc.runtime</groupId>
<artifactId>org.argeo.slc.support.simple</artifactId>
<Import-Package>
org.w3c.dom;version="0.0.0",
javax.xml.*;version="0.0.0",
+ org.apache.xerces.jaxp,
org.springframework.beans.factory;version="2.0",
org.springframework.beans.factory.support;version="2.0",
org.springframework.beans.factory.xml;version="2.0",
<groupId>org.slf4j</groupId>
<artifactId>com.springsource.slf4j.org.apache.commons.logging</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>com.springsource.slf4j.log4j</artifactId>
+ </dependency>
+
+ <!-- JRE 1.4 -->
+ <dependency>
+ <groupId>org.apache.xerces</groupId>
+ <artifactId>com.springsource.org.apache.xerces</artifactId>
+ </dependency>
</dependencies>
</project>
\ No newline at end of file
--- /dev/null
+package org.argeo.slc.detached;
+
+import java.util.Properties;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Dummy detached step which copies the request into the answer and log. Useful
+ * for testing.
+ */
+public class MirrorStep implements DetachedStep {
+ private final static Log log = LogFactory.getLog(MirrorStep.class);
+
+ public DetachedAnswer execute(DetachedContext detachedContext,
+ DetachedRequest req) {
+ log.debug(" uuid=" + req.getUuid());
+ log.debug(" ref=" + req.getRef());
+ log.debug(" path=" + req.getPath());
+ log.debug(" properties=" + req.getProperties());
+
+ DetachedAnswer answer = new DetachedAnswer(req, "Mirror");
+ Properties answerProps = new Properties();
+ answerProps.putAll(req.getProperties());
+ answer.setProperties(answerProps);
+ return answer;
+ }
+
+}
--- /dev/null
+package org.argeo.slc.detached.admin;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.FrameworkEvent;
+import org.osgi.framework.FrameworkListener;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.packageadmin.PackageAdmin;
+
+/**
+ * Wraps low-level access to a {@link BundleContext}. Hacked from the related
+ * class in org.argeo.slc.support.osgi.
+ */
+class MinimalBundlesManager implements FrameworkListener {
+ private final BundleContext bundleContext;
+
+ private long defaultTimeout = 10000l;
+ private final Object refreshedPackageSem = new Object();
+
+ private boolean debug = true;
+
+ public MinimalBundlesManager(BundleContext bundleContext) {
+ this.bundleContext = bundleContext;
+ bundleContext.addFrameworkListener(this);
+ }
+
+ protected void finalize() throws Throwable {
+ bundleContext.removeFrameworkListener(this);
+ }
+
+ /**
+ * Stop the module, update it, refresh it and restart it. All synchronously.
+ */
+ public void upgradeSynchronous(Bundle bundle) {
+ try {
+ stopSynchronous(bundle);
+ updateSynchronous(bundle);
+ // Refresh in case there are fragments
+ refreshSynchronous(bundle);
+ startSynchronous(bundle);
+
+ String filter = "(Bundle-SymbolicName=" + bundle.getSymbolicName()
+ + ")";
+ // Wait for application context to be ready
+ // TODO: use service tracker
+ getServiceRefSynchronous(
+ "org.springframework.context.ApplicationContext", filter);
+
+ if (debug)
+ debug("Bundle " + bundle.getSymbolicName()
+ + " ready to be used at latest version.");
+ } catch (Exception e) {
+ throw new RuntimeException("Cannot update bundle "
+ + bundle.getSymbolicName(), e);
+ }
+ }
+
+ /** Updates bundle synchronously. */
+ protected void updateSynchronous(Bundle bundle) throws BundleException {
+ // int originalState = bundle.getState();
+ bundle.update();
+ boolean waiting = true;
+
+ long begin = System.currentTimeMillis();
+ do {
+ int state = bundle.getState();
+ if (state == Bundle.INSTALLED || state == Bundle.ACTIVE
+ || state == Bundle.RESOLVED)
+ waiting = false;
+
+ sleep(100);
+ if (System.currentTimeMillis() - begin > defaultTimeout)
+ throw new RuntimeException("Update of bundle "
+ + bundle.getSymbolicName()
+ + " timed out. Bundle state = " + bundle.getState());
+ } while (waiting);
+
+ if (debug)
+ debug("Bundle " + bundle.getSymbolicName() + " updated.");
+ }
+
+ /** Starts bundle synchronously. Does nothing if already started. */
+ protected void startSynchronous(Bundle bundle) throws BundleException {
+ int originalState = bundle.getState();
+ if (originalState == Bundle.ACTIVE)
+ return;
+
+ bundle.start();
+ boolean waiting = true;
+
+ long begin = System.currentTimeMillis();
+ do {
+ if (bundle.getState() == Bundle.ACTIVE)
+ waiting = false;
+
+ sleep(100);
+ if (System.currentTimeMillis() - begin > defaultTimeout)
+ throw new RuntimeException("Start of bundle "
+ + bundle.getSymbolicName()
+ + " timed out. Bundle state = " + bundle.getState());
+ } while (waiting);
+
+ if (debug)
+ debug("Bundle " + bundle.getSymbolicName() + " started.");
+ }
+
+ /** Stops bundle synchronously. Does nothing if already started. */
+ protected void stopSynchronous(Bundle bundle) throws BundleException {
+ int originalState = bundle.getState();
+ if (originalState != Bundle.ACTIVE)
+ return;
+
+ bundle.stop();
+ boolean waiting = true;
+
+ long begin = System.currentTimeMillis();
+ do {
+ if (bundle.getState() != Bundle.ACTIVE
+ && bundle.getState() != Bundle.STOPPING)
+ waiting = false;
+
+ sleep(100);
+ if (System.currentTimeMillis() - begin > defaultTimeout)
+ throw new RuntimeException("Stop of bundle "
+ + bundle.getSymbolicName()
+ + " timed out. Bundle state = " + bundle.getState());
+ } while (waiting);
+
+ if (debug)
+ debug("Bundle " + bundle.getSymbolicName() + " stopped.");
+ }
+
+ /** Refresh bundle synchronously. Does nothing if already started. */
+ protected void refreshSynchronous(Bundle bundle) throws BundleException {
+ ServiceReference packageAdminRef = bundleContext
+ .getServiceReference(PackageAdmin.class.getName());
+ PackageAdmin packageAdmin = (PackageAdmin) bundleContext
+ .getService(packageAdminRef);
+ Bundle[] bundles = { bundle };
+ packageAdmin.refreshPackages(bundles);
+
+ synchronized (refreshedPackageSem) {
+ try {
+ refreshedPackageSem.wait(defaultTimeout);
+ } catch (InterruptedException e) {
+ // silent
+ }
+ }
+
+ if (debug)
+ debug("Bundle " + bundle.getSymbolicName() + " refreshed.");
+ }
+
+ public void frameworkEvent(FrameworkEvent event) {
+ if (event.getType() == FrameworkEvent.PACKAGES_REFRESHED) {
+ synchronized (refreshedPackageSem) {
+ refreshedPackageSem.notifyAll();
+ }
+ }
+ }
+
+ public ServiceReference[] getServiceRefSynchronous(String clss,
+ String filter) throws InvalidSyntaxException {
+ if (debug)
+ debug("Filter: '" + filter + "'");
+ ServiceReference[] sfs = null;
+ boolean waiting = true;
+ long begin = System.currentTimeMillis();
+ do {
+ sfs = bundleContext.getServiceReferences(clss, filter);
+
+ if (sfs != null)
+ waiting = false;
+
+ sleep(100);
+ if (System.currentTimeMillis() - begin > defaultTimeout)
+ throw new RuntimeException("Search of services " + clss
+ + " with filter " + filter + " timed out.");
+ } while (waiting);
+
+ return sfs;
+ }
+
+ /*
+ * protected void sleep(long ms) { try { Thread.sleep(ms); } catch
+ * (InterruptedException e) { // silent } }
+ *
+ * public ServiceTracker newTracker(Class<?> clss) { ServiceTracker st = new
+ * ServiceTracker(bundleContext, clss.getName(), null); st.open(); return
+ * st; }
+ *
+ * @SuppressWarnings(value = { "unchecked" }) public <T> T
+ * getSingleService(Class<T> clss, String filter) {
+ * Assert.isTrue(OsgiFilterUtils.isValidFilter(filter), "valid filter");
+ * ServiceReference[] sfs; try { sfs =
+ * bundleContext.getServiceReferences(clss.getName(), filter); } catch
+ * (InvalidSyntaxException e) { throw new
+ * SlcException("Cannot retrieve service reference for " + filter, e); }
+ *
+ * if (sfs == null || sfs.length == 0) return null; else if (sfs.length > 1)
+ * throw new SlcException("More than one execution flow found for " +
+ * filter); return (T) bundleContext.getService(sfs[0]); }
+ *
+ * public <T> T getSingleServiceStrict(Class<T> clss, String filter) { T
+ * service = getSingleService(clss, filter); if (service == null) throw new
+ * SlcException("No execution flow found for " + filter); else return
+ * service; }
+ *
+ * public Bundle findRelatedBundle(OsgiBundle osgiBundle) { Bundle bundle =
+ * null; if (osgiBundle.getInternalBundleId() != null) { bundle =
+ * bundleContext.getBundle(osgiBundle.getInternalBundleId()); Assert.isTrue(
+ * osgiBundle.getName().equals(bundle.getSymbolicName()),
+ * "symbolic name consistent");
+ * Assert.isTrue(osgiBundle.getVersion().equals(
+ * bundle.getHeaders().get(Constants.BUNDLE_VERSION)),
+ * "version consistent"); } else { for (Bundle b :
+ * bundleContext.getBundles()) { if
+ * (b.getSymbolicName().equals(osgiBundle.getName())) { if
+ * (b.getHeaders().get(Constants.BUNDLE_VERSION).equals(
+ * osgiBundle.getVersion())) { bundle = b;
+ * osgiBundle.setInternalBundleId(b.getBundleId()); } } } } return bundle; }
+ *
+ * public OsgiBundle findFromPattern(String pattern) { OsgiBundle osgiBundle
+ * = null; for (Bundle b : bundleContext.getBundles()) { if
+ * (b.getSymbolicName().contains(pattern)) { osgiBundle = new OsgiBundle(b);
+ * break; } } return osgiBundle; }
+ *
+ * public OsgiBundle getBundle(Long bundleId) { Bundle bundle =
+ * bundleContext.getBundle(bundleId); return new OsgiBundle(bundle); }
+ *
+ * public void setBundleContext(BundleContext bundleContext) {
+ * this.bundleContext = bundleContext; }
+ *
+ * public void afterPropertiesSet() throws Exception {
+ * bundleContext.addFrameworkListener(this); }
+ *
+ * public void setDefaultTimeout(Long defaultTimeout) { this.defaultTimeout
+ * = defaultTimeout; }
+ *
+ * BundleContext getBundleContext() { return bundleContext; }
+ */
+
+ protected void debug(Object obj) {
+ if (debug)
+ System.out.println("#OSGiMANAGER DEBUG# " + obj);
+ }
+
+ protected void sleep(long ms) {
+ try {
+ Thread.sleep(ms);
+ } catch (InterruptedException e) {
+ // silent
+ }
+ }
+
+}
import org.argeo.slc.detached.DetachedSession;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleException;
public class OpenSession implements DetachedAdminCommand {
private final static Log log = LogFactory.getLog(OpenSession.class);
public DetachedSession execute(DetachedRequest request,
BundleContext bundleContext) {
+ MinimalBundlesManager bundlesManager = new MinimalBundlesManager(bundleContext);
+
DetachedSession session = new DetachedSession();
session.setUuid(Long.toString(System.currentTimeMillis()));
for (int i = 0; i < bundlesToRefresh.size(); i++) {
Bundle bundle = (Bundle) bundlesToRefresh.get(i);
try {
- bundle.stop();
- bundle.update();
- bundle.start();
+ bundlesManager.upgradeSynchronous(bundle);
+// bundle.stop();
+// bundle.update();
+// bundle.start();
log.info("Refreshed bundle " + bundle.getSymbolicName());
- } catch (BundleException e) {
+
+// try {
+// Thread.sleep(2000);
+// } catch (InterruptedException e) {
+// e.printStackTrace();
+// }
+
+ } catch (Exception e) {
throw new DetachedException("Could not refresh bundle "
+ bundle.getSymbolicName(), e);
}
--- /dev/null
+package org.argeo.slc.detached.drivers;
+
+import java.util.Stack;
+
+import org.argeo.slc.detached.DetachedAnswer;
+import org.argeo.slc.detached.DetachedClient;
+import org.argeo.slc.detached.DetachedRequest;
+
+public class MemoryDriver extends AbstractDriver implements DetachedClient {
+ private final static Stack stack = new Stack();
+
+ // DRIVER
+ public DetachedRequest receiveRequest() throws Exception {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void sendAnswer(DetachedAnswer answer) throws Exception {
+ // TODO Auto-generated method stub
+
+ }
+
+ // CLIENT
+ public DetachedAnswer receiveAnswer() throws Exception {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void sendRequest(DetachedRequest request) throws Exception {
+ // TODO Auto-generated method stub
+
+ }
+
+}
package org.argeo.slc.lib.detached;
-import java.io.IOException;
-
import javax.xml.transform.Result;
import javax.xml.transform.Source;
import org.argeo.slc.detached.DetachedXmlConverter;
import org.springframework.oxm.Marshaller;
import org.springframework.oxm.Unmarshaller;
-import org.springframework.oxm.XmlMappingException;
-import org.springframework.xml.validation.XmlValidator;
-import org.xml.sax.InputSource;
public class DetachedXmlConverterSpring implements DetachedXmlConverter {
private Marshaller marshaller;
import org.osgi.framework.ServiceReference;
import org.osgi.service.packageadmin.PackageAdmin;
import org.osgi.util.tracker.ServiceTracker;
+import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.context.ApplicationContext;
import org.springframework.osgi.context.BundleContextAware;
/** Wraps low-level access to a {@link BundleContext} */
public class BundlesManager implements BundleContextAware, FrameworkListener,
- InitializingBean {
+ InitializingBean, DisposableBean {
private final static Log log = LogFactory.getLog(BundlesManager.class);
private BundleContext bundleContext;
bundleContext.addFrameworkListener(this);
}
+ public void destroy() throws Exception {
+ bundleContext.removeFrameworkListener(this);
+ }
+
public void setDefaultTimeout(Long defaultTimeout) {
this.defaultTimeout = defaultTimeout;
}
import java.util.List;
import java.util.Map;
-import javax.management.BadBinaryOpValueExpException;
-
import junit.framework.TestCase;
import org.apache.commons.logging.Log;