[jboss-cvs] JBossAS SVN: r84123 - in projects/jboss-felix/trunk/modules: integration/deployer/src/main/resources and 7 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Feb 12 08:51:34 EST 2009


Author: thomas.diesler at jboss.com
Date: 2009-02-12 08:51:34 -0500 (Thu, 12 Feb 2009)
New Revision: 84123

Added:
   projects/jboss-felix/trunk/modules/service/http/src/main/java/org/jboss/osgi/service/http/GenericEndpointServlet.java
   projects/jboss-felix/trunk/modules/service/http/src/main/java/org/jboss/osgi/service/http/HttpEndpointDeployer.java
   projects/jboss-felix/trunk/modules/service/http/src/main/java/org/jboss/osgi/service/http/HttpServiceClassLoader.java
   projects/jboss-felix/trunk/modules/service/http/src/main/java/org/jboss/osgi/service/http/HttpServiceClassLoaderMBean.java
   projects/jboss-felix/trunk/modules/service/http/src/main/java/org/jboss/osgi/service/http/ManagedHttpContext.java
   projects/jboss-felix/trunk/modules/service/http/src/main/java/org/jboss/osgi/service/http/ManagedHttpContextMBean.java
   projects/jboss-felix/trunk/modules/service/http/src/main/java/org/jboss/osgi/service/http/ManagedServlet.java
   projects/jboss-felix/trunk/modules/service/http/src/main/java/org/jboss/osgi/service/http/ManagedServletMBean.java
   projects/jboss-felix/trunk/modules/service/http/src/main/java/org/jboss/osgi/service/http/WebMetaDataFactory.java
Removed:
   projects/jboss-felix/trunk/modules/integration/deployer/src/main/resources/osgi-jboss-beans.xml
   projects/jboss-felix/trunk/modules/service/http-beans/
Modified:
   projects/jboss-felix/trunk/modules/distribution/src/main/resources/installer/install-definition.xml
   projects/jboss-felix/trunk/modules/integration/deployer/src/main/resources/osgi-deployers-jboss-beans.xml
   projects/jboss-felix/trunk/modules/integration/felix/
   projects/jboss-felix/trunk/modules/integration/testsuite/src/test/java/org/jboss/osgi/test/service/microcontainer/MBeanTestService.java
   projects/jboss-felix/trunk/modules/integration/testsuite/src/test/java/org/jboss/osgi/test/service/microcontainer/junit/MicrocontainerServiceTest.java
   projects/jboss-felix/trunk/modules/integration/testsuite/src/test/resources/service/http/http-service.bnd
   projects/jboss-felix/trunk/modules/service/http/pom.xml
   projects/jboss-felix/trunk/modules/service/http/src/main/java/org/jboss/osgi/service/http/HttpServiceImpl.java
   projects/jboss-felix/trunk/modules/service/pom.xml
Log:
tests ok

Modified: projects/jboss-felix/trunk/modules/distribution/src/main/resources/installer/install-definition.xml
===================================================================
--- projects/jboss-felix/trunk/modules/distribution/src/main/resources/installer/install-definition.xml	2009-02-12 12:23:20 UTC (rev 84122)
+++ projects/jboss-felix/trunk/modules/distribution/src/main/resources/installer/install-definition.xml	2009-02-12 13:51:34 UTC (rev 84123)
@@ -66,19 +66,11 @@
     
       <description>The JBoss OSGi Integration</description>
 
-      <!-- OSGi Beans -->
-      <fileset dir="@{deploy.artifacts.dir}/lib" targetdir="${jbossInstallPath}/server/${jbossTargetServer}/deploy/osgi" override="true">
-        <include name="jboss-osgi-service-http.jar" />
-        <include name="jboss-osgi-service-http-beans.jar" />
-      </fileset>
-      <fileset dir="@{deploy.artifacts.dir}/resources/jboss-osgi-deployer-config" targetdir="${jbossInstallPath}/server/${jbossTargetServer}/deploy/osgi" override="true">
-        <include name="osgi-jboss-beans.xml" />
-      </fileset>
-
       <!-- OSGi Deployer -->
       <fileset dir="@{deploy.artifacts.dir}/lib" targetdir="${jbossInstallPath}/server/${jbossTargetServer}/deployers/osgi.deployer" override="true">
         <include name="jboss-osgi-deployer.jar" />
         <include name="jboss-osgi-felix.jar" />
+        <include name="jboss-osgi-service-http.jar" />
         <include name="jboss-osgi-spi.jar" />
         <include name="org.apache.felix.framework.jar" />
         <include name="org.osgi.compendium.jar" />

Modified: projects/jboss-felix/trunk/modules/integration/deployer/src/main/resources/osgi-deployers-jboss-beans.xml
===================================================================
--- projects/jboss-felix/trunk/modules/integration/deployer/src/main/resources/osgi-deployers-jboss-beans.xml	2009-02-12 12:23:20 UTC (rev 84122)
+++ projects/jboss-felix/trunk/modules/integration/deployer/src/main/resources/osgi-deployers-jboss-beans.xml	2009-02-12 13:51:34 UTC (rev 84123)
@@ -18,41 +18,45 @@
           <value>
             javax.servlet,
             javax.servlet.http,
-            javax.xml.parsers,
+            javax.management,
+            javax.security.jacc,
+            org.jboss.classloading.spi,
             org.jboss.deployers.client.plugins.deployment,
             org.jboss.deployers.client.spi,
             org.jboss.deployers.spi.attachments,
             org.jboss.deployers.spi.structure,
+            org.jboss.deployers.structure.spi,
+            org.jboss.metadata.javaee.spec,
             org.jboss.metadata.javaee.support,
             org.jboss.metadata.web.jboss,
             org.jboss.metadata.web.spec,
-            org.jboss.osgi.service.http.beans,
-            org.osgi.service.deploymentadmin, 
+            org.jboss.mx.util,
+            org.jboss.osgi.service,
+            org.jboss.osgi.spi,
+            org.jboss.osgi.spi.framework,
+            org.jboss.web,
+            org.jboss.virtual,
             org.osgi.framework; version=1.4,
-            org.osgi.service.cm,
-            org.osgi.service.event,
-            org.osgi.service.http; version=1.2,
-            org.osgi.service.log,
-            org.osgi.service.metatype,
-            org.osgi.service.packageadmin,
-            org.osgi.service.prefs,
-            org.osgi.service.startlevel,
-            org.osgi.util.tracker,
-            org.xml.sax 
+            org.osgi.service.startlevel
           </value>
         </entry>
       </map>
     </property>
     <property name="autoStart">
      <list elementClass="java.net.URI">
