You are viewing a plain text version of this content. The canonical link for it is here.
Posted to muse-commits@ws.apache.org by da...@apache.org on 2006/07/28 17:06:06 UTC

svn commit: r426549 [1/2] - in /webservices/muse/trunk/modules: muse-osgi-core/ muse-osgi-core/resources/ muse-osgi-core/resources/META-INF/ muse-osgi-core/src/ muse-osgi-core/src/org/ muse-osgi-core/src/org/apache/ muse-osgi-core/src/org/apache/muse/ ...

Author: danj
Date: Fri Jul 28 08:06:01 2006
New Revision: 426549

URL: http://svn.apache.org/viewvc?rev=426549&view=rev
Log:
Initial commit of OSGi deployment for Muse, from Joel H. Submitted in JIRA as MUSE-38. The 
modules are installed in a local repository under /muse-osgi.

NOTE: There are three FIXMEs in OSGiResourceManager that need to be addressed. These were 
caused because Joel built his code while I was working on the persistence layer, which 
caused an API change in ResourceManager. We'll need to fix this before the OSGi code can 
be declared stable again.

Added:
    webservices/muse/trunk/modules/muse-osgi-core/
    webservices/muse/trunk/modules/muse-osgi-core/pom.xml
    webservices/muse/trunk/modules/muse-osgi-core/resources/
    webservices/muse/trunk/modules/muse-osgi-core/resources/META-INF/
    webservices/muse/trunk/modules/muse-osgi-core/resources/META-INF/MANIFEST.MF
    webservices/muse/trunk/modules/muse-osgi-core/src/
    webservices/muse/trunk/modules/muse-osgi-core/src/org/
    webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/
    webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/
    webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/
    webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/
    webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/
    webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/Activator.java
    webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/CreateStartupResourcesCallback.java
    webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/EnvironmentChangeEvent.java
    webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/EnvironmentChangeListener.java
    webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/OSGiEnvironment.java
    webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/OSGiEnvironmentImpl.java
    webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/OSGiPlatformConstants.java
    webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/OSGiResourceManager.java
    webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/OSGiResourceManagerListener.java
    webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/ResourceDefinitionCallback.java
    webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/ResourceManagementProvider.java
    webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/descriptor/
    webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/descriptor/OSGiCapabilityDescriptor.java
    webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/descriptor/OSGiDeploymentDescriptor.java
    webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/descriptor/OSGiResourceDefinition.java
    webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/descriptor/OSGiResourceDescriptor.java
    webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/routing/
    webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/routing/OSGiResourceIdFactory.java
    webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/routing/OSGiResourceRouter.java
    webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/routing/ResourceRouterDelegate.java
    webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/util/
    webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/util/OSGiReflectUtilHelper.java
    webservices/muse/trunk/modules/muse-osgi-soa-axis2/
    webservices/muse/trunk/modules/muse-osgi-soa-axis2/pom.xml
    webservices/muse/trunk/modules/muse-osgi-soa-axis2/resources/
    webservices/muse/trunk/modules/muse-osgi-soa-axis2/resources/META-INF/
    webservices/muse/trunk/modules/muse-osgi-soa-axis2/resources/META-INF/MANIFEST.MF
    webservices/muse/trunk/modules/muse-osgi-soa-axis2/resources/OSGI-INF/
    webservices/muse/trunk/modules/muse-osgi-soa-axis2/resources/OSGI-INF/muse-descriptor.xsd
    webservices/muse/trunk/modules/muse-osgi-soa-axis2/resources/OSGI-INF/muse.xml
    webservices/muse/trunk/modules/muse-osgi-soa-axis2/src/
    webservices/muse/trunk/modules/muse-osgi-soa-axis2/src/org/
    webservices/muse/trunk/modules/muse-osgi-soa-axis2/src/org/apache/
    webservices/muse/trunk/modules/muse-osgi-soa-axis2/src/org/apache/muse/
    webservices/muse/trunk/modules/muse-osgi-soa-axis2/src/org/apache/muse/core/
    webservices/muse/trunk/modules/muse-osgi-soa-axis2/src/org/apache/muse/core/platform/
    webservices/muse/trunk/modules/muse-osgi-soa-axis2/src/org/apache/muse/core/platform/osgi/
    webservices/muse/trunk/modules/muse-osgi-soa-axis2/src/org/apache/muse/core/platform/osgi/axis2/
    webservices/muse/trunk/modules/muse-osgi-soa-axis2/src/org/apache/muse/core/platform/osgi/axis2/Activator.java
    webservices/muse/trunk/modules/muse-osgi-soa-axis2/src/org/apache/muse/core/platform/osgi/axis2/Axis2Environment.java
    webservices/muse/trunk/modules/muse-osgi-soa-axis2/src/org/apache/muse/core/platform/osgi/axis2/Axis2IsolationLayer.java
    webservices/muse/trunk/modules/muse-osgi-soa-axis2/src/org/apache/muse/core/platform/osgi/axis2/Messages.properties
    webservices/muse/trunk/modules/muse-osgi-soa-axis2/src/org/apache/muse/core/platform/osgi/axis2/ResourceManagementAdminService.java
    webservices/muse/trunk/modules/muse-osgi-soa-axis2/src/org/apache/muse/core/platform/osgi/axis2/ResourceManagementProviderFactory.java
    webservices/muse/trunk/modules/muse-osgi-soa-axis2/src/org/apache/muse/core/platform/osgi/axis2/internal/
    webservices/muse/trunk/modules/muse-osgi-soa-axis2/src/org/apache/muse/core/platform/osgi/axis2/internal/Axis2ResourceManagementService.java
    webservices/muse/trunk/modules/muse-osgi-soa-axis2/src/org/apache/muse/core/platform/osgi/axis2/internal/OSGiRawXMLInOutMessageReceiver.java
    webservices/muse/trunk/modules/muse-osgi-soa-axis2/src/org/apache/muse/core/platform/osgi/axis2/internal/ResourceManagementAdminServiceImpl.java
    webservices/muse/trunk/modules/muse-osgi-soa-core/
    webservices/muse/trunk/modules/muse-osgi-soa-core/pom.xml
    webservices/muse/trunk/modules/muse-osgi-soa-core/resources/
    webservices/muse/trunk/modules/muse-osgi-soa-core/resources/META-INF/
    webservices/muse/trunk/modules/muse-osgi-soa-core/resources/META-INF/MANIFEST.MF
    webservices/muse/trunk/modules/muse-osgi-soa-core/src/
    webservices/muse/trunk/modules/muse-osgi-soa-core/src/org/
    webservices/muse/trunk/modules/muse-osgi-soa-core/src/org/apache/
    webservices/muse/trunk/modules/muse-osgi-soa-core/src/org/apache/muse/
    webservices/muse/trunk/modules/muse-osgi-soa-core/src/org/apache/muse/osgi/
    webservices/muse/trunk/modules/muse-osgi-soa-core/src/org/apache/muse/osgi/soa/
    webservices/muse/trunk/modules/muse-osgi-soa-core/src/org/apache/muse/osgi/soa/core/
    webservices/muse/trunk/modules/muse-osgi-soa-core/src/org/apache/muse/osgi/soa/core/Activator.java
    webservices/muse/trunk/modules/muse-osgi-soa-core/src/org/apache/muse/osgi/soa/core/BundleClassResolver.java
    webservices/muse/trunk/modules/muse-osgi-soa-core/src/org/apache/muse/osgi/soa/core/SOAPProvider.java
    webservices/muse/trunk/modules/muse-osgi-soa-core/src/org/apache/muse/osgi/soa/core/web/
    webservices/muse/trunk/modules/muse-osgi-soa-core/src/org/apache/muse/osgi/soa/core/web/ServletDescriptor.java
    webservices/muse/trunk/modules/muse-osgi-soa-core/src/org/apache/muse/osgi/soa/core/web/WebApp.java
    webservices/muse/trunk/modules/muse-osgi-soa-core/src/org/apache/muse/osgi/soa/core/web/WebAppDescriptor.java

