Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.virgo.kernel.dmfragment')
-rw-r--r--org.eclipse.virgo.kernel.dmfragment/.classpath43
-rw-r--r--org.eclipse.virgo.kernel.dmfragment/.project42
-rw-r--r--org.eclipse.virgo.kernel.dmfragment/.settings/com.springsource.server.ide.bundlor.core.prefs3
-rw-r--r--org.eclipse.virgo.kernel.dmfragment/.settings/org.eclipse.jdt.core.prefs12
-rw-r--r--org.eclipse.virgo.kernel.dmfragment/.settings/org.eclipse.wst.common.project.facet.core.xml4
-rw-r--r--org.eclipse.virgo.kernel.dmfragment/.settings/org.springframework.ide.eclipse.beans.core.prefs3
-rw-r--r--org.eclipse.virgo.kernel.dmfragment/.springBeans14
-rw-r--r--org.eclipse.virgo.kernel.dmfragment/build.xml8
-rw-r--r--org.eclipse.virgo.kernel.dmfragment/ivy.xml40
-rw-r--r--org.eclipse.virgo.kernel.dmfragment/src/main/java/org/eclipse/virgo/kernel/dmfragment/ModuleBeanFactoryPostProcessor.java26
-rw-r--r--org.eclipse.virgo.kernel.dmfragment/src/main/java/org/eclipse/virgo/kernel/dmfragment/internal/ApplicationContextShutdownBean.java58
-rw-r--r--org.eclipse.virgo.kernel.dmfragment/src/main/java/org/eclipse/virgo/kernel/dmfragment/internal/ApplicationContextShutdownBeanPostProcessor.java31
-rw-r--r--org.eclipse.virgo.kernel.dmfragment/src/main/java/org/eclipse/virgo/kernel/dmfragment/internal/ContextClassLoaderPostProcessor.java68
-rw-r--r--org.eclipse.virgo.kernel.dmfragment/src/main/java/org/eclipse/virgo/kernel/dmfragment/internal/KernelAnnotationMBeanExporter.java39
-rw-r--r--org.eclipse.virgo.kernel.dmfragment/src/main/java/org/eclipse/virgo/kernel/dmfragment/internal/KernelExtensionConfiguringOsgiPostProcessor.java49
-rw-r--r--org.eclipse.virgo.kernel.dmfragment/src/main/java/org/eclipse/virgo/kernel/dmfragment/internal/KernelLoadTimeWeaver.java97
-rw-r--r--org.eclipse.virgo.kernel.dmfragment/src/main/java/org/eclipse/virgo/kernel/dmfragment/internal/KernelMBeanExporter.java40
-rw-r--r--org.eclipse.virgo.kernel.dmfragment/src/main/java/org/eclipse/virgo/kernel/dmfragment/internal/KernelModelMBean.java50
-rw-r--r--org.eclipse.virgo.kernel.dmfragment/src/main/java/org/eclipse/virgo/kernel/dmfragment/internal/LoadTimeWeaverPostProcessor.java38
-rw-r--r--org.eclipse.virgo.kernel.dmfragment/src/main/java/org/eclipse/virgo/kernel/dmfragment/internal/MBeanExporterPostProcessor.java61
-rw-r--r--org.eclipse.virgo.kernel.dmfragment/src/main/java/org/eclipse/virgo/kernel/dmfragment/internal/ServiceProxyRetryDisablingBundleListener.java63
-rw-r--r--org.eclipse.virgo.kernel.dmfragment/src/main/resources/META-INF/spring/extender/kernel-dmfragment-context.xml39
-rw-r--r--org.eclipse.virgo.kernel.dmfragment/src/test/java/.gitignore0
-rw-r--r--org.eclipse.virgo.kernel.dmfragment/src/test/resources/.gitignore0
-rw-r--r--org.eclipse.virgo.kernel.dmfragment/template.mf21
25 files changed, 849 insertions, 0 deletions
diff --git a/org.eclipse.virgo.kernel.dmfragment/.classpath b/org.eclipse.virgo.kernel.dmfragment/.classpath
new file mode 100644
index 00000000..3aef51c5
--- /dev/null
+++ b/org.eclipse.virgo.kernel.dmfragment/.classpath
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src/main/java">
+ <attributes>
+ <attribute name="com.springsource.server.ide.jdt.core.test.classpathentry" value="false"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="src" path="src/main/resources">
+ <attributes>
+ <attribute name="com.springsource.server.ide.jdt.core.test.classpathentry" value="false"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="src" output="target/test-classes" path="src/test/java">
+ <attributes>
+ <attribute name="com.springsource.server.ide.jdt.core.test.classpathentry" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="src" output="target/test-classes" path="src/test/resources">
+ <attributes>
+ <attribute name="com.springsource.server.ide.jdt.core.test.classpathentry" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="var" path="KERNEL_IVY_CACHE/org.springframework/org.springframework.context/3.0.0.RELEASE/org.springframework.context-3.0.0.RELEASE.jar" sourcepath="/KERNEL_IVY_CACHE/org.springframework/org.springframework.context/2.5.6/org.springframework.context-sources-2.5.6.jar"/>
+ <classpathentry kind="var" path="KERNEL_IVY_CACHE/org.springframework/org.springframework.beans/3.0.0.RELEASE/org.springframework.beans-3.0.0.RELEASE.jar" sourcepath="/KERNEL_IVY_CACHE/org.springframework/org.springframework.beans/2.5.6/org.springframework.beans-sources-2.5.6.jar"/>
+ <classpathentry kind="var" path="KERNEL_IVY_CACHE/org.springframework/org.springframework.core/3.0.0.RELEASE/org.springframework.core-3.0.0.RELEASE.jar" sourcepath="/KERNEL_IVY_CACHE/org.springframework/org.springframework.core/3.0.0.RELEASE/org.springframework.core-sources-3.0.0.RELEASE.jar"/>
+ <classpathentry kind="var" path="KERNEL_IVY_CACHE/org.springframework/org.springframework.aop/3.0.0.RELEASE/org.springframework.aop-3.0.0.RELEASE.jar" sourcepath="/KERNEL_IVY_CACHE/org.springframework/org.springframework.aop/2.5.6/org.springframework.aop-2.5.6.jar"/>
+ <classpathentry kind="var" path="KERNEL_IVY_CACHE/org.springframework.osgi/org.springframework.osgi.core/1.2.1/org.springframework.osgi.core-1.2.1.jar" sourcepath="/KERNEL_IVY_CACHE/org.springframework.osgi/org.springframework.osgi.core/1.2.1/org.springframework.osgi.core-sources-1.2.1.jar"/>
+ <classpathentry kind="var" path="KERNEL_IVY_CACHE/org.springframework.osgi/org.springframework.osgi.extender/1.2.1/org.springframework.osgi.extender-1.2.1.jar" sourcepath="/KERNEL_IVY_CACHE/org.springframework.osgi/org.springframework.osgi.extender/1.2.1/org.springframework.osgi.extender-sources-1.2.1.jar"/>
+ <classpathentry kind="var" path="KERNEL_IVY_CACHE/org.springframework.osgi/org.springframework.osgi.io/1.2.1/org.springframework.osgi.io-1.2.1.jar" sourcepath="/KERNEL_IVY_CACHE/org.springframework.osgi/org.springframework.osgi.io/1.2.1/org.springframework.osgi.io-sources-1.2.1.jar"/>
+ <classpathentry kind="var" path="KERNEL_IVY_CACHE/org.eclipse.osgi/org.eclipse.osgi/3.5.1.R35x_v20091005/org.eclipse.osgi-3.5.1.R35x_v20091005.jar" sourcepath="/KERNEL_IVY_CACHE/org.eclipse.osgi/org.eclipse.osgi/3.5.0.200809221524/org.eclipse.osgi-3.5.0.200809221524.jar"/>
+ <classpathentry kind="con" path="org.eclipse.ajdt.core.ASPECTJRT_CONTAINER"/>
+ <classpathentry kind="var" path="KERNEL_IVY_CACHE/org.eclipse.virgo.medic/org.eclipse.virgo.medic/1.0.1.D-20100420092100/org.eclipse.virgo.medic-1.0.1.D-20100420092100.jar">
+ <attributes>
+ <attribute name="org.eclipse.ajdt.aspectpath" value="org.eclipse.ajdt.aspectpath"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="var" path="KERNEL_IVY_CACHE/org.slf4j/com.springsource.slf4j.api/1.5.10/com.springsource.slf4j.api-1.5.10.jar" sourcepath="/KERNEL_IVY_CACHE/org.slf4j/com.springsource.slf4j.api/1.5.10/com.springsource.slf4j.api-sources-1.5.10.jar"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/org.eclipse.virgo.kernel.core"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/org.eclipse.virgo.kernel.osgi"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/org.eclipse.virgo.kernel.agent.dm"/>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
diff --git a/org.eclipse.virgo.kernel.dmfragment/.project b/org.eclipse.virgo.kernel.dmfragment/.project
new file mode 100644
index 00000000..84883a8d
--- /dev/null
+++ b/org.eclipse.virgo.kernel.dmfragment/.project
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.virgo.kernel.dmfragment</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.wst.common.project.facet.core.builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.ajdt.core.ajbuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.springsource.server.dev.eclipse.serverdevelopmentbuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.springframework.ide.eclipse.core.springbuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.springsource.server.ide.bundlor.core.builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.ajdt.ui.ajnature</nature>
+ <nature>com.springsource.server.ide.facet.core.bundlenature</nature>
+ <nature>org.springframework.ide.eclipse.core.springnature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>com.springsource.server.dev.eclipse.serverdevelopmentnature</nature>
+ <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
+ </natures>
+</projectDescription>
diff --git a/org.eclipse.virgo.kernel.dmfragment/.settings/com.springsource.server.ide.bundlor.core.prefs b/org.eclipse.virgo.kernel.dmfragment/.settings/com.springsource.server.ide.bundlor.core.prefs
new file mode 100644
index 00000000..63a262a3
--- /dev/null
+++ b/org.eclipse.virgo.kernel.dmfragment/.settings/com.springsource.server.ide.bundlor.core.prefs
@@ -0,0 +1,3 @@
+#Mon Jul 06 09:06:52 BST 2009
+com.springsource.server.ide.bundlor.core.template.properties.files=../build.versions
+eclipse.preferences.version=1
diff --git a/org.eclipse.virgo.kernel.dmfragment/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.virgo.kernel.dmfragment/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000..b928aedf
--- /dev/null
+++ b/org.eclipse.virgo.kernel.dmfragment/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,12 @@
+#Wed Nov 26 10:58:22 GMT 2008
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
diff --git a/org.eclipse.virgo.kernel.dmfragment/.settings/org.eclipse.wst.common.project.facet.core.xml b/org.eclipse.virgo.kernel.dmfragment/.settings/org.eclipse.wst.common.project.facet.core.xml
new file mode 100644
index 00000000..801f856c
--- /dev/null
+++ b/org.eclipse.virgo.kernel.dmfragment/.settings/org.eclipse.wst.common.project.facet.core.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<faceted-project>
+ <installed facet="com.springsource.server.bundle" version="1.0"/>
+</faceted-project>
diff --git a/org.eclipse.virgo.kernel.dmfragment/.settings/org.springframework.ide.eclipse.beans.core.prefs b/org.eclipse.virgo.kernel.dmfragment/.settings/org.springframework.ide.eclipse.beans.core.prefs
new file mode 100644
index 00000000..e68da314
--- /dev/null
+++ b/org.eclipse.virgo.kernel.dmfragment/.settings/org.springframework.ide.eclipse.beans.core.prefs
@@ -0,0 +1,3 @@
+#Mon Jul 06 16:49:15 BST 2009
+eclipse.preferences.version=1
+org.springframework.ide.eclipse.beans.core.ignoreMissingNamespaceHandler=false
diff --git a/org.eclipse.virgo.kernel.dmfragment/.springBeans b/org.eclipse.virgo.kernel.dmfragment/.springBeans
new file mode 100644
index 00000000..a151801d
--- /dev/null
+++ b/org.eclipse.virgo.kernel.dmfragment/.springBeans
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beansProjectDescription>
+ <version>1</version>
+ <pluginVersion><![CDATA[2.2.5.200906231226-RC1]]></pluginVersion>
+ <configSuffixes>
+ <configSuffix><![CDATA[xml]]></configSuffix>
+ </configSuffixes>
+ <enableImports><![CDATA[false]]></enableImports>
+ <configs>
+ <config>src/main/resources/META-INF/spring/extender/kernel-dmfragment-context.xml</config>
+ </configs>
+ <configSets>
+ </configSets>
+</beansProjectDescription>
diff --git a/org.eclipse.virgo.kernel.dmfragment/build.xml b/org.eclipse.virgo.kernel.dmfragment/build.xml
new file mode 100644
index 00000000..70d6c23f
--- /dev/null
+++ b/org.eclipse.virgo.kernel.dmfragment/build.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="org.eclipse.virgo.kernel.dmfragment">
+
+ <property file="${basedir}/../build.properties"/>
+ <property file="${basedir}/../build.versions"/>
+ <import file="${basedir}/../virgo-build/weaving/default.xml"/>
+
+</project>
diff --git a/org.eclipse.virgo.kernel.dmfragment/ivy.xml b/org.eclipse.virgo.kernel.dmfragment/ivy.xml
new file mode 100644
index 00000000..670982dc
--- /dev/null
+++ b/org.eclipse.virgo.kernel.dmfragment/ivy.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?xml-stylesheet type="text/xsl" href="http://ivyrep.jayasoft.org/ivy-doc.xsl"?>
+<ivy-module
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:noNamespaceSchemaLocation="http://incubator.apache.org/ivy/schemas/ivy.xsd"
+ version="1.3">
+
+ <info organisation="org.eclipse.virgo.kernel" module="${ant.project.name}"/>
+
+ <configurations>
+ <include file="${virgo.build.dir}/common/default-ivy-configurations.xml"/>
+ </configurations>
+
+ <publications>
+ <artifact name="${ant.project.name}"/>
+ <artifact name="${ant.project.name}-sources" type="src" ext="jar"/>
+ </publications>
+
+ <dependencies>
+ <dependency org="org.springframework" name="org.springframework.beans" rev="${org.springframework}" conf="compile->runtime"/>
+ <dependency org="org.springframework" name="org.springframework.context" rev="${org.springframework}" conf="compile->runtime"/>
+ <dependency org="org.springframework" name="org.springframework.context.support" rev="${org.springframework}" conf="compile->runtime"/>
+ <dependency org="org.springframework" name="org.springframework.core" rev="${org.springframework}" conf="compile->runtime"/>
+ <dependency org="org.springframework.osgi" name="org.springframework.osgi.core" rev="${org.springframework.osgi}" conf="compile->runtime"/>
+ <dependency org="org.springframework.osgi" name="org.springframework.osgi.extender" rev="${org.springframework.osgi}" conf="compile->runtime"/>
+ <dependency org="org.springframework.osgi" name="org.springframework.osgi.io" rev="${org.springframework.osgi}" conf="compile->runtime"/>
+
+ <dependency org="org.eclipse.virgo.kernel" name="org.eclipse.virgo.kernel.core" rev="latest.integration" conf="compile->compile"/>
+ <dependency org="org.eclipse.virgo.kernel" name="org.eclipse.virgo.kernel.osgi" rev="latest.integration" conf="compile->compile"/>
+
+ <dependency org="org.slf4j" name="com.springsource.slf4j.api" rev="${org.slf4j}" conf="compile->runtime"/>
+ <dependency org="org.slf4j" name="com.springsource.slf4j.nop" rev="${org.slf4j}" conf="test->runtime"/>
+
+ <dependency org="org.eclipse.virgo.medic" name="org.eclipse.virgo.medic" rev="${org.eclipse.virgo.medic}" conf="aspects, compile->runtime"/>
+ <dependency org="org.eclipse.virgo.medic" name="org.eclipse.virgo.medic.core" rev="${org.eclipse.virgo.medic}" conf="runtime->runtime"/>
+
+ <override org="org.springframework" rev="${org.springframework}"/>
+ <override org="org.eclipse.virgo.util" rev="${org.eclipse.virgo.util}"/>
+ </dependencies>
+</ivy-module>
diff --git a/org.eclipse.virgo.kernel.dmfragment/src/main/java/org/eclipse/virgo/kernel/dmfragment/ModuleBeanFactoryPostProcessor.java b/org.eclipse.virgo.kernel.dmfragment/src/main/java/org/eclipse/virgo/kernel/dmfragment/ModuleBeanFactoryPostProcessor.java
new file mode 100644
index 00000000..8c252b11
--- /dev/null
+++ b/org.eclipse.virgo.kernel.dmfragment/src/main/java/org/eclipse/virgo/kernel/dmfragment/ModuleBeanFactoryPostProcessor.java
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.kernel.dmfragment;
+
+import org.osgi.framework.BundleContext;
+import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
+
+/**
+ * <strong>Concurrent Semantics</strong><br />
+ *
+ * Implementations must be thread-safe.
+ *
+ */
+public interface ModuleBeanFactoryPostProcessor {
+
+ void postProcess(BundleContext bundleContext, ConfigurableListableBeanFactory beanFactory);
+}
diff --git a/org.eclipse.virgo.kernel.dmfragment/src/main/java/org/eclipse/virgo/kernel/dmfragment/internal/ApplicationContextShutdownBean.java b/org.eclipse.virgo.kernel.dmfragment/src/main/java/org/eclipse/virgo/kernel/dmfragment/internal/ApplicationContextShutdownBean.java
new file mode 100644
index 00000000..579c69ff
--- /dev/null
+++ b/org.eclipse.virgo.kernel.dmfragment/src/main/java/org/eclipse/virgo/kernel/dmfragment/internal/ApplicationContextShutdownBean.java
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.kernel.dmfragment.internal;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.BeanFactoryUtils;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationEvent;
+import org.springframework.context.ApplicationListener;
+import org.springframework.context.event.ApplicationContextEvent;
+import org.springframework.context.event.ContextClosedEvent;
+import org.springframework.osgi.service.importer.support.OsgiServiceProxyFactoryBean;
+
+/**
+ * {@link ApplicationContextShutdownBean} manages the shutting down of application contexts in the dm Server. In
+ * particular it is responsible for ensuring that Spring DM service proxies do not hold up application context shutdown.
+ * <p />
+ *
+ * <strong>Concurrent Semantics</strong><br />
+ *
+ * This class is thread safe.
+ *
+ */
+// Note that this class must not implement ApplicationListener<ContextClosedEvent> since it needs to work with Spring
+// 2.5.x as well as Spring 3 and beyond.
+final class ApplicationContextShutdownBean implements ApplicationListener<ApplicationEvent> {
+
+ private static final Logger logger = LoggerFactory.getLogger(ApplicationContextShutdownBean.class);
+
+ /**
+ * {@inheritDoc}
+ */
+ public void onApplicationEvent(ApplicationEvent event) {
+ if (event instanceof ContextClosedEvent) {
+ logger.info("Processing ContextClosedEvent '{}'", event);
+ ApplicationContext applicationContext = ((ApplicationContextEvent) event).getApplicationContext();
+ disableServiceProxyRetry(applicationContext);
+ }
+ }
+
+ static void disableServiceProxyRetry(ApplicationContext applicationContext) {
+ for (OsgiServiceProxyFactoryBean proxyBean : BeanFactoryUtils.beansOfTypeIncludingAncestors(applicationContext,
+ OsgiServiceProxyFactoryBean.class, true, false).values()) {
+ logger.info("Setting timeout to 0 for proxy '{}' of application context '{}'", proxyBean, applicationContext);
+ proxyBean.setTimeout(0);
+ }
+ }
+}
diff --git a/org.eclipse.virgo.kernel.dmfragment/src/main/java/org/eclipse/virgo/kernel/dmfragment/internal/ApplicationContextShutdownBeanPostProcessor.java b/org.eclipse.virgo.kernel.dmfragment/src/main/java/org/eclipse/virgo/kernel/dmfragment/internal/ApplicationContextShutdownBeanPostProcessor.java
new file mode 100644
index 00000000..cb9e6b77
--- /dev/null
+++ b/org.eclipse.virgo.kernel.dmfragment/src/main/java/org/eclipse/virgo/kernel/dmfragment/internal/ApplicationContextShutdownBeanPostProcessor.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.kernel.dmfragment.internal;
+
+import org.eclipse.virgo.kernel.dmfragment.ModuleBeanFactoryPostProcessor;
+import org.osgi.framework.BundleContext;
+import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
+
+
+
+final class ApplicationContextShutdownBeanPostProcessor implements ModuleBeanFactoryPostProcessor{
+
+ private static final String APPLICATION_CONTEXT_SHUTDOWN_BEAN_NAME = "org.eclipse.virgo.server.applicationContextShutdownBean";
+
+ /**
+ * {@inheritDoc}
+ */
+ public void postProcess(BundleContext bundleContext, ConfigurableListableBeanFactory beanFactory) {
+ beanFactory.registerSingleton(APPLICATION_CONTEXT_SHUTDOWN_BEAN_NAME, new ApplicationContextShutdownBean());
+ }
+
+}
diff --git a/org.eclipse.virgo.kernel.dmfragment/src/main/java/org/eclipse/virgo/kernel/dmfragment/internal/ContextClassLoaderPostProcessor.java b/org.eclipse.virgo.kernel.dmfragment/src/main/java/org/eclipse/virgo/kernel/dmfragment/internal/ContextClassLoaderPostProcessor.java
new file mode 100644
index 00000000..cb08f03d
--- /dev/null
+++ b/org.eclipse.virgo.kernel.dmfragment/src/main/java/org/eclipse/virgo/kernel/dmfragment/internal/ContextClassLoaderPostProcessor.java
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.kernel.dmfragment.internal;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.virgo.kernel.dmfragment.ModuleBeanFactoryPostProcessor;
+import org.osgi.framework.BundleContext;
+import org.springframework.beans.MutablePropertyValues;
+import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
+import org.springframework.osgi.extender.OsgiBeanFactoryPostProcessor;
+import org.springframework.osgi.service.importer.support.ImportContextClassLoader;
+import org.springframework.osgi.service.importer.support.OsgiServiceCollectionProxyFactoryBean;
+import org.springframework.osgi.service.importer.support.OsgiServiceProxyFactoryBean;
+
+
+/**
+ * {@link OsgiBeanFactoryPostProcessor} that ensures that all service references are in unmanaged mode for thread
+ * context class loader propagation.<p/>
+ *
+ * <strong>Concurrent Semantics</strong><br />
+ *
+ * Threadsafe.
+ *
+ */
+final class ContextClassLoaderPostProcessor implements ModuleBeanFactoryPostProcessor {
+
+ private static final String PROPERTY_CONTEXT_CLASS_LOADER = "contextClassLoader";
+
+ private static final Set<String> IMPORTER_CLASS_NAMES = createImportClassNames();
+
+ /**
+ * {@inheritDoc}
+ */
+ public void postProcess(BundleContext bundleContext, ConfigurableListableBeanFactory beanFactory) {
+ String[] beanDefinitionNames = beanFactory.getBeanDefinitionNames();
+ for (String name : beanDefinitionNames) {
+ BeanDefinition beanDefinition = beanFactory.getBeanDefinition(name);
+ if (isServiceImportDefinition(beanDefinition)) {
+ MutablePropertyValues propertyValues = beanDefinition.getPropertyValues();
+ propertyValues.addPropertyValue(PROPERTY_CONTEXT_CLASS_LOADER, ImportContextClassLoader.UNMANAGED.getLabel());
+ }
+ }
+ }
+
+ private static Set<String> createImportClassNames() {
+ Set<String> names = new HashSet<String>();
+ names.add(OsgiServiceProxyFactoryBean.class.getName());
+ names.add(OsgiServiceCollectionProxyFactoryBean.class.getName());
+ return names;
+ }
+
+ private boolean isServiceImportDefinition(BeanDefinition beanDefinition) {
+ return IMPORTER_CLASS_NAMES.contains(beanDefinition.getBeanClassName());
+ }
+
+}
diff --git a/org.eclipse.virgo.kernel.dmfragment/src/main/java/org/eclipse/virgo/kernel/dmfragment/internal/KernelAnnotationMBeanExporter.java b/org.eclipse.virgo.kernel.dmfragment/src/main/java/org/eclipse/virgo/kernel/dmfragment/internal/KernelAnnotationMBeanExporter.java
new file mode 100644
index 00000000..111b288f
--- /dev/null
+++ b/org.eclipse.virgo.kernel.dmfragment/src/main/java/org/eclipse/virgo/kernel/dmfragment/internal/KernelAnnotationMBeanExporter.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.kernel.dmfragment.internal;
+
+import javax.management.MBeanException;
+import javax.management.modelmbean.ModelMBean;
+
+import org.eclipse.virgo.kernel.shim.serviceability.TracingService;
+import org.springframework.jmx.export.annotation.AnnotationMBeanExporter;
+
+
+/**
+ * An extension of {@link AnnotationMBeanExporter} that exports Kernel-specific MBeans.
+ *
+ * <strong>Concurrent Semantics</strong><br />
+ * As thread-safe as <code>MBeanExporter</code>.
+ */
+final class KernelAnnotationMBeanExporter extends AnnotationMBeanExporter {
+
+ private final TracingService tracingService;
+
+ KernelAnnotationMBeanExporter(TracingService tracingService) {
+ this.tracingService = tracingService;
+ }
+
+ @Override
+ protected ModelMBean createModelMBean() throws MBeanException {
+ return new KernelModelMBean(this.tracingService, this.tracingService.getCurrentApplicationName());
+ }
+}
diff --git a/org.eclipse.virgo.kernel.dmfragment/src/main/java/org/eclipse/virgo/kernel/dmfragment/internal/KernelExtensionConfiguringOsgiPostProcessor.java b/org.eclipse.virgo.kernel.dmfragment/src/main/java/org/eclipse/virgo/kernel/dmfragment/internal/KernelExtensionConfiguringOsgiPostProcessor.java
new file mode 100644
index 00000000..f20252ac
--- /dev/null
+++ b/org.eclipse.virgo.kernel.dmfragment/src/main/java/org/eclipse/virgo/kernel/dmfragment/internal/KernelExtensionConfiguringOsgiPostProcessor.java
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.kernel.dmfragment.internal;
+
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import org.eclipse.virgo.kernel.dmfragment.ModuleBeanFactoryPostProcessor;
+import org.osgi.framework.BundleContext;
+import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
+import org.springframework.osgi.extender.OsgiBeanFactoryPostProcessor;
+
+
+/**
+ * {@link OsgiBeanFactoryPostProcessor} implementation that plugs in Server extensions implementation when needed.<p/>
+ *
+ * <strong>Concurrent Semantics</strong><br />
+ *
+ * Threadsafe.
+ *
+ */
+final class KernelExtensionConfiguringOsgiPostProcessor implements OsgiBeanFactoryPostProcessor {
+
+ private final List<ModuleBeanFactoryPostProcessor> postProcessors = new CopyOnWriteArrayList<ModuleBeanFactoryPostProcessor>();
+
+ KernelExtensionConfiguringOsgiPostProcessor(List<ModuleBeanFactoryPostProcessor> defaultPostProcessors) {
+ this.postProcessors.addAll(defaultPostProcessors);
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void postProcessBeanFactory(BundleContext bundleContext, ConfigurableListableBeanFactory beanFactory) {
+ for (ModuleBeanFactoryPostProcessor postProcessor : this.postProcessors) {
+ postProcessor.postProcess(bundleContext, beanFactory);
+ }
+ }
+
+}
diff --git a/org.eclipse.virgo.kernel.dmfragment/src/main/java/org/eclipse/virgo/kernel/dmfragment/internal/KernelLoadTimeWeaver.java b/org.eclipse.virgo.kernel.dmfragment/src/main/java/org/eclipse/virgo/kernel/dmfragment/internal/KernelLoadTimeWeaver.java
new file mode 100644
index 00000000..1bb92fcd
--- /dev/null
+++ b/org.eclipse.virgo.kernel.dmfragment/src/main/java/org/eclipse/virgo/kernel/dmfragment/internal/KernelLoadTimeWeaver.java
@@ -0,0 +1,97 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.kernel.dmfragment.internal;
+
+import java.lang.instrument.ClassFileTransformer;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.springframework.beans.factory.BeanClassLoaderAware;
+import org.springframework.instrument.classloading.LoadTimeWeaver;
+import org.springframework.osgi.util.BundleDelegatingClassLoader;
+
+import org.eclipse.virgo.kernel.osgi.framework.InstrumentableClassLoader;
+import org.eclipse.virgo.kernel.osgi.framework.OsgiFramework;
+
+/**
+ * {@link LoadTimeWeaver} implementation that plugs into the {@link InstrumentableClassLoader
+ * InstrumentableClassLoaders} created for all installed bundles.<p/>
+ *
+ * <strong>Concurrent Semantics</strong><br />
+ *
+ * Threadsafe.
+ *
+ */
+final class KernelLoadTimeWeaver implements LoadTimeWeaver, BeanClassLoaderAware {
+
+ private volatile InstrumentableClassLoader instrumentableClassLoader;
+
+ /**
+ * {@inheritDoc}
+ */
+ public void addTransformer(ClassFileTransformer transformer) {
+ this.instrumentableClassLoader.addClassFileTransformer(transformer);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public ClassLoader getInstrumentableClassLoader() {
+ return (ClassLoader) this.instrumentableClassLoader;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public ClassLoader getThrowawayClassLoader() {
+ return this.instrumentableClassLoader.createThrowAway();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setBeanClassLoader(ClassLoader classLoader) {
+ InstrumentableClassLoader instrumentableClassLoader = null;
+ if (classLoader instanceof InstrumentableClassLoader) {
+ instrumentableClassLoader = (InstrumentableClassLoader) classLoader;
+ } else if (classLoader instanceof BundleDelegatingClassLoader) {
+ Bundle bundle = ((BundleDelegatingClassLoader) classLoader).getBundle();
+ ClassLoader bundleClassLoader = getBundleClassLoader(bundle);
+ if (bundleClassLoader instanceof InstrumentableClassLoader) {
+ instrumentableClassLoader = (InstrumentableClassLoader) bundleClassLoader;
+ }
+ }
+ if (instrumentableClassLoader == null) {
+ throw new IllegalStateException("ClassLoader '" + classLoader + "' is not instrumentable.");
+ }
+ this.instrumentableClassLoader = instrumentableClassLoader;
+ }
+
+ /**
+ * Gets the {@link ClassLoader} for the supplied {@link Bundle}.
+ *
+ * @param bundle the <code>Bundle</code>.
+ * @return the <code>Bundles</code> <code>ClassLoader</code>.
+ */
+ private ClassLoader getBundleClassLoader(Bundle bundle) {
+ BundleContext bundleContext = bundle.getBundleContext();
+ ServiceReference serviceReference = bundleContext.getServiceReference(OsgiFramework.class.getName());
+ try {
+ OsgiFramework framework = (OsgiFramework) bundleContext.getService(serviceReference);
+ return framework.getBundleClassLoader(bundle);
+ } finally {
+ bundleContext.ungetService(serviceReference);
+ }
+ }
+
+}
diff --git a/org.eclipse.virgo.kernel.dmfragment/src/main/java/org/eclipse/virgo/kernel/dmfragment/internal/KernelMBeanExporter.java b/org.eclipse.virgo.kernel.dmfragment/src/main/java/org/eclipse/virgo/kernel/dmfragment/internal/KernelMBeanExporter.java
new file mode 100644
index 00000000..d6cb410b
--- /dev/null
+++ b/org.eclipse.virgo.kernel.dmfragment/src/main/java/org/eclipse/virgo/kernel/dmfragment/internal/KernelMBeanExporter.java
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.kernel.dmfragment.internal;
+
+import javax.management.MBeanException;
+import javax.management.modelmbean.ModelMBean;
+
+import org.eclipse.virgo.kernel.shim.serviceability.TracingService;
+import org.springframework.jmx.export.MBeanExporter;
+
+
+/**
+ * An extension of {@link MBeanExporter} that exports Server-specific MBeans.
+ *
+ * <strong>Concurrent Semantics</strong><br />
+ * As thread-safe as <code>MBeanExporter</code>.
+ *
+ */
+final class KernelMBeanExporter extends MBeanExporter {
+
+ private final TracingService tracingService;
+
+ KernelMBeanExporter(TracingService tracingService) {
+ this.tracingService = tracingService;
+ }
+
+ @Override
+ protected ModelMBean createModelMBean() throws MBeanException {
+ return new KernelModelMBean(this.tracingService, this.tracingService.getCurrentApplicationName());
+ }
+}
diff --git a/org.eclipse.virgo.kernel.dmfragment/src/main/java/org/eclipse/virgo/kernel/dmfragment/internal/KernelModelMBean.java b/org.eclipse.virgo.kernel.dmfragment/src/main/java/org/eclipse/virgo/kernel/dmfragment/internal/KernelModelMBean.java
new file mode 100644
index 00000000..3f357741
--- /dev/null
+++ b/org.eclipse.virgo.kernel.dmfragment/src/main/java/org/eclipse/virgo/kernel/dmfragment/internal/KernelModelMBean.java
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.kernel.dmfragment.internal;
+
+import javax.management.MBeanException;
+import javax.management.ReflectionException;
+import javax.management.RuntimeOperationsException;
+
+import org.eclipse.virgo.kernel.shim.serviceability.TracingService;
+import org.springframework.jmx.export.SpringModelMBean;
+
+
+/**
+ * An extension of {@link SpringModelMBean} that acts as a Server-specific MBeans.
+ *
+ * <strong>Concurrent Semantics</strong><br />
+ * As thread-safe as <code>SpringModelMBean</code>.
+ */
+final class KernelModelMBean extends SpringModelMBean {
+
+ private final TracingService tracingService;
+
+ private final String applicationName;
+
+ public KernelModelMBean(TracingService tracingService, String applicationName) throws RuntimeOperationsException, MBeanException {
+ this.tracingService = tracingService;
+ this.applicationName = applicationName;
+ }
+
+ @Override
+ public Object invoke(String opName, Object[] opArgs, String[] sig) throws MBeanException, ReflectionException {
+ String originalApplicationName = this.tracingService.getCurrentApplicationName();
+
+ try {
+ this.tracingService.setCurrentApplicationName(this.applicationName);
+ return super.invoke(opName, opArgs, sig);
+ } finally {
+ this.tracingService.setCurrentApplicationName(originalApplicationName);
+ }
+ }
+}
diff --git a/org.eclipse.virgo.kernel.dmfragment/src/main/java/org/eclipse/virgo/kernel/dmfragment/internal/LoadTimeWeaverPostProcessor.java b/org.eclipse.virgo.kernel.dmfragment/src/main/java/org/eclipse/virgo/kernel/dmfragment/internal/LoadTimeWeaverPostProcessor.java
new file mode 100644
index 00000000..fc3efdd6
--- /dev/null
+++ b/org.eclipse.virgo.kernel.dmfragment/src/main/java/org/eclipse/virgo/kernel/dmfragment/internal/LoadTimeWeaverPostProcessor.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.kernel.dmfragment.internal;
+
+import static org.springframework.context.ConfigurableApplicationContext.LOAD_TIME_WEAVER_BEAN_NAME;
+
+import org.eclipse.virgo.kernel.dmfragment.ModuleBeanFactoryPostProcessor;
+import org.osgi.framework.BundleContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
+import org.springframework.beans.factory.support.AbstractBeanDefinition;
+
+
+final class LoadTimeWeaverPostProcessor implements ModuleBeanFactoryPostProcessor {
+
+ private final Logger logger = LoggerFactory.getLogger(this.getClass());
+
+ public void postProcess(BundleContext bundleContext, ConfigurableListableBeanFactory beanFactory) {
+ if (beanFactory.containsBean(LOAD_TIME_WEAVER_BEAN_NAME)) {
+ AbstractBeanDefinition ltwBean = (AbstractBeanDefinition) beanFactory.getBeanDefinition(LOAD_TIME_WEAVER_BEAN_NAME);
+ ltwBean.setBeanClass(KernelLoadTimeWeaver.class);
+ logger.info("Found load-time weaver bean for bundle '{}'. Switching to ServerLoadTimeWeaver.", bundleContext.getBundle());
+ } else {
+ logger.info("Load-time weaving not enabled for bundle '{}',", bundleContext.getBundle());
+ }
+ }
+
+}
diff --git a/org.eclipse.virgo.kernel.dmfragment/src/main/java/org/eclipse/virgo/kernel/dmfragment/internal/MBeanExporterPostProcessor.java b/org.eclipse.virgo.kernel.dmfragment/src/main/java/org/eclipse/virgo/kernel/dmfragment/internal/MBeanExporterPostProcessor.java
new file mode 100644
index 00000000..d675f043
--- /dev/null
+++ b/org.eclipse.virgo.kernel.dmfragment/src/main/java/org/eclipse/virgo/kernel/dmfragment/internal/MBeanExporterPostProcessor.java
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.kernel.dmfragment.internal;
+
+import org.eclipse.virgo.kernel.dmfragment.ModuleBeanFactoryPostProcessor;
+import org.eclipse.virgo.kernel.shim.serviceability.TracingService;
+import org.osgi.framework.BundleContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
+import org.springframework.beans.factory.support.AbstractBeanDefinition;
+import org.springframework.jmx.export.MBeanExporter;
+import org.springframework.jmx.export.annotation.AnnotationMBeanExporter;
+
+
+final class MBeanExporterPostProcessor implements ModuleBeanFactoryPostProcessor {
+
+ private final Logger logger = LoggerFactory.getLogger(this.getClass());
+
+ private final TracingService tracingService;
+
+ public MBeanExporterPostProcessor(TracingService tracingService) {
+ this.tracingService = tracingService;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void postProcess(BundleContext bundleContext, ConfigurableListableBeanFactory beanFactory) {
+ boolean foundExporter = false;
+ String[] beanDefinitionNames = beanFactory.getBeanDefinitionNames();
+ for (String beanDefinitionName : beanDefinitionNames) {
+ AbstractBeanDefinition definition = (AbstractBeanDefinition) beanFactory.getBeanDefinition(beanDefinitionName);
+ if (MBeanExporter.class.getName().equals(definition.getBeanClassName())) {
+ definition.setBeanClass(KernelMBeanExporter.class);
+ definition.getConstructorArgumentValues().addGenericArgumentValue(this.tracingService);
+ foundExporter = true;
+ } else if (AnnotationMBeanExporter.class.getName().equals(definition.getBeanClassName())) {
+ definition.setBeanClass(KernelAnnotationMBeanExporter.class);
+ definition.getConstructorArgumentValues().addGenericArgumentValue(this.tracingService);
+ foundExporter = true;
+ }
+ }
+ if (foundExporter) {
+ logger.info("Found MBean exporter bean for bundle '{}'. Switching to ServerMBeanExporter or ServerAnnotationMBeanExporter.",
+ bundleContext.getBundle());
+ } else {
+ logger.info("MBean exporting not enabled for bundle '{}',", bundleContext.getBundle());
+ }
+ }
+
+}
diff --git a/org.eclipse.virgo.kernel.dmfragment/src/main/java/org/eclipse/virgo/kernel/dmfragment/internal/ServiceProxyRetryDisablingBundleListener.java b/org.eclipse.virgo.kernel.dmfragment/src/main/java/org/eclipse/virgo/kernel/dmfragment/internal/ServiceProxyRetryDisablingBundleListener.java
new file mode 100644
index 00000000..48af4475
--- /dev/null
+++ b/org.eclipse.virgo.kernel.dmfragment/src/main/java/org/eclipse/virgo/kernel/dmfragment/internal/ServiceProxyRetryDisablingBundleListener.java
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.kernel.dmfragment.internal;
+
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleEvent;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.SynchronousBundleListener;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.context.ApplicationContext;
+import org.springframework.osgi.service.importer.support.OsgiServiceProxyFactoryBean;
+
+/**
+ * A {@link SynchronousBundleListener} that reacts to a {@link BundleEvent#STOPPING STOPPING} event for the system
+ * bundle. Upon such an event being received the listener retrieves all {@link ApplicationContext ApplicationContexts}
+ * from the service registry and disables retry on any {@link OsgiServiceProxyFactoryBean OsgiServiceProxyFactoryBeans}
+ * which they contain.
+ * <p />
+ *
+ * <strong>Concurrent Semantics</strong><br />
+ *
+ * Thread-safe.
+ *
+ *
+ * @see ApplicationContextShutdownBean#disableServiceProxyRetry(ApplicationContext)
+ */
+class ServiceProxyRetryDisablingBundleListener implements SynchronousBundleListener {
+
+ private final Logger logger = LoggerFactory.getLogger(this.getClass());
+
+ ServiceProxyRetryDisablingBundleListener(BundleContext bundleContext) {
+ bundleContext.addBundleListener(this);
+ }
+
+ public void bundleChanged(BundleEvent event) {
+ if (event.getBundle().getBundleId() == 0 && event.getType() == BundleEvent.STOPPING) {
+ BundleContext bundleContext = event.getBundle().getBundleContext();
+ try {
+ ServiceReference[] applicationContextServiceReferences = event.getBundle().getBundleContext().getAllServiceReferences(
+ ApplicationContext.class.getName(), null);
+
+ for (ServiceReference applicationContextServiceReference : applicationContextServiceReferences) {
+ ApplicationContext applicationContext = (ApplicationContext) bundleContext.getService(applicationContextServiceReference);
+ ApplicationContextShutdownBean.disableServiceProxyRetry(applicationContext);
+ bundleContext.ungetService(applicationContextServiceReference);
+ }
+ } catch (InvalidSyntaxException ise) {
+ logger.error("Failed to retrieve all application contexts from service registry", ise);
+ }
+ }
+ }
+}
diff --git a/org.eclipse.virgo.kernel.dmfragment/src/main/resources/META-INF/spring/extender/kernel-dmfragment-context.xml b/org.eclipse.virgo.kernel.dmfragment/src/main/resources/META-INF/spring/extender/kernel-dmfragment-context.xml
new file mode 100644
index 00000000..93ceda9a
--- /dev/null
+++ b/org.eclipse.virgo.kernel.dmfragment/src/main/resources/META-INF/spring/extender/kernel-dmfragment-context.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://www.springframework.org/schema/beans"
+ xmlns:osgi="http://www.springframework.org/schema/osgi"
+ 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-2.5.xsd">
+
+ <osgi:reference id="tracingService" interface="org.eclipse.virgo.kernel.shim.serviceability.TracingService"/>
+
+ <bean id="serverExtensionConfigurer" class="org.eclipse.virgo.kernel.dmfragment.internal.KernelExtensionConfiguringOsgiPostProcessor">
+ <constructor-arg>
+ <list>
+ <bean class="org.eclipse.virgo.kernel.dmfragment.internal.ContextClassLoaderPostProcessor"/>
+ <bean class="org.eclipse.virgo.kernel.dmfragment.internal.LoadTimeWeaverPostProcessor"/>
+ <bean class="org.eclipse.virgo.kernel.dmfragment.internal.MBeanExporterPostProcessor">
+ <constructor-arg ref="tracingService"/>
+ </bean>
+ <bean class="org.eclipse.virgo.kernel.dmfragment.internal.ApplicationContextShutdownBeanPostProcessor"/>
+ </list>
+ </constructor-arg>
+ </bean>
+
+ <osgi:service ref="serverExtensionConfigurer" interface="org.springframework.osgi.extender.OsgiBeanFactoryPostProcessor" />
+
+ <bean id="taskExecutor" class="org.eclipse.virgo.kernel.agent.dm.ContextPropagatingTaskExecutor">
+ <constructor-arg value="region-dm-" />
+ <constructor-arg value="15" />
+ <constructor-arg ref="bundleContext"/>
+ </bean>
+
+ <alias alias="shutdownTaskExecutor" name="taskExecutor"/>
+
+ <bean id="serviceProxyRetryDisabler" class="org.eclipse.virgo.kernel.dmfragment.internal.ServiceProxyRetryDisablingBundleListener">
+ <constructor-arg ref="bundleContext"/>
+ </bean>
+
+</beans>
diff --git a/org.eclipse.virgo.kernel.dmfragment/src/test/java/.gitignore b/org.eclipse.virgo.kernel.dmfragment/src/test/java/.gitignore
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/org.eclipse.virgo.kernel.dmfragment/src/test/java/.gitignore
diff --git a/org.eclipse.virgo.kernel.dmfragment/src/test/resources/.gitignore b/org.eclipse.virgo.kernel.dmfragment/src/test/resources/.gitignore
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/org.eclipse.virgo.kernel.dmfragment/src/test/resources/.gitignore
diff --git a/org.eclipse.virgo.kernel.dmfragment/template.mf b/org.eclipse.virgo.kernel.dmfragment/template.mf
new file mode 100644
index 00000000..7a67d8f7
--- /dev/null
+++ b/org.eclipse.virgo.kernel.dmfragment/template.mf
@@ -0,0 +1,21 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Virgo Kernel User Region OSGi Spring DM Fragment
+Fragment-Host: org.springframework.osgi.extender
+Bundle-SymbolicName: org.eclipse.virgo.kernel.dmfragment
+Bundle-Version: 2.1.0
+Import-Package:
+ org.eclipse.virgo.kernel.agent.dm;version="${version:[=.=.=, =.+1)}",
+ org.eclipse.virgo.kernel.shim.serviceability;version="${version:[=.=.=, =.+1)}"
+Import-Template:
+ org.eclipse.virgo.kernel.*;version="${version:[=.=.=, =.+1)}",
+ org.eclipse.virgo.medic.*;version="${org.eclipse.virgo.medic:[=.=.=, =.+1)}",
+ org.slf4j.*;version="${org.slf4j:[=.=.=, +1)}",
+ org.aspectj.*;version="${org.aspectj:[=.=.=.=, +1)}",
+ javax.management.*;version="0",
+ org.osgi.framework.*;version="0",
+ org.springframework.*;version="${org.springframework:[2.5.6, =.+1)}"
+Excluded-Imports:
+ org.springframework.osgi.*
+Excluded-Exports:
+ org.eclipse.virgo.kernel.dmfragment.internal.*

Back to the top