Return-Path: Delivered-To: apmail-geronimo-scm-archive@www.apache.org Received: (qmail 50186 invoked from network); 25 Jan 2010 18:56:02 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 25 Jan 2010 18:56:02 -0000 Received: (qmail 97615 invoked by uid 500); 25 Jan 2010 18:56:02 -0000 Delivered-To: apmail-geronimo-scm-archive@geronimo.apache.org Received: (qmail 97555 invoked by uid 500); 25 Jan 2010 18:56:02 -0000 Mailing-List: contact scm-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@geronimo.apache.org List-Id: Delivered-To: mailing list scm@geronimo.apache.org Received: (qmail 97546 invoked by uid 99); 25 Jan 2010 18:56:02 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 25 Jan 2010 18:56:02 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 25 Jan 2010 18:56:01 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 121122388906; Mon, 25 Jan 2010 18:55:41 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r902923 - in /geronimo/server/trunk: framework/modules/geronimo-kernel/src/test/java/org/apache/geronimo/kernel/osgi/ plugins/jetty8/geronimo-jetty8/ plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/ plugins/j... Date: Mon, 25 Jan 2010 18:55:40 -0000 To: scm@geronimo.apache.org From: gawor@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100125185541.121122388906@eris.apache.org> Author: gawor Date: Mon Jan 25 18:55:39 2010 New Revision: 902923 URL: http://svn.apache.org/viewvc?rev=902923&view=rev Log: GERONIMO-5030: Register ServletContext into service registry as mandated by OSGi Web Applications specification Added: geronimo/server/trunk/plugins/wab/geronimo-web/src/main/java/org/apache/geronimo/osgi/web/WebApplicationUtils.java (with props) Modified: geronimo/server/trunk/framework/modules/geronimo-kernel/src/test/java/org/apache/geronimo/kernel/osgi/MockBundle.java geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/pom.xml geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/GeronimoWebAppContext.java geronimo/server/trunk/plugins/jetty8/jetty8-clustering-wadi/src/main/history/dependencies.xml geronimo/server/trunk/plugins/jetty8/jetty8/src/main/history/dependencies.xml geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/pom.xml geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/GeronimoStandardContext.java geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatContainer.java geronimo/server/trunk/plugins/tomcat/tomcat7/src/main/history/dependencies.xml geronimo/server/trunk/plugins/wab/geronimo-web/pom.xml Modified: geronimo/server/trunk/framework/modules/geronimo-kernel/src/test/java/org/apache/geronimo/kernel/osgi/MockBundle.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-kernel/src/test/java/org/apache/geronimo/kernel/osgi/MockBundle.java?rev=902923&r1=902922&r2=902923&view=diff ============================================================================== --- geronimo/server/trunk/framework/modules/geronimo-kernel/src/test/java/org/apache/geronimo/kernel/osgi/MockBundle.java (original) +++ geronimo/server/trunk/framework/modules/geronimo-kernel/src/test/java/org/apache/geronimo/kernel/osgi/MockBundle.java Mon Jan 25 18:55:39 2010 @@ -27,6 +27,7 @@ import java.util.Dictionary; import java.util.Enumeration; import java.util.HashMap; +import java.util.Hashtable; import java.util.Map; import java.util.Vector; @@ -80,7 +81,7 @@ } public Dictionary getHeaders() { - return null; + return new Hashtable(); } public long getBundleId() { Modified: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/pom.xml URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/pom.xml?rev=902923&r1=902922&r2=902923&view=diff ============================================================================== --- geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/pom.xml (original) +++ geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/pom.xml Mon Jan 25 18:55:39 2010 @@ -51,6 +51,12 @@ + org.apache.geronimo.modules + geronimo-web + ${version} + + + org.apache.geronimo.framework geronimo-kernel ${version} Modified: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/GeronimoWebAppContext.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/GeronimoWebAppContext.java?rev=902923&r1=902922&r2=902923&view=diff ============================================================================== --- geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/GeronimoWebAppContext.java (original) +++ geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/GeronimoWebAppContext.java Mon Jan 25 18:55:39 2010 @@ -23,14 +23,11 @@ import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; -import java.net.URLConnection; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.eclipse.jetty.server.Handler; -import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.Request; import org.eclipse.jetty.server.handler.ErrorHandler; import org.eclipse.jetty.security.SecurityHandler; @@ -39,8 +36,12 @@ import org.eclipse.jetty.webapp.WebAppContext; import org.eclipse.jetty.util.resource.Resource; import org.eclipse.jetty.util.resource.URLResource; +import org.osgi.framework.Bundle; +import org.osgi.framework.ServiceRegistration; import org.apache.geronimo.connector.outbound.connectiontracking.ConnectorInstanceContext; import org.apache.geronimo.connector.outbound.connectiontracking.SharedConnectorInstanceContext; +import org.apache.geronimo.osgi.web.WebApplicationConstants; +import org.apache.geronimo.osgi.web.WebApplicationUtils; /** * @version $Rev$ $Date$ @@ -49,12 +50,13 @@ private final IntegrationContext integrationContext; private final String modulePath; + private ServiceRegistration serviceRegistration; public GeronimoWebAppContext(SecurityHandler securityHandler, SessionHandler sessionHandler, ServletHandler servletHandler, ErrorHandler errorHandler, IntegrationContext integrationContext, ClassLoader classLoader, String modulePath) { super(sessionHandler, securityHandler, servletHandler, errorHandler); this.integrationContext = integrationContext; setClassLoader(classLoader); - setAttribute("osgi-bundlecontext", integrationContext.getBundle().getBundleContext()); + setAttribute(WebApplicationConstants.BUNDLE_CONTEXT_ATTRIBUTE, integrationContext.getBundle().getBundleContext()); this.modulePath = modulePath; } @@ -74,10 +76,18 @@ integrationContext.restoreContext(context); integrationContext.completeTx(txActive, null); } + // for OSGi Web Applications support register ServletContext in service registry + Bundle bundle = integrationContext.getBundle(); + if (WebApplicationUtils.isWebApplicationBundle(bundle)) { + serviceRegistration = WebApplicationUtils.registerServletContext(bundle, getServletContext()); + } } @Override protected void doStop() throws Exception { + if (serviceRegistration != null) { + serviceRegistration.unregister(); + } javax.naming.Context context = integrationContext.setContext(); boolean txActive = integrationContext.isTxActive(); SharedConnectorInstanceContext newContext = integrationContext.newConnectorInstanceContext(null); Modified: geronimo/server/trunk/plugins/jetty8/jetty8-clustering-wadi/src/main/history/dependencies.xml URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jetty8/jetty8-clustering-wadi/src/main/history/dependencies.xml?rev=902923&r1=902922&r2=902923&view=diff ============================================================================== --- geronimo/server/trunk/plugins/jetty8/jetty8-clustering-wadi/src/main/history/dependencies.xml (original) +++ geronimo/server/trunk/plugins/jetty8/jetty8-clustering-wadi/src/main/history/dependencies.xml Mon Jan 25 18:55:39 2010 @@ -32,6 +32,11 @@ jar + org.apache.geronimo.modules + geronimo-web + jar + + org.eclipse.jetty jetty-jaspi jar Modified: geronimo/server/trunk/plugins/jetty8/jetty8/src/main/history/dependencies.xml URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jetty8/jetty8/src/main/history/dependencies.xml?rev=902923&r1=902922&r2=902923&view=diff ============================================================================== --- geronimo/server/trunk/plugins/jetty8/jetty8/src/main/history/dependencies.xml (original) +++ geronimo/server/trunk/plugins/jetty8/jetty8/src/main/history/dependencies.xml Mon Jan 25 18:55:39 2010 @@ -37,6 +37,11 @@ jar + org.apache.geronimo.modules + geronimo-web + jar + + org.eclipse.jetty jetty-ajp jar Modified: geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/pom.xml URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/pom.xml?rev=902923&r1=902922&r2=902923&view=diff ============================================================================== --- geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/pom.xml (original) +++ geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/pom.xml Mon Jan 25 18:55:39 2010 @@ -47,6 +47,12 @@ ${version} + + org.apache.geronimo.modules + geronimo-web + ${version} + + org.apache.geronimo.framework Modified: geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/GeronimoStandardContext.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/GeronimoStandardContext.java?rev=902923&r1=902922&r2=902923&view=diff ============================================================================== --- geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/GeronimoStandardContext.java (original) +++ geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/GeronimoStandardContext.java Mon Jan 25 18:55:39 2010 @@ -45,6 +45,7 @@ import org.apache.catalina.valves.ValveBase; import org.apache.geronimo.common.DeploymentException; import org.apache.geronimo.common.GeronimoSecurityException; +import org.apache.geronimo.osgi.web.WebApplicationUtils; import org.apache.geronimo.security.ContextManager; import org.apache.geronimo.security.jaas.ConfigurationFactory; import org.apache.geronimo.security.jacc.RunAsSource; @@ -60,6 +61,8 @@ import org.apache.geronimo.webservices.WebServiceContainer; import org.apache.geronimo.webservices.WebServiceContainerInvoker; import org.apache.tomcat.InstanceManager; +import org.osgi.framework.Bundle; +import org.osgi.framework.ServiceRegistration; /** @@ -87,11 +90,16 @@ private boolean authenticatorInstalled; private ConfigurationFactory configurationFactory; private String policyContextId; + + private Bundle bundle; + private ServiceRegistration serviceRegistration; public GeronimoStandardContext() { } public void setContextProperties(TomcatContext ctx) throws DeploymentException { + bundle = ctx.getBundle(); + setResources(new BundleDirContext(ctx.getBundle(), ctx.getModulePath())); // Create ReadOnlyContext @@ -304,6 +312,10 @@ } public void kill() throws Exception { + if (serviceRegistration != null) { + serviceRegistration.unregister(); + } + Object context[] = null; if (beforeAfter != null){ @@ -359,6 +371,11 @@ } else { super.start(); } + + // for OSGi Web Applications support register ServletContext in service registry + if (WebApplicationUtils.isWebApplicationBundle(bundle)) { + serviceRegistration = WebApplicationUtils.registerServletContext(bundle, getServletContext()); + } } public void addChild(Container child) { Modified: geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatContainer.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatContainer.java?rev=902923&r1=902922&r2=902923&view=diff ============================================================================== --- geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatContainer.java (original) +++ geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatContainer.java Mon Jan 25 18:55:39 2010 @@ -46,6 +46,7 @@ import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory; import org.apache.geronimo.management.geronimo.NetworkConnector; import org.apache.geronimo.management.geronimo.WebManager; +import org.apache.geronimo.osgi.web.WebApplicationConstants; import org.apache.geronimo.security.jaas.ConfigurationFactory; import org.apache.geronimo.security.ContextManager; import org.apache.geronimo.system.serverinfo.ServerInfo; @@ -283,7 +284,8 @@ } context.setParent(host); // set the bundle context attribute in the servlet context - context.getServletContext().setAttribute("osgi-bundlecontext", contextInfo.getBundle().getBundleContext()); + context.getServletContext().setAttribute(WebApplicationConstants.BUNDLE_CONTEXT_ATTRIBUTE, + contextInfo.getBundle().getBundleContext()); // Set the context for the Tomcat implementation contextInfo.setContext(context); Modified: geronimo/server/trunk/plugins/tomcat/tomcat7/src/main/history/dependencies.xml URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/tomcat/tomcat7/src/main/history/dependencies.xml?rev=902923&r1=902922&r2=902923&view=diff ============================================================================== --- geronimo/server/trunk/plugins/tomcat/tomcat7/src/main/history/dependencies.xml (original) +++ geronimo/server/trunk/plugins/tomcat/tomcat7/src/main/history/dependencies.xml Mon Jan 25 18:55:39 2010 @@ -1,5 +1,5 @@ - + org.apache.geronimo.configs tomcat7 @@ -58,6 +58,11 @@ org.apache.geronimo.modules + geronimo-web + jar + + + org.apache.geronimo.modules geronimo-webservices jar Modified: geronimo/server/trunk/plugins/wab/geronimo-web/pom.xml URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/wab/geronimo-web/pom.xml?rev=902923&r1=902922&r2=902923&view=diff ============================================================================== --- geronimo/server/trunk/plugins/wab/geronimo-web/pom.xml (original) +++ geronimo/server/trunk/plugins/wab/geronimo-web/pom.xml Mon Jan 25 18:55:39 2010 @@ -50,6 +50,11 @@ org.ops4j.pax.logging pax-logging-api + + + org.apache.geronimo.specs + geronimo-servlet_3.0_spec + Added: geronimo/server/trunk/plugins/wab/geronimo-web/src/main/java/org/apache/geronimo/osgi/web/WebApplicationUtils.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/wab/geronimo-web/src/main/java/org/apache/geronimo/osgi/web/WebApplicationUtils.java?rev=902923&view=auto ============================================================================== --- geronimo/server/trunk/plugins/wab/geronimo-web/src/main/java/org/apache/geronimo/osgi/web/WebApplicationUtils.java (added) +++ geronimo/server/trunk/plugins/wab/geronimo-web/src/main/java/org/apache/geronimo/osgi/web/WebApplicationUtils.java Mon Jan 25 18:55:39 2010 @@ -0,0 +1,51 @@ +/** + * 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.geronimo.osgi.web; + +import java.util.Hashtable; + +import javax.servlet.ServletContext; + +import org.osgi.framework.Bundle; +import org.osgi.framework.BundleContext; +import org.osgi.framework.Constants; +import org.osgi.framework.ServiceRegistration; + +public class WebApplicationUtils { + + public static boolean isWebApplicationBundle(Bundle bundle) { + return (bundle != null && bundle.getHeaders().get(WebApplicationConstants.CONTEXT_PATH_HEADER) != null); + } + + public static ServiceRegistration registerServletContext(BundleContext bundleContext, ServletContext context) { + return registerServletContext(bundleContext.getBundle(), context); + } + + public static ServiceRegistration registerServletContext(Bundle bundle, ServletContext context) { + Hashtable properties = new Hashtable(); + properties.put(WebApplicationConstants.WEB_SYMBOLIC_NAME, bundle.getSymbolicName()); + String version = (String) bundle.getHeaders().get(Constants.BUNDLE_VERSION); + if (version != null) { + properties.put(WebApplicationConstants.WEB_VERSION, version); + } + properties.put(WebApplicationConstants.WEB_CONTEXT_PATH, context.getContextPath()); + return bundle.getBundleContext().registerService(ServletContext.class.getName(), context, properties); + } + +} Propchange: geronimo/server/trunk/plugins/wab/geronimo-web/src/main/java/org/apache/geronimo/osgi/web/WebApplicationUtils.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: geronimo/server/trunk/plugins/wab/geronimo-web/src/main/java/org/apache/geronimo/osgi/web/WebApplicationUtils.java ------------------------------------------------------------------------------ svn:keywords = Date Revision Propchange: geronimo/server/trunk/plugins/wab/geronimo-web/src/main/java/org/apache/geronimo/osgi/web/WebApplicationUtils.java ------------------------------------------------------------------------------ svn:mime-type = text/plain