You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by di...@apache.org on 2008/03/06 16:45:19 UTC
svn commit: r634314 - in
/webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/extensions/osgi/core:
./ SOAPProvider.java web/ web/ServletDescriptor.java web/WebApp.java
web/WebAppDescriptor.java
Author: dims
Date: Thu Mar 6 07:45:18 2008
New Revision: 634314
URL: http://svn.apache.org/viewvc?rev=634314&view=rev
Log:
copy some stuff over from muse for prototyping a new explicit deploy service for programatically adding new web services
Added:
webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/extensions/osgi/core/
webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/extensions/osgi/core/SOAPProvider.java
webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/extensions/osgi/core/web/
webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/extensions/osgi/core/web/ServletDescriptor.java
webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/extensions/osgi/core/web/WebApp.java
webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/extensions/osgi/core/web/WebAppDescriptor.java
Added: webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/extensions/osgi/core/SOAPProvider.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/extensions/osgi/core/SOAPProvider.java?rev=634314&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/extensions/osgi/core/SOAPProvider.java (added)
+++ webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/extensions/osgi/core/SOAPProvider.java Thu Mar 6 07:45:18 2008
@@ -0,0 +1,151 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.axis2.extensions.osgi.core;
+
+import org.apache.axis2.extensions.osgi.core.web.WebApp;
+import org.osgi.framework.Bundle;
+
+/**
+ * SOAPProvider is an interface for generic SOAP functionality.
+ * Use this interface to register SOAPProvider services with the OSGi
+ * runtime using the <code>BundleContext.registerService()</code> methods.
+ */
+
+public interface SOAPProvider {
+
+ /**
+ * The name of the SOAPProvider implementation. Use this as the key when constructing
+ * the service's properties for registration with the OSGi runtime.
+ */
+ public static final String PROVIDER_NAME = "Name";
+
+ /**
+ * The major version of the SOAPProvider implementation. Use this as the key when constructing
+ * the service's properties for registration with the OSGi runtime.
+ */
+ public static final String PROVIDER_MAJOR_VERSION = "MajorVersion";
+
+ /**
+ * The minor version of the SOAPProvider implementation. Use this as the key when constructing
+ * the service's properties for registration with the OSGi runtime.
+ */
+ public static final String PROVIDER_MINOR_VERSION = "MinorVersion";
+
+ /**
+ * Getter method for the implementation's provider name. This name should be the same
+ * as the one used during the registration of the SOAPProvider service
+ *
+ * @return the Provider Name
+ */
+ public String getProviderName();
+
+ /**
+ * Getter method for the implementation's version. This name should be constructed
+ * from the major and minor versions used during registration of the SOAPProvider service.
+ *
+ * @return the Provider Version
+ */
+ public String getProviderVersion();
+
+ public Object getProviderEngine();
+
+ public Object getProviderDeployer();
+
+ public Object getProviderDeployer(WebApp webApp);
+
+ /**
+ * Deploys an Object as a WebService using the implementation's default binding type.
+ * The service is deployed into the provider's default application context.
+ *
+ * @param srvName the display name of the service
+ * @param srvClass the class or interface that should be exposed. Specifying an interface
+ * allows only the desired methods of the service object to be published.
+ * @param srvObject the actual implementation
+ * @throws Exception
+ */
+ public void deployService(String srvName, Class srvClass, Object srvObject, String handlerChain) throws Exception;
+
+ /**
+ * Deploys an Object as a WebService using a specified binding type
+ * The service is deployed into the provider's default application context.
+ *
+ * @param srvName the display name of the service
+ * @param bindingType the name of the desired binding type
+ * @param srvClass the class or interface that should be exposed. Specifying an interface
+ * allows only the desired methods of the service object to be published.
+ * @param srvObject the actual implementation
+ * @throws Exception
+ */
+ public void deployService(String srvName, String bindingType, Class srvClass, Object srvObject, String handlerChain) throws Exception;
+
+ /**
+ * Deploys an Object as a WebService using the provider's default binding type.
+ * The service is deployed into the specified <code>WebApp</code> context
+ *
+ * @param WebApp the target web application context
+ * @param srvName the display name of the service
+ * @param srvClass the class or interface that should be exposed. Specifying an interface
+ * allows only the desired methods of the service object to be published.
+ * @param srvObject the actual implementation
+ * @throws Exception
+ */
+ public void deployService(WebApp webApp, String srvName, Class srvClass, Object srvObject, String handlerChain) throws Exception;
+
+ /**
+ * Deploys an Object as a WebService using a specified binding type
+ * The service is deployed into the specified <code>WebApp</code> context
+ *
+ * @param WebApp the target web application context
+ * @param srvName the display name of the service
+ * @param bindingType the name of the desired binding type
+ * @param srvClass the class or interface that should be exposed. Specifying an interface
+ * allows only the desired methods of the service object to be published.
+ * @param srvObject the actual implementation
+ * @throws Exception
+ */
+ public void deployService(WebApp webApp, String srvName, String bindingType, Class srvClass, Object srvObject, String handlerChain) throws Exception;
+
+ public void undeployService(String srvName, Class srvClass) throws Exception;
+
+ public void undeployService(WebApp webApp, String srvName, Class srvClass) throws Exception;
+
+ /**
+ * Gets a web application from the provider for the given context path.
+ *
+ * @param contextPath the context path of the desired WebApp
+ * @param create if <code>true</code>, create the WebApp if it does not exits.
+ * @return return the WebApp
+ * @throws Exception
+ */
+ public WebApp getWebApp(String contextPath, boolean create) throws Exception;
+
+ /**
+ * Gets a web application from the provider for the given context path, using
+ * the provided bundle as the location for the engine's configuration information
+ *
+ * @param contextPath the context path of the desired WebApp
+ * @param create if <code>true</code>, create the WebApp if it does not exits.
+ * @return return the WebApp
+ * @throws Exception
+ */
+ public WebApp getWebApp(Bundle bundle, String contextPath, boolean create) throws Exception;
+
+}
Added: webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/extensions/osgi/core/web/ServletDescriptor.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/extensions/osgi/core/web/ServletDescriptor.java?rev=634314&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/extensions/osgi/core/web/ServletDescriptor.java (added)
+++ webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/extensions/osgi/core/web/ServletDescriptor.java Thu Mar 6 07:45:18 2008
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.axis2.extensions.osgi.core.web;
+
+import javax.servlet.http.HttpServlet;
+import java.util.Hashtable;
+
+/**
+ *
+ * ServletDescriptor a utility class for describing Servlets to be deployed into a WebApp
+ */
+
+public class ServletDescriptor {
+ protected Hashtable initParameters;
+
+ protected HttpServlet servlet;
+
+ protected String subContext;
+
+ public ServletDescriptor(String subContext, HttpServlet servlet) {
+ this.subContext = subContext;
+ this.servlet = servlet;
+ }
+
+ public Hashtable getInitParameters() {
+ return initParameters;
+ }
+
+ public void setInitParameters(Hashtable initParameters) {
+ this.initParameters = initParameters;
+ }
+
+ public HttpServlet getServlet() {
+ return servlet;
+ }
+
+ public void setServlet(HttpServlet servlet) {
+ this.servlet = servlet;
+ }
+
+ public String getSubContext() {
+ return subContext;
+ }
+
+ public void setSubContext(String subContext) {
+ this.subContext = subContext;
+ }
+}
Added: webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/extensions/osgi/core/web/WebApp.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/extensions/osgi/core/web/WebApp.java?rev=634314&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/extensions/osgi/core/web/WebApp.java (added)
+++ webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/extensions/osgi/core/web/WebApp.java Thu Mar 6 07:45:18 2008
@@ -0,0 +1,136 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.axis2.extensions.osgi.core.web;
+
+import java.net.URL;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.http.HttpContext;
+import org.osgi.service.http.HttpService;
+
+/**
+ *
+ * WebApp is a utility class for describing a WebApplication to be deployed into an OSGi
+ * HTTP Service implementation. The WebApp implementation extends the OSGi <code>HttpContext</code>.
+ */
+public class WebApp implements HttpContext {
+ protected static WebAppDescriptor webAppDescriptor = null;
+
+ protected HttpService httpService;
+
+ protected ServiceReference sRef;
+
+ public WebApp(WebAppDescriptor descriptor) {
+ webAppDescriptor = descriptor;
+ }
+
+ // Return null and let the HTTP determine the type
+ public String getMimeType(String reqEntry) {
+ return null;
+ }
+
+ // Get the resource from the jar file, use the class loader to do it
+ public URL getResource(String name) {
+ URL url = getClass().getResource(name);
+
+ return url;
+ }
+
+ public boolean handleSecurity(HttpServletRequest request,
+ HttpServletResponse response) throws java.io.IOException {
+ return true;
+ }
+
+ /**
+ * Starts the WebApp
+ * @param bc the BundleContext of the WebApp host
+ * @throws BundleException
+ */
+ public void start(BundleContext bc) throws BundleException {
+ if ((sRef = bc.getServiceReference("org.osgi.service.http.HttpService")) == null)
+ throw new BundleException("Failed to get HttpServiceReference");
+ if ((httpService = (HttpService) bc.getService(sRef)) == null)
+ throw new BundleException("Failed to get HttpService");
+ try {
+ WebAppDescriptor wad = webAppDescriptor;
+
+ for (int i = 0; i < wad.servlet.length; i++) {
+ ServletDescriptor servlet = wad.servlet[i];
+
+ httpService.registerServlet(wad.context + servlet.subContext,
+ servlet.servlet, servlet.initParameters, this);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new BundleException("Failed to register servlets");
+ }
+ }
+
+ /**
+ * Stops the WebApp
+ * @param bc the BundleContext of the WebApp host
+ * @throws BundleException
+ */
+ public void stop(BundleContext bc) throws BundleException {
+ try {
+ for (int i = 0; i < webAppDescriptor.servlet.length; i++) {
+ ServletDescriptor servlet = webAppDescriptor.servlet[i];
+
+ httpService.unregister(webAppDescriptor.context
+ + servlet.subContext);
+ }
+ bc.ungetService(sRef);
+ httpService = null;
+ webAppDescriptor = null;
+ } catch (Exception e) {
+ throw new BundleException("Failed to unregister resources", e);
+ }
+ }
+
+ public static WebAppDescriptor getWebAppDescriptor() {
+ return webAppDescriptor;
+ }
+
+ public static void setWebAppDescriptor(WebAppDescriptor webAppDescriptor) {
+ WebApp.webAppDescriptor = webAppDescriptor;
+ }
+
+ public HttpService getHttpService() {
+ return httpService;
+ }
+
+ public void setHttpService(HttpService httpService) {
+ this.httpService = httpService;
+ }
+
+ public ServiceReference getSRef() {
+ return sRef;
+ }
+
+ public void setSRef(ServiceReference sRef) {
+ this.sRef = sRef;
+ }
+}
Added: webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/extensions/osgi/core/web/WebAppDescriptor.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/extensions/osgi/core/web/WebAppDescriptor.java?rev=634314&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/extensions/osgi/core/web/WebAppDescriptor.java (added)
+++ webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/extensions/osgi/core/web/WebAppDescriptor.java Thu Mar 6 07:45:18 2008
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.axis2.extensions.osgi.core.web;
+
+/**
+ *
+ * WebAppDescriptor is a utility class for containing the static information
+ * required by the WebApp class
+ */
+
+public class WebAppDescriptor {
+ protected String context;
+
+ protected ServletDescriptor[] servlet;
+
+ public String getContext() {
+ return context;
+ }
+
+ public void setContext(String context) {
+ this.context = context;
+ }
+
+ public ServletDescriptor[] getServlet() {
+ return servlet;
+ }
+
+ public void setServlet(ServletDescriptor[] servlet) {
+ this.servlet = servlet;
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org