Skip to content

Commit 0141977

Browse files
committed
Code refactoring.
1 parent 5a11aa9 commit 0141977

File tree

21 files changed

+20
-22
lines changed

21 files changed

+20
-22
lines changed

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Example program for WS-Transfer SOAP extension implemented in the Apache CXF pro
66
Scenario
77
--------
88

9-
There are two separate servers. The first server called *ResourceFactoryServer* provides two services - *ResourceFactory* and *Resource*. The second server called *ResourceServer* contains one service *Resource*. Client program has reference only to the *ResourceFactory*. When the client sends request to create resource, the *ResourceFactory* makes decision where the resource will be stored. It can be stored locally in the first server or remotely in the second server. After creating the resource a reference parameters are returned. By this way the client can later *get*, *put* or *delete* the created resource.
9+
There are two separate servers. The first server called *Student* provides two services - *ResourceFactory* and *Resource*. The second server called *Teacher* contains one service *Resource*. Client program has reference only to the first server on *ResourceFactory* endpoint. When the client sends request to create resource, the *ResourceFactory* makes decision where the resource will be stored. It can be stored locally in the first server or remotely in the second server. After creating the resource a reference parameters are returned. By this way the client can later *get*, *put* or *delete* the created resource.
1010

1111
The *ResourceFactory* supports two types of XML representations - student and teacher. If other type of XML representation is requested to create, the InvalidRepresentation fault is thrown. All elements in representations are optional. If they are not defined so the "Unspecified" value is set. The *ResourceFactory* generates an *UID* (University Identifier) for each accepted XML representation. The *UID* can't be modified by *put* request. If the method tries to change the *UID* the *PutDenied* fault is thrown.
1212