Added: webservices/muse/trunk/modules/muse-osgi-core/pom.xml
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-osgi-core/pom.xml?rev=426549&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-osgi-core/pom.xml (added)
+++ webservices/muse/trunk/modules/muse-osgi-core/pom.xml Fri Jul 28 08:06:01 2006
@@ -0,0 +1,100 @@
+<?xml version="1.0"?>
+<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>
+  <groupId>muse-osgi</groupId>
+  <artifactId>muse-osgi-core</artifactId>
+  <packaging>jar</packaging>
+  <version>2.0.0-M2-SNAPSHOT</version>
+  <name>Apache Muse - OSGi Deployment</name>
+  <url>http://ws.apache.org/muse</url>
+  <dependencies>
+    <dependency>
+      <groupId>muse</groupId>
+      <artifactId>muse-util</artifactId>
+      <version>2.0.0-M2-SNAPSHOT</version>
+      <scope>compile</scope>
+    </dependency>
+    <dependency>
+      <groupId>muse</groupId>
+      <artifactId>muse-util-qname</artifactId>
+      <version>2.0.0-M2-SNAPSHOT</version>
+      <scope>compile</scope>
+    </dependency>
+    <dependency>
+      <groupId>muse</groupId>
+      <artifactId>muse-util-xml</artifactId>
+      <version>2.0.0-M2-SNAPSHOT</version>
+      <scope>compile</scope>
+    </dependency>
+    <dependency>
+      <groupId>muse</groupId>
+      <artifactId>muse-core</artifactId>
+      <version>2.0.0-M2-SNAPSHOT</version>
+      <scope>compile</scope>
+    </dependency>
+    <dependency>
+      <groupId>wsdl4j</groupId>
+      <artifactId>wsdl4j</artifactId>
+      <version>1.5.1</version>
+      <scope>compile</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.osgi</groupId>
+      <artifactId>osgi_R4_core</artifactId>
+      <version>1.0</version>
+      <scope>compile</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.osgi</groupId>
+      <artifactId>osgi_R4_compendium</artifactId>
+      <version>1.0</version>
+      <scope>compile</scope>
+    </dependency>
+  </dependencies>
+  <build>
+    <sourceDirectory>src</sourceDirectory>
+    <outputDirectory>build/classes</outputDirectory>
+    <directory>build/jars</directory>
+    <resources>
+      <resource>
+        <directory>src</directory>
+        <includes>
+        	<include>**/*.properties</include>
+        </includes>
+      </resource>
+    </resources>
+    
+    <plugins>
+        <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-jar-plugin</artifactId>
+            <configuration>
+                <archive>
+		    <manifestFile>resources/META-INF/MANIFEST.MF</manifestFile>
+                </archive>
+            </configuration>
+        </plugin>
+    </plugins>
+    
+    <!-- 
+    
+        This feature can be used when Maven 2.1 is released 
+         
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-jar-plugin</artifactId>
+        <configuration>
+          <archive>
+            <addMavenDescriptor>false</addMavenDescriptor>
+          </archive>
+        </configuration>
+      </plugin>
+    </plugins>
+    
+    -->
+    
+  </build>
+</project>

Added: webservices/muse/trunk/modules/muse-osgi-core/resources/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-osgi-core/resources/META-INF/MANIFEST.MF?rev=426549&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-osgi-core/resources/META-INF/MANIFEST.MF (added)
+++ webservices/muse/trunk/modules/muse-osgi-core/resources/META-INF/MANIFEST.MF Fri Jul 28 08:06:01 2006
@@ -0,0 +1,31 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Apache Muse OSGi Plug-in
+Bundle-SymbolicName: muse-osgi-core
+Bundle-Version: 1.0.0
+Bundle-Activator: org.apache.muse.core.platform.osgi.Activator
+Bundle-Vendor: Apache
+Bundle-Localization: plugin
+Import-Package: javax.servlet;version="2.3.0",
+ javax.servlet.http;version="2.3.0",
+ javax.wsdl,
+ javax.wsdl.extensions,
+ javax.wsdl.factory,
+ javax.wsdl.xml,
+ javax.xml.soap,
+ org.osgi.framework;version="1.3.0"
+Require-Bundle: org.apache.muse.core,
+ org.apache.muse.util,
+ org.apache.muse.wsa.soap,
+ org.apache.wsdl4j,
+ org.apache.muse.wsrf,
+ org.apache.muse.mex,
+ org.apache.muse.muws,
+ org.apache.muse.wef,
+ org.apache.muse.wsn,
+ org.eclipse.osgi.services,
+ org.apache.muse.muws.adv
+Export-Package: org.apache.muse.core.platform.osgi,
+ org.apache.muse.core.platform.osgi.descriptor,
+ org.apache.muse.core.platform.osgi.routing,
+ org.apache.muse.core.platform.osgi.util

Added: webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/Activator.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/Activator.java?rev=426549&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/Activator.java (added)
+++ webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/Activator.java Fri Jul 28 08:06:01 2006
@@ -0,0 +1,112 @@
+/*=============================================================================*
+ *  Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *=============================================================================*/
+
+
+package org.apache.muse.core.platform.osgi;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceEvent;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceListener;
+
+/**
+ *
+ * Activator is ...
+ *
+ * @author Joel Hawkins (joelh)
+ *
+ */
+
+public class Activator implements BundleActivator {
+
+	private static final String MANAGEMENT_ENVIRONMENT_FILTER = "(objectclass=org.apache.muse.core.platform.osgi.ResourceManagementProvider)";
+
+	private ServiceReference managementServiceRef;
+
+	private static Activator activator;
+
+	private BundleContext context;
+
+	private ResourceManagementProvider provider;
+
+	static private class ManagementServiceListener implements ServiceListener {
+
+		/**
+		 *
+		 * @see org.osgi.framework.ServiceListener#serviceChanged(org.osgi.framework.ServiceEvent)
+		 */
+		public void serviceChanged(ServiceEvent event) {
+			ServiceReference ref = event.getServiceReference();
+			switch (event.getType()) {
+			case ServiceEvent.REGISTERED:
+				if (activator.managementServiceRef == null) {
+					activator.managementServiceRef = event.getServiceReference();
+					activator.provider = (ResourceManagementProvider) activator.context
+							.getService(activator.managementServiceRef);
+					OSGiResourceManager.getDefault().attachManagementProvider(
+							activator.provider);
+				}
+				break;
+			case ServiceEvent.MODIFIED:
+				break;
+			case ServiceEvent.UNREGISTERING:
+				ref = event.getServiceReference();
+				if (ref == activator.managementServiceRef) {
+					activator.managementServiceRef = null;
+					OSGiResourceManager.getDefault().releaseManagementProvider();
+				}
+				break;
+			}
+		}
+	}
+
+	private ManagementServiceListener managementListener = new ManagementServiceListener();
+
+	/**
+	 * (non-Javadoc)
+	 *
+	 * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
+	 */
+	public void start(BundleContext context) throws Exception {
+		activator = this;
+		this.context = context;
+		try {
+			OSGiResourceManager.getDefault().initialize(context);
+		} catch (Throwable t) {
+			t.printStackTrace();
+		}
+
+		if ((managementServiceRef = context.getServiceReference("org.apache.muse.core.platform.osgi.ResourceManagementProvider")) != null) {
+			activator.provider = (ResourceManagementProvider) activator.context.getService(activator.managementServiceRef);
+			OSGiResourceManager.getDefault().attachManagementProvider(activator.provider);
+		}
+
+		context.addServiceListener(managementListener, MANAGEMENT_ENVIRONMENT_FILTER);
+
+	}
+
+	/**
+	 * (non-Javadoc)
+	 *
+	 * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
+	 */
+	public void stop(BundleContext context) throws Exception {
+		context.removeBundleListener(OSGiResourceManager.getDefault());
+		context.removeServiceListener(managementListener);
+	}
+
+}

Added: webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/CreateStartupResourcesCallback.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/CreateStartupResourcesCallback.java?rev=426549&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/CreateStartupResourcesCallback.java (added)
+++ webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/CreateStartupResourcesCallback.java Fri Jul 28 08:06:01 2006
@@ -0,0 +1,30 @@
+/*=============================================================================*
+ *  Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *=============================================================================*/
+
+package org.apache.muse.core.platform.osgi;
+
+/**
+ *
+ * CreateStartupResourcesCallback is ...
+ *
+ * @author Joel Hawkins (joelh)
+ *
+ */
+
+public interface CreateStartupResourcesCallback {
+	void notifyCreateStartupResources();
+
+}

Added: webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/EnvironmentChangeEvent.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/EnvironmentChangeEvent.java?rev=426549&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/EnvironmentChangeEvent.java (added)
+++ webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/EnvironmentChangeEvent.java Fri Jul 28 08:06:01 2006
@@ -0,0 +1,48 @@
+/*=============================================================================*
+ *  Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *=============================================================================*/
+
+package org.apache.muse.core.platform.osgi;
+
+import org.apache.muse.core.Environment;
+
+/**
+ *
+ * EnvironmentChangeEvent is ...
+ *
+ * @author Joel Hawkins (joelh)
+ *
+ */
+
+public class EnvironmentChangeEvent {
+
+	public static final int ENVIRONMENT_INITIALIZED = 1;
+	public static final int ENVIRONMENT_UPDATED = 2;
+
+	private Environment env;
+	private Object source;
+	private int state;
+
+	public EnvironmentChangeEvent(Environment env, int state, Object source){
+		this.env = env;
+		this.state = state;
+		this.source = source;
+	}
+
+	public Environment getEnvironment(){return env;}
+	public int getState(){return state;}
+	public Object getSource(){return source;}
+
+}

Added: webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/EnvironmentChangeListener.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/EnvironmentChangeListener.java?rev=426549&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/EnvironmentChangeListener.java (added)
+++ webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/EnvironmentChangeListener.java Fri Jul 28 08:06:01 2006
@@ -0,0 +1,29 @@
+/*=============================================================================*
+ *  Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *=============================================================================*/
+
+package org.apache.muse.core.platform.osgi;
+
+/**
+ *
+ * EnvironmentChangeListener is ...
+ *
+ * @author Joel Hawkins (joelh)
+ *
+ */
+
+public interface EnvironmentChangeListener {
+	void environmentChanged(EnvironmentChangeEvent event);
+}

