Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.virgo.kernel.dm/src')
-rw-r--r--org.eclipse.virgo.kernel.dm/src/main/java/org/eclipse/virgo/kernel/dm/internal/StandardBundleDelegatingClassLoaderFactory.java43
-rw-r--r--org.eclipse.virgo.kernel.dm/src/main/java/org/eclipse/virgo/kernel/dm/internal/StandardServiceProxyInspector.java33
-rw-r--r--org.eclipse.virgo.kernel.dm/src/main/resources/META-INF/spring/kernel-dm-context.xml25
-rw-r--r--org.eclipse.virgo.kernel.dm/src/test/java/.gitignore0
-rw-r--r--org.eclipse.virgo.kernel.dm/src/test/resources/.gitignore0
5 files changed, 101 insertions, 0 deletions
diff --git a/org.eclipse.virgo.kernel.dm/src/main/java/org/eclipse/virgo/kernel/dm/internal/StandardBundleDelegatingClassLoaderFactory.java b/org.eclipse.virgo.kernel.dm/src/main/java/org/eclipse/virgo/kernel/dm/internal/StandardBundleDelegatingClassLoaderFactory.java
new file mode 100644
index 00000000..d573fe65
--- /dev/null
+++ b/org.eclipse.virgo.kernel.dm/src/main/java/org/eclipse/virgo/kernel/dm/internal/StandardBundleDelegatingClassLoaderFactory.java
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * 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.dm.internal;
+
+import org.eclipse.virgo.kernel.serviceability.Assert;
+import org.osgi.framework.Bundle;
+import org.springframework.osgi.util.BundleDelegatingClassLoader;
+
+import org.eclipse.virgo.kernel.module.BundleDelegatingClassLoaderFactory;
+
+/**
+ */
+final class StandardBundleDelegatingClassLoaderFactory implements BundleDelegatingClassLoaderFactory {
+
+ /**
+ * {@inheritDoc}
+ */
+ public ClassLoader createBundleDelegatingClassLoader(Bundle... bundles) {
+
+ Assert.notEmpty(bundles, "at least one bundle must be specified");
+
+ int delegates = bundles.length;
+ Bundle head = bundles[0];
+
+ if (delegates == 1) {
+ return BundleDelegatingClassLoader.createBundleClassLoaderFor(head);
+ } else {
+ Bundle[] tail = new Bundle[delegates - 1];
+ System.arraycopy(bundles, 1, tail, 0, delegates - 1);
+ return BundleDelegatingClassLoader.createBundleClassLoaderFor(head, createBundleDelegatingClassLoader(tail));
+ }
+ }
+
+}
diff --git a/org.eclipse.virgo.kernel.dm/src/main/java/org/eclipse/virgo/kernel/dm/internal/StandardServiceProxyInspector.java b/org.eclipse.virgo.kernel.dm/src/main/java/org/eclipse/virgo/kernel/dm/internal/StandardServiceProxyInspector.java
new file mode 100644
index 00000000..0e564f9d
--- /dev/null
+++ b/org.eclipse.virgo.kernel.dm/src/main/java/org/eclipse/virgo/kernel/dm/internal/StandardServiceProxyInspector.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * 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.dm.internal;
+
+import org.springframework.osgi.service.importer.ImportedOsgiServiceProxy;
+
+import org.eclipse.virgo.kernel.module.ServiceProxyInspector;
+
+/**
+ */
+final class StandardServiceProxyInspector implements ServiceProxyInspector {
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isLive(Object proxy) {
+ if (proxy instanceof ImportedOsgiServiceProxy) {
+ return ((ImportedOsgiServiceProxy) proxy).getServiceReference().getBundle() != null;
+ } else {
+ return true;
+ }
+ }
+
+}
diff --git a/org.eclipse.virgo.kernel.dm/src/main/resources/META-INF/spring/kernel-dm-context.xml b/org.eclipse.virgo.kernel.dm/src/main/resources/META-INF/spring/kernel-dm-context.xml
new file mode 100644
index 00000000..4050aad4
--- /dev/null
+++ b/org.eclipse.virgo.kernel.dm/src/main/resources/META-INF/spring/kernel-dm-context.xml
@@ -0,0 +1,25 @@
+<?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: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.xsd">
+
+ <bean id="serviceProxyInspector" class="org.eclipse.virgo.kernel.dm.internal.StandardServiceProxyInspector"/>
+
+ <osgi:service ref="serviceProxyInspector" interface="org.eclipse.virgo.kernel.module.ServiceProxyInspector">
+ <osgi:service-properties>
+ <entry key="com.springsource.service.scope" value="global"/>
+ </osgi:service-properties>
+ </osgi:service>
+
+ <bean id="bundleDelegatingClassLoaderFactory" class="org.eclipse.virgo.kernel.dm.internal.StandardBundleDelegatingClassLoaderFactory"/>
+
+ <osgi:service ref="bundleDelegatingClassLoaderFactory" interface="org.eclipse.virgo.kernel.module.BundleDelegatingClassLoaderFactory">
+ <osgi:service-properties>
+ <entry key="com.springsource.service.scope" value="global"/>
+ </osgi:service-properties>
+ </osgi:service>
+
+ <osgi:reference id="tracingService" interface="org.eclipse.virgo.kernel.shim.serviceability.TracingService"/>
+
+ <osgi:reference id="eventLogger" interface="org.eclipse.virgo.medic.eventlog.EventLogger"/>
+</beans>
diff --git a/org.eclipse.virgo.kernel.dm/src/test/java/.gitignore b/org.eclipse.virgo.kernel.dm/src/test/java/.gitignore
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/org.eclipse.virgo.kernel.dm/src/test/java/.gitignore
diff --git a/org.eclipse.virgo.kernel.dm/src/test/resources/.gitignore b/org.eclipse.virgo.kernel.dm/src/test/resources/.gitignore
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/org.eclipse.virgo.kernel.dm/src/test/resources/.gitignore

Back to the top