Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlyn Normington2010-05-11 08:15:08 -0400
committerGlyn Normington2010-05-11 08:15:08 -0400
commit5dfdbe75bdf1ba2476fe2e60e62e3454a3565de7 (patch)
tree5522099ce269769cdd39fe31fbe2d20afd416a1c /org.eclipse.virgo.kernel.deployer.dm
parentb99bf75af622c030c6c9b479c1639925bd1ea872 (diff)
downloadorg.eclipse.virgo.kernel-5dfdbe75bdf1ba2476fe2e60e62e3454a3565de7.tar.gz
org.eclipse.virgo.kernel-5dfdbe75bdf1ba2476fe2e60e62e3454a3565de7.tar.xz
org.eclipse.virgo.kernel-5dfdbe75bdf1ba2476fe2e60e62e3454a3565de7.zip
initial checkin from dm Server kernel commit dffbc217a919cefba04886160ba820f2c6cf5f57 omitting build-kernel/bin/service
Diffstat (limited to 'org.eclipse.virgo.kernel.deployer.dm')
-rw-r--r--org.eclipse.virgo.kernel.deployer.dm/.classpath47
-rw-r--r--org.eclipse.virgo.kernel.deployer.dm/.project42
-rw-r--r--org.eclipse.virgo.kernel.deployer.dm/.settings/com.springsource.server.ide.bundlor.core.prefs3
-rw-r--r--org.eclipse.virgo.kernel.deployer.dm/.settings/org.eclipse.jdt.core.prefs12
-rw-r--r--org.eclipse.virgo.kernel.deployer.dm/.settings/org.eclipse.wst.common.project.facet.core.xml4
-rw-r--r--org.eclipse.virgo.kernel.deployer.dm/.springBeans13
-rw-r--r--org.eclipse.virgo.kernel.deployer.dm/build.xml8
-rw-r--r--org.eclipse.virgo.kernel.deployer.dm/ivy.xml37
-rw-r--r--org.eclipse.virgo.kernel.deployer.dm/src/main/java/org/eclipse/virgo/kernel/deployer/app/spring/ApplicationBundleUtils.java40
-rw-r--r--org.eclipse.virgo.kernel.deployer.dm/src/main/java/org/eclipse/virgo/kernel/deployer/app/spring/ModuleContextWrapper.java101
-rw-r--r--org.eclipse.virgo.kernel.deployer.dm/src/main/java/org/eclipse/virgo/kernel/deployer/app/spring/UserRegionModuleContextAccessor.java71
-rw-r--r--org.eclipse.virgo.kernel.deployer.dm/src/main/resources/META-INF/spring/deployer-dm-context.xml16
-rw-r--r--org.eclipse.virgo.kernel.deployer.dm/src/test/java/.gitignore0
-rw-r--r--org.eclipse.virgo.kernel.deployer.dm/src/test/java/org/eclipse/virgo/kernel/deployer/app/spring/UserRegionModuleContextAccessorTests.java142
-rw-r--r--org.eclipse.virgo.kernel.deployer.dm/src/test/resources/.gitignore0
-rw-r--r--org.eclipse.virgo.kernel.deployer.dm/template.mf13
16 files changed, 549 insertions, 0 deletions
diff --git a/org.eclipse.virgo.kernel.deployer.dm/.classpath b/org.eclipse.virgo.kernel.deployer.dm/.classpath
new file mode 100644
index 00000000..ce32fd4d
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.dm/.classpath
@@ -0,0 +1,47 @@
+<?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.junit/com.springsource.org.junit/4.7.0/com.springsource.org.junit-4.7.0.jar" sourcepath="/KERNEL_IVY_CACHE/org.junit/com.springsource.org.junit/4.7.0/com.springsource.org.junit-sources-4.7.0.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/org.springframework.beans/3.0.0.RELEASE/org.springframework.beans-3.0.0.RELEASE.jar" sourcepath="/KERNEL_IVY_CACHE/org.springframework/org.springframework.beans/3.0.0.RELEASE/org.springframework.beans-sources-3.0.0.RELEASE.jar"/>
+ <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/3.0.0.RELEASE/org.springframework.context-sources-3.0.0.RELEASE.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.1.R35x_v20091005/org.eclipse.osgi-sources-3.5.1.R35x_v20091005.jar"/>
+ <classpathentry kind="var" path="KERNEL_IVY_CACHE/org.springframework/org.springframework.context.support/3.0.0.RELEASE/org.springframework.context.support-3.0.0.RELEASE.jar" sourcepath="/KERNEL_IVY_CACHE/org.springframework/org.springframework.context.support/3.0.0.RELEASE/org.springframework.context.support-sources-3.0.0.RELEASE.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.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 combineaccessrules="false" kind="src" path="/org.eclipse.virgo.kernel.deployer"/>
+ <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.eclipse.virgo.teststubs/org.eclipse.virgo.teststubs.osgi/1.0.0.D-20100420091314/org.eclipse.virgo.teststubs.osgi-1.0.0.D-20100420091314.jar" sourcepath="/KERNEL_IVY_CACHE/org.eclipse.virgo.test/org.eclipse.virgo.teststubs.osgi/1.0.0.D-20100420091314/org.eclipse.virgo.teststubs.osgi-sources-1.0.0.D-20100420091314.jar"/>
+ <classpathentry kind="var" path="KERNEL_IVY_CACHE/org.apache.commons/com.springsource.org.apache.commons.logging/1.1.1/com.springsource.org.apache.commons.logging-1.1.1.jar"/>
+ <classpathentry kind="var" path="KERNEL_IVY_CACHE/org.aopalliance/com.springsource.org.aopalliance/1.0.0/com.springsource.org.aopalliance-1.0.0.jar"/>
+ <classpathentry kind="src" path="/org.eclipse.virgo.kernel.core"/>
+ <classpathentry kind="var" path="KERNEL_IVY_CACHE/org.easymock/com.springsource.org.easymock/2.3.0/com.springsource.org.easymock-2.3.0.jar" sourcepath="/KERNEL_IVY_CACHE/org.easymock/com.springsource.org.easymock/2.3.0/com.springsource.org.easymock-sources-2.3.0.jar"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/org.eclipse.virgo.kernel.dmfragment"/>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
diff --git a/org.eclipse.virgo.kernel.deployer.dm/.project b/org.eclipse.virgo.kernel.deployer.dm/.project
new file mode 100644
index 00000000..ad4333ae
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.dm/.project
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.virgo.kernel.deployer.dm</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.deployer.dm/.settings/com.springsource.server.ide.bundlor.core.prefs b/org.eclipse.virgo.kernel.deployer.dm/.settings/com.springsource.server.ide.bundlor.core.prefs
new file mode 100644
index 00000000..fcf52735
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.dm/.settings/com.springsource.server.ide.bundlor.core.prefs
@@ -0,0 +1,3 @@
+#Mon Jul 06 09:07:34 BST 2009
+com.springsource.server.ide.bundlor.core.template.properties.files=../build.versions
+eclipse.preferences.version=1
diff --git a/org.eclipse.virgo.kernel.deployer.dm/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.virgo.kernel.deployer.dm/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000..f1f8b361
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.dm/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,12 @@
+#Wed Nov 26 11:05:44 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.deployer.dm/.settings/org.eclipse.wst.common.project.facet.core.xml b/org.eclipse.virgo.kernel.deployer.dm/.settings/org.eclipse.wst.common.project.facet.core.xml
new file mode 100644
index 00000000..801f856c
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.dm/.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.deployer.dm/.springBeans b/org.eclipse.virgo.kernel.deployer.dm/.springBeans
new file mode 100644
index 00000000..4dbe37b1
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.dm/.springBeans
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beansProjectDescription>
+ <version>1</version>
+ <pluginVersion><![CDATA[2.2.7.200910202224-RELEASE]]></pluginVersion>
+ <configSuffixes>
+ <configSuffix><![CDATA[xml]]></configSuffix>
+ </configSuffixes>
+ <enableImports><![CDATA[false]]></enableImports>
+ <configs>
+ </configs>
+ <configSets>
+ </configSets>
+</beansProjectDescription>
diff --git a/org.eclipse.virgo.kernel.deployer.dm/build.xml b/org.eclipse.virgo.kernel.deployer.dm/build.xml
new file mode 100644
index 00000000..3480f876
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.dm/build.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="org.eclipse.virgo.kernel.deployer.dm">
+
+ <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.deployer.dm/ivy.xml b/org.eclipse.virgo.kernel.deployer.dm/ivy.xml
new file mode 100644
index 00000000..f0ed87a7
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.dm/ivy.xml
@@ -0,0 +1,37 @@
+<?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.junit" name="com.springsource.org.junit" rev="${org.junit}" conf="test->runtime"/>
+ <dependency name='com.springsource.org.easymock' rev='${org.easymock}' org='org.easymock' conf='test->runtime'/>
+
+ <dependency org="org.eclipse.virgo.teststubs" name="org.eclipse.virgo.teststubs.osgi" rev="${org.eclipse.virgo.teststubs}" conf="test->runtime"/>
+ <dependency org="org.slf4j" name="com.springsource.slf4j.nop" rev="${org.slf4j}" conf="test->runtime"/>
+
+ <dependency org="org.springframework" name="org.springframework.beans" 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.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.deployer" rev="latest.integration" conf="compile->compile"/>
+ <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.deployer.dm/src/main/java/org/eclipse/virgo/kernel/deployer/app/spring/ApplicationBundleUtils.java b/org.eclipse.virgo.kernel.deployer.dm/src/main/java/org/eclipse/virgo/kernel/deployer/app/spring/ApplicationBundleUtils.java
new file mode 100644
index 00000000..99d0201e
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.dm/src/main/java/org/eclipse/virgo/kernel/deployer/app/spring/ApplicationBundleUtils.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.deployer.app.spring;
+
+import org.osgi.framework.Bundle;
+
+/**
+ * Utility methods for working with server application module bundles. <p/>
+ *
+ * <strong>Concurrent Semantics</strong><br />
+ *
+ * Thread-safe.
+ *
+ */
+public final class ApplicationBundleUtils {
+
+ private static final String MODULE_TYPE_MANIFEST_HEADER = "Module-Type";
+
+
+ /**
+ * Gets the server module type for the supplied {@link Bundle}.
+ *
+ * @param bundle the <code>Bundle</code>.
+ * @return the server module type, or <code>null</code> if the supplied <code>Bundle</code> is not a server
+ * application module.
+ */
+ public static String getModuleType(Bundle bundle) {
+ String value = (String) bundle.getHeaders().get(MODULE_TYPE_MANIFEST_HEADER);
+ return (value == null || value.length() == 0 ? null : value);
+ }
+}
diff --git a/org.eclipse.virgo.kernel.deployer.dm/src/main/java/org/eclipse/virgo/kernel/deployer/app/spring/ModuleContextWrapper.java b/org.eclipse.virgo.kernel.deployer.dm/src/main/java/org/eclipse/virgo/kernel/deployer/app/spring/ModuleContextWrapper.java
new file mode 100644
index 00000000..1f8c6c91
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.dm/src/main/java/org/eclipse/virgo/kernel/deployer/app/spring/ModuleContextWrapper.java
@@ -0,0 +1,101 @@
+/*******************************************************************************
+ * 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.deployer.app.spring;
+
+import org.springframework.beans.BeansException;
+import org.springframework.context.ConfigurableApplicationContext;
+
+import org.eclipse.virgo.kernel.module.Component;
+import org.eclipse.virgo.kernel.module.ModuleContext;
+import org.eclipse.virgo.kernel.module.NoSuchComponentException;
+
+/**
+ * {@link ModuleContextWrapper} wraps a {@link ConfigurableApplicationContext} to provide an equivalent {@link ModuleContext}.
+ * <p />
+ *
+ * <strong>Concurrent Semantics</strong><br />
+ *
+ * Thread safe.
+ *
+ */
+final class ModuleContextWrapper implements ModuleContext {
+
+ private final ConfigurableApplicationContext appCtx;
+
+ ModuleContextWrapper(ConfigurableApplicationContext appCtx) {
+ this.appCtx = appCtx;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Object getApplicationContext() {
+ return this.appCtx;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Component getComponent(final String componentName) throws NoSuchComponentException {
+ try {
+ final Object component = this.appCtx.getBean(componentName);
+ return new Component() {
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getName() {
+ return componentName;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getType() {
+ return component.getClass().getName();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isPrototype() {
+ return ModuleContextWrapper.this.appCtx.getBeanFactory().isPrototype(componentName);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isSingleton() {
+ return ModuleContextWrapper.this.appCtx.getBeanFactory().isSingleton(componentName);
+ }
+
+ };
+ } catch (BeansException e) {
+ throw new NoSuchComponentException(e.getMessage());
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String[] getComponentNames() {
+ return this.appCtx.getBeanDefinitionNames();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getDisplayName() {
+ return this.appCtx.getDisplayName();
+ }
+
+}
diff --git a/org.eclipse.virgo.kernel.deployer.dm/src/main/java/org/eclipse/virgo/kernel/deployer/app/spring/UserRegionModuleContextAccessor.java b/org.eclipse.virgo.kernel.deployer.dm/src/main/java/org/eclipse/virgo/kernel/deployer/app/spring/UserRegionModuleContextAccessor.java
new file mode 100644
index 00000000..0821a1e7
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.dm/src/main/java/org/eclipse/virgo/kernel/deployer/app/spring/UserRegionModuleContextAccessor.java
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * 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.deployer.app.spring;
+
+import org.eclipse.virgo.kernel.serviceability.Assert;
+import org.eclipse.virgo.kernel.serviceability.NonNull;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
+import org.springframework.context.ApplicationContext;
+import org.springframework.osgi.context.ConfigurableOsgiBundleApplicationContext;
+
+import org.eclipse.virgo.kernel.module.ModuleContext;
+import org.eclipse.virgo.kernel.module.ModuleContextAccessor;
+
+
+/**
+ * {@link UserRegionModuleContextAccessor} accesses {@link ModuleContext ModuleContexts} in the user region.
+ * <p />
+ *
+ * <strong>Concurrent Semantics</strong><br />
+ *
+ * Thread safe.
+ *
+ */
+final class UserRegionModuleContextAccessor implements ModuleContextAccessor {
+
+ /**
+ * {@inheritDoc}
+ */
+ public ModuleContext getModuleContext(@NonNull Bundle bundle) {
+ BundleContext bundleContext = bundle.getBundleContext();
+ // The bundle must have a bundle context in order to have a module context.
+ if (bundleContext != null) {
+ String symbolicName = bundle.getSymbolicName();
+ try {
+ ServiceReference[] refs = bundleContext.getServiceReferences(ApplicationContext.class.getName(), "(Bundle-SymbolicName="
+ + symbolicName + ")");
+ if (refs != null) {
+ for (ServiceReference ref : refs) {
+ ApplicationContext appCtx = (ApplicationContext) bundleContext.getService(ref);
+ try {
+ if (appCtx instanceof ConfigurableOsgiBundleApplicationContext) {
+ ConfigurableOsgiBundleApplicationContext cAppCtx = (ConfigurableOsgiBundleApplicationContext) appCtx;
+ if (bundleContext == cAppCtx.getBundleContext()) {
+ return new ModuleContextWrapper(cAppCtx);
+ }
+ }
+ } finally {
+ bundleContext.ungetService(ref);
+ }
+ }
+ }
+ } catch (InvalidSyntaxException e) {
+ Assert.isFalse(true, "Unexpected exception %s", e.getMessage());
+ }
+ }
+ return null;
+ }
+
+}
diff --git a/org.eclipse.virgo.kernel.deployer.dm/src/main/resources/META-INF/spring/deployer-dm-context.xml b/org.eclipse.virgo.kernel.deployer.dm/src/main/resources/META-INF/spring/deployer-dm-context.xml
new file mode 100644
index 00000000..b6f267c8
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.dm/src/main/resources/META-INF/spring/deployer-dm-context.xml
@@ -0,0 +1,16 @@
+<?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"
+ 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">
+
+ <beans:bean id="moduleContextAccessor"
+ class="org.eclipse.virgo.kernel.deployer.app.spring.UserRegionModuleContextAccessor" />
+
+ <osgi:service ref="moduleContextAccessor"
+ interface="org.eclipse.virgo.kernel.module.ModuleContextAccessor" />
+
+</beans:beans>
diff --git a/org.eclipse.virgo.kernel.deployer.dm/src/test/java/.gitignore b/org.eclipse.virgo.kernel.deployer.dm/src/test/java/.gitignore
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.dm/src/test/java/.gitignore
diff --git a/org.eclipse.virgo.kernel.deployer.dm/src/test/java/org/eclipse/virgo/kernel/deployer/app/spring/UserRegionModuleContextAccessorTests.java b/org.eclipse.virgo.kernel.deployer.dm/src/test/java/org/eclipse/virgo/kernel/deployer/app/spring/UserRegionModuleContextAccessorTests.java
new file mode 100644
index 00000000..40a4c3fa
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.dm/src/test/java/org/eclipse/virgo/kernel/deployer/app/spring/UserRegionModuleContextAccessorTests.java
@@ -0,0 +1,142 @@
+/*******************************************************************************
+ * 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.deployer.app.spring;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import java.util.Dictionary;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.osgi.framework.Filter;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.Version;
+import org.springframework.context.ApplicationContext;
+import org.springframework.osgi.context.ConfigurableOsgiBundleApplicationContext;
+
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+
+import org.eclipse.virgo.kernel.deployer.app.spring.UserRegionModuleContextAccessor;
+import org.eclipse.virgo.kernel.module.ModuleContext;
+import org.eclipse.virgo.kernel.module.ModuleContextAccessor;
+import org.eclipse.virgo.teststubs.osgi.framework.StubBundle;
+import org.eclipse.virgo.teststubs.osgi.framework.StubBundleContext;
+
+/**
+ */
+public class UserRegionModuleContextAccessorTests {
+
+ private static final String BUNDLE_SYMBOLIC_NAME = "bundle";
+
+ private ModuleContextAccessor moduleContextAccessor;
+
+ private StubBundle stubBundle;
+
+ private StubBundleContext stubBundleContext;
+
+ private ApplicationContext mockBasicApplicationContext;
+
+ private interface TestAppCtx extends ConfigurableOsgiBundleApplicationContext, ModuleContext {}
+
+ private TestAppCtx mockTestAppCtx;
+
+ private static final Filter NEGATIVE_FILTER = new Filter() {
+
+ public boolean match(ServiceReference reference) {
+ return false;
+ }
+
+ @SuppressWarnings("unchecked")
+ public boolean match(Dictionary dictionary) {
+ return false;
+ }
+
+ @SuppressWarnings("unchecked")
+ public boolean matchCase(Dictionary dictionary) {
+ return false;
+ }
+
+ };
+
+private static final Filter POSITIVE_FILTER = new Filter() {
+
+ public boolean match(ServiceReference reference) {
+ return true;
+ }
+
+ @SuppressWarnings("unchecked")
+ public boolean match(Dictionary dictionary) {
+ return true;
+ }
+
+ @SuppressWarnings("unchecked")
+ public boolean matchCase(Dictionary dictionary) {
+ return true;
+ }
+
+ };
+
+ @Before
+ public void setUp() throws Exception {
+ this.moduleContextAccessor = new UserRegionModuleContextAccessor();
+
+ this.stubBundle = new StubBundle(BUNDLE_SYMBOLIC_NAME, Version.emptyVersion);
+
+ this.stubBundleContext = new StubBundleContext();
+
+ this.stubBundle.setBundleContext(this.stubBundleContext);
+
+ this.mockBasicApplicationContext= createMock(ApplicationContext.class);
+
+ this.mockTestAppCtx = createMock(TestAppCtx.class);
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testUnpublishedApplicationContext() {
+ this.stubBundleContext.addFilter("(Bundle-SymbolicName=" + BUNDLE_SYMBOLIC_NAME + ")", NEGATIVE_FILTER);
+ assertNull(this.moduleContextAccessor.getModuleContext(this.stubBundle));
+ }
+
+ @Test
+ public void testUnpublishedApplicationContextWithOtherServicesPresent() {
+ this.stubBundleContext.addFilter("(Bundle-SymbolicName=" + BUNDLE_SYMBOLIC_NAME + ")", NEGATIVE_FILTER);
+ this.stubBundleContext.registerService(String.class.getName(), "", null);
+ assertNull(this.moduleContextAccessor.getModuleContext(this.stubBundle));
+ }
+
+ @Test
+ public void testPublishedApplicationContextOfWrongType() {
+ this.stubBundleContext.addFilter("(Bundle-SymbolicName=" + BUNDLE_SYMBOLIC_NAME + ")", POSITIVE_FILTER);
+ this.stubBundleContext.registerService(ApplicationContext.class.getName(), this.mockBasicApplicationContext, null);
+ assertNull(this.moduleContextAccessor.getModuleContext(this.stubBundle));
+ }
+
+ @Test
+ public void testPublishedApplicationContextOfCorrectType() {
+ this.stubBundleContext.addFilter("(Bundle-SymbolicName=" + BUNDLE_SYMBOLIC_NAME + ")", POSITIVE_FILTER);
+ this.stubBundleContext.registerService(ApplicationContext.class.getName(), this.mockTestAppCtx, null);
+ expect(this.mockTestAppCtx.getBundleContext()).andReturn(this.stubBundleContext);
+ replay(this.mockTestAppCtx);
+ assertNotNull(this.moduleContextAccessor.getModuleContext(this.stubBundle));
+ verify(this.mockTestAppCtx);
+ }
+
+}
diff --git a/org.eclipse.virgo.kernel.deployer.dm/src/test/resources/.gitignore b/org.eclipse.virgo.kernel.deployer.dm/src/test/resources/.gitignore
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.dm/src/test/resources/.gitignore
diff --git a/org.eclipse.virgo.kernel.deployer.dm/template.mf b/org.eclipse.virgo.kernel.deployer.dm/template.mf
new file mode 100644
index 00000000..073fc866
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.dm/template.mf
@@ -0,0 +1,13 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Virgo Kernel Deployer Spring DM Integration
+Bundle-SymbolicName: org.eclipse.virgo.kernel.deployer.dm
+Bundle-Version: 2.1.0
+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)}",
+ org.osgi.framework.*;version="0",
+ org.springframework.*;version="${org.springframework:[2.5.6, =.+1)}",
+ org.springframework.osgi.*;version="${org.springframework.osgi:[=.=.=, +1)}"

Back to the top