This is an automated email from the ASF dual-hosted git repository.
lukaszlenart pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/struts-examples.git
The following commit(s) were added to refs/heads/master by this push:
new b51b77f Adds example app how to use Struts 2 with Quarkus
b51b77f is described below
commit b51b77f6a622ecaed3d1f0694d7cb277e5293876
Author: Lukasz Lenart <[email protected]>
AuthorDate: Sun Nov 15 16:06:16 2020 +0100
Adds example app how to use Struts 2 with Quarkus
---
pom.xml | 8 +-
quarkus/README.md | 15 ++++
quarkus/pom.xml | 98 ++++++++++++++++++++++
.../struts2/examples/quarkus/IndexAction.java | 33 ++++++++
.../main/resources/META-INF/resources/hello.ftl | 1 +
quarkus/src/main/resources/META-INF/web.xml | 28 +++++++
quarkus/src/main/resources/application.properties | 2 +
quarkus/src/main/resources/log4j2.xml | 16 ++++
quarkus/src/main/resources/struts.xml | 19 +++++
9 files changed, 216 insertions(+), 4 deletions(-)
diff --git a/pom.xml b/pom.xml
index 435a1a7..500b563 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,6 +1,5 @@
-<?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/xsd/maven-4.0.0.xsd">
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.struts</groupId>
@@ -96,6 +95,7 @@
<module>message-store</module>
<module>portlet</module>
<module>preparable-interface</module>
+ <module>quarkus</module>
<module>restful2actionmapper</module>
<module>rest-angular</module>
<module>shiro-basic</module>
@@ -106,11 +106,11 @@
<module>themes-override</module>
<module>type-conversion</module>
<module>unit-testing</module>
+ <module>unknown-handler</module>
<module>using-tags</module>
<module>validation-messages</module>
<module>wildcard-method-selection</module>
<module>wildcard-regex</module>
- <module>unknown-handler</module>
</modules>
<dependencies>
diff --git a/quarkus/README.md b/quarkus/README.md
new file mode 100644
index 0000000..ced849f
--- /dev/null
+++ b/quarkus/README.md
@@ -0,0 +1,15 @@
+# Quarkus example
+
+This is a simple example how to use Struts 2 with
[Quarkus](https://quarkus.io/). Quarkus doesn't support JSPs
+but yoy can use Freemarker instead or writing directly into
HttpServletResponse.
+
+In `application.properties` has been defined `quarkus.oidc.enabled=false` to
disable redirecting to `/auth` even
+if the "oidc" extension has not been loaded. You will also notice a warning
when starting Quarkus - just ignore it.
+
+## Running
+
+Use the below command to start the example Quarkus application (from within
the project's root folder):
+
+```
+mvn clean compile quarkus:dev
+```
diff --git a/quarkus/pom.xml b/quarkus/pom.xml
new file mode 100644
index 0000000..4f1c0b0
--- /dev/null
+++ b/quarkus/pom.xml
@@ -0,0 +1,98 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
https://maven.apache.org/xsd/maven-4.0.0.xsd"
+ xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.struts</groupId>
+ <artifactId>struts-examples</artifactId>
+ <version>1.1.0</version>
+ </parent>
+ <groupId>org.apache.struts.examples</groupId>
+ <artifactId>quarkus</artifactId>
+ <name>Struts 2 Quarkus</name>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <quarkus-plugin.version>1.9.2.Final</quarkus-plugin.version>
+ </properties>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-universe-bom</artifactId>
+ <version>${quarkus-plugin.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <dependencies>
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-undertow</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ <scope>provided</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <defaultGoal>quarkus:dev</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-maven-plugin</artifactId>
+ <version>${quarkus-plugin.version}</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>build</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+ <profiles>
+ <profile>
+ <id>native</id>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-failsafe-plugin</artifactId>
+ <version>3.0.0-M4</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>integration-test</goal>
+ <goal>verify</goal>
+ </goals>
+ <configuration>
+ <systemPropertyVariables>
+ <native.image.path>
+
${project.build.directory}/${project.build.finalName}-runner
+ </native.image.path>
+
<java.util.logging.manager>org.jboss.logmanager.LogManager
+ </java.util.logging.manager>
+ </systemPropertyVariables>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ <properties>
+ <quarkus.package.type>native</quarkus.package.type>
+ </properties>
+ </profile>
+ </profiles>
+</project>
diff --git
a/quarkus/src/main/java/org/apache/struts2/examples/quarkus/IndexAction.java
b/quarkus/src/main/java/org/apache/struts2/examples/quarkus/IndexAction.java
new file mode 100644
index 0000000..5360973
--- /dev/null
+++ b/quarkus/src/main/java/org/apache/struts2/examples/quarkus/IndexAction.java
@@ -0,0 +1,33 @@
+package org.apache.struts2.examples.quarkus;
+
+import com.opensymphony.xwork2.Action;
+import com.opensymphony.xwork2.Result;
+import org.apache.struts2.ServletActionContext;
+
+import javax.servlet.http.HttpServletResponse;
+
+public class IndexAction {
+
+ private String message;
+ private String name;
+
+ public Result execute() {
+ return (Result) invocation -> {
+ HttpServletResponse response = ServletActionContext.getResponse();
+ response.getWriter().println("Hello!");
+ };
+ }
+
+ public String hello() {
+ message = "Hello " + name;
+ return Action.SUCCESS;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+}
diff --git a/quarkus/src/main/resources/META-INF/resources/hello.ftl
b/quarkus/src/main/resources/META-INF/resources/hello.ftl
new file mode 100644
index 0000000..f906b18
--- /dev/null
+++ b/quarkus/src/main/resources/META-INF/resources/hello.ftl
@@ -0,0 +1 @@
+<@s.property value="message"/>
\ No newline at end of file
diff --git a/quarkus/src/main/resources/META-INF/web.xml
b/quarkus/src/main/resources/META-INF/web.xml
new file mode 100644
index 0000000..0eb6bbf
--- /dev/null
+++ b/quarkus/src/main/resources/META-INF/web.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app id="struts_angularjs" version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
+ <display-name>Struts Blank AngularJS App</display-name>
+
+ <filter>
+ <filter-name>struts2</filter-name>
+
<filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class>
+ </filter>
+
+ <filter-mapping>
+ <filter-name>struts2</filter-name>
+ <url-pattern>/*</url-pattern>
+ </filter-mapping>
+
+ <welcome-file-list>
+ <welcome-file>index.jsp</welcome-file>
+ </welcome-file-list>
+
+ <jsp-config>
+ <jsp-property-group>
+ <url-pattern>*.jsp</url-pattern>
+ <page-encoding>UTF-8</page-encoding>
+ </jsp-property-group>
+ </jsp-config>
+
+</web-app>
diff --git a/quarkus/src/main/resources/application.properties
b/quarkus/src/main/resources/application.properties
new file mode 100644
index 0000000..f3c1dc4
--- /dev/null
+++ b/quarkus/src/main/resources/application.properties
@@ -0,0 +1,2 @@
+# Disables redirect to /auth
+quarkus.oidc.enabled=false
diff --git a/quarkus/src/main/resources/log4j2.xml
b/quarkus/src/main/resources/log4j2.xml
new file mode 100644
index 0000000..712b825
--- /dev/null
+++ b/quarkus/src/main/resources/log4j2.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Configuration>
+ <Appenders>
+ <Console name="STDOUT" target="SYSTEM_OUT">
+ <PatternLayout pattern="%d %-5p [%t] %C{2} (%F:%L) - %m%n"/>
+ </Console>
+ </Appenders>
+ <Loggers>
+ <Logger name="com.opensymphony.xwork2" level="debug"/>
+ <Logger name="org.apache.struts2" level="debug"/>
+ <Logger name="org.apache.examples.struts" level="debug"/>
+ <Root level="warn">
+ <AppenderRef ref="STDOUT"/>
+ </Root>
+ </Loggers>
+</Configuration>
\ No newline at end of file
diff --git a/quarkus/src/main/resources/struts.xml
b/quarkus/src/main/resources/struts.xml
new file mode 100644
index 0000000..2054240
--- /dev/null
+++ b/quarkus/src/main/resources/struts.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE struts PUBLIC
+ "-//Apache Software Foundation//DTD Struts Configuration 2.5//EN"
+ "http://struts.apache.org/dtds/struts-2.5.dtd">
+<struts>
+
+ <constant name="struts.enable.DynamicMethodInvocation" value="false"/>
+ <constant name="struts.devMode" value="true"/>
+
+ <package name="quarkus-default" extends="struts-default">
+ <default-action-ref name="index" />
+
+ <action name="index"
class="org.apache.struts2.examples.quarkus.IndexAction"/>
+ <action name="hello"
class="org.apache.struts2.examples.quarkus.IndexAction" method="hello">
+ <result type="freemarker">hello.ftl</result>
+ </action>
+ </package>
+
+</struts>