-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #5013 Classloader.getResources resolves preferentially from osg…
…i bundle loader Signed-off-by: Jan Bartel <[email protected]>
- Loading branch information
Showing
9 changed files
with
385 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<parent> | ||
<groupId>org.eclipse.jetty.osgi</groupId> | ||
<artifactId>jetty-osgi-project</artifactId> | ||
<version>9.4.31-SNAPSHOT</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
<artifactId>test-jetty-osgi-webapp-resources</artifactId> | ||
<name>OSGi Test :: Webapp With Resources</name> | ||
<url>http://www.eclipse.org/jetty</url> | ||
<packaging>war</packaging> | ||
<properties> | ||
<bundle-symbolic-name>${project.groupId}.webapp.resources</bundle-symbolic-name> | ||
</properties> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-resources-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>copy-resources</id> | ||
<phase>validate</phase> | ||
<goals> | ||
<goal>copy-resources</goal> | ||
</goals> | ||
<configuration> | ||
<outputDirectory>${basedir}/target/classes</outputDirectory> | ||
<resources> | ||
<resource> | ||
<directory>src/main/resources</directory> | ||
</resource> | ||
</resources> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.felix</groupId> | ||
<artifactId>maven-bundle-plugin</artifactId> | ||
<extensions>true</extensions> | ||
<configuration> | ||
<supportedProjectTypes> | ||
<supportedProjectType>war</supportedProjectType> | ||
</supportedProjectTypes> | ||
<instructions> | ||
<Export-Package>!com.acme*</Export-Package> | ||
<Web-ContextPath>/</Web-ContextPath> | ||
</instructions> | ||
</configuration> | ||
</plugin> | ||
<!-- also make this webapp an osgi bundle --> | ||
<plugin> | ||
<artifactId>maven-war-plugin</artifactId> | ||
<configuration> | ||
<archive> | ||
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile> | ||
</archive> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-deploy-plugin</artifactId> | ||
<configuration> | ||
<!-- must deploy: required for jetty-distribution --> | ||
<skip>false</skip> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
<dependencies> | ||
<dependency> | ||
<groupId>javax.servlet</groupId> | ||
<artifactId>javax.servlet-api</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
</dependencies> | ||
</project> |
67 changes: 67 additions & 0 deletions
67
jetty-osgi/test-jetty-osgi-webapp-resources/src/main/java/com/acme/HelloWorld.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// | ||
// ======================================================================== | ||
// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others. | ||
// ------------------------------------------------------------------------ | ||
// All rights reserved. This program and the accompanying materials | ||
// are made available under the terms of the Eclipse Public License v1.0 | ||
// and Apache License v2.0 which accompanies this distribution. | ||
// | ||
// The Eclipse Public License is available at | ||
// http://www.eclipse.org/legal/epl-v10.html | ||
// | ||
// The Apache License v2.0 is available at | ||
// http://www.opensource.org/licenses/apache2.0.php | ||
// | ||
// You may elect to redistribute this code under either of these licenses. | ||
// ======================================================================== | ||
// | ||
|
||
package com.acme; | ||
|
||
import java.io.IOException; | ||
import java.net.URL; | ||
import java.util.Enumeration; | ||
import java.util.Set; | ||
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; | ||
|
||
/** | ||
* Dump Servlet Request. | ||
*/ | ||
@SuppressWarnings("serial") | ||
public class HelloWorld extends HttpServlet | ||
{ | ||
|
||
@Override | ||
public void init(ServletConfig config) throws ServletException | ||
{ | ||
super.init(config); | ||
} | ||
|
||
@Override | ||
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException | ||
{ | ||
doGet(request, response); | ||
} | ||
|
||
@Override | ||
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException | ||
{ | ||
response.setContentType("text/html"); | ||
ServletOutputStream out = response.getOutputStream(); | ||
out.println("<html>"); | ||
out.println("<h1>Hello World</h1>"); | ||
|
||
Enumeration<URL> resources = Thread.currentThread().getContextClassLoader().getResources("fake.properties"); | ||
|
||
while (resources.hasMoreElements()) | ||
out.println(resources.nextElement().toString()); | ||
|
||
out.println("</html>"); | ||
out.flush(); | ||
} | ||
} |
Empty file.
24 changes: 24 additions & 0 deletions
24
jetty-osgi/test-jetty-osgi-webapp-resources/src/main/webapp/WEB-INF/web.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<web-app | ||
xmlns="http://xmlns.jcp.org/xml/ns/javaee" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" | ||
metadata-complete="false" | ||
version="3.1"> | ||
|
||
<display-name>WebApp With Resources</display-name> | ||
|
||
<servlet> | ||
<servlet-name>Hello</servlet-name> | ||
<servlet-class>com.acme.HelloWorld</servlet-class> | ||
<load-on-startup>1</load-on-startup> | ||
</servlet> | ||
|
||
<servlet-mapping> | ||
<servlet-name>Hello</servlet-name> | ||
<url-pattern>/hello/*</url-pattern> | ||
</servlet-mapping> | ||
|
||
</web-app> | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
jetty-osgi/test-jetty-osgi/src/test/config/etc/jetty-http-boot-with-resources.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?xml version="1.0"?><!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_3.dtd"> | ||
|
||
<!-- ============================================================= --><!-- Configure the Jetty Server instance with an ID "Server" --><!-- by adding an HTTP connector. --><!-- This configuration must be used in conjunction with jetty.xml --><!-- ============================================================= --> | ||
<Configure id="Server" class="org.eclipse.jetty.server.Server"> | ||
|
||
<!-- =========================================================== --> | ||
<!-- Add an HTTP Connector. --> | ||
<!-- Configure an o.e.j.server.ServerConnector with a single --> | ||
<!-- HttpConnectionFactory instance using the common httpConfig --> | ||
<!-- instance defined in jetty.xml --> | ||
<!-- --> | ||
<!-- Consult the javadoc of o.e.j.server.ServerConnector and --> | ||
<!-- o.e.j.server.HttpConnectionFactory for all configuration --> | ||
<!-- that may be set here. --> | ||
<!-- =========================================================== --> | ||
<Call name="addConnector"> | ||
<Arg> | ||
<New class="org.eclipse.jetty.server.ServerConnector"> | ||
<Arg name="server"><Ref refid="Server" /></Arg> | ||
<Arg name="factories"> | ||
<Array type="org.eclipse.jetty.server.ConnectionFactory"> | ||
<Item> | ||
<New class="org.eclipse.jetty.server.HttpConnectionFactory"> | ||
<Arg name="config"><Ref refid="httpConfig" /></Arg> | ||
</New> | ||
</Item> | ||
</Array> | ||
</Arg> | ||
<Call name="addLifeCycleListener"> | ||
<Arg> | ||
<New class="org.eclipse.jetty.osgi.boot.utils.ServerConnectorListener"> | ||
<Set name="sysPropertyName">boot.resources.port</Set> | ||
</New> | ||
</Arg> | ||
</Call> | ||
<Set name="host"><Property name="jetty.http.host" /></Set> | ||
<Set name="port"><Property name="jetty.http.port" default="80" /></Set> | ||
<Set name="idleTimeout"><Property name="jetty.http.idleTimeout" default="30000"/></Set> | ||
</New> | ||
</Arg> | ||
</Call> | ||
|
||
</Configure> |
Oops, something went wrong.