Added: webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/OSGiEnvironment.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/OSGiEnvironment.java?rev=426549&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/OSGiEnvironment.java (added)
+++ webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/OSGiEnvironment.java Fri Jul 28 08:06:01 2006
@@ -0,0 +1,33 @@
+/*=============================================================================*
+ *  Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *=============================================================================*/
+
+package org.apache.muse.core.platform.osgi;
+
+import org.osgi.framework.Bundle;
+
+/**
+ *
+ * OSGiEnvironment is ...
+ *
+ * @author Joel Hawkins (joelh)
+ *
+ */
+
+public interface OSGiEnvironment extends org.apache.muse.core.Environment {
+	Bundle getThreadLocalBundle();
+
+	void setThreadLocalBundle(Bundle bundle);
+}

Added: webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/OSGiEnvironmentImpl.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/OSGiEnvironmentImpl.java?rev=426549&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/OSGiEnvironmentImpl.java (added)
+++ webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/OSGiEnvironmentImpl.java Fri Jul 28 08:06:01 2006
@@ -0,0 +1,94 @@
+/*=============================================================================*
+ *  Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *=============================================================================*/
+
+
+package org.apache.muse.core.platform.osgi;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+
+import org.apache.muse.core.AbstractEnvironment;
+import org.apache.muse.ws.addressing.EndpointReference;
+import org.apache.muse.core.platform.osgi.util.OSGiReflectUtilHelper;
+import org.osgi.framework.Bundle;
+
+/**
+ *
+ * OSGiEnvironmentImpl is ...
+ *
+ * @author Joel Hawkins (joelh)
+ *
+ */
+
+public class OSGiEnvironmentImpl extends AbstractEnvironment implements
+		OSGiEnvironment {
+
+	protected ThreadLocal localEnvironmentContext = new ThreadLocal();
+
+	public OSGiEnvironmentImpl(boolean createSoapClient) {
+		super(createSoapClient);
+	}
+
+	public EndpointReference getDeploymentEPR() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	public File getRealDirectory() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	private OSGiReflectUtilHelper reflectHelper;
+
+	public Bundle getThreadLocalBundle() {
+		return (Bundle) localEnvironmentContext.get();
+	}
+
+	public void setThreadLocalBundle(Bundle bundle) {
+		localEnvironmentContext.set(bundle);
+		if (reflectHelper != null)
+			reflectHelper.setThreadLocalBundle(bundle);
+	}
+
+	public InputStream getDataResourceStream(String path) {
+		if (path == null)
+			throw new NullPointerException("NullResourcePath");
+
+		InputStream input = null;
+		Bundle bundle = getThreadLocalBundle();
+		if (bundle != null) {
+			URL url = bundle.getResource(path);
+			if (url != null) {
+				try {
+					input = url.openStream();
+				} catch (IOException ioe) {
+					input = null;
+				}
+			}
+		}
+
+		if (input == null)
+			input = this.getClass().getResourceAsStream(path);
+		if (input == null)
+			input = this.getClass().getResourceAsStream("/OSGI-INF/" + path);
+		return input;
+
+	}
+
+}

Added: webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/OSGiPlatformConstants.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/OSGiPlatformConstants.java?rev=426549&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/OSGiPlatformConstants.java (added)
+++ webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/OSGiPlatformConstants.java Fri Jul 28 08:06:01 2006
@@ -0,0 +1,33 @@
+/*=============================================================================*
+ *  Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *=============================================================================*/
+
+
+package org.apache.muse.core.platform.osgi;
+
+/**
+ *
+ * OSGiPlatformConstants is ...
+ *
+ * @author Joel Hawkins (joelh)
+ *
+ */
+
+public interface OSGiPlatformConstants {
+	public final String MANAGEMENT_MANIFEST_HEADER = "MUSE-CONFIG";
+
+	public final String MANAGEMENT_CONTEXT_HEADER = "MUSE-CONTEXT";
+
+}

