X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=org.argeo.slc.autoui%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fslc%2Fautoui%2FAbstractDetachedActivator.java;h=877d8b6742483ae4649cb9c734980982c45e1d3a;hb=494aaacdfe1ac2e28fb3eaebb7952ecb1e274a5e;hp=b1fe56922695f39f6c55141a557cfa20b38fc665;hpb=4bafe4b45c92437f769495c038203a048a4e793a;p=gpl%2Fargeo-slc.git diff --git a/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/AbstractDetachedActivator.java b/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/AbstractDetachedActivator.java index b1fe56922..877d8b674 100644 --- a/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/AbstractDetachedActivator.java +++ b/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/AbstractDetachedActivator.java @@ -3,6 +3,8 @@ package org.argeo.slc.autoui; import java.net.URL; import java.util.Properties; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.osgi.framework.Bundle; import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; @@ -13,24 +15,24 @@ import org.springframework.context.support.GenericApplicationContext; import org.springframework.core.io.UrlResource; public class AbstractDetachedActivator implements BundleActivator { + private final Log log = LogFactory.getLog(getClass()); + private SpringStaticRefProvider staticRefProvider; public final void start(BundleContext context) throws Exception { - ClassLoader classLoader = getClass().getClassLoader(); - // Creates application context + Bundle bundle = context.getBundle(); + + // Creates application context with this class class loader + ClassLoader classLoader = getClass().getClassLoader(); Thread cur = Thread.currentThread(); ClassLoader save = cur.getContextClassLoader(); cur.setContextClassLoader(classLoader); try { - // applicationContext = new ClassPathXmlApplicationContext( - // "/slc/conf/applicationContext.xml"); - AbstractApplicationContext applicationContext = new GenericApplicationContext(); XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader( (BeanDefinitionRegistry) applicationContext); - Bundle bundle = context.getBundle(); URL url = bundle .getResource("META-INF/slc/conf/applicationContext.xml"); @@ -38,15 +40,17 @@ public class AbstractDetachedActivator implements BundleActivator { System.out.println("Loads application context from bundle " + bundle.getSymbolicName() + " (url=" + url + ")"); xmlReader.loadBeanDefinitions(new UrlResource(url)); - } - // Register static ref provider - staticRefProvider = new SpringStaticRefProvider(applicationContext); - Properties properties = new Properties(); - properties.setProperty("slc.detached.bundle", bundle - .getSymbolicName()); - context.registerService(StaticRefProvider.class.getName(), - staticRefProvider, properties); + // Register static ref provider + staticRefProvider = new SpringStaticRefProvider( + applicationContext); + Properties properties = new Properties(); + properties.setProperty("slc.detached.bundle", bundle + .getSymbolicName()); + context.registerService(StaticRefProvider.class.getName(), + staticRefProvider, properties); + + } } catch (Exception e) { e.printStackTrace(); @@ -56,6 +60,9 @@ public class AbstractDetachedActivator implements BundleActivator { } startAutoBundle(context); + + log.info("SLC Detached bundle " + bundle.getSymbolicName() + " (" + + bundle.getBundleId() + ") started"); } /** Does nothing by default. */