-      <!-- 
-      <value>${jboss.server.home.url}/deployers/osgi.deployer/org.osgi.core.jar</value>
       <value>${jboss.server.home.url}/deployers/osgi.deployer/org.osgi.compendium.jar</value>
-      -->
+      <value>${jboss.server.home.url}/deployers/osgi.deployer/jboss-osgi-service-http.jar</value>
      </list>
     </property>
   </bean>
 
+  <!-- A Service that gives access to the Microcontainer Kernel -->
+  <bean name="jboss.osgi:service=Microcontainer" class="org.jboss.osgi.service.MicrocontainerService">
+   <property name="bundleContext"><inject bean="jboss.osgi:service=Framework" property="systemBundleContext"/></property>
+   <property name="mbeanServer"><inject bean="JMXKernel" property="mbeanServer"/></property>
+   <property name="kernel"><inject bean="jboss.kernel:service=Kernel" /></property>
+  </bean>
+
   <!-- The OSGi Meta Data Deployer -->
   <bean name="jboss.osgi:service=MetaDataDeployer" class="org.jboss.osgi.deployer.OSGiMetaDataDeployer" />
 
@@ -62,4 +66,4 @@
     <property name="skipBundles"><inject bean="jboss.osgi:service=Framework" property="autoInstall" /></property>
   </bean>
 
-</deployment>
+</deployment>
\ No newline at end of file

Deleted: projects/jboss-felix/trunk/modules/integration/deployer/src/main/resources/osgi-jboss-beans.xml
===================================================================
--- projects/jboss-felix/trunk/modules/integration/deployer/src/main/resources/osgi-jboss-beans.xml	2009-02-12 12:23:20 UTC (rev 84122)
+++ projects/jboss-felix/trunk/modules/integration/deployer/src/main/resources/osgi-jboss-beans.xml	2009-02-12 13:51:34 UTC (rev 84123)
@@ -1,20 +0,0 @@
-<!--
-  $Id$ 
--->
-<deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:jboss:bean-deployer:2.0 bean-deployer_2_0.xsd" xmlns="urn:jboss:bean-deployer:2.0">
-
- <!-- A Service that gives access to the Microcontainer Kernel -->
- <bean name="jboss.osgi:service=Microcontainer" class="org.jboss.osgi.service.MicrocontainerService">
-  <property name="bundleContext"><inject bean="jboss.osgi:service=Framework" property="systemBundleContext"/></property>
-  <property name="mbeanServer"><inject bean="JMXKernel" property="mbeanServer"/></property>
-  <property name="kernel"><inject bean="jboss.kernel:service=Kernel" /></property>
- </bean>
- 
- <!-- A Service that generates and deployes webapps on behalf of the HttpService -->
- <bean name="jboss.osgi:service=HttpEndpointDeployer" class="org.jboss.osgi.service.http.beans.HttpEndpointDeployer">
-  <property name="bundleContext"><inject bean="jboss.osgi:service=Framework" property="systemBundleContext"/></property>
-  <property name="mbeanServer"><inject bean="JMXKernel" property="mbeanServer"/></property>
-  <property name="mainDeployer"><inject bean="MainDeployer"/></property>
- </bean>
- 
-</deployment>


Property changes on: projects/jboss-felix/trunk/modules/integration/felix
___________________________________________________________________
Name: svn:ignore
   - target

   + target
felix-cache