Added: webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/OSGiResourceManager.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/OSGiResourceManager.java?rev=426549&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/OSGiResourceManager.java (added)
+++ webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/OSGiResourceManager.java Fri Jul 28 08:06:01 2006
@@ -0,0 +1,684 @@
+/*=============================================================================*
+ *  Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *=============================================================================*/
+
+
+package org.apache.muse.core.platform.osgi;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Collection;
+import java.util.ArrayList;
+import java.util.logging.Logger;
+
+import org.apache.muse.core.Environment;
+import org.apache.muse.core.Resource;
+import org.apache.muse.core.ResourceManagerListener;
+import org.apache.muse.core.SimpleResourceManager;
+import org.apache.muse.core.descriptor.DeploymentDescriptor;
+import org.apache.muse.core.descriptor.ResourceDefinition;
+import org.apache.muse.core.descriptor.RouterDefinition;
+import org.apache.muse.core.descriptor.SerializerDefinition;
+import org.apache.muse.core.serializer.ArraySerializer;
+import org.apache.muse.core.serializer.Serializer;
+import org.apache.muse.core.serializer.SerializerRegistry;
+import org.apache.muse.core.platform.osgi.descriptor.OSGiDeploymentDescriptor;
+import org.apache.muse.core.platform.osgi.routing.ResourceRouterDelegate;
+import org.apache.muse.core.platform.osgi.util.OSGiReflectUtilHelper;
+import org.apache.muse.core.platform.osgi.OSGiEnvironment;
+import org.apache.muse.util.ReflectUtils;
+import org.apache.muse.util.xml.XmlUtils;
+import org.apache.muse.ws.addressing.EndpointReference;
+import org.apache.muse.ws.addressing.soap.SoapFault;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleEvent;
+import org.osgi.framework.BundleListener;
+import org.w3c.dom.Document;
+
+import org.apache.muse.ws.addressing.WsaConstants;
+
+/**
+ *
+ * OSGiResourceManager is ...
+ *
+ * @author Joel Hawkins (joelh)
+ *
+ */
+
+public class OSGiResourceManager extends SimpleResourceManager implements
+		BundleListener {
+
+	protected static OSGiResourceManager defaultInstance;
+
+	private HashMap bundleToDefinitionMap = new HashMap();
+
+	private HashMap deferredResources = new HashMap();
+
+	private HashMap bundleToContextMap = new HashMap();
+
+	private HashMap listenerToBundleMap = new HashMap();
+
+	private HashMap definitionToBundleMap = new HashMap();
+
+	private HashMap delegateMap = new HashMap();
+
+	private HashMap resourceDefinitionCallbackMap = new HashMap();
+
+	private HashMap createStartupResourcesCallbackMap = new HashMap();
+
+	private HashMap resourceToBundleMap = new HashMap();
+
+	private HashMap eprToBundleMap = new HashMap();
+	private HashMap bundleToEprMap = new HashMap();
+
+	private Logger log;
+
+	private ResourceManagementProvider provider;
+
+	private ThreadLocal creatingStartupResources = new ThreadLocal();
+
+	public static OSGiResourceManager getDefault() {
+		if (defaultInstance == null)
+			defaultInstance = new OSGiResourceManager();
+		return defaultInstance;
+	}
+
+	public void setLog(Logger log) {
+		this.log = log;
+	}
+
+	public void attachManagementProvider(ResourceManagementProvider provider) {
+		this.provider = provider;
+		synchronized(deferredResources){
+			Iterator i = deferredResources.keySet().iterator();
+			while(i.hasNext()){
+				Bundle bundle = (Bundle)i.next();
+				Boolean resource = (Boolean)deferredResources.get(bundle);
+				if(resource != null && resource.booleanValue()){
+					String target = (String) bundle.getHeaders().get(
+							OSGiPlatformConstants.MANAGEMENT_MANIFEST_HEADER);
+					String contextPath = (String) bundle.getHeaders().get(
+							OSGiPlatformConstants.MANAGEMENT_CONTEXT_HEADER);
+					deployManagementServices(bundle, contextPath, target);
+				}
+			}
+		}
+	}
+
+	public void releaseManagementProvider() {
+		provider = null;
+	}
+
+	public void addResourceDefinitions(Collection definitions) {
+		if (definitions.isEmpty())
+			return;
+		Iterator i = definitions.iterator();
+		while (i.hasNext()) {
+			Object obj = i.next();
+			ResourceDefinition def = (ResourceDefinition) obj;
+			def.setLog(log);
+		}
+		super.addResourceDefinitions(definitions);
+	}
+
+	protected void addResourceDefinitions(Bundle bundle, Collection definitions) {
+		if (definitions.isEmpty())
+			return;
+		synchronized (bundleToDefinitionMap) {
+			bundleToDefinitionMap.put(bundle, definitions);
+			Iterator iter = definitions.iterator();
+			ArrayList list = new ArrayList();
+			while (iter.hasNext()) {
+				ResourceDefinition def = (ResourceDefinition) iter.next();
+				definitionToBundleMap.put(def, bundle);
+				list.add(def.getContextPath());
+			}
+			bundleToContextMap.put(bundle, list);
+		}
+		addResourceDefinitions(definitions);
+	}
+
+	private Collection getContextPathsForBundle(Bundle bundle, String target) {
+		ArrayList list = new ArrayList();
+		OSGiEnvironment env = new OSGiEnvironmentImpl(false);
+		env.setThreadLocalBundle(bundle);
+		OSGiReflectUtilHelper.getDefault().setThreadLocalBundle(bundle);
+		try {
+			Document ddXML = env.getDocument(target);
+			OSGiDeploymentDescriptor dd = new OSGiDeploymentDescriptor();
+			Collection resourceDefs = dd.loadContextPaths(ddXML, env);
+			Iterator defs = resourceDefs.iterator();
+			while (defs.hasNext()) {
+				list.add((String) defs.next());
+			}
+
+			this.bundleToContextMap.put(bundle, new ArrayList(list));
+
+		} catch (Throwable t) {
+			t.printStackTrace();
+		}
+		return list;
+
+	}
+
+	private void deployManagementServices(Bundle bundle, String contextName, String target){
+		Collection contextPaths = getContextPathsForBundle(bundle, target);
+		Iterator i = contextPaths.iterator();
+		while (i.hasNext()) {
+			String path = (String) i.next();
+			String trimmedPath = path;
+			if (trimmedPath.startsWith("/"))
+				trimmedPath = trimmedPath.substring(1);
+			try {
+				provider.deployManagementService(contextName, trimmedPath);
+			} catch (Exception e) {
+				// TODO requeue?
+				e.printStackTrace();
+			}
+		}
+	}
+
+	protected void deferBundleResources(Bundle bundle, String contextName,
+			String target) {
+		// Register the resource contexts with the soap provider
+		synchronized(deferredResources){
+			if (provider != null) {
+				deployManagementServices(bundle, contextName, target);
+				deferredResources.put(bundle, Boolean.FALSE);
+			} else {
+				deferredResources.put(bundle, Boolean.TRUE);
+			}
+		}
+
+	}
+
+	protected synchronized void registerBundleResources(Bundle bundle, String contextPath,
+			String target) {
+		OSGiEnvironment env = (OSGiEnvironment) this.getEnvironment();
+		if (env != null) {
+			URL resourceURL = bundle.getResource(target);
+			try {
+				env.setThreadLocalBundle(bundle);
+				OSGiReflectUtilHelper.getDefault().setThreadLocalBundle(bundle);
+				addResourceDefinitions(bundle, resourceURL);
+			} catch (Throwable t) {
+				// TODO JOEL log this somewhere.
+				t.printStackTrace();
+			} finally {
+				((OSGiEnvironment) this.getEnvironment())
+						.setThreadLocalBundle(null);
+				OSGiReflectUtilHelper.getDefault().setThreadLocalBundle(null);
+
+			}
+		} else {
+			deferBundleResources(bundle, contextPath, target);
+		}
+	}
+
+	public void initialize(BundleContext context) {
+		context.addBundleListener(this);
+		Bundle bundles[] = context.getBundles();
+		OSGiEnvironment env = new OSGiEnvironmentImpl(false);
+		for (int i = 0; i < bundles.length; i++) {
+			switch (bundles[i].getState()) {
+			case Bundle.ACTIVE:
+			case Bundle.RESOLVED:
+			case Bundle.STARTING:
+				String target = (String) bundles[i].getHeaders().get(
+						OSGiPlatformConstants.MANAGEMENT_MANIFEST_HEADER);
+				String contextPath = (String) bundles[i].getHeaders().get(
+						OSGiPlatformConstants.MANAGEMENT_CONTEXT_HEADER);
+				if (target != null) {
+					registerBundleResources(bundles[i], contextPath, target);
+				}
+				break;
+			default:
+				break;
+			}
+		}
+	}
+
+	public void setEnvironment(Environment environment) {
+		super.setEnvironment(environment);
+		//set the environment of all the delegates
+		Iterator i = delegateMap.keySet().iterator();
+		while(i.hasNext()){
+			((ResourceRouterDelegate)i.next()).setEnvironment(environment);
+		}
+		if (!deferredResources.isEmpty()) {
+			synchronized (deferredResources) {
+				Iterator iter = deferredResources.keySet().iterator();
+				while (iter.hasNext()) {
+					Bundle bundle = (Bundle) iter.next();
+					try {
+						String target = (String) bundle.getHeaders().get(
+								OSGiPlatformConstants.MANAGEMENT_MANIFEST_HEADER);
+						URL resourceURL = bundle.getResource(target);
+						((OSGiEnvironment) this.getEnvironment())
+								.setThreadLocalBundle(bundle);
+						OSGiReflectUtilHelper.getDefault().setThreadLocalBundle(bundle);
+						addResourceDefinitions(bundle, resourceURL);
+					} catch (Throwable t) {
+						t.printStackTrace();
+					} finally {
+						((OSGiEnvironment) this.getEnvironment())
+								.setThreadLocalBundle(null);
+						OSGiReflectUtilHelper.getDefault().setThreadLocalBundle(null);
+					}
+				}
+				//TODO I think we just set these to FALSE
+				deferredResources.clear();
+			}
+		}
+	}
+
+	public void bundleChanged(BundleEvent event) {
+		String target;
+		Bundle bundle;
+		switch (event.getType()) {
+		case BundleEvent.INSTALLED:
+			break;
+		case BundleEvent.RESOLVED:
+			// Check for SOA deployment information
+			target = (String) event.getBundle().getHeaders().get(
+					OSGiPlatformConstants.MANAGEMENT_MANIFEST_HEADER);
+			String contextPath = (String) event.getBundle().getHeaders().get(
+					OSGiPlatformConstants.MANAGEMENT_CONTEXT_HEADER);
+			bundle = event.getBundle();
+			if (target != null) {
+				if (this.getEnvironment() != null) {
+					URL resourceURL = bundle.getResource(target);
+					addResourceDefinitions(bundle, resourceURL);
+				} else {
+					registerBundleResources(bundle, contextPath, target);
+				}
+			}
+			break;
+		case BundleEvent.STARTING:
+			break;
+		case BundleEvent.STARTED:
+			// Check for SOA deployment information
+			target = (String) event.getBundle().getHeaders().get(
+					OSGiPlatformConstants.MANAGEMENT_MANIFEST_HEADER);
+			contextPath = (String) event.getBundle().getHeaders().get(
+					OSGiPlatformConstants.MANAGEMENT_CONTEXT_HEADER);
+			bundle = event.getBundle();
+			if (target != null) {
+				// process SOA artifacts - expecting a set of comma-delimited
+				// names.
+				// The lookup process is as follows - look in configuration
+				// repository,
+				// then look in bundle classpath
+				if (getEnvironment() != null) {
+					((OSGiEnvironment)getEnvironment()).setThreadLocalBundle(event.getBundle());
+					URL resourceURL = bundle.getResource(target);
+					addResourceDefinitions(bundle, resourceURL);
+                    /*
+                    FIXME: this should be replaced with persistence reloading
+					try {
+						createBundleStartupResources(bundle);
+					} catch (SoapFault e) {
+						// TODO Auto-generated catch block
+						e.printStackTrace();
+					}
+                    */
+					((OSGiEnvironment)getEnvironment()).setThreadLocalBundle(null);
+				} else {
+					registerBundleResources(bundle, contextPath, target);
+				}
+				dumpTables("Starting " + bundle.getBundleId());
+			}
+			break;
+		case BundleEvent.STOPPING:
+			break;
+		case BundleEvent.STOPPED:
+			removeBundleResources(event.getBundle());
+			dumpTables("Stopping " + event.getBundle().getBundleId());
+			break;
+		case BundleEvent.UNINSTALLED:
+			break;
+		case BundleEvent.UNRESOLVED:
+			break;
+		case BundleEvent.UPDATED:
+			break;
+		default:
+			break;
+		}
+	}
+
+	protected DeploymentDescriptor createDeploymentDescriptor() {
+		return new OSGiDeploymentDescriptor();
+	}
+
+	public Document getDocument(Bundle bundle, URL resourceConfig) {
+		try {
+			return XmlUtils.createDocument(resourceConfig.openStream());
+		}
+
+		catch (Exception error) {
+			error.printStackTrace();
+			return null;
+		}
+	}
+
+    public synchronized Resource getResource(EndpointReference epr)
+    {
+    	Resource resource = super.getResource(epr);
+    	if(resource == null){
+            String address = epr.getAddress().toString();
+            ResourceDefinition definition = getResourceDefinition(address);
+            if(definition != null){
+            	ResourceRouterDelegate delegate = (ResourceRouterDelegate)delegateMap.get(definition);
+            	try {
+            		if(delegate != null){
+            			Bundle bundle = (Bundle)definitionToBundleMap.get(definition);
+            			Bundle prev = ((OSGiEnvironment)getEnvironment()).getThreadLocalBundle();
+            			((OSGiEnvironment)getEnvironment()).setThreadLocalBundle(bundle);
+            			resource = delegate.getResource(epr);
+            			((OSGiEnvironment)getEnvironment()).setThreadLocalBundle(prev);
+            		}
+            	} catch (SoapFault sf){
+            		resource = null;
+            	}
+            }
+    	}
+    	return resource;
+    }
+
+	protected void addResourceDefinitions(Bundle bundle, URL resourceConfig) {
+
+		OSGiDeploymentDescriptor dd = (OSGiDeploymentDescriptor) createDeploymentDescriptor();
+
+		Document ddXML = getDocument(bundle, resourceConfig);
+		if (ddXML == null)
+			return;
+		try {
+			dd.setBundle(bundle);
+			dd.load(ddXML, this.getEnvironment());
+
+			//
+			// put all custom serializers in the serializer registry
+			//
+			Collection serializerDefinitions = dd.getSerializerDefinitions();
+			Iterator i = serializerDefinitions.iterator();
+
+			SerializerRegistry registry = SerializerRegistry.getInstance();
+
+			while (i.hasNext()) {
+				SerializerDefinition next = (SerializerDefinition) i.next();
+
+				Serializer ser = next.create();
+				Class type = ser.getSerializableType();
+
+				Class arrayType = ReflectUtils.getArrayClassFromClass(type);
+				Serializer arraySer = new ArraySerializer(arrayType, ser);
+
+				registry.registerSerializer(type, ser);
+				registry.registerSerializer(arrayType, arraySer);
+			}
+
+			//
+			// check for any specified router - this may be used
+			// as a delegate when trying to resolve a reference
+			// to a resource
+			//
+			RouterDefinition rd = dd.getRouterDefinition();
+			Class delegateRouter = rd.getRouterClass();
+			ResourceRouterDelegate delegate = null;
+
+			if(delegateRouter != null && ResourceRouterDelegate.class.isAssignableFrom(delegateRouter)){
+				//go ahead and instantiate...
+				delegate = (ResourceRouterDelegate)rd.newInstance();
+				delegate.initialize(this, null);
+			}
+
+			Collection resourceDefs = dd.getResourceDefinitions();
+
+			this.addResourceDefinitions(bundle, resourceDefs);
+
+			if(delegate != null){
+				Iterator iter = resourceDefs.iterator();
+				while(iter.hasNext()){
+					delegateMap.put(iter.next(), delegate);
+				}
+			}
+			ResourceDefinitionCallback callback = (ResourceDefinitionCallback)resourceDefinitionCallbackMap.get(bundle);
+			if(callback != null){
+				callback.notifyResourceDefinition(resourceDefs);
+			}
+		} catch (Throwable t) {
+			// Log the error somewhere
+			t.printStackTrace();
+		}
+
+	}
+
+    /* FIXME: this is handled by persistence/reloading now
+    
+	public void createStartupResources() throws SoapFault {
+		Iterator i = bundleToDefinitionMap.keySet().iterator();
+		creatingStartupResources.set(Boolean.TRUE);
+		while (i.hasNext()) {
+			Bundle bundle = (Bundle) i.next();
+			((OSGiEnvironment) this.getEnvironment())
+					.setThreadLocalBundle(bundle);
+			OSGiReflectUtilHelper.getDefault().setThreadLocalBundle(bundle);
+			try {
+				super.createStartupResources();
+				CreateStartupResourcesCallback callback = (CreateStartupResourcesCallback)createStartupResourcesCallbackMap.get(bundle);
+				if(callback != null){
+					callback.notifyCreateStartupResources();
+				}
+			} finally {
+				((OSGiEnvironment) this.getEnvironment())
+						.setThreadLocalBundle(null);
+				OSGiReflectUtilHelper.getDefault().setThreadLocalBundle(null);
+			}
+		}
+		creatingStartupResources.set(null);
+	}
+
+
+	protected void createBundleStartupResources(Bundle bundle) throws SoapFault {
+		creatingStartupResources.set(Boolean.TRUE);
+		((OSGiEnvironment) this.getEnvironment())
+				.setThreadLocalBundle(bundle);
+		OSGiReflectUtilHelper.getDefault().setThreadLocalBundle(bundle);
+		try {
+			super.createStartupResources();
+		} finally {
+			((OSGiEnvironment) this.getEnvironment())
+					.setThreadLocalBundle(null);
+			OSGiReflectUtilHelper.getDefault().setThreadLocalBundle(null);
+		}
+		creatingStartupResources.set(null);
+
+	}
+    */
+
+	public Collection getResourceContextPaths() {
+		OSGiEnvironment env = (OSGiEnvironment) this.getEnvironment();
+		Boolean startup = (Boolean) creatingStartupResources.get();
+		if (startup == null || !startup.booleanValue()) {
+			return super.getResourceContextPaths();
+		} else {
+			Bundle activeBundle = env.getThreadLocalBundle();
+			Collection paths = (Collection) this.bundleToContextMap
+					.get(activeBundle);
+			ArrayList list = new ArrayList();
+
+			if (paths == null)
+				return list;
+
+			Iterator i = paths.iterator();
+			while (i.hasNext()) {
+				String path = (String) i.next();
+				list.add(path);
+			}
+			return list;
+		}
+	}
+
+	public synchronized void addListener(ResourceManagerListener listener) {
+		OSGiEnvironment env = (OSGiEnvironment) this.getEnvironment();
+		Bundle bundle = env.getThreadLocalBundle();
+		listenerToBundleMap.put(listener, bundle);
+		super.addListener(listener);
+	}
+
+	public synchronized void removeListener(ResourceManagerListener listener) {
+		listenerToBundleMap.remove(listener);
+		super.removeListener(listener);
+	}
+
+	protected void notifyListenersOfAdd(EndpointReference epr, Resource resource)
+			throws SoapFault {
+		OSGiEnvironment env = (OSGiEnvironment) this.getEnvironment();
+		Bundle bundle = env.getThreadLocalBundle();
+		Iterator i = getListeners().iterator();
+
+		while (i.hasNext()) {
+			ResourceManagerListener next = (ResourceManagerListener) i.next();
+			if (bundle != null
+					&& bundle.equals(this.listenerToBundleMap.get(next)))
+				next.resourceAdded(epr, resource);
+			else if (next instanceof OSGiResourceManagerListener)
+				next.resourceAdded(epr, resource);
+		}
+	}
+
+	protected void notifyListenersOfRemove(EndpointReference epr)
+			throws SoapFault {
+		OSGiEnvironment env = (OSGiEnvironment) this.getEnvironment();
+		Bundle bundle = env.getThreadLocalBundle();
+		Iterator i = getListeners().iterator();
+
+		while (i.hasNext()) {
+			ResourceManagerListener next = (ResourceManagerListener) i.next();
+			if (bundle != null
+					&& bundle.equals(this.listenerToBundleMap.get(next)))
+				next.resourceRemoved(epr);
+			else if (next instanceof OSGiResourceManagerListener)
+				next.resourceRemoved(epr);
+		}
+	}
+
+	public void registerResourceDefinitionCallback(Bundle bundle, ResourceDefinitionCallback callback) {
+		resourceDefinitionCallbackMap.put(bundle,callback);
+	}
+
+	public void registerCreateStartupResourcesCallback(Bundle bundle, CreateStartupResourcesCallback callback) {
+		createStartupResourcesCallbackMap.put(bundle,callback);
+	}
+
+	protected void removeBundleResources(Bundle bundle){
+		Collection resourceDefs = null;
+		synchronized(bundleToContextMap){
+			//context for bundle - reference counted
+			bundleToContextMap.remove(bundle);
+		}
+		synchronized(bundleToDefinitionMap){
+			//remove bundle's resources
+			resourceDefs = (Collection)bundleToDefinitionMap.remove(bundle);
+			if(resourceDefs != null) removeResourceDefinitions(resourceDefs);
+		}
+		if(resourceDefs != null){
+			HashMap eprs = (HashMap)eprToBundleMap.remove(bundle);
+			if(eprs != null){
+				Iterator i = eprs.keySet().iterator();
+				while(i.hasNext()){
+					EndpointReference epr = (EndpointReference)i.next();
+					try {
+						removeResource(epr);
+					} catch (SoapFault e) {
+						// TODO Auto-generated catch block
+						e.printStackTrace();
+					}
+				}
+			}
+		}
+	}
+
+	public void addResource(EndpointReference epr, Resource resource) throws SoapFault {
+		String context = resource.getContextPath();
+		Bundle bundle = (Bundle)bundleToContextMap.get(context);
+		try {
+			super.addResource(epr, resource);
+			Bundle resourceBundle = (Bundle)resourceToBundleMap.get(resource);
+			if(resourceBundle == null) resourceBundle = ((OSGiEnvironment)getEnvironment()).getThreadLocalBundle();
+			if(resourceBundle != null){
+				resourceToBundleMap.remove(resource);
+				HashMap bundleResources = (HashMap)eprToBundleMap.get(resourceBundle);
+				if(bundleResources == null){
+					bundleResources = new HashMap();
+					eprToBundleMap.put(resourceBundle, bundleResources);
+				}
+				bundleToEprMap.put(epr, resourceBundle);
+				bundleResources.put(epr,epr);
+			}
+		} finally {
+			return;
+		}
+	}
+
+	public void removeResource(EndpointReference epr) throws SoapFault {
+		try {
+			//remove from eprToBundleMap
+			Bundle bundle = (Bundle)bundleToEprMap.remove(epr);
+			if(bundle != null){
+				HashMap eprs = (HashMap)eprToBundleMap.get(bundle);
+				if(eprs != null){
+					eprs.remove(epr);
+				}
+			}
+			super.removeResource(epr);
+		} finally {
+			return;
+		}
+	}
+
+	public void addBundleResource(Bundle bundle,Resource resource){
+		resourceToBundleMap.put(resource, bundle);
+	}
+
+	private void dumpTables(String message){
+		//test method for debugging purposes
+		System.out.println(message);
+		Iterator i = bundleToDefinitionMap.keySet().iterator();
+		while(i.hasNext()){
+			Bundle b = (Bundle)i.next();
+			HashMap m = (HashMap)eprToBundleMap.get(b);
+			System.out.println("  Bundle " + b.getSymbolicName());
+			if(m != null){
+				Iterator j = m.keySet().iterator();
+				while(j.hasNext()){
+					EndpointReference e = (EndpointReference)j.next();
+					System.out.println("");
+					System.out.println(e.toString());
+					System.out.println("");
+				}
+			}
+		}
+	}
+
+	public Bundle getBundleForResource(Resource resource){
+		return (Bundle)this.bundleToEprMap.get(resource.getEndpointReference());
+	}
+
+}

