Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*
!/entrypoint.sh
!/target/extracted

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
target/
.idea/
9 changes: 9 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM docker.io/azul/zulu-openjdk:21.0.1-21.30.15
WORKDIR /app
COPY target/extracted/dependencies/ ./
COPY target/extracted/spring-boot-loader/ ./
COPY target/extracted/snapshot-dependencies/ ./
COPY target/extracted/application/ ./
COPY entrypoint.sh ./

ENTRYPOINT ["./entrypoint.sh"]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ How to run
- Run the following command.

```bash
./scripts/deploy-local.sh
./scripts/start.sh
```

- Open the following URL with your browser.
Expand Down
13 changes: 13 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash

main() {
launch
}

launch() {
java \
${DEBUG_PORT:+ -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:${DEBUG_PORT}} \
"org.springframework.boot.loader.launch.WarLauncher"
}

main
3 changes: 3 additions & 0 deletions mise.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[tools]
java = 'zulu-21.40.17'
maven = '3.9.9'
42 changes: 42 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?xml version="1.0"?>
<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>
<groupId>org.apache.struts</groupId>
<artifactId>struts-blank</artifactId>
<packaging>war</packaging>
<name>Struts Apps - Blank</name>
<version>1.0.0</version>
<properties>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
</properties>
<repositories>
<repository>
<id>local-repo</id>
<url>file:../mvn-repo</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>io.github.iwauo.springing-struts</groupId>
<artifactId>struts1-core</artifactId>
<version>0.0.4</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>springing.struts1.entrypoint.Main</mainClass>
<layout>WAR</layout>
<version>3.2.5</version>
</configuration>
</plugin>
</plugins>
</build>
</project>
47 changes: 47 additions & 0 deletions scripts/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/env bash

set -eu

SCRIPT_DIR=$(realpath "$(dirname $BASH_SOURCE)")
PROJECT_BASE_DIR=$(realpath "$SCRIPT_DIR/..")

APP_NAME=struts-blank
CONTAINER_NAME=springing-struts-$APP_NAME
DOCKER=$( (command -v podman &> /dev/null) && echo podman || echo docker )

main() {
build && start
}

build() {
mvn \
clean \
dependency:purge-local-repository \
-DreResolve=false \
-DactTransitively=false \
-DmanualInclude='io.github.iwauo.springing-struts' \
package -U \
spring-boot:repackage \
&& java \
-Djarmode=layertools \
-jar target/$APP_NAME-*.war \
extract --destination target/extracted
}

start() {
$DOCKER build -t $CONTAINER_NAME . \
&& ($DOCKER stop -t 0 $CONTAINER_NAME || true) \
&& $DOCKER rm -f $CONTAINER_NAME \
&& $DOCKER run -d \
-p 8080:8080 \
-p 5005:5005 \
--name $CONTAINER_NAME \
--env DEBUG_PORT=5005 \
$CONTAINER_NAME \
&& $DOCKER logs -f $CONTAINER_NAME
}

(cd "$PROJECT_BASE_DIR" \
&& eval "$(mise env)" \
&& main
)
44 changes: 44 additions & 0 deletions src/main/resources/MessageResources.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# -- standard errors --
errors.header=<UL>
errors.prefix=<LI>
errors.suffix=</LI>
errors.footer=</UL>
# -- validator --
errors.invalid={0} is invalid.
errors.maxlength={0} can not be greater than {1} characters.
errors.minlength={0} can not be less than {1} characters.
errors.range={0} is not in the range {1} through {2}.
errors.required={0} is required.
errors.byte={0} must be an byte.
errors.date={0} is not a date.
errors.double={0} must be an double.
errors.float={0} must be an float.
errors.integer={0} must be an integer.
errors.long={0} must be an long.
errors.short={0} must be an short.
errors.creditcard={0} is not a valid credit card number.
errors.email={0} is an invalid e-mail address.
# -- other --
errors.cancel=Operation cancelled.
errors.detail={0}
errors.general=The process did not complete. Details should follow.
errors.token=Request could not be completed. Operation is not in sequence.
# -- welcome --
welcome.title=Struts Blank Application
welcome.heading=Welcome!
welcome.message=To get started on your own application, copy the struts-blank.war to a new WAR file using the name for your application. Place it in your container's "webapp" folder (or equivalent), and let your container auto-deploy the application. Edit the skeleton configuration files as needed, restart your container, and you are on your way! (You can find the MessageResources.properties file with this message in the /WEB-INF/src folder.)
179 changes: 179 additions & 0 deletions src/main/webapp/WEB-INF/struts-config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.4//EN"
"http://struts.apache.org/dtds/struts-config_1_4.dtd">