Modified: projects/jboss-felix/trunk/modules/integration/testsuite/src/test/java/org/jboss/osgi/test/service/microcontainer/MBeanTestService.java
===================================================================
--- projects/jboss-felix/trunk/modules/integration/testsuite/src/test/java/org/jboss/osgi/test/service/microcontainer/MBeanTestService.java	2009-02-12 12:23:20 UTC (rev 84122)
+++ projects/jboss-felix/trunk/modules/integration/testsuite/src/test/java/org/jboss/osgi/test/service/microcontainer/MBeanTestService.java	2009-02-12 13:51:34 UTC (rev 84123)
@@ -41,7 +41,7 @@
  */
 public class MBeanTestService implements ServiceListener
 {
-  private ObjectName oname = ObjectNameFactory.create("jboss.osgi:service=mbean-test-service");
+  public static ObjectName OBJECT_NAME = ObjectNameFactory.create("jboss.osgi:service=mbean-test-service");
   
   private BundleContext context;
   private MBeanServer mbeanServer;
@@ -58,7 +58,7 @@
     {
     	MicrocontainerService mcService = getMicrocontainerService();
     	mbeanServer = mcService.getMbeanServer();
-      mbeanServer.registerMBean(new Foo(), oname);
+      mbeanServer.registerMBean(new Foo(), OBJECT_NAME);
     }
     catch (Exception ex)
     {
@@ -70,8 +70,8 @@
   {
     try
     {
-      if (mbeanServer != null && mbeanServer.isRegistered(oname))
-        mbeanServer.unregisterMBean(oname);
+      if (mbeanServer != null && mbeanServer.isRegistered(OBJECT_NAME))
+        mbeanServer.unregisterMBean(OBJECT_NAME);
     }
     catch (Exception ex)
     {

Modified: projects/jboss-felix/trunk/modules/integration/testsuite/src/test/java/org/jboss/osgi/test/service/microcontainer/junit/MicrocontainerServiceTest.java
===================================================================
--- projects/jboss-felix/trunk/modules/integration/testsuite/src/test/java/org/jboss/osgi/test/service/microcontainer/junit/MicrocontainerServiceTest.java	2009-02-12 12:23:20 UTC (rev 84122)
+++ projects/jboss-felix/trunk/modules/integration/testsuite/src/test/java/org/jboss/osgi/test/service/microcontainer/junit/MicrocontainerServiceTest.java	2009-02-12 13:51:34 UTC (rev 84123)
@@ -23,10 +23,13 @@
 
 //$Id$
 
+import javax.management.MBeanServerConnection;
+
 import junit.framework.Test;
 
 import org.jboss.osgi.spi.junit.IntegrationTestCase;
 import org.jboss.osgi.spi.junit.IntegrationTestSetup;
+import org.jboss.osgi.test.service.microcontainer.MBeanTestService;
 
 /**
  * A test that deployes a bundle that registeres an MBean
@@ -40,8 +43,11 @@
   {
     return new IntegrationTestSetup(MicrocontainerServiceTest.class, "microcontainer-service.jar");
   }
-  
+
   public void testMBeanAccess() throws Exception
   {
+    MBeanServerConnection server = getServer();
+    Object retStr = server.invoke(MBeanTestService.OBJECT_NAME, "echo", new Object[] { "hello" }, new String[] { String.class.getName() });
+    assertEquals("hello", retStr);
   }
 }
\ No newline at end of file

Modified: projects/jboss-felix/trunk/modules/integration/testsuite/src/test/resources/service/http/http-service.bnd
===================================================================
--- projects/jboss-felix/trunk/modules/integration/testsuite/src/test/resources/service/http/http-service.bnd	2009-02-12 12:23:20 UTC (rev 84122)
+++ projects/jboss-felix/trunk/modules/integration/testsuite/src/test/resources/service/http/http-service.bnd	2009-02-12 13:51:34 UTC (rev 84123)
@@ -2,7 +2,7 @@
 
 Bundle-SymbolicName: http-service-test
 Bundle-Activator: org.jboss.osgi.test.service.http.ServiceActivator
-Export-Package: org.jboss.osgi.test.service.http
+Export-Package: org.jboss.osgi.test.service.http
 Include-Resource: res/message.txt=message.txt
 
 # For some reason this does not work

Modified: projects/jboss-felix/trunk/modules/service/http/pom.xml
===================================================================
--- projects/jboss-felix/trunk/modules/service/http/pom.xml	2009-02-12 12:23:20 UTC (rev 84122)
+++ projects/jboss-felix/trunk/modules/service/http/pom.xml	2009-02-12 13:51:34 UTC (rev 84123)
@@ -23,9 +23,49 @@
   <dependencies>
     <dependency>
       <groupId>org.jboss.osgi</groupId>
-      <artifactId>jboss-osgi-service-http-beans</artifactId>
+      <artifactId>jboss-osgi-spi</artifactId>
       <version>${version}</version>
     </dependency>
+    <dependency>
+      <groupId>org.apache.felix</groupId>
+      <artifactId>org.apache.felix.framework</artifactId>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.deployers</groupId>
+      <artifactId>jboss-deployers-client</artifactId>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.deployers</groupId>
+      <artifactId>jboss-deployers-client-spi</artifactId>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.deployers</groupId>
+      <artifactId>jboss-deployers-structure-spi</artifactId>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.deployers</groupId>
+      <artifactId>jboss-deployers-vfs-spi</artifactId>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.javaee</groupId>
+      <artifactId>jboss-jacc-api</artifactId>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.jbossas</groupId>
+      <artifactId>jboss-as-server</artifactId>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.metadata</groupId>
+      <artifactId>jboss-metadata</artifactId>
+      <scope>provided</scope>
+    </dependency>
   </dependencies>
 
   <build>
@@ -40,10 +80,29 @@
             <Bundle-Activator>org.jboss.osgi.service.http.HttpServiceActivator</Bundle-Activator>
             <Private-Package>org.jboss.osgi.service.http</Private-Package>
             <Import-Package>
-               !javax.servlet, !javax.servlet.http,
-               org.jboss.osgi.service.http.beans, 
-               org.osgi.framework, 
-               org.osgi.service.http
+               javax.servlet,
+               javax.servlet.http,
+               javax.management, 
+               javax.security.jacc,
+               org.jboss.classloading.spi, 
+               org.jboss.deployers.client.plugins.deployment, 
+               org.jboss.deployers.client.spi, 
+               org.jboss.deployers.spi.attachments, 
+               org.jboss.deployers.spi.structure, 
+               org.jboss.deployers.structure.spi, 
+               org.jboss.metadata.javaee.spec, 
+               org.jboss.metadata.javaee.support, 
+               org.jboss.metadata.web.jboss, 
+               org.jboss.metadata.web.spec, 
+               org.jboss.mx.util, 
+               org.jboss.osgi.service, 
+               org.jboss.osgi.spi, 
+               org.jboss.osgi.spi.framework, 
+               org.jboss.virtual, 
+               org.jboss.web, 
+               org.osgi.framework,
+               org.osgi.service.http,
+               org.osgi.util.tracker
             </Import-Package>
           </instructions>
         </configuration>

Copied: projects/jboss-felix/trunk/modules/service/http/src/main/java/org/jboss/osgi/service/http/GenericEndpointServlet.java (from rev 84117, projects/jboss-felix/trunk/modules/service/http-beans/src/main/java/org/jboss/osgi/service/http/beans/GenericEndpointServlet.java)
===================================================================
--- projects/jboss-felix/trunk/modules/service/http/src/main/java/org/jboss/osgi/service/http/GenericEndpointServlet.java	                        (rev 0)
+++ projects/jboss-felix/trunk/modules/service/http/src/main/java/org/jboss/osgi/service/http/GenericEndpointServlet.java	2009-02-12 13:51:34 UTC (rev 84123)
@@ -0,0 +1,131 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.service.http;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.jboss.mx.util.MBeanProxy;
+import org.jboss.mx.util.MBeanProxyCreationException;
+import org.jboss.osgi.service.MicrocontainerService;
+import org.jboss.osgi.spi.ObjectNameFactory;
+import org.jboss.osgi.spi.framework.OSGiConfiguration;
+import org.jboss.osgi.spi.framework.OSGiFramework;
+import org.jboss.virtual.VFSUtils;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+
+/**
+ * A generic servlet that handles http service requests
+ * 
+ * @author Thomas.Diesler at jboss.org
+ * @since 05-Feb-2009
+ */
+ at SuppressWarnings("serial")
+public class GenericEndpointServlet extends HttpServlet
+{
+  private ObjectName httpContextName;
+  private ObjectName httpServletName;
+  private ManagedHttpContextMBean httpContext;
+  private ManagedServletMBean httpServlet;
+  private String resourceLocation;
+
+  @Override
+  public void init(ServletConfig config) throws ServletException
+  {
+    super.init(config);
+
+    // Get the MBeanServer
+    OSGiFramework framework = OSGiConfiguration.getFramework();
+    BundleContext context = framework.getSystemBundleContext();
+    ServiceReference sref = context.getServiceReference(MicrocontainerService.class.getName());
+    MicrocontainerService service = (MicrocontainerService)context.getService(sref);
+    MBeanServer server = service.getMbeanServer();
+
+    try
+    {
+      // Get the HttpContext, which must alway be there
+      httpContextName = ObjectNameFactory.create(getInitParameter(HttpEndpointDeployer.INIT_PARAM_HTTP_CONTEXT_NAME));
+      httpContext = (ManagedHttpContextMBean)MBeanProxy.get(ManagedHttpContextMBean.class, httpContextName, server);
+      
+      // Get the HttpSerlet, which must be there for a registered servlet
+      String servletName = getInitParameter(HttpEndpointDeployer.INIT_PARAM_SERVLET_NAME);
+      if (servletName != null)
+      {
+        httpServletName = ObjectNameFactory.create(servletName);
+        httpServlet = (ManagedServletMBean)MBeanProxy.get(ManagedServletMBean.class, httpServletName, server);
+        httpServlet.init(config);
+      }
+      
+      // Get the resource location, which must be there for a registered resources
+      resourceLocation = getInitParameter(HttpEndpointDeployer.INIT_PARAM_RESOURCE_LOCATION);
+    }
+    catch (MBeanProxyCreationException ex)
+    {
+      throw new ServletException("Cannot obtain MBeanProxy", ex);
+    }
+  }
+
+  @Override
+  protected void service(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
+  {
+    // Handle a service request to a registered servlet
+    if (httpServlet != null)
+    {
+      httpServlet.service(req, res);
+    }
+    
+    // Handle a service request to a registered resource
+    else 
+    {
+      String resourcePath = resourceLocation + req.getPathInfo();
+
+      URL resourceUrl = httpContext.getResource(resourcePath);
+      if (resourceUrl != null)
+      {
+        String mimeType = httpContext.getMimeType(resourcePath);
+        if (mimeType != null)
+          res.setContentType(mimeType);
+
+        ServletOutputStream outStream = res.getOutputStream();
+        InputStream inStream = resourceUrl.openStream();
+        VFSUtils.copyStream(inStream, outStream);
+        outStream.close();
+        inStream.close();
+      }
+      else
+      {
+        res.sendError(HttpServletResponse.SC_NOT_FOUND, resourcePath);
+      }
+    }
+  }
+}


Property changes on: projects/jboss-felix/trunk/modules/service/http/src/main/java/org/jboss/osgi/service/http/GenericEndpointServlet.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:mergeinfo
   + 
Name: svn:eol-style
   + LF

Copied: projects/jboss-felix/trunk/modules/service/http/src/main/java/org/jboss/osgi/service/http/HttpEndpointDeployer.java (from rev 84117, projects/jboss-felix/trunk/modules/service/http-beans/src/main/java/org/jboss/osgi/service/http/beans/HttpEndpointDeployer.java)
===================================================================
--- projects/jboss-felix/trunk/modules/service/http/src/main/java/org/jboss/osgi/service/http/HttpEndpointDeployer.java	                        (rev 0)
+++ projects/jboss-felix/trunk/modules/service/http/src/main/java/org/jboss/osgi/service/http/HttpEndpointDeployer.java	2009-02-12 13:51:34 UTC (rev 84123)
@@ -0,0 +1,274 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.service.http;
+
+import java.util.Dictionary;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+import javax.servlet.Servlet;
+
+import org.jboss.deployers.client.plugins.deployment.AbstractDeployment;
+import org.jboss.deployers.client.spi.DeployerClient;
+import org.jboss.deployers.client.spi.Deployment;
+import org.jboss.deployers.client.spi.DeploymentFactory;
+import org.jboss.deployers.spi.attachments.MutableAttachments;
+import org.jboss.deployers.structure.spi.ClassLoaderFactory;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.metadata.web.jboss.JBossWebMetaData;
+import org.jboss.osgi.service.MicrocontainerService;
+import org.jboss.osgi.spi.ObjectNameFactory;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.util.tracker.ServiceTracker;
+
+/**
+ * Generates a webapp for a HttpService servlet registration
+ * 
+ * @author Thomas.Diesler at jboss.org
+ * @since 26-Jan-2009
+ */
+public class HttpEndpointDeployer
+{
+  static final String INIT_PARAM_RESOURCE_LOCATION = "org.jboss.osgi.service.http.resource.location";
+  static final String INIT_PARAM_HTTP_CONTEXT_NAME = "org.jboss.osgi.service.http.context.name";
+  static final String INIT_PARAM_SERVLET_NAME = "org.jboss.osgi.service.http.servlet.name";
+
+  private DeployerClient mainDeployer;
+  private MBeanServer mbeanServer;
+
+  private DeploymentFactory factory = new DeploymentFactory();
+  private Map<String, Deployment> deployments = new HashMap<String, Deployment>();
+
+  public HttpEndpointDeployer(BundleContext context)
+  {
+    ServiceTracker tracker = new ServiceTracker(context, MicrocontainerService.class.getName(), null)
+    {
+      @Override
+      public Object addingService(ServiceReference reference)
+      {
+        MicrocontainerService mcService = (MicrocontainerService)super.addingService(reference);
+        mainDeployer = (DeployerClient)mcService.getRegisteredBean("MainDeployer");
+        mbeanServer = mcService.getMbeanServer();
+        return mcService;
+      }
+    };
+    tracker.open();
+  }
+
+  @SuppressWarnings("unchecked")
+  public void registerServlet(String alias, ManagedServlet servlet, Dictionary initParams, ManagedHttpContext httpContext)
+  {
+    registerServletInternal(alias, servlet, initParams, httpContext);
+  }
+
+  public void registerResources(String alias, String name, ManagedHttpContext httpContext)
+  {
+    Properties initParams = new Properties();
+    initParams.setProperty(HttpEndpointDeployer.INIT_PARAM_RESOURCE_LOCATION, name);
+    registerServletInternal(alias, null, initParams, httpContext);
+  }
+
+  public void unregister(String alias)
+  {
+    assertAlias(alias);
+
+    Deployment deployment = deployments.remove(alias);
+    if (deployment != null)
+    {
+      try
+      {
+        if (mainDeployer != null)
+          mainDeployer.undeploy(deployment);
+
+        MutableAttachments mutableAttachments = (MutableAttachments)deployment.getPredeterminedManagedObjects();
+        unregisterManagedObject(mutableAttachments.getAttachment(INIT_PARAM_HTTP_CONTEXT_NAME, ObjectName.class));
+        unregisterManagedObject(mutableAttachments.getAttachment(INIT_PARAM_SERVLET_NAME, ObjectName.class));
+        unregisterManagedObject(mutableAttachments.getAttachment(HttpServiceClassLoader.class.getName(), ObjectName.class));
+      }
+      catch (Exception ex)
+      {
+        throw new IllegalStateException("Cannot undeploy webapp: " + alias, ex);
+      }
+    }
+  }
+
+  @SuppressWarnings("unchecked")
+  private void registerServletInternal(String alias, ManagedServlet servlet, Dictionary initParams, ManagedHttpContext httpContext)
+  {
+    assertAlias(alias);
+
+    if (initParams == null)
+      initParams = new Properties();
+
+    ObjectName contextName = null;
+    ObjectName loaderName = null;
+    ObjectName servletName = null;
+    try
+    {
+      contextName = registerHttpContext(alias, httpContext);
+      initParams.put(INIT_PARAM_HTTP_CONTEXT_NAME, contextName.getCanonicalName());
+
+      HttpServiceClassLoader classLoader = null;
+      if (servlet != null)
+      {
+        ClassLoader osgiLoader = servlet.getClassLoader();
+        classLoader = createHttpServiceClassLoader(osgiLoader);
+        loaderName = registerClassLoader(alias, classLoader);
+        
+        servletName = registerServlet(alias, servlet);
+        initParams.put(INIT_PARAM_SERVLET_NAME, servletName.getCanonicalName());
+      }
+
+      // Add the registered objects to the deployment, so that they can be unregistered again
+      Deployment deployment = deployWebApp(alias, new GenericEndpointServlet(), initParams, classLoader);
+      MutableAttachments mutableAttachments = (MutableAttachments)deployment.getPredeterminedManagedObjects();
+      mutableAttachments.addAttachment(INIT_PARAM_HTTP_CONTEXT_NAME, contextName, ObjectName.class);
+      
+      if (servlet != null)
+      {
+        mutableAttachments.addAttachment(INIT_PARAM_SERVLET_NAME, servletName, ObjectName.class);
+      }
+    }
+    catch (RuntimeException rte)
+    {
+      unregisterManagedObject(contextName);
+      unregisterManagedObject(loaderName);
+      unregisterManagedObject(servletName);
+      throw rte;
+    }
+    catch (Exception ex)
+    {
+      unregisterManagedObject(contextName);
+      unregisterManagedObject(loaderName);
+      unregisterManagedObject(servletName);
+      throw new IllegalStateException("Cannot deploy webapp: " + alias, ex);
+    }
+  }
+
+  private ObjectName registerServlet(String alias, ManagedServlet managedServlet) throws Exception
+  {
+    ObjectName objectName = ObjectNameFactory.create("jboss.osgi:service=http,object=servlet,alias=" + alias);
+    mbeanServer.registerMBean(managedServlet, objectName);
+    return objectName;
+  }
+
+  private ObjectName registerHttpContext(String alias, ManagedHttpContext managedContext) throws Exception
+  {
+    ObjectName objectName = ObjectNameFactory.create("jboss.osgi:service=http,object=httpcontext,alias=" + alias);
+    mbeanServer.registerMBean(managedContext, objectName);
+    return objectName;
+  }
+
+  private ObjectName registerClassLoader(String alias, HttpServiceClassLoader classLoader) throws Exception
+  {
+    ObjectName objectName = ObjectNameFactory.create("jboss.osgi:service=http,object=classloader,alias=" + alias);
+    mbeanServer.registerMBean(classLoader, objectName);
+    classLoader.setObjectName(objectName);
+    return objectName;
+  }
+
+  @SuppressWarnings("unchecked")
+  private Deployment deployWebApp(String alias, Servlet servlet, Dictionary initParams, HttpServiceClassLoader classLoader) throws Exception
+  {
+    WebMetaDataFactory metaDatafactory = new WebMetaDataFactory();
+    JBossWebMetaData jbwmd = metaDatafactory.generateWebMetaData(alias, servlet, initParams);
+
+    String contextRoot = jbwmd.getContextRoot();
+
+    Deployment deployment = deployments.get(contextRoot);
+    if (deployment != null)
+      throw new IllegalStateException("HttpService alias already deployed: " + contextRoot);
+
+    String depName = "http://osgi-http-service" + contextRoot;
+    deployment = new AbstractDeployment(depName);
+    factory.addContext(deployment, "");
+
+    metaDatafactory.generateJACCPermissions(depName, jbwmd);
+
+    MutableAttachments mutableAttachments = (MutableAttachments)deployment.getPredeterminedManagedObjects();
+    mutableAttachments.addAttachment("org.jboss.web.explicitDocBase", "/", String.class);
+    mutableAttachments.addAttachment(JBossWebMetaData.class, jbwmd);
+    
+    if (classLoader != null)
+    {
+      mutableAttachments.addAttachment(ClassLoaderFactory.class, new ContextClassLoaderFactory(classLoader));
+      mutableAttachments.addAttachment(HttpServiceClassLoader.class.getName(), classLoader.getObjectName(), ObjectName.class);
+    }
+
+    mainDeployer.deploy(deployment);
+
+    deployments.put(contextRoot, deployment);
+    return deployment;
+  }
+
+  private HttpServiceClassLoader createHttpServiceClassLoader(ClassLoader osgiLoader) throws Exception
+  {
+    ClassLoader kernelLoader = mainDeployer.getClass().getClassLoader();
+    HttpServiceClassLoader classLoader = new HttpServiceClassLoader(kernelLoader, osgiLoader);
+    return classLoader;
+  }
+
+  private void unregisterManagedObject(ObjectName objectName)
+  {
+    if (objectName != null && mbeanServer != null && mbeanServer.isRegistered(objectName))
+    {
+      try
+      {
+        mbeanServer.unregisterMBean(objectName);
+      }
+      catch (Exception ex)
+      {
+        // ignore;
+      }
+    }
+  }
+
+  private void assertAlias(String alias)
+  {
+    if (alias.equals("/") == false && (alias.startsWith("/") == false || alias.endsWith("/")))
+      throw new IllegalArgumentException("An alias must begin with slash ('/') and must not end with slash ('/')");
+  }
+
+  private static class ContextClassLoaderFactory implements ClassLoaderFactory
+  {
+    private ClassLoader classLoader;
+
+    public ContextClassLoaderFactory(ClassLoader classLoader)
+    {
+      this.classLoader = classLoader;
+    }
+
+    public ClassLoader createClassLoader(DeploymentUnit unit) throws Exception
+    {
+      return classLoader;
+    }
+
+    public void removeClassLoader(DeploymentUnit unit) throws Exception
+    {
+      classLoader = null;
+    }
+  }
+}


Property changes on: projects/jboss-felix/trunk/modules/service/http/src/main/java/org/jboss/osgi/service/http/HttpEndpointDeployer.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:mergeinfo
   + 
Name: svn:eol-style
   + LF

Copied: projects/jboss-felix/trunk/modules/service/http/src/main/java/org/jboss/osgi/service/http/HttpServiceClassLoader.java (from rev 84117, projects/jboss-felix/trunk/modules/service/http-beans/src/main/java/org/jboss/osgi/service/http/beans/HttpServiceClassLoader.java)
===================================================================
--- projects/jboss-felix/trunk/modules/service/http/src/main/java/org/jboss/osgi/service/http/HttpServiceClassLoader.java	                        (rev 0)
+++ projects/jboss-felix/trunk/modules/service/http/src/main/java/org/jboss/osgi/service/http/HttpServiceClassLoader.java	2009-02-12 13:51:34 UTC (rev 84123)
@@ -0,0 +1,104 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.service.http;
+
+import java.net.URL;
+import java.security.SecureClassLoader;
+
+import javax.management.ObjectName;
+
+
+/**
+ * A ClassLoader that implements RealClassLoader and delegates to 
+ * the JBoss system classloader when a class cannot be found in the 
+ * OSGi class loader.
+ * 
+ * @author Thomas.Diesler at jboss.org
+ * @since 29-Jan-2009
+ */
+public class HttpServiceClassLoader extends SecureClassLoader implements HttpServiceClassLoaderMBean
+{
+  private ClassLoader osgiLoader;
+  private ObjectName objectName;
+
+  public HttpServiceClassLoader(ClassLoader kernelLoader, ClassLoader osgiLoader)
+  {
+    super(kernelLoader);
+    this.osgiLoader = osgiLoader;
+  }
+
+  public ObjectName getObjectName()
+  {
+    return objectName;
+  }
+
+  public void setObjectName(ObjectName objectName)
+  {
+    this.objectName = objectName;
+  }
+
+  @Override
+  public Class<?> loadClass(String name) throws ClassNotFoundException
+  {
+    Class<?> clazz;
+    try
+    {
+      clazz = osgiLoader.loadClass(name);
+    }
+    catch (ClassNotFoundException ex)
+    {
+      clazz = super.loadClass(name);
+    }
+    return clazz;
+  }
+
+  @Override
+  public URL getResource(String name)
+  {
+    URL resUrl = osgiLoader.getResource(name);
+    return resUrl;
+  }
+
+  public void clearBlackList(String name)
+  {
+  }
+
+  public Class<?> getCachedClass(String name)
+  {
+    return null;
+  }
+
+  public URL getCachedResource(String name)
+  {
+    return null;
+  }
+
+  public boolean isValid()
+  {
+    return true;
+  }
+
+  public URL getResourceLocally(String name)
+  {
+    return null;
+  }
+}


Property changes on: projects/jboss-felix/trunk/modules/service/http/src/main/java/org/jboss/osgi/service/http/HttpServiceClassLoader.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:mergeinfo
   + 
Name: svn:eol-style
   + LF

Copied: projects/jboss-felix/trunk/modules/service/http/src/main/java/org/jboss/osgi/service/http/HttpServiceClassLoaderMBean.java (from rev 84117, projects/jboss-felix/trunk/modules/service/http-beans/src/main/java/org/jboss/osgi/service/http/beans/HttpServiceClassLoaderMBean.java)
===================================================================
--- projects/jboss-felix/trunk/modules/service/http/src/main/java/org/jboss/osgi/service/http/HttpServiceClassLoaderMBean.java	                        (rev 0)
+++ projects/jboss-felix/trunk/modules/service/http/src/main/java/org/jboss/osgi/service/http/HttpServiceClassLoaderMBean.java	2009-02-12 13:51:34 UTC (rev 84123)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.service.http;
+
+import org.jboss.classloading.spi.RealClassLoader;
+
+/**
+ * The associated MBean interface 
+ * 
+ * @author Thomas.Diesler at jboss.org
+ * @since 29-Jan-2009
+ */
+public interface HttpServiceClassLoaderMBean extends RealClassLoader
+{
+}


Property changes on: projects/jboss-felix/trunk/modules/service/http/src/main/java/org/jboss/osgi/service/http/HttpServiceClassLoaderMBean.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:mergeinfo
   + 
Name: svn:eol-style
   + LF

Modified: projects/jboss-felix/trunk/modules/service/http/src/main/java/org/jboss/osgi/service/http/HttpServiceImpl.java
===================================================================
--- projects/jboss-felix/trunk/modules/service/http/src/main/java/org/jboss/osgi/service/http/HttpServiceImpl.java	2009-02-12 12:23:20 UTC (rev 84122)
+++ projects/jboss-felix/trunk/modules/service/http/src/main/java/org/jboss/osgi/service/http/HttpServiceImpl.java	2009-02-12 13:51:34 UTC (rev 84123)
@@ -28,9 +28,6 @@
 import javax.servlet.Servlet;
 import javax.servlet.ServletException;
 
-import org.jboss.osgi.service.http.beans.HttpEndpointDeployer;
-import org.jboss.osgi.service.http.beans.ManagedHttpContext;
-import org.jboss.osgi.service.http.beans.ManagedServlet;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceReference;
@@ -47,15 +44,12 @@
 public class HttpServiceImpl implements HttpService
 {
   private Bundle bundle;
-  private HttpEndpointDeployer webappService;
+  private HttpEndpointDeployer webappDeployer;
 
   public HttpServiceImpl(Bundle bundle)
   {
     this.bundle = bundle;
-    
-    BundleContext bundleContext = bundle.getBundleContext();
-    ServiceReference sref = bundleContext.getServiceReference(HttpEndpointDeployer.class.getName());
-    webappService = (HttpEndpointDeployer)bundleContext.getService(sref);
+    this.webappDeployer = new HttpEndpointDeployer(bundle.getBundleContext());
   }
 
   public HttpContext createDefaultHttpContext()
@@ -69,7 +63,7 @@
     if (httpContext == null)
       httpContext = createDefaultHttpContext();
     
-      webappService.registerServlet(alias, new ManagedServlet(servlet), initParams, new ManagedHttpContext(httpContext));
+      webappDeployer.registerServlet(alias, new ManagedServlet(servlet), initParams, new ManagedHttpContext(httpContext));
   }
 
   public void registerResources(String alias, String name, HttpContext httpContext) throws NamespaceException
@@ -77,11 +71,11 @@
     if (httpContext == null)
       httpContext = createDefaultHttpContext();
     
-      webappService.registerResources(alias, name, new ManagedHttpContext(httpContext));
+      webappDeployer.registerResources(alias, name, new ManagedHttpContext(httpContext));
   }
 
   public void unregister(String alias)
   {
-    webappService.unregister(alias);
+    webappDeployer.unregister(alias);
   }
 }
\ No newline at end of file

Copied: projects/jboss-felix/trunk/modules/service/http/src/main/java/org/jboss/osgi/service/http/ManagedHttpContext.java (from rev 84117, projects/jboss-felix/trunk/modules/service/http-beans/src/main/java/org/jboss/osgi/service/http/beans/ManagedHttpContext.java)
===================================================================
--- projects/jboss-felix/trunk/modules/service/http/src/main/java/org/jboss/osgi/service/http/ManagedHttpContext.java	                        (rev 0)
+++ projects/jboss-felix/trunk/modules/service/http/src/main/java/org/jboss/osgi/service/http/ManagedHttpContext.java	2009-02-12 13:51:34 UTC (rev 84123)
@@ -0,0 +1,63 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.service.http;
+
+//$Id$
+
+import java.io.IOException;
+import java.net.URL;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.osgi.service.http.HttpContext;
+
+/**
+ * An HTTPContext that can be registered with the MBeanServer
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 23-Jan-2009
+ */
+public class ManagedHttpContext implements ManagedHttpContextMBean
+{
+  private HttpContext httpContext;
+
+  public ManagedHttpContext(Object delegate)
+  {
+    this.httpContext = (HttpContext)delegate;
+  }
+
+  public String getMimeType(String name)
+  {
+    return httpContext.getMimeType(name);
+  }
+
+  public URL getResource(String name)
+  {
+    return httpContext.getResource(name);
+  }
+
+  public boolean handleSecurity(HttpServletRequest req, HttpServletResponse res) throws IOException
+  {
+    return httpContext.handleSecurity(req, res);
+  }
+}
\ No newline at end of file


Property changes on: projects/jboss-felix/trunk/modules/service/http/src/main/java/org/jboss/osgi/service/http/ManagedHttpContext.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:mergeinfo
   + 
Name: svn:eol-style
   + LF

Copied: projects/jboss-felix/trunk/modules/service/http/src/main/java/org/jboss/osgi/service/http/ManagedHttpContextMBean.java (from rev 84117, projects/jboss-felix/trunk/modules/service/http-beans/src/main/java/org/jboss/osgi/service/http/beans/ManagedHttpContextMBean.java)
===================================================================
--- projects/jboss-felix/trunk/modules/service/http/src/main/java/org/jboss/osgi/service/http/ManagedHttpContextMBean.java	                        (rev 0)
+++ projects/jboss-felix/trunk/modules/service/http/src/main/java/org/jboss/osgi/service/http/ManagedHttpContextMBean.java	2009-02-12 13:51:34 UTC (rev 84123)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.service.http;
+
+import java.io.IOException;
+import java.net.URL;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * An MBean interface for the HttpContext
+ * 
+ * @author Thomas.Diesler at jboss.org
+ * @since 06-Feb-2009
+ */
+public interface ManagedHttpContextMBean
+{
+  String getMimeType(String name);
+
+  URL getResource(String name);
+
+  boolean handleSecurity(HttpServletRequest req, HttpServletResponse res) throws IOException;
+}


Property changes on: projects/jboss-felix/trunk/modules/service/http/src/main/java/org/jboss/osgi/service/http/ManagedHttpContextMBean.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:mergeinfo
   + 
Name: svn:eol-style
   + LF

Copied: projects/jboss-felix/trunk/modules/service/http/src/main/java/org/jboss/osgi/service/http/ManagedServlet.java (from rev 84117, projects/jboss-felix/trunk/modules/service/http-beans/src/main/java/org/jboss/osgi/service/http/beans/ManagedServlet.java)
===================================================================
--- projects/jboss-felix/trunk/modules/service/http/src/main/java/org/jboss/osgi/service/http/ManagedServlet.java	                        (rev 0)
+++ projects/jboss-felix/trunk/modules/service/http/src/main/java/org/jboss/osgi/service/http/ManagedServlet.java	2009-02-12 13:51:34 UTC (rev 84123)
@@ -0,0 +1,81 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.service.http;
+
+//$Id$
+
+import java.io.IOException;
+
+import javax.servlet.Servlet;
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+
+
+/**
+ * A Servlet that can be registered with the MBeanServer
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 23-Jan-2009
+ */
+public class ManagedServlet implements ManagedServletMBean
+{
+  private Servlet delegate;
+  private ClassLoader classLoader;
+
+  public ManagedServlet(Servlet delegate)
+  {
+    this.delegate = delegate;
+    this.classLoader = delegate.getClass().getClassLoader();
+  }
+
+  public ClassLoader getClassLoader()
+  {
+    return classLoader;
+  }
+
+  public void destroy()
+  {
+    delegate.destroy();
+  }
+
+  public ServletConfig getServletConfig()
+  {
+    return delegate.getServletConfig();
+  }
+
+  public String getServletInfo()
+  {
+    return delegate.getServletInfo();
+  }
+
+  public void init(ServletConfig config) throws ServletException
+  {
+    delegate.init(config);
+  }
+
+  public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException
+  {
+    delegate.service(req, res);
+  }
+}
\ No newline at end of file


Property changes on: projects/jboss-felix/trunk/modules/service/http/src/main/java/org/jboss/osgi/service/http/ManagedServlet.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:mergeinfo
   + 
Name: svn:eol-style
   + LF

Copied: projects/jboss-felix/trunk/modules/service/http/src/main/java/org/jboss/osgi/service/http/ManagedServletMBean.java (from rev 84117, projects/jboss-felix/trunk/modules/service/http-beans/src/main/java/org/jboss/osgi/service/http/beans/ManagedServletMBean.java)
===================================================================
--- projects/jboss-felix/trunk/modules/service/http/src/main/java/org/jboss/osgi/service/http/ManagedServletMBean.java	                        (rev 0)
+++ projects/jboss-felix/trunk/modules/service/http/src/main/java/org/jboss/osgi/service/http/ManagedServletMBean.java	2009-02-12 13:51:34 UTC (rev 84123)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.service.http;
+
+//$Id$
+
+import javax.servlet.Servlet;
+
+/**
+ * A Servlet that can be registered with the MBeanServer
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 23-Jan-2009
+ */
+public interface ManagedServletMBean extends Servlet
+{
+  ClassLoader getClassLoader();
+}
\ No newline at end of file


Property changes on: projects/jboss-felix/trunk/modules/service/http/src/main/java/org/jboss/osgi/service/http/ManagedServletMBean.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:mergeinfo
   + 
Name: svn:eol-style
   + LF

Copied: projects/jboss-felix/trunk/modules/service/http/src/main/java/org/jboss/osgi/service/http/WebMetaDataFactory.java (from rev 84117, projects/jboss-felix/trunk/modules/service/http-beans/src/main/java/org/jboss/osgi/service/http/beans/WebMetaDataFactory.java)
===================================================================
--- projects/jboss-felix/trunk/modules/service/http/src/main/java/org/jboss/osgi/service/http/WebMetaDataFactory.java	                        (rev 0)
+++ projects/jboss-felix/trunk/modules/service/http/src/main/java/org/jboss/osgi/service/http/WebMetaDataFactory.java	2009-02-12 13:51:34 UTC (rev 84123)
@@ -0,0 +1,129 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.service.http;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Dictionary;
+import java.util.Enumeration;
+import java.util.List;
+
+import javax.security.jacc.PolicyConfiguration;
+import javax.security.jacc.PolicyConfigurationFactory;
+import javax.security.jacc.PolicyContextException;
+import javax.servlet.Servlet;
+
+import org.jboss.metadata.javaee.spec.ParamValueMetaData;
+import org.jboss.metadata.web.jboss.JBossServletMetaData;
+import org.jboss.metadata.web.jboss.JBossServletsMetaData;
+import org.jboss.metadata.web.jboss.JBossWebMetaData;
+import org.jboss.metadata.web.spec.ServletMappingMetaData;
+import org.jboss.web.WebPermissionMapping;
+
+/**
+ * Generates a webapp for a HttpService servlet registration
+ * 
+ * @author Thomas.Diesler at jboss.org
+ * @since 26-Jan-2009
+ */
+public class WebMetaDataFactory
+{
+  @SuppressWarnings("unchecked")
+  public JBossWebMetaData generateWebMetaData(String alias, Servlet servletImpl, Dictionary initParams)
+  {
+    String servletClass = servletImpl.getClass().getName();
+    String servletName = servletClass;
+
+    JBossWebMetaData jbwmd = new JBossWebMetaData();
+    jbwmd.setContextRoot(alias);
+
+    /*
+     * <servlet> 
+     *  <servlet-name> 
+     *  <servlet-class> 
+     * </servlet>
+     */
+    JBossServletsMetaData servlets = jbwmd.getServlets();
+    JBossServletMetaData servlet = new JBossServletMetaData();
+    servlet.setServletName(servletName);
+    servlet.setServletClass(servletClass);
+    servlets.add(servlet);
+
+    /*
+     * <init-param>
+     *  <param-name>
+     *  <param-value>
+     * </init-param>
+     */
+    if (initParams != null)
+    {
+      List<ParamValueMetaData> servletParams = servlet.getInitParam();
+      if (servletParams == null)
+      {
+        servletParams = new ArrayList<ParamValueMetaData>();
+        servlet.setInitParam(servletParams);
+      }
+      Enumeration en = initParams.keys();
+      while (en.hasMoreElements())
+      {
+        String name = (String)en.nextElement();
+        String value = (String)initParams.get(name);
+        ParamValueMetaData param = new ParamValueMetaData();
+        param.setParamName(name);
+        param.setParamValue(value);
+        servletParams.add(param);
+      }
+    }
+
+    /*
+     * <servlet-mapping> 
+     *  <servlet-name> 
+     *  <url-pattern> 
+     * </servlet-mapping>
+     */
+    List<ServletMappingMetaData> servletMappings = jbwmd.getServletMappings();
+    if (servletMappings == null)
+    {
+      servletMappings = new ArrayList<ServletMappingMetaData>();
+      jbwmd.setServletMappings(servletMappings);
+    }
+    ServletMappingMetaData servletMapping = new ServletMappingMetaData();
+    servletMapping.setServletName(servletName);
+    servletMapping.setUrlPatterns(Arrays.asList(new String[] { "/*" }));
+    servletMappings.add(servletMapping);
+
+    return jbwmd;
+  }
+
+  /**
+   * JBAS-5935: The dynamic web application does not go through the war security deployer. 
+   * Hence the JACC permissions are not created. There is a need to explicitly create
+   * the war jacc permissions.
+   */
+  public void generateJACCPermissions(String depName, JBossWebMetaData jbwmd) throws ClassNotFoundException, PolicyContextException
+  {
+    PolicyConfigurationFactory policyConfigurationFactory = PolicyConfigurationFactory.getPolicyConfigurationFactory();
+    PolicyConfiguration policyConfiguration = policyConfigurationFactory.getPolicyConfiguration(depName, false);
+    WebPermissionMapping.createPermissions(jbwmd, policyConfiguration);
+    policyConfiguration.commit();
+  }
+}


Property changes on: projects/jboss-felix/trunk/modules/service/http/src/main/java/org/jboss/osgi/service/http/WebMetaDataFactory.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:mergeinfo
   + 
Name: svn:eol-style
   + LF

Modified: projects/jboss-felix/trunk/modules/service/pom.xml
===================================================================
--- projects/jboss-felix/trunk/modules/service/pom.xml	2009-02-12 12:23:20 UTC (rev 84122)
+++ projects/jboss-felix/trunk/modules/service/pom.xml	2009-02-12 13:51:34 UTC (rev 84123)
@@ -18,7 +18,6 @@
 
   <modules>
     <module>http</module>
-    <module>http-beans</module>
   </modules>
 
 </project>




More information about the jboss-cvs-commits mailing list