Added: webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/OSGiResourceManagerListener.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/OSGiResourceManagerListener.java?rev=426549&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/OSGiResourceManagerListener.java (added)
+++ webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/OSGiResourceManagerListener.java Fri Jul 28 08:06:01 2006
@@ -0,0 +1,32 @@
+/*=============================================================================*
+ *  Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *=============================================================================*/
+
+
+package org.apache.muse.core.platform.osgi;
+
+import org.apache.muse.core.ResourceManagerListener;
+
+/**
+ *
+ * OSGiResourceManagerListener is ...
+ *
+ * @author Joel Hawkins (joelh)
+ *
+ */
+
+public interface OSGiResourceManagerListener extends ResourceManagerListener {
+
+}

Added: webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/ResourceDefinitionCallback.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/ResourceDefinitionCallback.java?rev=426549&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/ResourceDefinitionCallback.java (added)
+++ webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/ResourceDefinitionCallback.java Fri Jul 28 08:06:01 2006
@@ -0,0 +1,31 @@
+/*=============================================================================*
+ *  Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *=============================================================================*/
+
+
+package org.apache.muse.core.platform.osgi;
+
+import java.util.Collection;
+
+/**
+ *
+ * ResourceDefinitionCallback is ...
+ *
+ * @author Joel Hawkins (joelh)
+ *
+ */
+public interface ResourceDefinitionCallback {
+	void notifyResourceDefinition(Collection resourceDefs);
+}