<!--
This is a blank Struts configuration file with an example
welcome action/page and other commented sample elements.

Struts Validator is configured using the factory defaults
and is ready-to-use.

NOTE: If you have a generator tool to create the corresponding Java classes
for you, you could include the details in the "form-bean" declarations.
Otherwise, you would only define the "form-bean" element itself, with the
corresponding "name" and "type" attributes, as shown here.
-->


<struts-config>


<!-- ================================================ Form Bean Definitions -->

<form-beans>
<!-- sample form bean descriptor for an ActionForm
<form-bean
name="inputForm"
type="app.InputForm"/>
end sample -->

<!-- sample form bean descriptor for a DynaActionForm
<form-bean
name="logonForm"
type="org.apache.struts.action.DynaActionForm">
<form-property
name="username"
type="java.lang.String"/>
<form-property
name="password"
type="java.lang.String"/>
</form-bean>
end sample -->
</form-beans>


<!-- ========================================= Global Exception Definitions -->

<global-exceptions>
<!-- sample exception handler
<exception
key="expired.password"
type="app.ExpiredPasswordException"
path="/changePassword.jsp"/>
end sample -->
</global-exceptions>


<!-- =========================================== Global Forward Definitions -->

<global-forwards>
<!-- Default forward to "Welcome" action -->
<!-- Demonstrates using index.jsp to forward -->
<forward
name="welcome"
path="/Welcome.do"/>
</global-forwards>


<!-- =========================================== Action Mapping Definitions -->

<action-mappings>
<!-- Default "Welcome" action -->
<!-- Forwards to Welcome.jsp -->
<action
path="/Welcome"
forward="/pages/Welcome.jsp"/>

<!-- sample input and input submit actions

<action
path="/Input"
type="org.apache.struts.actions.ForwardAction"
parameter="/pages/Input.jsp"/>

<action
path="/InputSubmit"
type="app.InputAction"
name="inputForm"
scope="request"
validate="true"
input="/pages/Input.jsp"/>

<action
path="/edit*"
type="app.Edit{1}Action"
name="inputForm"
scope="request"
validate="true"
input="/pages/Edit{1}.jsp"/>

end samples -->
</action-mappings>


<!-- ======================================== Message Resources Definitions -->

<message-resources parameter="MessageResources" />


<!-- =============================================== Plug Ins Configuration -->

<!-- ======================================================= Tiles plugin -->
<!--
This plugin initialize Tiles definition factory. This later can takes some
parameters explained here after. The plugin first read parameters from
web.xml, thenoverload them with parameters defined here. All parameters
are optional.
The plugin should be declared in each struts-config file.
- definitions-config: (optional)
Specify configuration file names. There can be several comma
separated file names (default: ?? )
- moduleAware: (optional - struts1.1)
Specify if the Tiles definition factory is module aware. If true
(default), there will be one factory for each Struts module.
If false, there will be one common factory for all module. In this
later case, it is still needed to declare one plugin per module.
The factory will be initialized with parameters found in the first
initialized plugin (generally the one associated with the default
module).
true : One factory per module. (default)
false : one single shared factory for all modules
- definitions-parser-validate: (optional)
Specify if xml parser should validate the Tiles configuration file.
true : validate. DTD should be specified in file header (default)
false : no validation

Paths found in Tiles definitions are relative to the main context.

To use this plugin, download and add the Tiles jar to your WEB-INF/lib
directory then uncomment the plugin definition below.

<plug-in className="org.apache.struts.tiles.TilesPlugin" >

<set-property property="definitions-config"
value="/WEB-INF/tiles-defs.xml" />
<set-property property="moduleAware" value="true" />
</plug-in>
-->


<!-- =================================================== Validator plugin -->

<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
<set-property
property="pathnames"
value="/org/apache/struts/validator/validator-rules.xml,
/WEB-INF/validation.xml"/>
</plug-in>

</struts-config>

Loading