You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by dj...@apache.org on 2009/12/01 01:11:55 UTC
svn commit: r885632 - in /geronimo/server/trunk:
framework/modules/geronimo-kernel/src/test/java/org/apache/geronimo/kernel/osgi/
plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/
plugins/jetty8/geronimo-jetty8/src/main/java/org/...
Author: djencks
Date: Tue Dec 1 00:11:54 2009
New Revision: 885632
URL: http://svn.apache.org/viewvc?rev=885632&view=rev
Log:
GERONIMO-4964 base jetty ServletContext.getResource on bundle.getEntry
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/src/main/java/org/apache/geronimo/jetty8/WebAppContextWrapper.java
geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/GeronimoWebAppContext.java
geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/IntegrationContext.java
geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/AbstractWebModuleTest.java
geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/ApplicationTest.java
geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/StatTest.java
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=885632&r1=885631&r2=885632&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 Tue Dec 1 00:11:54 2009
@@ -23,6 +23,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
+import java.net.MalformedURLException;
import java.util.Dictionary;
import java.util.Enumeration;
import java.util.HashMap;
@@ -127,7 +128,11 @@
}
public URL getEntry(String s) {
- return null;
+ try {
+ return new URL(location + s);
+ } catch (MalformedURLException e) {
+ throw new RuntimeException(e);
+ }
}
public long getLastModified() {
Modified: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/WebAppContextWrapper.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/WebAppContextWrapper.java?rev=885632&r1=885631&r2=885632&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/WebAppContextWrapper.java (original)
+++ geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/WebAppContextWrapper.java Tue Dec 1 00:11:54 2009
@@ -66,6 +66,7 @@
import org.eclipse.jetty.servlet.ServletMapping;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.osgi.framework.Bundle;
/**
* Wrapper for a WebApplicationContext that sets up its J2EE environment.
@@ -107,6 +108,7 @@
@ParamAttribute(name = "deploymentDescriptor") String originalSpecDD,
@ParamAttribute(name = "componentContext") Map<String, Object> componentContext,
@ParamSpecial(type = SpecialAttributeType.classLoader) ClassLoader classLoader,
+ @ParamSpecial(type = SpecialAttributeType.bundle) Bundle bundle,
@ParamAttribute(name = "configurationBaseUrl") URL configurationBaseUrl,
@ParamAttribute(name = "workDir") String workDir,
@ParamAttribute(name = "unshareableResources") Set<String> unshareableResources,
@@ -184,7 +186,7 @@
//wrap the web app context with the jndi handler
GeronimoUserTransaction userTransaction = new GeronimoUserTransaction(transactionManager);
this.componentContext = EnterpriseNamingContext.createEnterpriseNamingContext(componentContext, userTransaction, kernel, classLoader);
- integrationContext = new IntegrationContext(this.componentContext, unshareableResources, applicationManagedSecurityResources, trackedConnectionAssociator, userTransaction);
+ integrationContext = new IntegrationContext(this.componentContext, unshareableResources, applicationManagedSecurityResources, trackedConnectionAssociator, userTransaction, bundle);
webAppContext = new GeronimoWebAppContext(securityHandler, sessionHandler, servletHandler, null, integrationContext, classLoader);
webAppContext.setContextPath(contextPath);
//See Jetty-386. Setting this to true can expose secured content.
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=885632&r1=885631&r2=885632&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 Tue Dec 1 00:11:54 2009
@@ -21,6 +21,9 @@
package org.apache.geronimo.jetty8.handler;
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;
@@ -34,6 +37,8 @@
import org.eclipse.jetty.servlet.ServletHandler;
import org.eclipse.jetty.server.session.SessionHandler;
import org.eclipse.jetty.webapp.WebAppContext;
+import org.eclipse.jetty.util.resource.Resource;
+import org.eclipse.jetty.util.resource.URLResource;
import org.apache.geronimo.connector.outbound.connectiontracking.ConnectorInstanceContext;
import org.apache.geronimo.connector.outbound.connectiontracking.SharedConnectorInstanceContext;
@@ -42,7 +47,6 @@
*/
public class GeronimoWebAppContext extends WebAppContext {
- private Handler handler;
protected final IntegrationContext integrationContext;
@@ -52,14 +56,6 @@
setClassLoader(classLoader);
}
- public void setTwistyHandler(Handler handler) {
- this.handler = handler;
- }
-
- public Handler newTwistyHandler() {
- return new TwistyHandler();
- }
-
@Override
protected void doStart() throws Exception {
javax.naming.Context context = integrationContext.setContext();
@@ -114,67 +110,19 @@
}
}
-
-// @Override
-// public void doHandle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
-// handler.handle(target, baseRequest, request, response);
-// }
-
- private class TwistyHandler implements Handler {
-
- public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
- GeronimoWebAppContext.super.doHandle(target, baseRequest, request, response);
- }
-
- public void setServer(Server server) {
- GeronimoWebAppContext.super.setServer(server);
- }
-
- public Server getServer() {
- return GeronimoWebAppContext.super.getServer();
- }
-
- public void destroy() {
- GeronimoWebAppContext.super.destroy();
- }
-
- public void start() throws Exception {
- GeronimoWebAppContext.super.start();
- }
-
- public void stop() throws Exception {
- GeronimoWebAppContext.super.stop();
- }
-
- public boolean isRunning() {
- return GeronimoWebAppContext.super.isRunning();
- }
-
- public boolean isStarted() {
- return GeronimoWebAppContext.super.isStarted();
- }
-
- public boolean isStarting() {
- return GeronimoWebAppContext.super.isStarting();
- }
-
- public boolean isStopping() {
- return GeronimoWebAppContext.super.isStopping();
- }
-
- public boolean isStopped() {
- return GeronimoWebAppContext.super.isStopped();
- }
-
- public boolean isFailed() {
- return GeronimoWebAppContext.super.isFailed();
+ @Override
+ public Resource getResource(String uriInContext) throws MalformedURLException {
+ URL url = integrationContext.getBundle().getEntry(uriInContext);
+ if (url == null) {
+ return null;
}
+ return new BasicURLResource(url);
+ }
- public void addLifeCycleListener(Listener listener) {
- }
+ private static class BasicURLResource extends URLResource {
- public void removeLifeCycleListener(Listener listener) {
+ protected BasicURLResource(URL url) {
+ super(url, null);
}
}
-
}
Modified: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/IntegrationContext.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/IntegrationContext.java?rev=885632&r1=885631&r2=885632&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/IntegrationContext.java (original)
+++ geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/IntegrationContext.java Tue Dec 1 00:11:54 2009
@@ -35,6 +35,7 @@
import org.apache.geronimo.connector.outbound.connectiontracking.ConnectorInstanceContext;
import org.apache.geronimo.naming.java.RootContext;
import org.eclipse.jetty.server.Request;
+import org.osgi.framework.Bundle;
/**
* @version $Rev$ $Date$
@@ -46,13 +47,15 @@
private final Set<String> applicationManagedSecurityResources;
private final TrackedConnectionAssociator trackedConnectionAssociator;
private final UserTransaction userTransaction;
+ private final Bundle bundle;
- public IntegrationContext(Context componentContext, Set<String> unshareableResources, Set<String> applicationManagedSecurityResources, TrackedConnectionAssociator trackedConnectionAssociator, UserTransaction userTransaction) {
+ public IntegrationContext(Context componentContext, Set<String> unshareableResources, Set<String> applicationManagedSecurityResources, TrackedConnectionAssociator trackedConnectionAssociator, UserTransaction userTransaction, Bundle bundle) {
this.componentContext = componentContext;
this.unshareableResources = unshareableResources;
this.applicationManagedSecurityResources = applicationManagedSecurityResources;
this.trackedConnectionAssociator = trackedConnectionAssociator;
this.userTransaction = userTransaction;
+ this.bundle = bundle;
}
public Context getComponentContext() {
@@ -74,7 +77,11 @@
public UserTransaction getUserTransaction() {
return userTransaction;
}
-
+
+ public Bundle getBundle() {
+ return bundle;
+ }
+
public SharedConnectorInstanceContext newConnectorInstanceContext(Request baseRequest) {
return new SharedConnectorInstanceContext(getUnshareableResources(),
getApplicationManagedSecurityResources(),
Modified: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/AbstractWebModuleTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/AbstractWebModuleTest.java?rev=885632&r1=885631&r2=885632&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/AbstractWebModuleTest.java (original)
+++ geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/AbstractWebModuleTest.java Tue Dec 1 00:11:54 2009
@@ -18,6 +18,7 @@
import java.io.File;
import java.net.URL;
+import java.net.URI;
import java.security.PermissionCollection;
import java.security.Permissions;
import java.security.Principal;
@@ -68,6 +69,7 @@
import org.eclipse.jetty.security.IdentityService;
import org.eclipse.jetty.security.UserAuthentication;
import org.eclipse.jetty.security.authentication.FormAuthenticator;
+import org.osgi.framework.Bundle;
/**
@@ -83,6 +85,8 @@
private URL configurationBaseURL;
protected PreHandlerFactory preHandlerFactory = null;
protected SessionHandlerFactory sessionHandlerFactory = null;
+ private Bundle bundle;
+ protected String appPath;
protected void setUpStaticContentServlet(JettyServletRegistration webModule) throws Exception {
Map<String, String> staticContentServletInitParams = new HashMap<String, String>();
@@ -141,6 +145,7 @@
null,
Collections.<String, Object>emptyMap(),
cl,
+ bundle,
new URL(configurationBaseURL, uriString),
null, null,
null,
@@ -226,8 +231,14 @@
configurationBaseURL = cl.getResource("deployables/");
ServerInfo serverInfo = new BasicServerInfo(".");
+ String location = configurationBaseURL.toString();
+ if (appPath != null) {
+ location = configurationBaseURL.toURI().resolve(appPath).toString();
+ }
+ MockBundleContext bundleContext = new MockBundleContext(cl, location, new HashMap<Artifact, ConfigurationData>(), null);
+ bundle = bundleContext.getBundle();
container = new JettyContainerImpl("test:name=JettyContainer",
- new MockBundleContext(getClass().getClassLoader(), "", new HashMap<Artifact, ConfigurationData>(), null),
+ bundleContext,
null, new File(BASEDIR, "target/var/jetty").toString(), serverInfo);
container.doStart();
connector = new HTTPSocketConnector(container, null);
Modified: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/ApplicationTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/ApplicationTest.java?rev=885632&r1=885631&r2=885632&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/ApplicationTest.java (original)
+++ geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/ApplicationTest.java Tue Dec 1 00:11:54 2009
@@ -36,6 +36,12 @@
*/
public class ApplicationTest extends AbstractWebModuleTest {
+ @Override
+ protected void setUp() throws Exception {
+ appPath = "war1";
+ super.setUp();
+ }
+
public void testApplication() throws Exception {
WebAppContextWrapper app = setUpAppContext(null, null, "policyContextID", null, "war1/");
Modified: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/StatTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/StatTest.java?rev=885632&r1=885631&r2=885632&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/StatTest.java (original)
+++ geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/StatTest.java Tue Dec 1 00:11:54 2009
@@ -82,6 +82,7 @@
}
protected void setUp() throws Exception {
+ appPath = "war1";
super.setUp();
WebAppContextWrapper app;
app = setUpAppContext(null, null, "policyContextID", null, "war1/");