Added: webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/ResourceManagementProvider.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/ResourceManagementProvider.java?rev=426549&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/ResourceManagementProvider.java (added)
+++ webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/ResourceManagementProvider.java Fri Jul 28 08:06:01 2006
@@ -0,0 +1,41 @@
+/*=============================================================================*
+ *  Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *=============================================================================*/
+
+
+package org.apache.muse.core.platform.osgi;
+
+import org.apache.muse.core.ResourceManager;
+import org.osgi.framework.Bundle;
+
+/**
+ *
+ * ResourcemanagementProvider is ...
+ *
+ * @author Joel Hawkins (joelh)
+ *
+ */
+
+public interface ResourceManagementProvider {
+	public void deployManagementService(String contextName, String homeName) throws Exception;
+
+	public void deployManagementService(String homeName) throws Exception;
+
+	public void registerResourceDefinitionCallback(Bundle bundle, ResourceDefinitionCallback callback);
+
+	public void registerCreateStartupResourcesCallback(Bundle bundle, CreateStartupResourcesCallback callback);
+
+
+}

Added: webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/descriptor/OSGiCapabilityDescriptor.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/descriptor/OSGiCapabilityDescriptor.java?rev=426549&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/descriptor/OSGiCapabilityDescriptor.java (added)
+++ webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/descriptor/OSGiCapabilityDescriptor.java Fri Jul 28 08:06:01 2006
@@ -0,0 +1,88 @@
+/*=============================================================================*
+ *  Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *=============================================================================*/
+
+
+package org.apache.muse.core.platform.osgi.descriptor;
+
+import org.apache.muse.core.Capability;
+import org.apache.muse.core.Environment;
+import org.apache.muse.core.descriptor.DescriptorConstants;
+import org.apache.muse.core.descriptor.SimpleCapabilityDescriptor;
+import org.apache.muse.core.descriptor.SimpleRouterDescriptor;
+import org.apache.muse.util.ReflectUtils;
+import org.apache.muse.util.messages.Messages;
+import org.apache.muse.util.messages.MessagesFactory;
+import org.apache.muse.util.xml.XmlUtils;
+import org.w3c.dom.Element;
+
+import org.osgi.framework.Bundle;
+
+/**
+ *
+ * OSGiCapabilityDescriptor is ...
+ *
+ * @author Joel Hawkins (joelh)
+ *
+ */
+
+public class OSGiCapabilityDescriptor extends SimpleCapabilityDescriptor {
+
+	private static Messages _MESSAGES = MessagesFactory
+			.get(SimpleRouterDescriptor.class);
+
+	private Bundle bundle;
+
+	public OSGiCapabilityDescriptor(Bundle bundle) {
+		super();
+		this.bundle = bundle;
+	}
+
+	protected Class createImplementationClass(Element xml, Environment env) {
+		String className = XmlUtils.getElementText(xml,
+				DescriptorConstants.JAVA_CAPABILITY_QNAME);
+		Class theClass = null;
+		if (bundle == null) {
+			ReflectUtils.getClass(className, env.getClassLoader());
+		} else {
+			try {
+				if (className.startsWith("org.apache.muse.")){
+					try {
+						theClass = this.getClass().getClassLoader().loadClass(
+								className);
+					} catch(ClassNotFoundException cnfe){
+						//Nothing to do, just drop thru
+					}
+				}
+				if(theClass == null) theClass = bundle.loadClass(className);
+			} catch (ClassNotFoundException cnfe) {
+				throw new RuntimeException("Class not found " + className);
+			}
+		}
+
+		//
+		// make sure this class is an instance of ResourceRouter
+		//
+		if (!Capability.class.isAssignableFrom(theClass)) {
+			// FIXME: fix message
+			Object[] filler = { className, Capability.class.getName() };
+			String message = _MESSAGES.get("IncorrectCapabilityRoot", filler);
+			throw new RuntimeException(message);
+		}
+
+		return theClass;
+	}
+
+}

