Skip to content
This repository has been archived by the owner on Jul 11, 2024. It is now read-only.

Commit

Permalink
Original
Browse files Browse the repository at this point in the history
  • Loading branch information
Damien Le Berrigaud authored and cschuyle committed Mar 22, 2019
0 parents commit 781dda6
Show file tree
Hide file tree
Showing 24 changed files with 976 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*.iml
target
classes
build
.idea
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Struts Example

## Build the app with maven

```
$ mvn clean package
```

## Deploy the war to PCF

```
$ cf push struts-example -p target/struts.war
```
89 changes: 89 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!--
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.
-->
<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.superbiz.struts</groupId>
<artifactId>struts</artifactId>
<packaging>war</packaging>
<version>1.1.0-SNAPSHOT</version>
<name>OpenEJB :: Web Examples :: Struts</name>
<url>http://tomee.apache.org</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<repositories>
<repository>
<id>apache-m2-snapshot</id>
<name>Apache Snapshot Repository</name>
<url>https://repository.apache.org/content/groups/snapshots</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>

<build>
<finalName>struts</finalName>
</build>

<dependencies>
<dependency>
<groupId>org.apache.tomee</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>taglibs</groupId>
<artifactId>standard</artifactId>
<version>1.1.2</version>
</dependency>

<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.13</version>
</dependency>

<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>2.1.8.1</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-sitemesh-plugin</artifactId>
<version>2.1.8.1</version>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
80 changes: 80 additions & 0 deletions src/main/java/org/superbiz/struts/AddUser.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*
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.
*/
package org.superbiz.struts;

import javax.naming.Context;
import javax.naming.InitialContext;
import java.util.Properties;

public class AddUser {

private int id;
private String firstName;
private String lastName;
private String errorMessage;

public String getFirstName() {
return firstName;
}

public void setFirstName(String firstName) {
this.firstName = firstName;
}

public String getLastName() {
return lastName;
}

public void setLastName(String lastName) {
this.lastName = lastName;
}

public String getErrorMessage() {
return errorMessage;
}

public void setErrorMessage(String errorMessage) {
this.errorMessage = errorMessage;
}

public int getId() {
return id;
}

public void setId(int id) {
this.id = id;
}

public String execute() {

try {
UserService service = null;
Properties props = new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY,
"org.apache.openejb.core.LocalInitialContextFactory");
Context ctx = new InitialContext(props);
service = (UserService) ctx.lookup("UserServiceImplLocal");
service.add(new User(id, firstName, lastName));
} catch (Exception e) {
this.errorMessage = e.getMessage();
return "failure";
}

return "success";
}
}
24 changes: 24 additions & 0 deletions src/main/java/org/superbiz/struts/AddUserForm.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
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.
*/
package org.superbiz.struts;

import com.opensymphony.xwork2.ActionSupport;

public class AddUserForm extends ActionSupport {

}
71 changes: 71 additions & 0 deletions src/main/java/org/superbiz/struts/FindUser.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
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.
*/
package org.superbiz.struts;

import javax.naming.Context;
import javax.naming.InitialContext;
import java.util.Properties;

public class FindUser {

private int id;
private String errorMessage;
private User user;

public User getUser() {
return user;
}

public void setUser(User user) {
this.user = user;
}

public String getErrorMessage() {
return errorMessage;
}

public void setErrorMessage(String errorMessage) {
this.errorMessage = errorMessage;
}

public int getId() {
return id;
}

public void setId(int id) {
this.id = id;
}

public String execute() {

try {
UserService service = null;
Properties props = new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY,
"org.apache.openejb.core.LocalInitialContextFactory");
Context ctx = new InitialContext(props);
service = (UserService) ctx.lookup("UserServiceImplLocal");
this.user = service.find(id);
} catch (Exception e) {
this.errorMessage = e.getMessage();
return "failure";
}

return "success";
}
}
24 changes: 24 additions & 0 deletions src/main/java/org/superbiz/struts/FindUserForm.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
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.
*/
package org.superbiz.struts;

import com.opensymphony.xwork2.ActionSupport;

public class FindUserForm extends ActionSupport {

}
72 changes: 72 additions & 0 deletions src/main/java/org/superbiz/struts/ListAllUsers.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
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.
*/
package org.superbiz.struts;

import javax.naming.Context;
import javax.naming.InitialContext;
import java.util.List;
import java.util.Properties;

public class ListAllUsers {

private int id;
private String errorMessage;
private List<User> users;

public List<User> getUsers() {
return users;
}

public void setUsers(List<User> users) {
this.users = users;
}

public String getErrorMessage() {
return errorMessage;
}

public void setErrorMessage(String errorMessage) {
this.errorMessage = errorMessage;
}

public int getId() {
return id;
}

public void setId(int id) {
this.id = id;
}

public String execute() {

try {
UserService service = null;
Properties props = new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY,
"org.apache.openejb.core.LocalInitialContextFactory");
Context ctx = new InitialContext(props);
service = (UserService) ctx.lookup("UserServiceImplLocal");
this.users = service.findAll();
} catch (Exception e) {
this.errorMessage = e.getMessage();
return "failure";
}

return "success";
}
}
Loading

0 comments on commit 781dda6

Please sign in to comment.