Skip to content
This repository was archived by the owner on Mar 7, 2024. It is now read-only.

Commit 01b7a46

Browse files
committed
Envers functionality added in Server modules
1 parent 057f107 commit 01b7a46

File tree

24 files changed

+19287
-252
lines changed

24 files changed

+19287
-252
lines changed

.idea/dataSources.ids

+18,564
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/dataSources.xml

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/libraries/Maven__org_hibernate_hibernate_envers_4_1_2_Final.xml

+13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/workspace.xml

+285-232
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,22 @@ A sample project for exemplifying and testing various JEE technologies - mainly
44

55
## Contents
66

7-
The project consists of serveral sub-projects or modules grouped by name as follows...
7+
The project consists of several sub-projects or modules grouped by name as follows...
88

99
- sample-jee-client-*
1010
- sample-jee-relay-*
1111
- sample-jee-server-*
1212
- sample-jee-standalone-*
1313

14-
The *client* modules contins various server-based client components (EJBs, Servlets etc) that calls other server components
15-
in the *relay* or *server* moules.
14+
The *client* modules contains various server-based client components (EJBs, Servlets etc) that calls other server components
15+
in the *relay* or *server* modules.
1616

1717
The *relay* modules act as intermediaries, accepting calls from some client and sending it on to some component in the
1818
*server* modules.
1919

2020
The *server* modules accept calls from some client.
2121

22-
The *standalone* modules normally act as Java standlone clients - in counterpart to the ones in the *client* modules
22+
The *standalone* modules normally act as Java standalone clients - in counterpart to the ones in the *client* modules
2323
that normally are server-based components acting as clients.
2424

2525
### sample-jee-client-*
@@ -50,7 +50,7 @@ and/or sample-jee-server-*.
5050

5151
### sample-jee-relay-*
5252

53-
Three moudules (ear, ejb, ejb-remote)
53+
Three modules (ear, ejb, ejb-remote)
5454

5555
#### sample-jee-relay-ear
5656

sample-jee-server-domain/pom.xml

+6
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@
1616
<name>${project.parent.artifactId} Server Domain Model JAR</name>
1717

1818
<dependencies>
19+
<!-- hibernate envers -->
20+
<dependency>
21+
<groupId>org.hibernate</groupId>
22+
<artifactId>hibernate-envers</artifactId>
23+
<scope>provided</scope>
24+
</dependency>
1925
<!-- jpa -->
2026
<dependency>
2127
<groupId>org.hibernate.javax.persistence</groupId>

sample-jee-server-domain/sample-jee-server-domain.iml