Added: webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/descriptor/OSGiDeploymentDescriptor.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/descriptor/OSGiDeploymentDescriptor.java?rev=426549&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/descriptor/OSGiDeploymentDescriptor.java (added)
+++ webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/descriptor/OSGiDeploymentDescriptor.java Fri Jul 28 08:06:01 2006
@@ -0,0 +1,235 @@
+/*=============================================================================*
+ *  Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *=============================================================================*/
+
+
+package org.apache.muse.core.platform.osgi.descriptor;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import javax.xml.namespace.QName;
+
+import org.apache.muse.core.Environment;
+import org.apache.muse.core.descriptor.DescriptorConstants;
+import org.apache.muse.core.descriptor.ResourceDefinition;
+import org.apache.muse.core.descriptor.ResourceDescriptor;
+import org.apache.muse.core.descriptor.RouterDefinition;
+import org.apache.muse.core.descriptor.RouterDescriptor;
+import org.apache.muse.core.descriptor.SerializerDefinition;
+import org.apache.muse.core.descriptor.SerializerDescriptor;
+import org.apache.muse.core.descriptor.DeploymentDescriptor;
+import org.apache.muse.core.descriptor.SimpleDeploymentDescriptor;
+import org.apache.muse.core.descriptor.SimpleResourceDescriptor;
+import org.apache.muse.core.descriptor.SimpleRouterDescriptor;
+import org.apache.muse.core.descriptor.SimpleSerializerDescriptor;
+import org.apache.muse.util.messages.Messages;
+import org.apache.muse.util.messages.MessagesFactory;
+import org.apache.muse.util.xml.XmlUtils;
+import org.apache.muse.ws.addressing.soap.SoapFault;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+
+import org.osgi.framework.Bundle;
+
+/**
+ *
+ * OSGiDeploymentDescriptor is ...
+ *
+ * @author Joel Hawkins (joelh)
+ *
+ */
+
+public class OSGiDeploymentDescriptor implements DeploymentDescriptor {// extends
+																		// SimpleDeploymentDescriptor
+																		// {
+	//
+	// Used to lookup all exception messages
+	//
+	private static Messages _MESSAGES = MessagesFactory
+			.get(SimpleDeploymentDescriptor.class);
+
+	//
+	// Stores info on the concrete implementations of the resource type.
+	// There will be at least one resource-instance in the factory.
+	//
+	private Collection _resourceDefinitions = null;
+
+	//
+	// The data used to instantiate the router
+	//
+	private static RouterDefinition _routerDefinition = null;
+	private RouterDefinition _localRouterDefinition = null;
+
+	private Collection _serializerDefinitions = null;
+
+	protected Bundle bundle;
+
+	public void setBundle(Bundle bundle) {
+		this.bundle = bundle;
+	}
+
+	public Collection loadContextPaths(Document xml, Environment env)
+			throws SoapFault {
+		if (xml == null)
+			throw new NullPointerException(_MESSAGES
+					.get("NullDescriptorDocument"));
+
+		Element root = XmlUtils.getElement(xml, DescriptorConstants.MUSE_QNAME);
+
+		Element[] resourceXML = XmlUtils.getElements(root,
+				DescriptorConstants.RESOURCE_TYPE_QNAME);
+
+		ArrayList contextPaths = new ArrayList(resourceXML.length);
+
+		QName qname = DescriptorConstants.CONTEXT_PATH_QNAME;
+		for (int n = 0; n < resourceXML.length; ++n) {
+			String path = XmlUtils.getElementText(resourceXML[n], qname);
+
+			if (path == null)
+				continue;
+
+			contextPaths.add(path);
+		}
+		return contextPaths;
+	}
+
+	public void load(Document xml, Environment environment) throws SoapFault {
+		if (xml == null)
+			throw new NullPointerException(_MESSAGES
+					.get("NullDescriptorDocument"));
+
+		Element root = XmlUtils.getElement(xml, DescriptorConstants.MUSE_QNAME);
+
+		//
+		// make sure we're starting with a valid DD (<muse/>)
+		//
+		// FIXME: if (root == null)
+
+		//
+		// any user-defined serializers must be loaded before we try to
+		// load the operations/handlers
+		//
+		_serializerDefinitions = createSerializerDefinitions(root, environment);
+
+		//
+		// one router used to map all resource types...
+		//
+		// Ignored - OSGi Router mandated by default plugin
+		RouterDefinition localRouter;
+		if (_routerDefinition == null)
+			_localRouterDefinition = _routerDefinition = createRouterDefinition(root, environment);
+		else
+			_localRouterDefinition = createRouterDelegate(root, environment);
+
+		//
+		// there will be one definition for each resource type
+		//
+		_resourceDefinitions = createResourceDefinitions(root, environment);
+
+		if (_localRouterDefinition != null)
+			_localRouterDefinition.setResourceDefinitions(_resourceDefinitions);
+	}
+
+	protected Collection createResourceDefinitions(Element xml, Environment env)
+			throws SoapFault {
+		Element[] resourceXML = XmlUtils.getElements(xml,
+				DescriptorConstants.RESOURCE_TYPE_QNAME);
+
+		Collection definitions = new ArrayList(resourceXML.length);
+
+		for (int n = 0; n < resourceXML.length; ++n) {
+			OSGiResourceDescriptor rd = (OSGiResourceDescriptor) createResourceDescriptor();
+			rd.setBundle(bundle);
+			rd.load(resourceXML[n], env);
+
+			ResourceDefinition definition = rd.getResourceDefinition();
+			definitions.add(definition);
+		}
+
+		return definitions;
+	}
+
+	protected ResourceDescriptor createResourceDescriptor() {
+		return new OSGiResourceDescriptor();
+	}
+
+	protected RouterDescriptor createRouterDescriptor() {
+		return new SimpleRouterDescriptor();
+	}
+
+	protected RouterDefinition createRouterDefinition(Element xml,
+			Environment env) throws SoapFault {
+		Element routerXML = XmlUtils.getElement(xml,
+				DescriptorConstants.ROUTER_QNAME);
+
+		RouterDescriptor rd = createRouterDescriptor();
+		rd.load(routerXML, env);
+
+		return rd.getRouterDefinition();
+	}
+
+	protected RouterDefinition createRouterDelegate(Element xml,
+			Environment env) throws SoapFault {
+		Element routerXML = XmlUtils.getElement(xml,
+				DescriptorConstants.ROUTER_QNAME);
+
+		if("true".equals(routerXML.getAttribute("delegate"))){
+			RouterDescriptor rd = createRouterDescriptor();
+			rd.load(routerXML, env);
+
+			return rd.getRouterDefinition();
+		} else {
+			return _routerDefinition;
+		}
+	}
+
+
+	protected SerializerDescriptor createSerializerDescriptor() {
+		return new SimpleSerializerDescriptor();
+	}
+
+	public Collection createSerializerDefinitions(Element xml, Environment env)
+			throws SoapFault {
+		QName qname = DescriptorConstants.CUSTOM_SERIALIZER_QNAME;
+		Element[] serializerXML = XmlUtils.getElements(xml, qname);
+
+		Collection definitions = new ArrayList(serializerXML.length);
+
+		for (int n = 0; n < serializerXML.length; ++n) {
+			SerializerDescriptor sd = createSerializerDescriptor();
+			sd.load(serializerXML[n], env);
+
+			SerializerDefinition definition = sd.getSerializerDefinition();
+			definitions.add(definition);
+		}
+
+		return definitions;
+	}
+
+	public Collection getSerializerDefinitions() {
+		return _serializerDefinitions;
+	}
+
+	public Collection getResourceDefinitions() {
+		return _resourceDefinitions;
+	}
+
+	public RouterDefinition getRouterDefinition() {
+		return _localRouterDefinition;
+	}
+
+}

Added: webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/descriptor/OSGiResourceDefinition.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/descriptor/OSGiResourceDefinition.java?rev=426549&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/descriptor/OSGiResourceDefinition.java (added)
+++ webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/descriptor/OSGiResourceDefinition.java Fri Jul 28 08:06:01 2006
@@ -0,0 +1,49 @@
+/*=============================================================================*
+ *  Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *=============================================================================*/
+
+
+package org.apache.muse.core.platform.osgi.descriptor;
+
+import org.apache.muse.core.descriptor.ResourceDefinition;
+import org.apache.muse.core.Resource;
+import org.apache.muse.core.platform.osgi.OSGiResourceManager;
+
+import org.osgi.framework.Bundle;
+
+/**
+ *
+ * OSGiResourceDefinition is ...
+ *
+ * @author Joel Hawkins (joelh)
+ *
+ */
+
+public class OSGiResourceDefinition extends ResourceDefinition {
+
+	private  Bundle bundle;
+
+	public OSGiResourceDefinition(Bundle bundle){
+		this.bundle = bundle;
+	}
+
+	public Resource newInstance(){
+		Resource instance = super.newInstance();
+		//Register with bunde to resource mapper
+		OSGiResourceManager.getDefault().addBundleResource(bundle,instance);
+		return instance;
+	}
+
+}

