Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reorg of /demos/ with focus on demo-spec downstream dependencies. #5367

Merged
merged 6 commits into from
Sep 29, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion demos/demo-async-rest/demo-async-rest-jar/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>demo-async-rest-jar</artifactId>
<packaging>jar</packaging>
<name>Demo Async Rest :: Jar</name>
<name>Demo :: Async Rest :: Jar</name>

<properties>
<bundle-symbolic-name>${project.parent.groupId}.async.rest</bundle-symbolic-name>
Expand Down
2 changes: 1 addition & 1 deletion demos/demo-async-rest/demo-async-rest-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>demo-async-rest-server</artifactId>
<packaging>jar</packaging>
<name>Demo Async Rest :: Server</name>
<name>Demo :: Async Rest :: Server</name>

<properties>
<bundle-symbolic-name>${project.parent.groupId}.async.rest.server</bundle-symbolic-name>
Expand Down
2 changes: 1 addition & 1 deletion demos/demo-async-rest/demo-async-rest-webapp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>demo-async-rest-webapp</artifactId>
<packaging>war</packaging>
<name>Demo Async Rest :: Webapp</name>
<name>Demo :: Async Rest :: WebApp</name>

<dependencies>
<dependency>
Expand Down
2 changes: 1 addition & 1 deletion demos/demo-async-rest/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>demo-async-rest-parent</artifactId>
<packaging>pom</packaging>
<name>Demo Async Rest</name>
<name>Demo :: Async Rest</name>

<modules>
<module>demo-async-rest-jar</module>
Expand Down
2 changes: 1 addition & 1 deletion demos/demo-jaas-webapp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<version>10.0.0-SNAPSHOT</version>
</parent>
<artifactId>demo-jaas-webapp</artifactId>
<name>Jetty Tests :: WebApp :: JAAS</name>
<name>Demo :: JAAS :: WebApp</name>
<packaging>war</packaging>
<properties>
<bundle-symbolic-name>${project.groupId}.jaas</bundle-symbolic-name>
Expand Down
2 changes: 1 addition & 1 deletion demos/demo-jetty-webapp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>demo-jetty-webapp</artifactId>
<name>Demo :: Jetty Test Webapp</name>
<name>Demo :: Jetty :: WebApp</name>
<url>http://www.eclipse.org/jetty</url>
<packaging>war</packaging>
<properties>
Expand Down
2 changes: 1 addition & 1 deletion demos/demo-jndi-webapp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<version>10.0.0-SNAPSHOT</version>
</parent>
<artifactId>demo-jndi-webapp</artifactId>
<name>Demo :: WebApp :: JNDI</name>
<name>Demo :: JNDI :: WebApp</name>
<packaging>war</packaging>
<properties>
<bundle-symbolic-name>${project.groupId}.jndi</bundle-symbolic-name>
Expand Down
2 changes: 1 addition & 1 deletion demos/demo-proxy-webapp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>demo-proxy-webapp</artifactId>
<name>Demo :: Jetty Proxy Webapp</name>
<name>Demo :: Proxy :: Webapp</name>
<packaging>war</packaging>
<properties>
<bundle-symbolic-name>${project.groupId}.proxy</bundle-symbolic-name>
Expand Down
41 changes: 41 additions & 0 deletions demos/demo-spec/demo-container-initializer/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<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">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.eclipse.jetty.demos</groupId>
<artifactId>demos-parent</artifactId>
<version>10.0.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<artifactId>demo-container-initializer</artifactId>
<packaging>jar</packaging>
<name>Demo :: Servlet Spec :: ServletContainerInitializer Jar</name>
<properties>
<bundle-symbolic-name>${project.groupId}.sci</bundle-symbolic-name>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>org.eclipse.jetty.demos.demo-servlet-container-initializer;singleton:=true</Bundle-SymbolicName>
<Bundle-Description>A bundle containing a ServletContainerInitializer for testing</Bundle-Description>
<Require-Capability>osgi.extender; filter:="(osgi.extender=osgi.serviceloader.registrar)"</Require-Capability>
<Provide-Capability>osgi.serviceloader; osgi.serviceloader=javax.servlet.ServletContainerInitializer</Provide-Capability>
<Export-Package>com.acme.initializer;version="${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion}"</Export-Package>
<_nouses>true</_nouses>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.eclipse.jetty.toolchain</groupId>
<artifactId>jetty-servlet-api</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//
// ========================================================================
// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
//
// This program and the accompanying materials are made available under
// the terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0
//
// This Source Code may also be made available under the following
// Secondary Licenses when the conditions for such availability set
// forth in the Eclipse Public License, v. 2.0 are satisfied:
// the Apache License v2.0 which is available at
// https://www.apache.org/licenses/LICENSE-2.0
//
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ========================================================================
//