@@ -22,11 +22,11 @@ mvn exec:java -pl client
2222
```
2323

2424
```
25-
mvn exec:java -pl resourcefactory
25+
mvn exec:java -pl studentserver
2626
```
2727

2828
```
29-
mvn exec:java -pl resource
29+
mvn exec:java -pl teacherserver
3030
```
3131

3232
Usage

pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616

1717
<modules>
1818
<module>client</module>
19-
<module>resourcefactory</module>
20-
<module>resource</module>
19+
<module>studentserver</module>
20+
<module>teacherserver</module>
2121
</modules>
2222

2323
</project>

resourcefactory/pom.xml studentserver/pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
</execution>
3535
</executions>
3636
<configuration>
37-
<mainClass>org.apache.cxf.example.wstransferexample.server.resourcefactory.ResourceFactoryServer</mainClass>
37+
<mainClass>org.apache.cxf.example.wstransferexample.server.resourcefactory.Server</mainClass>
3838
</configuration>
3939
</plugin>
4040
<plugin>
@@ -50,7 +50,7 @@
5050
<configuration>
5151
<transformers>
5252
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
53-
<mainClass>org.apache.cxf.example.wstransferexample.server.resourcefactory.ResourceFactoryServer</mainClass>
53+
<mainClass>org.apache.cxf.example.wstransferexample.server.resourcefactory.Server</mainClass>
5454
</transformer>
5555
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
5656
<resource>META-INF/cxf/bus-extensions.txt</resource>
File renamed without changes.
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,13 @@
2323
import org.apache.cxf.ws.transfer.resourcefactory.ResourceFactory;
2424
import org.apache.cxf.ws.transfer.resourcefactory.ResourceFactoryImpl;
2525
import org.apache.cxf.ws.transfer.validationtransformation.XSDResourceTypeIdentifier;
26-
import org.apache.cxf.ws.transfer.validationtransformation.XSDResourceValidator;
2726
import org.apache.cxf.ws.transfer.validationtransformation.XSLTResourceTransformer;
2827

2928
/**
30-
* ResourceFactoryServer main class.
29+
* Server main class.
3130
* @author Erich Duda
3231
*/
33-
public class ResourceFactoryServer {
32+
public class Server {
3433

3534
public static void main(String[] args) {
3635
Options options = new Options();
@@ -64,9 +63,9 @@ private static void createResource(ResourceManager resourceManager) {
6463
resourceLocal.setManager(resourceManager);
6564
resourceLocal.getResourceTypeIdentifiers().add(
6665
new XSDResourceTypeIdentifier(
67-
new StreamSource(ResourceFactoryServer.class.getResourceAsStream("/xml/schema/studentPut.xsd")),
66+
new StreamSource(Server.class.getResourceAsStream("/xml/schema/studentPut.xsd")),
6867
new XSLTResourceTransformer(
69-
new StreamSource(ResourceFactoryServer.class.getResourceAsStream("/xml/xslt/studentPut.xsl")),
68+
new StreamSource(Server.class.getResourceAsStream("/xml/xslt/studentPut.xsl")),
7069
new StudentPutResourceValidator())));
7170
JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
7271
factory.setServiceClass(Resource.class);
@@ -91,15 +90,15 @@ private static void createResourceFactory(ResourceManager resourceManager) {
9190
Config.getInstance().getResourceTeachersUrl()));
9291
resourceFactory.getResourceTypeIdentifiers().add(
9392
new XSDResourceTypeIdentifier(
94-
new StreamSource(ResourceFactoryServer.class.getResourceAsStream("/xml/schema/studentCreate.xsd")),
93+
new StreamSource(Server.class.getResourceAsStream("/xml/schema/studentCreate.xsd")),
9594
new XSLTResourceTransformer(
96-
new StreamSource(ResourceFactoryServer.class.getResourceAsStream("/xml/xslt/studentCreate.xsl")))));
95+
new StreamSource(Server.class.getResourceAsStream("/xml/xslt/studentCreate.xsl")))));
9796
resourceFactory.getResourceTypeIdentifiers().add(
9897
new XSDResourceTypeIdentifier(
99-
new StreamSource(ResourceFactoryServer.class.getResourceAsStream("/xml/schema/teacherCreateBasic.xsd")),
98+
new StreamSource(Server.class.getResourceAsStream("/xml/schema/teacherCreateBasic.xsd")),
10099
new XSLTResourceTransformer(
101100
new StreamSource(
102-
ResourceFactoryServer.class.getResourceAsStream("/xml/xslt/teacherCreateBasic.xsl")))));
101+
Server.class.getResourceAsStream("/xml/xslt/teacherCreateBasic.xsl")))));
103102
JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
104103
factory.setServiceClass(ResourceFactory.class);
105104
factory.setServiceBean(resourceFactory);

resource/pom.xml teacherserver/pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
</execution>
3535
</executions>
3636
<configuration>
37-
<mainClass>org.apache.cxf.example.wstransfexample.server.resource.ResourceServer</mainClass>
37+
<mainClass>org.apache.cxf.example.wstransfexample.server.resource.Server</mainClass>
3838
</configuration>
3939
</plugin>
4040
<plugin>
@@ -50,7 +50,7 @@
5050
<configuration>
5151
<transformers>
5252
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
53-
<mainClass>org.apache.cxf.example.wstransfexample.server.resource.ResourceServer</mainClass>
53+
<mainClass>org.apache.cxf.example.wstransfexample.server.resource.Server</mainClass>
5454
</transformer>
5555
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
5656
<resource>META-INF/cxf/bus-extensions.txt</resource>

resource/src/main/java/org/apache/cxf/example/wstransfexample/server/resource/ResourceServer.java teacherserver/src/main/java/org/apache/cxf/example/wstransfexample/server/resource/Server.java

+3-4
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,13 @@
2323
import org.apache.cxf.ws.transfer.resourcefactory.ResourceFactory;
2424
import org.apache.cxf.ws.transfer.shared.TransferConstants;
2525
import org.apache.cxf.ws.transfer.validationtransformation.XSDResourceTypeIdentifier;
26-
import org.apache.cxf.ws.transfer.validationtransformation.XSDResourceValidator;
2726
import org.apache.cxf.ws.transfer.validationtransformation.XSLTResourceTransformer;
2827

2928
/**
3029
*
3130
* @author erich
3231
*/
33-
public class ResourceServer {
32+
public class Server {
3433

3534
public static void main(String[] args) {
3635
Options options = new Options();
@@ -54,9 +53,9 @@ public static void main(String[] args) {
5453
ResourceRemote resourceRemote = new ResourceRemote();
5554
resourceRemote.setManager(resourceManager);
5655
resourceRemote.getResourceTypeIdentifiers().add(new XSDResourceTypeIdentifier(
57-
new StreamSource(ResourceServer.class.getResourceAsStream("/xml/schema/teacher.xsd")),
56+
new StreamSource(Server.class.getResourceAsStream("/xml/schema/teacher.xsd")),
5857
new XSLTResourceTransformer(
59-
new StreamSource(ResourceServer.class.getResourceAsStream("/xml/xslt/teacherDefaultValues.xsl")),
58+
new StreamSource(Server.class.getResourceAsStream("/xml/xslt/teacherDefaultValues.xsl")),
6059
new TeacherResourceValidator())));
6160

6261
createResourceFactoryEndpoint(resourceRemote);

0 commit comments

Comments
 (0)