Skip to content

Commit cf32e14

Browse files
vitallanKevinGilmore
authored andcommitted
[BAEL-1218] Guide to Spring EJB Integration (eugenp#3266)
* Evaluation article about types of bean injection in spring * BAEL-1319 Quick Guide on Data.sql and Schema.sql Files in Spring * Revert "Evaluation article about types of bean injection in spring" This reverts commit eb07117. * BAEL-1218: adding spring-ejb and configuring ejb start and deploy * BAEL-1218: adding spring * BAEL-1218: wrapping all together * BAEL-1218: new spring-ejb module * BAEL-1218: tests and improvements * BAEL-1218: removing moved files from old article * BAEL-1218: code review requested changes * BAEL-1218: test methods nomenclature correction * BAEL-1418: removing tabs * BAEL-1218: removing tabs * BAEL-1218: correcting boot parent module path
1 parent 09cbc1c commit cf32e14

15 files changed

Lines changed: 463 additions & 0 deletions

File tree

‎pom.xml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@
161161
<module>spring-cloud</module>
162162
<module>spring-core</module>
163163
<module>spring-cucumber</module>
164+
<module>spring-ejb</module>
164165
<module>spring-aop</module>
165166
<module>persistence-modules/spring-data-cassandra</module>
166167
<module>spring-data-couchbase-2</module>
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
6+
<parent>
7+
<groupId>com.baeldung.spring.ejb</groupId>
8+
<artifactId>ejb-for-spring</artifactId>
9+
<version>1.0.1</version>
10+
</parent>
11+
12+
<artifactId>ejb-remote-for-spring</artifactId>
13+
<packaging>ejb</packaging>
14+
15+
<dependencies>
16+
<dependency>
17+
<groupId>javax</groupId>
18+
<artifactId>javaee-api</artifactId>
19+
<scope>provided</scope>
20+
</dependency>
21+
<dependency>
22+
<groupId>org.assertj</groupId>
23+
<artifactId>assertj-core</artifactId>
24+
<version>3.9.0</version>
25+
<scope>test</scope>
26+
</dependency>
27+
</dependencies>
28+
29+
30+
<profiles>
31+
<!-- mvn clean package cargo:run -Pwildfly-standalone-->
32+
<profile>
33+
<id>wildfly-standalone</id>
34+
<activation>
35+
<activeByDefault>false</activeByDefault>
36+
</activation>
37+
<build>
38+
<plugins>
39+
<plugin>
40+
<groupId>org.codehaus.cargo</groupId>
41+
<artifactId>cargo-maven2-plugin</artifactId>
42+
<version>${cargo-maven2-plugin.version}</version>
43+
44+
<configuration>
45+
46+
<container>
47+
<containerId>wildfly10x</containerId>
48+
<zipUrlInstaller>
49+
<url>http://download.jboss.org/wildfly/10.1.0.Final/wildfly-10.1.0.Final.zip</url>
50+
</zipUrlInstaller>
51+
</container>
52+
53+
<configuration>
54+
<properties>
55+
<cargo.hostname>127.0.0.1</cargo.hostname>
56+
<cargo.jboss.configuration>standalone-full</cargo.jboss.configuration>
57+
<cargo.jboss.management-http.port>9990</cargo.jboss.management-http.port>
58+
<cargo.servlet.users>testUser:admin1234!</cargo.servlet.users>
59+
</properties>
60+
</configuration>
61+
62+
</configuration>
63+
</plugin>
64+
</plugins>
65+
</build>
66+
</profile>
67+
</profiles>
68+
69+
<properties>
70+
<javaee-api.version>7.0</javaee-api.version>
71+
<cargo-maven2-plugin.version>1.6.1</cargo-maven2-plugin.version>
72+
</properties>
73+
74+
</project>
75+
76+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package com.baeldung.ejb.tutorial;
2+
3+
import javax.ejb.Remote;
4+
5+
@Remote
6+
public interface HelloStatefulWorld {
7+
8+
int howManyTimes();
9+
String getHelloWorld();
10+
11+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.baeldung.ejb.tutorial;
2+
3+
import javax.ejb.Stateful;
4+
5+
@Stateful(name = "HelloStatefulWorld")
6+
public class HelloStatefulWorldBean implements HelloStatefulWorld {
7+
8+
private int howManyTimes = 0;
9+
10+
public int howManyTimes() {
11+
return howManyTimes;
12+
}
13+
14+
public String getHelloWorld() {
15+
howManyTimes++;
16+
return "Hello Stateful World!";
17+
}
18+
19+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package com.baeldung.ejb.tutorial;
2+
3+
import javax.ejb.Remote;
4+
5+
@Remote
6+
public interface HelloStatelessWorld {
7+
8+
String getHelloWorld();
9+
10+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.baeldung.ejb.tutorial;
2+
3+
import javax.ejb.Stateless;
4+
5+
@Stateless(name = "HelloStatelessWorld")
6+
public class HelloStatelessWorldBean implements HelloStatelessWorld {
7+
8+
public String getHelloWorld() {
9+
return "Hello Stateless World!";
10+
}
11+
12+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ejb-jar xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/ejb-jar_3_2.xsd"
4+
version="3.2">
5+
<module-name>ejb-remote-for-spring</module-name>
6+
</ejb-jar>
7+
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package com.baeldung.ejb.tutorial;
2+
3+
import static org.assertj.core.api.Assertions.assertThat;
4+
5+
import org.junit.Before;
6+
import org.junit.Test;
7+
8+
public class HelloStatefulWorldTestUnitTest {
9+
10+
private HelloStatefulWorldBean statefulBean;
11+
12+
@Before
13+
public void setup() {
14+
statefulBean = new HelloStatefulWorldBean();
15+
}
16+
17+
@Test
18+
public void whenGetHelloWorld_thenHelloStatefulWorldIsReturned() {
19+
String helloWorld = statefulBean.getHelloWorld();
20+
21+
assertThat(helloWorld).isEqualTo("Hello Stateful World!");
22+
}
23+
24+
@Test
25+
public void whenGetHelloWorldIsCalledTwice_thenCounterIs2() {
26+
statefulBean.getHelloWorld();
27+
statefulBean.getHelloWorld();
28+
29+
assertThat(statefulBean.howManyTimes()).isEqualTo(2);
30+
}
31+
32+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.baeldung.ejb.tutorial;
2+
3+
import static org.assertj.core.api.Assertions.assertThat;
4+
5+
import org.junit.Before;
6+
import org.junit.Test;
7+
8+
public class HelloStatelessWorldTestUnitTest {
9+
10+
private HelloStatelessWorldBean statelessBean;
11+
12+
@Before
13+
public void setup() {
14+
statelessBean = new HelloStatelessWorldBean();
15+
}
16+
17+
@Test
18+
public void whenGetHelloWorld_thenHelloStatelessWorldIsReturned() {
19+
String helloWorld = statelessBean.getHelloWorld();
20+
21+
assertThat(helloWorld).isEqualTo("Hello Stateless World!");
22+
}
23+
24+
}

‎spring-ejb/pom.xml‎

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
<groupId>com.baeldung.spring.ejb</groupId>
6+
<artifactId>ejb-for-spring</artifactId>
7+
<version>1.0.1</version>
8+
<packaging>pom</packaging>
9+
<name>ejb</name>
10+
<description>Spring EJB Tutorial</description>
11+
12+
<parent>
13+
<groupId>com.baeldung</groupId>
14+
<artifactId>parent-modules</artifactId>
15+
<version>1.0.0-SNAPSHOT</version>
16+
</parent>
17+
18+
<repositories>
19+
<repository>
20+
<id>jboss-public-repository-group</id>
21+
<name>JBoss Public Maven Repository Group</name>
22+
<url>http://repository.jboss.org/nexus/content/groups/public/</url>
23+
<layout>default</layout>
24+
<releases>
25+
<enabled>true</enabled>
26+
<updatePolicy>never</updatePolicy>
27+
</releases>
28+
<snapshots>
29+
<enabled>true</enabled>
30+
<updatePolicy>never</updatePolicy>
31+
</snapshots>
32+
</repository>
33+
</repositories>
34+
35+
<dependencyManagement>
36+
<dependencies>
37+
<dependency>
38+
<groupId>com.baeldung.spring.ejb</groupId>
39+
<artifactId>ejb-remote-for-spring</artifactId>
40+
<version>1.0.1</version>
41+
<type>ejb</type>
42+
</dependency>
43+
<dependency>
44+
<groupId>javax</groupId>
45+
<artifactId>javaee-api</artifactId>
46+
<version>7.0</version>
47+
<scope>provided</scope>
48+
</dependency>
49+
<dependency>
50+
<groupId>org.wildfly</groupId>
51+
<artifactId>wildfly-ejb-client-bom</artifactId>
52+
<version>10.1.0.Final</version>
53+
<type>pom</type>
54+
<scope>import</scope>
55+
</dependency>
56+
</dependencies>
57+
</dependencyManagement>
58+
59+
<build>
60+
<pluginManagement>
61+
<plugins>
62+
<plugin>
63+
<artifactId>maven-ejb-plugin</artifactId>
64+
<version>2.4</version>
65+
<configuration>
66+
<ejbVersion>3.2</ejbVersion>
67+
</configuration>
68+
</plugin>
69+
</plugins>
70+
</pluginManagement>
71+
</build>
72+
73+
<modules>
74+
<module>ejb-remote-for-spring</module>
75+
<module>spring-ejb-client</module>
76+
</modules>
77+
</project>

0 commit comments

Comments
 (0)