package com.acme.initializer;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD})
public @interface Foo
{
int value();
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
//
// ========================================================================
// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
//
// This program and the accompanying materials are made available under
// the terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0
//
// This Source Code may also be made available under the following
// Secondary Licenses when the conditions for such availability set
// forth in the Eclipse Public License, v. 2.0 are satisfied:
// the Apache License v2.0 which is available at
// https://www.apache.org/licenses/LICENSE-2.0
//
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ========================================================================
//

package com.acme.initializer;

import java.util.ArrayList;
import java.util.Set;
import javax.servlet.ServletContainerInitializer;
import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.ServletRegistration;
import javax.servlet.annotation.HandlesTypes;

@HandlesTypes({javax.servlet.Servlet.class, Foo.class})
public class FooInitializer implements ServletContainerInitializer
{
public static class BarListener implements ServletContextListener
{

@Override
public void contextInitialized(ServletContextEvent sce)
{
throw new IllegalStateException("BAR LISTENER CALLED!");
}

@Override
public void contextDestroyed(ServletContextEvent sce)
{

}
}

public static class FooListener implements ServletContextListener
{

@Override
public void contextInitialized(ServletContextEvent sce)
{
if (sce.getServletContext().getAttribute("com.acme.AnnotationTest.listenerTest") != null)
throw new IllegalStateException("FooListener already initialized");

//Can add a ServletContextListener from a ServletContainerInitializer
sce.getServletContext().setAttribute("com.acme.AnnotationTest.listenerTest", Boolean.TRUE);

//Can't add a ServletContextListener from a ServletContextListener
try
{
sce.getServletContext().addListener(new BarListener());
sce.getServletContext().setAttribute("com.acme.AnnotationTest.listenerRegoTest", Boolean.FALSE);
}
catch (UnsupportedOperationException e)
{
sce.getServletContext().setAttribute("com.acme.AnnotationTest.listenerRegoTest", Boolean.TRUE);
}
catch (Exception e)
{
sce.getServletContext().setAttribute("com.acme.AnnotationTest.listenerRegoTest", Boolean.FALSE);
}
}

@Override
public void contextDestroyed(ServletContextEvent sce)
{

}
}

@Override
public void onStartup(Set<Class<?>> classes, ServletContext context)
{
if (context.getAttribute("com.acme.Foo") != null)
throw new IllegalStateException("FooInitializer on Startup already called");

context.setAttribute("com.acme.Foo", new ArrayList<Class>(classes));
ServletRegistration.Dynamic reg = context.addServlet("AnnotationTest", "com.acme.AnnotationTest");
context.setAttribute("com.acme.AnnotationTest.complete", (reg == null));
context.addListener(new FooListener());

//test adding jsp file dynamically
ServletRegistration.Dynamic jspFile = context.addJspFile("dynamic.jsp", "/dynamic.jsp");
context.setAttribute("com.acme.jsp.file", (jspFile != null));
jspFile.addMapping("/dynamicjsp/*");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
com.acme.initializer.FooInitializer
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
<groupId>org.eclipse.jetty.demos</groupId>
<artifactId>demos-parent</artifactId>
<version>10.0.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<name>Demos :: WebApp :: Mock Resources</name>
<name>Demo :: Servlet Spec :: Mock Resources</name>
<artifactId>demo-mock-resources</artifactId>
<packaging>jar</packaging>
<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
<groupId>org.eclipse.jetty.demos</groupId>
<artifactId>demos-parent</artifactId>
<version>10.0.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<name>Demo :: Spec Webapp</name>
<name>Demo :: Servlet Spec :: Webapp</name>
<artifactId>demo-spec-webapp</artifactId>
<packaging>war</packaging>
<properties>
Expand Down Expand Up @@ -199,13 +200,13 @@
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.tests</groupId>
<artifactId>test-web-fragment</artifactId>
<groupId>org.eclipse.jetty.demos</groupId>
<artifactId>demo-web-fragment</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.tests</groupId>
<artifactId>test-container-initializer</artifactId>
<groupId>org.eclipse.jetty.demos</groupId>
<artifactId>demo-container-initializer</artifactId>
<version>${project.version}</version>
</dependency>

Expand Down
24 changes: 24 additions & 0 deletions demos/demo-spec/demo-web-fragment/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<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">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.eclipse.jetty.demos</groupId>
<artifactId>demos-parent</artifactId>
<version>10.0.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>

<name>Demo :: Servlet Spec :: Fragment Jar</name>
<artifactId>demo-web-fragment</artifactId>
<packaging>jar</packaging>

<properties>
<bundle-symbolic-name>${project.groupId}.spec.fragment</bundle-symbolic-name>
</properties>

<dependencies>
<dependency>
<groupId>org.eclipse.jetty.toolchain</groupId>
<artifactId>jetty-servlet-api</artifactId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
//
// ========================================================================
// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
//
// This program and the accompanying materials are made available under
// the terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0
//
// This Source Code may also be made available under the following
// Secondary Licenses when the conditions for such availability set
// forth in the Eclipse Public License, v. 2.0 are satisfied:
// the Apache License v2.0 which is available at
// https://www.apache.org/licenses/LICENSE-2.0
//
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ========================================================================
//

package com.acme.fragment;

import java.io.IOException;
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;

/**
* FragmentServlet
*
* A web fragment jar.
*/

public class FragmentServlet extends HttpServlet
{
private ServletConfig config;

@Override
public void init(ServletConfig config) throws ServletException
{
super.init(config);
this.config = 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
{
try
{
response.setContentType("text/html");
ServletOutputStream out = response.getOutputStream();
out.println("<html>");
out.println("<h1>Jetty Fragment Servlet</h1>");
out.println("<body>");
out.println("</body>");
out.println("</html>");
out.flush();
}
catch (Exception e)
{
throw new ServletException(e);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<h1>Welcome to a Fragment</h1>

<p>
This index.html file was included in a fragment's META-INF/resources directory.
</p>

<a href="../fragment/">Now hit a servlet added by a fragment</a>

Loading