+4
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
</content>
2323
<orderEntry type="inheritedJdk" />
2424
<orderEntry type="sourceFolder" forTests="false" />
25+
<orderEntry type="library" scope="PROVIDED" name="Maven: org.hibernate:hibernate-envers:4.1.2.Final" level="project" />
26+
<orderEntry type="library" scope="PROVIDED" name="Maven: org.jboss.logging:jboss-logging:3.1.1.GA" level="project" />
27+
<orderEntry type="library" scope="PROVIDED" name="Maven: dom4j:dom4j:1.6.1" level="project" />
28+
<orderEntry type="library" scope="PROVIDED" name="Maven: org.hibernate.common:hibernate-commons-annotations:4.0.1.Final" level="project" />
2529
<orderEntry type="library" scope="PROVIDED" name="Maven: org.hibernate.javax.persistence:hibernate-jpa-2.0-api:1.0.1.Final" level="project" />
2630
<orderEntry type="library" scope="PROVIDED" name="Maven: javax.validation:validation-api:1.0.0.GA" level="project" />
2731
</component>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
package com.swesource.sample.jee.domain;
2+
3+
import org.hibernate.envers.Audited;
4+
5+
import javax.persistence.Column;
6+
import javax.persistence.Entity;
7+
import javax.persistence.GeneratedValue;
8+
import javax.persistence.Id;
9+
import javax.persistence.Temporal;
10+
import javax.persistence.TemporalType;
11+
import javax.validation.constraints.Digits;
12+
import javax.validation.constraints.Size;
13+
import java.io.Serializable;
14+
import java.util.Date;
15+
16+
/**
17+
* @author arnie
18+
*/
19+
@Entity
20+
@Audited
21+
public class Address implements Serializable {
22+
23+
private static final long serialVersionUID = 1L;
24+
private static final int ZIP_LENGTH = 5;
25+
private static final int COUNTRY_MAX = 2;
26+
private static final int COUNTRY_MIN = 2;
27+
28+
@Id
29+
@GeneratedValue
30+
private Long id;
31+
32+
private String street;
33+
34+
private String city;
35+
36+
@Column(length = ZIP_LENGTH)
37+
@Digits(integer = ZIP_LENGTH, fraction = 0)
38+
private String zip;
39+
40+
/* ISO 3166 A2 compliant country code */
41+
@Column(length = COUNTRY_MAX)
42+
@Size(min = COUNTRY_MIN, max = COUNTRY_MAX)
43+
private String country;
44+
45+
@Temporal(value = TemporalType.DATE)
46+
private Date movingInDate;
47+
48+
@Override
49+
public String toString() {
50+
return this.getClass().getName() + "@" + hashCode() + " [id = " + id + "]";
51+
}
52+
53+
public Long getId() {
54+
return id;
55+
}
56+
57+
public void setId(Long id) {
58+
this.id = id;
59+
}
60+
61+
public String getStreet() {
62+
return street;
63+
}
64+
65+
public void setStreet(String street) {
66+
this.street = street;
67+
}
68+
69+
public String getCity() {
70+
return city;
71+
}
72+
73+
public void setCity(String city) {
74+
this.city = city;
75+
}
76+
77+
public String getZip() {
78+
return zip;
79+
}
80+
81+
public void setZip(String zip) {
82+
this.zip = zip;
83+
}
84+
85+
public String getCountry() {
86+
return country;
87+
}
88+
89+
public void setCountry(String country) {
90+
this.country = country;
91+
}
92+
93+
public Date getMovingInDate() {
94+
return movingInDate;
95+
}
96+
97+
public void setMovingInDate(Date movingInDate) {
98+
this.movingInDate = movingInDate;
99+
}
100+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
package com.swesource.sample.jee.domain;
2+
3+
import org.hibernate.envers.Audited;
4+
5+
import javax.persistence.CascadeType;
6+
import javax.persistence.Entity;
7+
import javax.persistence.GeneratedValue;
8+
import javax.persistence.Id;
9+
import javax.persistence.NamedQueries;
10+
import javax.persistence.NamedQuery;
11+
import javax.persistence.OneToMany;
12+
import java.io.Serializable;
13+
import java.util.Collection;
14+
15+
/**
16+
* @author arnie
17+
*/
18+
@Entity
19+
@Audited(withModifiedFlag = true)
20+
@NamedQueries(value =
21+
@NamedQuery(name = "findPersonVersionsById", query = "select p from Person p where p.id = :id")
22+
)
23+
public class Person implements Serializable {
24+
25+
private static final long serialVersionUID = 1L;
26+
27+
@Id
28+
@GeneratedValue
29+
private Long id;
30+
31+
private String firstName;
32+
33+
private String lastName;
34+
35+
@OneToMany(cascade = CascadeType.ALL)
36+
private Collection<Address> addresses;
37+
38+
@Override
39+
public String toString() {
40+
return this.getClass().getName() + "@" + hashCode() + " [id = " + id + "]";
41+
}
42+
43+
public Long getId() {
44+
return id;
45+
}
46+
47+
public void setId(Long id) {
48+
this.id = id;
49+
}
50+
51+
public String getFirstName() {
52+
return firstName;
53+
}
54+
55+
public void setFirstName(String firstName) {
56+
this.firstName = firstName;
57+
}
58+
59+
public String getLastName() {
60+
return lastName;
61+
}
62+
63+
public void setLastName(String lastName) {
64+
this.lastName = lastName;
65+
}
66+
67+
public Collection<Address> getAddresses() {
68+
return addresses;
69+
}
70+
71+
public void setAddresses(Collection<Address> addresses) {
72+
this.addresses = addresses;
73+
}
74+
}

sample-jee-server-domain/src/main/java/com/swesource/sample/jee/domain/User.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public class User implements Serializable {
2323
private Long id;
2424

2525
@Column(unique = true, nullable = false, length = USERNAME_MAX)
26+
//@Column(nullable = false, length = USERNAME_MAX)
2627
@NotNull
2728
@Size(min = USERNAME_MIN, max = USERNAME_MAX)
2829
private String username;
@@ -45,6 +46,6 @@ public void setUsername(String username) {
4546

4647
@Override
4748
public String toString() {
48-
return "User@" + hashCode() + " [id = " + id + "]";
49+
return this.getClass().getName() + "@" + hashCode() + " [id = " + id + "]";
4950
}
5051
}

sample-jee-server-ejb-remote/pom.xml

+9
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,14 @@
3030
<artifactId>jboss-ejb-api_3.1_spec</artifactId>
3131
<scope>provided</scope>
3232
</dependency>
33+
<!--
34+
jpa - needed for java.persistence.CascadeType in
35+
sample-jee-server-domain : com.swesource.sample.jee.domain.Person
36+
-->
37+
<dependency>
38+
<groupId>org.hibernate.javax.persistence</groupId>
39+
<artifactId>hibernate-jpa-2.0-api</artifactId>
40+
<scope>provided</scope>
41+
</dependency>
3342
</dependencies>
3443
</project>

sample-jee-server-ejb-remote/sample-jee-server-ejb-remote.iml

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<orderEntry type="sourceFolder" forTests="false" />
1212
<orderEntry type="module" module-name="sample-jee-server-domain" scope="PROVIDED" />
1313
<orderEntry type="library" scope="PROVIDED" name="Maven: org.jboss.spec.javax.ejb:jboss-ejb-api_3.1_spec:1.0.2.Final" level="project" />
14+
<orderEntry type="library" scope="PROVIDED" name="Maven: org.hibernate.javax.persistence:hibernate-jpa-2.0-api:1.0.1.Final" level="project" />
1415
</component>
1516
</module>
1617

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.swesource.sample.jee;
2+
3+
import com.swesource.sample.jee.domain.Person;
4+
import com.swesource.sample.jee.domain.User;
5+
6+
import javax.ejb.Remote;
7+
import java.util.List;
8+
9+
/**
10+
* Remote interface to com.swesource.sample.jee.EnversSlsbSlsbBean
11+
* @author Arnold Johansson
12+
*/
13+
@Remote
14+
public interface EnversSlsbRemote {
15+
public void persistPerson(Person person);
16+
public Person findPerson(Long id);
17+
public List<Person> findByRevisionAndLastName(int revision, String propertyName, String propertyValue);
18+
public Person updatePerson(Person person);
19+
}

sample-jee-server-ejb-ws-endpoint/sample-jee-server-ejb-ws-endpoint.iml

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_6" inherit-compiler-output="false">
44
<output url="file://$MODULE_DIR$/target/classes" />
55
<output-test url="file://$MODULE_DIR$/target/test-classes" />
6-
<exclude-output />
76
<content url="file://$MODULE_DIR$">
87
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
98
<excludeFolder url="file://$MODULE_DIR$/target" />

sample-jee-server-ejb-ws-endpoint/src/main/java/com/swesource/sample/jee/ServerWsEndpoint.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import javax.jws.WebParam;
77
import javax.jws.WebResult;
88
import javax.jws.WebService;
9-
import javax.xml.ws.Holder;
109

1110
/**
1211
* @author arnie
@@ -27,8 +26,8 @@ public interface ServerWsEndpoint {
2726

2827
@WebMethod
2928
public String wsWithParams(
30-
@WebParam(name = "idParamAsString") String idAsString,
31-
@WebParam(name = "idParamAsInteger")Holder<Integer> isAsInteger);
29+
@WebParam(name = "idParamAsString") String idParamAsString,
30+
@WebParam(name = "idParamAsInteger")Integer idParamAsInteger);
3231

3332
@WebMethod
3433
@WebResult

sample-jee-server-ejb/pom.xml

+6
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,12 @@
102102
<artifactId>hibernate-core</artifactId>
103103
<scope>provided</scope>
104104
</dependency>
105+
<!-- hibernate envers -->
106+
<dependency>
107+
<groupId>org.hibernate</groupId>
108+
<artifactId>hibernate-envers</artifactId>
109+
<scope>provided</scope>
110+
</dependency>
105111
<!-- jsf -->
106112
<dependency>
107113
<groupId>org.jboss.spec.javax.faces</groupId>

sample-jee-server-ejb/sample-jee-server-ejb.iml

+1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
<orderEntry type="library" scope="PROVIDED" name="Maven: org.hibernate.common:hibernate-commons-annotations:4.0.1.Final" level="project" />
5252
<orderEntry type="library" scope="PROVIDED" name="Maven: org.hibernate:hibernate-core:4.1.2.Final" level="project" />
5353
<orderEntry type="library" scope="PROVIDED" name="Maven: antlr:antlr:2.7.7" level="project" />
54+
<orderEntry type="library" scope="PROVIDED" name="Maven: org.hibernate:hibernate-envers:4.1.2.Final" level="project" />
5455
<orderEntry type="library" scope="PROVIDED" name="Maven: org.jboss.spec.javax.faces:jboss-jsf-api_2.1_spec:2.0.2.Final" level="project" />
5556
<orderEntry type="library" scope="PROVIDED" name="Maven: postgresql:postgresql:9.1-901.jdbc4" level="project" />
5657
<orderEntry type="library" scope="PROVIDED" name="Maven: org.jboss.ejb3:jboss-ejb3-ext-api:2.0.0" level="project" />

0 commit comments

Comments
 (0)