Added: webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/descriptor/OSGiResourceDescriptor.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/descriptor/OSGiResourceDescriptor.java?rev=426549&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/descriptor/OSGiResourceDescriptor.java (added)
+++ webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/descriptor/OSGiResourceDescriptor.java Fri Jul 28 08:06:01 2006
@@ -0,0 +1,239 @@
+/*=============================================================================*
+ *  Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *=============================================================================*/
+
+
+package org.apache.muse.core.platform.osgi.descriptor;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.io.File;
+import java.io.InputStream;
+
+import javax.wsdl.Definition;
+import javax.wsdl.Operation;
+import javax.wsdl.Output;
+import javax.wsdl.Part;
+import javax.wsdl.PortType;
+import javax.wsdl.factory.WSDLFactory;
+import javax.wsdl.xml.WSDLReader;
+import javax.xml.namespace.QName;
+import javax.wsdl.xml.WSDLLocator;
+
+import org.apache.muse.core.Environment;
+import org.apache.muse.core.Resource;
+import org.apache.muse.core.descriptor.CapabilityDescriptor;
+import org.apache.muse.core.descriptor.DescriptorConstants;
+import org.apache.muse.core.descriptor.ResourceDefinition;
+import org.apache.muse.core.descriptor.SimpleResourceDescriptor;
+import org.apache.muse.core.descriptor.WsdlConfig;
+import org.apache.muse.util.ReflectUtils;
+import org.apache.muse.util.messages.Messages;
+import org.apache.muse.util.messages.MessagesFactory;
+import org.apache.muse.util.xml.XmlUtils;
+import org.apache.muse.util.xml.XsdUtils;
+import org.apache.muse.ws.wsdl.WsdlUtils;
+import org.osgi.framework.Bundle;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.xml.sax.InputSource;
+
+import java.net.URL;
+
+/**
+ *
+ * OSGiResourceDescriptor is ...
+ *
+ * @author Joel Hawkins (joelh)
+ *
+ */
+
+public class OSGiResourceDescriptor extends SimpleResourceDescriptor {
+
+	private static class OSGiWsdlLocator implements WSDLLocator {
+
+		private Bundle bundle;
+
+		private WsdlConfig wsdlConfig;
+
+		private String baseURI = "";
+
+		private String lastPath = "";
+
+		public OSGiWsdlLocator(Bundle bundle, WsdlConfig wsdlConfig) {
+			this.bundle = bundle;
+			this.wsdlConfig = wsdlConfig;
+		}
+
+		public InputSource getBaseInputSource() {
+			String path = wsdlConfig.getWsdlPath();
+			URL url = bundle.getResource(path);
+			InputStream stream = null;
+			try {
+				stream = url.openStream();
+			} catch (Throwable t) {
+				return null;
+			}
+			if (stream != null)
+				return new InputSource(stream);
+			return null;
+		}
+
+		public String getBaseURI() {
+			// TODO JOEL this is a hack for testing purposes
+			if (wsdlConfig.getWsdlPath().startsWith("OSGI-INF/wsdl"))
+				baseURI = "OSGI-INF/wsdl";
+			return baseURI;
+		}
+
+		public InputSource getImportInputSource(String base, String path) {
+			lastPath = path;
+			String fullPath = path;
+			if (base != null) {
+				fullPath = base + "/" + path;
+			}
+			URL url = bundle.getResource(fullPath);
+			InputStream stream = null;
+			try {
+				stream = url.openStream();
+			} catch (Throwable t) {
+				return null;
+			}
+			if (stream != null)
+				return new InputSource(stream);
+			return null;
+		}
+
+		public String getLatestImportURI() {
+			// TODO Auto-generated method stub
+			return getBaseURI() + "/";
+		}
+
+	};
+
+	private static Messages _MESSAGES = MessagesFactory
+			.get(SimpleResourceDescriptor.class);
+
+	protected Bundle bundle;
+
+	public void setBundle(Bundle bundle) {
+		this.bundle = bundle;
+	}
+
+	protected Class createResourceClass(Element xml, Environment env) {
+		QName qname = DescriptorConstants.JAVA_RESOURCE_QNAME;
+		String className = XmlUtils.getElementText(xml, qname);
+
+		if (className == null)
+			throw new RuntimeException(_MESSAGES.get("NullJavaBase"));
+		ClassLoader loader = env.getClassLoader();
+		Class resourceClass = null;
+		if (bundle == null) {
+			loader = env.getClassLoader();
+			resourceClass = ReflectUtils.getClass(className, loader);
+		} else {
+			try {
+				if (className.startsWith("org.apache.muse.ws.resource.impl."))
+					resourceClass = this.getClass().getClassLoader().loadClass(
+							className);
+				else
+					resourceClass = bundle.loadClass(className);
+			} catch (ClassNotFoundException e) {
+				throw new RuntimeException("Class Not Found " + className);
+			}
+		}
+
+		if (!Resource.class.isAssignableFrom(resourceClass)) {
+			Object[] filler = { className, Resource.class.getName() };
+			String message = _MESSAGES.get("IncorrectResourceRoot", filler);
+			throw new RuntimeException(message);
+		}
+
+		return resourceClass;
+	}
+
+
+	protected Map getWsdlOperations(Document wsdlDoc,
+			WsdlConfig wsdlConfig,
+			Environment env)
+	{
+		String wsdlPath = wsdlConfig.getWsdlPath();
+		String absolutePath = env.getRealDirectory().getAbsolutePath();
+
+		if (wsdlPath.charAt(0) != '/')
+			absolutePath += '/';
+
+		absolutePath += wsdlPath;
+		File wsdlFile = new File(absolutePath);
+		File wsdlDir = wsdlFile.getParentFile();
+
+		Definition def = null;
+
+		//
+		// use WSDL4J to parse/validate the WSDL
+		//
+		try {
+
+			WSDLFactory factory = WSDLFactory.newInstance();
+			WSDLReader reader = factory.newWSDLReader();
+			javax.wsdl.xml.WSDLLocator locator = new OSGiWsdlLocator(bundle,
+					wsdlConfig);
+			reader.setFeature("javax.wsdl.verbose", false);
+			def = reader.readWSDL(locator);
+
+		}
+
+		catch (Exception error) {
+			throw new RuntimeException(error);
+		}
+
+//		find the port type named in the descriptor and process
+//		all of the operations
+
+		QName portTypeName = wsdlConfig.getWsdlPortType();
+		PortType portType = def.getPortType(portTypeName);
+
+		if (portType == null) // FIXME: extract message
+			throw new RuntimeException("No port type of name " + portType);
+
+		Collection ops = portType.getOperations();
+		Iterator i = ops.iterator();
+
+		Map opsByAction = new HashMap();
+
+		while (i.hasNext())
+		{
+			Operation next = (Operation)i.next();
+			String action = WsdlUtils.getAction(next);
+			opsByAction.put(action, next);
+		}
+
+		return opsByAction;
+	}
+
+
+	protected CapabilityDescriptor createCapabilityDescriptor() {
+		return new OSGiCapabilityDescriptor(bundle);
+	}
+
+    protected ResourceDefinition createResourceDefinition(){
+    	return new OSGiResourceDefinition(bundle);
+    }
+
+
+}

Added: webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/routing/OSGiResourceIdFactory.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/routing/OSGiResourceIdFactory.java?rev=426549&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/routing/OSGiResourceIdFactory.java (added)
+++ webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/routing/OSGiResourceIdFactory.java Fri Jul 28 08:06:01 2006
@@ -0,0 +1,74 @@
+/*=============================================================================*
+ *  Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *=============================================================================*/
+
+package org.apache.muse.core.platform.osgi.routing;
+
+import java.net.URI;
+
+import javax.xml.namespace.QName;
+
+import org.apache.muse.core.routing.ResourceIdFactory;
+import org.apache.muse.ws.addressing.WsaConstants;
+import java.util.HashMap;
+import org.apache.muse.core.platform.osgi.OSGiResourceManager;
+import org.apache.muse.core.platform.osgi.OSGiEnvironment;
+import org.osgi.framework.Bundle;
+
+/**
+ *
+ * OSGiResourceIdFactory is ...
+ *
+ * @author Joel Hawkins (joelh)
+ *
+ */
+
+public class OSGiResourceIdFactory implements ResourceIdFactory {
+
+	protected HashMap bundleToCounterMap = new HashMap();
+	protected String name;
+    private static final String _DEFAULT_NAME = "MuseResource";
+    private int count = 0;
+    private Integer FIRST = new Integer(1);
+
+	public OSGiResourceIdFactory(){
+		name = _DEFAULT_NAME;
+	}
+
+    public OSGiResourceIdFactory(String name)
+    {
+        this.name = name;
+    }
+
+    public QName getIdentifierName() {
+        return WsaConstants.DEFAULT_RESOURCE_ID_QNAME;
+	}
+
+	public synchronized String getNextIdentifier() {
+		OSGiEnvironment env = (OSGiEnvironment)OSGiResourceManager.getDefault().getEnvironment();
+		Bundle bundle = env.getThreadLocalBundle();
+		if(bundle != null){
+			Integer bCount = (Integer)bundleToCounterMap.get(bundle);
+			if(bCount == null) bCount = FIRST;
+			int value = bCount.intValue();
+			bundleToCounterMap.put(bundle, new Integer(value+1));
+			return name + '-' + value++;
+
+		} else {
+			return name + '-' + count++;
+		}
+	}
+
+}

Added: webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/routing/OSGiResourceRouter.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/routing/OSGiResourceRouter.java?rev=426549&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/routing/OSGiResourceRouter.java (added)
+++ webservices/muse/trunk/modules/muse-osgi-core/src/org/apache/muse/core/platform/osgi/routing/OSGiResourceRouter.java Fri Jul 28 08:06:01 2006
@@ -0,0 +1,68 @@
+/*=============================================================================*
+ *  Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *=============================================================================*/
+
+
+package org.apache.muse.core.platform.osgi.routing;
+
+import java.util.Collection;
+import java.util.logging.Logger;
+
+import org.apache.muse.core.Environment;
+import org.apache.muse.core.ResourceManager;
+import org.apache.muse.core.routing.ResourceRouter;
+import org.apache.muse.core.routing.SimpleResourceRouter;
+import org.apache.muse.core.platform.osgi.OSGiResourceManager;
+import org.apache.muse.core.platform.osgi.OSGiEnvironment;
+import org.apache.muse.ws.addressing.soap.SoapFault;
+import org.apache.muse.core.Resource;
+import org.w3c.dom.Element;
+import org.osgi.framework.Bundle;
+
+/**
+ *
+ * OSGiResourceRouter is ...
+ *
+ * @author Joel Hawkins (joelh)
+ *
+ */
+
+public class OSGiResourceRouter extends SimpleResourceRouter {
+
+	protected ResourceManager createResourceManager() {
+		OSGiResourceManager manager = OSGiResourceManager.getDefault();
+		manager.setLog(this.getLog());
+		return manager;
+	}
+
+
+	public Element invoke(Element soapBody){
+		Resource resource = null;
+        try
+        {
+            resource = getTargetResource();
+            Bundle bundle = ((OSGiResourceManager)this.getResourceManager()).getBundleForResource(resource);
+            ((OSGiEnvironment)getEnvironment()).setThreadLocalBundle(bundle);
+    		return super.invoke(soapBody);
+        }
+        catch (SoapFault fault)
+        {
+            return fault.toXML();
+        } finally {
+            ((OSGiEnvironment)getEnvironment()).setThreadLocalBundle(null);
+        }
+	}
+
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: muse-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: muse-commits-help@ws.apache.org