[jboss-cvs] JBossAS SVN: r83605 - in projects/jboss-felix/trunk/modules: felix/.settings and 5 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Jan 29 06:23:44 EST 2009
Author: thomas.diesler at jboss.com
Date: 2009-01-29 06:23:44 -0500 (Thu, 29 Jan 2009)
New Revision: 83605
Added:
projects/jboss-felix/trunk/modules/felix/.settings/org.eclipse.jdt.core.prefs
projects/jboss-felix/trunk/modules/service/http-beans/src/main/java/org/jboss/osgi/service/http/beans/BundleClassLoader.java
projects/jboss-felix/trunk/modules/service/http-beans/src/main/java/org/jboss/osgi/service/http/beans/BundleClassLoaderMBean.java
projects/jboss-felix/trunk/modules/spi/.settings/org.eclipse.jdt.core.prefs
projects/jboss-felix/trunk/modules/spi/.settings/org.maven.ide.eclipse.prefs
Removed:
projects/jboss-felix/trunk/modules/spi/src/main/java/org/jboss/osgi/spi/ObjectNameFactory.java
Modified:
projects/jboss-felix/trunk/modules/felix/.project
projects/jboss-felix/trunk/modules/felix/src/main/resources/jboss-beans.xml
projects/jboss-felix/trunk/modules/service/http-beans/src/main/java/org/jboss/osgi/service/http/beans/WebAppGeneratorService.java
projects/jboss-felix/trunk/modules/spi/src/main/java/org/jboss/osgi/spi/test/IntegrationTestHelper.java
Log:
http context created
Modified: projects/jboss-felix/trunk/modules/felix/.project
===================================================================
--- projects/jboss-felix/trunk/modules/felix/.project 2009-01-29 09:06:43 UTC (rev 83604)
+++ projects/jboss-felix/trunk/modules/felix/.project 2009-01-29 11:23:44 UTC (rev 83605)
@@ -17,7 +17,7 @@
</buildCommand>
</buildSpec>
<natures>
+ <nature>org.maven.ide.eclipse.maven2Nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
- <nature>org.maven.ide.eclipse.maven2Nature</nature>
</natures>
</projectDescription>
Added: projects/jboss-felix/trunk/modules/felix/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- projects/jboss-felix/trunk/modules/felix/.settings/org.eclipse.jdt.core.prefs (rev 0)
+++ projects/jboss-felix/trunk/modules/felix/.settings/org.eclipse.jdt.core.prefs 2009-01-29 11:23:44 UTC (rev 83605)
@@ -0,0 +1,12 @@
+#Thu Jan 29 11:48:03 CET 2009
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
Modified: projects/jboss-felix/trunk/modules/felix/src/main/resources/jboss-beans.xml
===================================================================
--- projects/jboss-felix/trunk/modules/felix/src/main/resources/jboss-beans.xml 2009-01-29 09:06:43 UTC (rev 83604)
+++ projects/jboss-felix/trunk/modules/felix/src/main/resources/jboss-beans.xml 2009-01-29 11:23:44 UTC (rev 83605)
@@ -49,6 +49,7 @@
<bean name="jboss.osgi:service=WebAppGenerator" class="org.jboss.osgi.service.http.beans.WebAppGeneratorService">
<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>
Added: projects/jboss-felix/trunk/modules/service/http-beans/src/main/java/org/jboss/osgi/service/http/beans/BundleClassLoader.java
===================================================================
--- projects/jboss-felix/trunk/modules/service/http-beans/src/main/java/org/jboss/osgi/service/http/beans/BundleClassLoader.java (rev 0)
+++ projects/jboss-felix/trunk/modules/service/http-beans/src/main/java/org/jboss/osgi/service/http/beans/BundleClassLoader.java 2009-01-29 11:23:44 UTC (rev 83605)
@@ -0,0 +1,92 @@
+/*
+ * 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.beans;
+
+import java.net.URL;
+import java.security.SecureClassLoader;
+
+import javax.management.ObjectName;
+
+import org.jboss.classloading.spi.RealClassLoader;
+import org.osgi.framework.Bundle;
+
+/**
+ * A SecureClassLoader that implements the JBoss RealClassLoader
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 29-Jan-2009
+ */
+public class BundleClassLoader extends SecureClassLoader implements BundleClassLoaderMBean, RealClassLoader
+{
+ private ObjectName objectName;
+ private Bundle bundle;
+
+ public BundleClassLoader(Bundle bundle, ClassLoader parent)
+ {
+ super(parent);
+ this.bundle = bundle;
+ }
+
+ public ObjectName getObjectName()
+ {
+ return objectName;
+ }
+
+ public void setObjectName(ObjectName objectName)
+ {
+ this.objectName = objectName;
+ }
+
+ public String getLocation()
+ {
+ return bundle.getLocation();
+ }
+
+ public String getSymbolicName()
+ {
+ return bundle.getSymbolicName();
+ }
+
+ 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-beans/src/main/java/org/jboss/osgi/service/http/beans/BundleClassLoader.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/jboss-felix/trunk/modules/service/http-beans/src/main/java/org/jboss/osgi/service/http/beans/BundleClassLoaderMBean.java
===================================================================
--- projects/jboss-felix/trunk/modules/service/http-beans/src/main/java/org/jboss/osgi/service/http/beans/BundleClassLoaderMBean.java (rev 0)
+++ projects/jboss-felix/trunk/modules/service/http-beans/src/main/java/org/jboss/osgi/service/http/beans/BundleClassLoaderMBean.java 2009-01-29 11:23:44 UTC (rev 83605)
@@ -0,0 +1,42 @@
+/*
+ * 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.beans;
+
+/**
+ * The associated MBean interface
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 29-Jan-2009
+ */
+public interface BundleClassLoaderMBean
+{
+ /**
+ * Get the symbolic name of the associated bundle;
+ */
+ String getSymbolicName();
+
+ /**
+ * Get the location of the associated bundle;
+ */
+ String getLocation();
+
+}
Property changes on: projects/jboss-felix/trunk/modules/service/http-beans/src/main/java/org/jboss/osgi/service/http/beans/BundleClassLoaderMBean.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: projects/jboss-felix/trunk/modules/service/http-beans/src/main/java/org/jboss/osgi/service/http/beans/WebAppGeneratorService.java
===================================================================
--- projects/jboss-felix/trunk/modules/service/http-beans/src/main/java/org/jboss/osgi/service/http/beans/WebAppGeneratorService.java 2009-01-29 09:06:43 UTC (rev 83604)
+++ projects/jboss-felix/trunk/modules/service/http-beans/src/main/java/org/jboss/osgi/service/http/beans/WebAppGeneratorService.java 2009-01-29 11:23:44 UTC (rev 83605)
@@ -26,8 +26,12 @@
import java.util.Dictionary;
import java.util.List;
+import javax.management.MBeanServer;
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
import javax.servlet.Servlet;
+import org.jboss.classloading.spi.RealClassLoader;
import org.jboss.deployers.client.plugins.deployment.AbstractDeployment;
import org.jboss.deployers.client.spi.DeployerClient;
import org.jboss.deployers.client.spi.DeploymentFactory;
@@ -38,6 +42,7 @@
import org.jboss.metadata.web.jboss.JBossServletsMetaData;
import org.jboss.metadata.web.jboss.JBossWebMetaData;
import org.jboss.metadata.web.spec.ServletMappingMetaData;
+import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
/**
@@ -50,6 +55,7 @@
{
private BundleContext bundleContext;
private DeployerClient mainDeployer;
+ private MBeanServer mbeanServer;
private DeploymentFactory factory = new DeploymentFactory();
@@ -63,6 +69,11 @@
this.mainDeployer = mainDeployer;
}
+ public void setMbeanServer(MBeanServer mbeanServer)
+ {
+ this.mbeanServer = mbeanServer;
+ }
+
public void registerServlet(String alias, Servlet servlet, Dictionary<String, String> initParams)
{
JBossWebMetaData jbwmd = generatWebDeployment(alias, servlet);
@@ -73,6 +84,18 @@
factory.addContext(deployment, "");
ClassLoader classLoader = servlet.getClass().getClassLoader();
+ RealClassLoader realClassLoader = getRealClassLoader(classLoader);
+ if (realClassLoader == null)
+ {
+ Bundle bundle = bundleContext.getBundle();
+ ObjectName objectName = getObjectName(bundle, alias);
+ BundleClassLoader bundleCL = new BundleClassLoader(bundle, classLoader);
+
+ mbeanServer.registerMBean(bundleCL, objectName);
+ bundleCL.setObjectName(objectName);
+
+ classLoader = bundleCL;
+ }
MutableAttachments mutableAttachments = (MutableAttachments)deployment.getPredeterminedManagedObjects();
mutableAttachments.addAttachment(ClassLoaderFactory.class, new ContextClassLoaderFactory(classLoader));
@@ -85,6 +108,31 @@
}
}
+ private RealClassLoader getRealClassLoader(ClassLoader classLoader)
+ {
+ RealClassLoader realCL = null;
+
+ if (classLoader instanceof RealClassLoader)
+ realCL = (RealClassLoader)classLoader;
+ else if (classLoader.getParent() != null)
+ realCL = getRealClassLoader(classLoader.getParent());
+
+ return realCL;
+ }
+
+ private ObjectName getObjectName(Bundle bundle, String alias)
+ {
+ String namestr = "jboss.classloader:bundle=" + bundle.getSymbolicName() + ",alias=" + alias;
+ try
+ {
+ return new ObjectName(namestr);
+ }
+ catch (MalformedObjectNameException ex)
+ {
+ throw new IllegalArgumentException("Malformed object name: " + namestr);
+ }
+ }
+
public JBossWebMetaData generatWebDeployment(String alias, Servlet servletImpl)
{
String servletName = alias;
Added: projects/jboss-felix/trunk/modules/spi/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- projects/jboss-felix/trunk/modules/spi/.settings/org.eclipse.jdt.core.prefs (rev 0)
+++ projects/jboss-felix/trunk/modules/spi/.settings/org.eclipse.jdt.core.prefs 2009-01-29 11:23:44 UTC (rev 83605)
@@ -0,0 +1,12 @@
+#Thu Jan 29 11:47:25 CET 2009
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
Added: projects/jboss-felix/trunk/modules/spi/.settings/org.maven.ide.eclipse.prefs
===================================================================
--- projects/jboss-felix/trunk/modules/spi/.settings/org.maven.ide.eclipse.prefs (rev 0)
+++ projects/jboss-felix/trunk/modules/spi/.settings/org.maven.ide.eclipse.prefs 2009-01-29 11:23:44 UTC (rev 83605)
@@ -0,0 +1,8 @@
+#Thu Jan 29 11:21:45 CET 2009
+activeProfiles=
+eclipse.preferences.version=1
+fullBuildGoals=process-test-resources
+includeModules=false
+resolveWorkspaceProjects=true
+resourceFilterGoals=process-resources resources\:testResources
+version=1
Deleted: projects/jboss-felix/trunk/modules/spi/src/main/java/org/jboss/osgi/spi/ObjectNameFactory.java
===================================================================
--- projects/jboss-felix/trunk/modules/spi/src/main/java/org/jboss/osgi/spi/ObjectNameFactory.java 2009-01-29 09:06:43 UTC (rev 83604)
+++ projects/jboss-felix/trunk/modules/spi/src/main/java/org/jboss/osgi/spi/ObjectNameFactory.java 2009-01-29 11:23:44 UTC (rev 83605)
@@ -1,74 +0,0 @@
-/*
- * 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.spi;
-
-// $Id$
-
-import java.util.Hashtable;
-
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-
-/**
- * A simple factory for creating safe object names.
- *
- * @author Thomas.Diesler at jboss.org
- * @since 08-May-2006
- */
-public class ObjectNameFactory
-{
- public static ObjectName create(String name)
- {
- try
- {
- return new ObjectName(name);
- }
- catch (MalformedObjectNameException e)
- {
- throw new Error("Invalid ObjectName: " + name + "; " + e);
- }
- }
-
- public static ObjectName create(String domain, String key, String value)
- {
- try
- {
- return new ObjectName(domain, key, value);
- }
- catch (MalformedObjectNameException e)
- {
- throw new Error("Invalid ObjectName: " + domain + "," + key + "," + value + "; " + e);
- }
- }
-
- public static ObjectName create(String domain, Hashtable<String, String> table)
- {
- try
- {
- return new ObjectName(domain, table);
- }
- catch (MalformedObjectNameException e)
- {
- throw new Error("Invalid ObjectName: " + domain + "," + table + "; " + e);
- }
- }
-}
Modified: projects/jboss-felix/trunk/modules/spi/src/main/java/org/jboss/osgi/spi/test/IntegrationTestHelper.java
===================================================================
--- projects/jboss-felix/trunk/modules/spi/src/main/java/org/jboss/osgi/spi/test/IntegrationTestHelper.java 2009-01-29 09:06:43 UTC (rev 83604)
+++ projects/jboss-felix/trunk/modules/spi/src/main/java/org/jboss/osgi/spi/test/IntegrationTestHelper.java 2009-01-29 11:23:44 UTC (rev 83605)
@@ -29,8 +29,6 @@
import javax.naming.InitialContext;
import javax.naming.NamingException;
-import org.jboss.osgi.spi.ObjectNameFactory;
-
/**
* An integration test helper that deals with test deployment/undeployment, etc.
*
@@ -89,7 +87,7 @@
String jbossVersion;
try
{
- ObjectName oname = ObjectNameFactory.create("jboss.system:type=ServerConfig");
+ ObjectName oname = new ObjectName("jboss.system:type=ServerConfig");
jbossVersion = (String)getServer().getAttribute(oname, "SpecificationVersion");
}
catch (Exception ex)
More information about the jboss-cvs-commits
mailing list