浏览代码

Updated to 1.1 web service API

peter_backlund 17 年前
父节点
当前提交
f4e7c8c3de

+ 5
- 80
register-app/pom.xml 查看文件

@@ -4,7 +4,7 @@
4 4
   <groupId>se.citerus</groupId>
5 5
   <artifactId>register-app</artifactId>
6 6
   <name>register-app</name>
7
-  <version>1.0.1-SNAPSHOT</version>
7
+  <version>1.1-SNAPSHOT</version>
8 8
   <url>http://dddsample.sf.net</url>
9 9
   <scm>
10 10
     <developerConnection>scm:svn:https://dddsample.svn.sourceforge.net/svnroot/dddsample</developerConnection>
@@ -66,17 +66,17 @@
66 66
     <dependency>
67 67
       <groupId>org.springframework</groupId>
68 68
       <artifactId>spring-context</artifactId>
69
-      <version>2.5.5</version>
69
+      <version>2.5.6</version>
70 70
     </dependency>
71 71
     <dependency>
72 72
       <groupId>org.springframework</groupId>
73 73
       <artifactId>spring-web</artifactId>
74
-      <version>2.5.5</version>
74
+      <version>2.5.6</version>
75 75
     </dependency>
76 76
     <dependency>
77 77
       <groupId>org.springframework</groupId>
78 78
       <artifactId>spring-aop</artifactId>
79
-      <version>2.5.5</version>
79
+      <version>2.5.6</version>
80 80
     </dependency>
81 81
     <dependency>
82 82
       <groupId>com.jgoodies</groupId>
@@ -89,85 +89,10 @@
89 89
       <version>2.1.2</version>
90 90
     </dependency>
91 91
     <dependency>
92
-      <groupId>com.sun.xml.ws</groupId>
93
-      <artifactId>jaxws-rt</artifactId>
94
-      <version>2.1.3</version>
95
-    </dependency>
96
-    <dependency>
97 92
       <groupId>se.citerus</groupId>
98 93
       <artifactId>dddsample</artifactId>
99
-      <version>1.0</version>
94
+      <version>1.1-SNAPSHOT</version>
100 95
       <classifier>ws-client</classifier>
101
-      <exclusions>
102
-        <exclusion>
103
-          <artifactId>spring-core</artifactId>
104
-          <groupId>org.springframework</groupId>
105
-        </exclusion>
106
-        <exclusion>
107
-          <artifactId>spring-webmvc</artifactId>
108
-          <groupId>org.springframework</groupId>
109
-        </exclusion>
110
-        <exclusion>
111
-          <artifactId>spring-orm</artifactId>
112
-          <groupId>org.springframework</groupId>
113
-        </exclusion>
114
-        <exclusion>
115
-          <artifactId>spring-jdbc</artifactId>
116
-          <groupId>org.springframework</groupId>
117
-        </exclusion>
118
-        <exclusion>
119
-          <artifactId>spring-aop</artifactId>
120
-          <groupId>org.springframework</groupId>
121
-        </exclusion>
122
-        <exclusion>
123
-          <artifactId>spring-context</artifactId>
124
-          <groupId>org.springframework</groupId>
125
-        </exclusion>
126
-        <exclusion>
127
-          <artifactId>spring-jms</artifactId>
128
-          <groupId>org.springframework</groupId>
129
-        </exclusion>
130
-        <exclusion>
131
-          <artifactId>spring-beans</artifactId>
132
-          <groupId>org.springframework</groupId>
133
-        </exclusion>
134
-        <exclusion>
135
-          <artifactId>hibernate</artifactId>
136
-          <groupId>org.hibernate</groupId>
137
-        </exclusion>
138
-        <exclusion>
139
-          <artifactId>hibernate-annotations</artifactId>
140
-          <groupId>org.hibernate</groupId>
141
-        </exclusion>
142
-        <exclusion>
143
-          <artifactId>hibernate-commons-annotations</artifactId>
144
-          <groupId>org.hibernate</groupId>
145
-        </exclusion>
146
-        <exclusion>
147
-          <artifactId>commons-dbcp</artifactId>
148
-          <groupId>commons-dbcp</groupId>
149
-        </exclusion>
150
-        <exclusion>
151
-          <artifactId>hsqldb</artifactId>
152
-          <groupId>hsqldb</groupId>
153
-        </exclusion>
154
-        <exclusion>
155
-          <artifactId>servlet-api</artifactId>
156
-          <groupId>javax.servlet</groupId>
157
-        </exclusion>
158
-        <exclusion>
159
-          <artifactId>standard</artifactId>
160
-          <groupId>taglibs</groupId>
161
-        </exclusion>
162
-        <exclusion>
163
-          <artifactId>jstl</artifactId>
164
-          <groupId>javax.servlet</groupId>
165
-        </exclusion>
166
-        <exclusion>
167
-          <artifactId>sitemesh</artifactId>
168
-          <groupId>opensymphony</groupId>
169
-        </exclusion>
170
-      </exclusions>
171 96
     </dependency>
172 97
   </dependencies>
173 98
 </project>

+ 58
- 44
register-app/src/main/java/se/citerus/registerapp/RegisterApp.java 查看文件

@@ -6,7 +6,9 @@ import java.awt.Dimension;
6 6
 import java.awt.event.ActionEvent;
7 7
 import java.awt.event.ActionListener;
8 8
 import java.text.SimpleDateFormat;
9
+import java.text.ParseException;
9 10
 import java.util.Date;
11
+import java.util.GregorianCalendar;
10 12
 
11 13
 import javax.swing.*;
12 14
 import javax.swing.border.Border;
@@ -14,20 +16,25 @@ import javax.swing.border.CompoundBorder;
14 16
 import javax.swing.border.LineBorder;
15 17
 import javax.swing.plaf.basic.BasicBorders;
16 18
 import javax.swing.text.DefaultFormatter;
19
+import javax.xml.datatype.XMLGregorianCalendar;
17 20
 
18 21
 import se.citerus.registerapp.service.HandlingEventService;
19 22
 import se.citerus.registerapp.validation.FormValidationDecorator;
20 23
 import se.citerus.registerapp.validation.FormValidationSwingDecorator;
21 24
 import se.citerus.registerapp.validation.MandatoryTextFieldValidator;
25
+import se.citerus.dddsample.interfaces.handling.ws.HandlingReportService;
26
+import se.citerus.dddsample.interfaces.handling.ws.HandlingReport;
27
+import se.citerus.dddsample.interfaces.handling.ws.HandlingReportErrors;
22 28
 
23 29
 import com.jgoodies.forms.builder.DefaultFormBuilder;
24 30
 import com.jgoodies.forms.debug.FormDebugPanel;
25 31
 import com.jgoodies.forms.factories.ButtonBarFactory;
26 32
 import com.jgoodies.forms.layout.FormLayout;
33
+import com.sun.org.apache.xerces.internal.jaxp.datatype.XMLGregorianCalendarImpl;
27 34
 
28 35
 public class RegisterApp {
29 36
   private static final DefaultFormatter DEFAULT_FORMATTER = new DefaultFormatter();
30
-  private static final SimpleDateFormat ISO8601_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:MM:SS.SSS");
37
+  private static final SimpleDateFormat ISO8601_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd");
31 38
   private static final String TITLE = "Incident Logging Application";
32 39
   private JFrame frame;
33 40
   private JFormattedTextField completionTimeField;
@@ -37,31 +44,38 @@ public class RegisterApp {
37 44
   //private JFormattedTextField eventTypeField;
38 45
   private JComboBox eventTypeField;
39 46
   private JButton registerButton;
40
-  
41
-  private HandlingEventService handlingEventService;
47
+
48
+  private HandlingReportService handlingReportService;
42 49
   private boolean debugUI;
43 50
   private FormValidationDecorator validator;
44 51
 
45 52
 
46
-
47
-  /////////////////////////////////////////////////////////////////////////////
53
+    /////////////////////////////////////////////////////////////////////////////
48 54
   // GUI EVENT HANDLING
49 55
   /////////////////////////////////////////////////////////////////////////////
50 56
   protected void onRegister(){
51
-    assert handlingEventService != null : "No HandlingEventService available";
52
-
53
-      handlingEventService.register(ISO8601_DATE_FORMAT.format(completionTimeField.getValue()),
54
-                                  getStringValue(trackingIdField),
55
-                                  getStringValue(carrierMovementField),
56
-                                  getStringValue(locationField),
57
-                                  getStringValue(eventTypeField).toUpperCase());
58
-    
59
-    clearForm();
57
+    assert handlingReportService != null : "No HandlingEventService available";
58
+
59
+        try {
60
+            final HandlingReport report = new HandlingReport();
61
+            final GregorianCalendar completionTime = new GregorianCalendar();
62
+            completionTime.setTime((Date) completionTimeField.getValue());
63
+            report.setCompletionTime(new XMLGregorianCalendarImpl(completionTime));
64
+            report.setTrackingIds(new String[] {getStringValue(trackingIdField)});
65
+            report.setType(getStringValue(eventTypeField).toUpperCase());
66
+            report.setUnLocode(getStringValue(locationField));
67
+            report.setVoyageNumber(getStringValue(carrierMovementField));
68
+
69
+            handlingReportService.submitReport(report);
70
+            clearForm();
71
+        } catch (HandlingReportErrors handlingReportErrors) {
72
+            System.err.println(handlingReportErrors.getMessage());
73
+        }
60 74
   }
61 75
 
62 76
   private String getStringValue(JComboBox comboBox) {
63 77
       Object value = comboBox.getSelectedItem();
64
-      
78
+
65 79
       if (value != null) {
66 80
         return value.toString();
67 81
       } else {
@@ -72,15 +86,15 @@ public class RegisterApp {
72 86
 
73 87
   private String getStringValue(JFormattedTextField formattedTextField) {
74 88
     Object value = formattedTextField.getValue();
75
-    
89
+
76 90
     if (value != null) {
77 91
       return value.toString();
78 92
     } else {
79 93
       return null;
80 94
     }
81 95
   }
82
-  
83
-  
96
+
97
+
84 98
   /////////////////////////////////////////////////////////////////////////////
85 99
   // PUBLIC API
86 100
   /////////////////////////////////////////////////////////////////////////////
@@ -90,25 +104,25 @@ public class RegisterApp {
90 104
     } catch (Exception e) {
91 105
       // Likely PlasticXP is not in the class path; ignore.
92 106
     }
93
-    
107
+
94 108
     initComponents();
95 109
     JComponent panel = createMainPanel();
96
-    
97
-    
110
+
111
+
98 112
     frame = createFrame(panel);
99 113
     frame.pack();
100 114
     centerOnScreen(frame);
101
-    
115
+
102 116
     initValidation(frame);
103
-    
117
+
104 118
     frame.setVisible(true);
105
-    
119
+
106 120
     clearForm();
107 121
   }
108 122
 
109 123
 
110
-  public void setHandlingEventService(HandlingEventService handlingEventService) {
111
-    this.handlingEventService = handlingEventService;
124
+  public void setHandlingReportService(HandlingReportService handlingReportService) {
125
+    this.handlingReportService = handlingReportService;
112 126
   }
113 127
 
114 128
   public void setDebugUI(boolean on){
@@ -129,14 +143,14 @@ public class RegisterApp {
129 143
   public static Border getMandatoryBorder() {
130 144
     return new CompoundBorder(new LineBorder(Color.RED), new BasicBorders.MarginBorder());
131 145
   }
132
-  
146
+
133 147
   private void initComponents(){
134 148
     completionTimeField = new JFormattedTextField(ISO8601_DATE_FORMAT);
135 149
     trackingIdField = new JFormattedTextField(DEFAULT_FORMATTER);
136 150
     carrierMovementField = new JFormattedTextField(DEFAULT_FORMATTER);
137 151
     locationField = new JFormattedTextField(DEFAULT_FORMATTER);
138 152
     eventTypeField = new JComboBox(new String[] {"-- Select --","Receive","Load","Unload","Customs","Claim"});
139
-    
153
+
140 154
     registerButton = new JButton("Register");
141 155
     registerButton.addActionListener(new ActionListener(){
142 156
       public void actionPerformed(ActionEvent e) {
@@ -149,20 +163,20 @@ public class RegisterApp {
149 163
 
150 164
   /**
151 165
    * We need to do initialization of validators after the components and their parent frame has been initialized.
152
-   * @param frame 
153
-   * 
166
+   * @param frame
167
+   *
154 168
    */
155 169
   private void initValidation(JFrame frame){
156 170
     validator = new FormValidationSwingDecorator(frame);
157
-    
171
+
158 172
     validator.add(trackingIdField, new MandatoryTextFieldValidator("Tracking id can't be empty"));
159 173
     validator.add(locationField, new MandatoryTextFieldValidator("Location can't be empty"));
160 174
   }
161
-  
162
-  
175
+
176
+
163 177
   /**
164 178
    * Center a component on the screen.
165
-   * 
179
+   *
166 180
    * @param component the component to be centered
167 181
    */
168 182
 
@@ -181,18 +195,18 @@ public class RegisterApp {
181 195
     f.setTitle(TITLE);
182 196
     f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
183 197
     f.getContentPane().add(panel);
184
-    
198
+
185 199
     return f;
186 200
   }
187 201
 
188 202
   private JComponent createMainPanel() {
189 203
     JComponent fieldPanel = createFieldPanel();
190 204
     JComponent buttonPanel = createButtonPanel();
191
-    
205
+
192 206
     DefaultFormBuilder mainBuilder = createBuilder("p");
193 207
     mainBuilder.append(fieldPanel);
194 208
     mainBuilder.append(buttonPanel);
195
-    
209
+
196 210
     return mainBuilder.getPanel();
197 211
   }
198 212
 
@@ -204,20 +218,20 @@ public class RegisterApp {
204 218
 
205 219
   private JComponent createFieldPanel() {
206 220
     DefaultFormBuilder builder = createBuilder("right:pref, 3dlu, 100dlu");
207
-    
221
+
208 222
     builder.appendSeparator("Completion");
209 223
     builder.append("Time", completionTimeField); builder.nextLine();
210
-    
224
+
211 225
     builder.appendSeparator("Cargo");
212 226
     builder.append("Tracking Id", trackingIdField); builder.nextLine();
213
-    
227
+
214 228
     builder.appendSeparator("Event");
215
-    builder.append("Carrier Movement", carrierMovementField); builder.nextLine();
229
+    builder.append("Voyage", carrierMovementField); builder.nextLine();
216 230
     builder.append("Location UN/Locode", locationField); builder.nextLine();
217 231
     builder.append("Event Type", eventTypeField); builder.nextLine();
218
-    
232
+
219 233
     builder.appendSeparator("");
220
-    
234
+
221 235
     return builder.getPanel();
222 236
   }
223 237
 
@@ -238,5 +252,5 @@ public class RegisterApp {
238 252
       return new DefaultFormBuilder(layout);
239 253
     }
240 254
   }
241
- 
255
+
242 256
 }

+ 0
- 17
register-app/src/main/java/se/citerus/registerapp/service/HandlingEventServiceWs.java 查看文件

@@ -1,17 +0,0 @@
1
-package se.citerus.registerapp.service;
2
-
3
-import se.citerus.dddsample.application.ws.HandlingEventServiceEndpoint;
4
-
5
-
6
-public class HandlingEventServiceWs implements HandlingEventService {
7
-  private HandlingEventServiceEndpoint endPoint;
8
-  
9
-  public void register(String completionTime, String trackingId, String carrierMovementId, String unlocode, String eventType){
10
-    System.out.println(completionTime);
11
-    endPoint.register(completionTime, trackingId, carrierMovementId, unlocode, eventType);
12
-  }
13
-
14
-  public void setEndPoint(HandlingEventServiceEndpoint endPoint) {
15
-    this.endPoint = endPoint;
16
-  }
17
-}

+ 1
- 1
register-app/src/main/resources/app.properties 查看文件

@@ -1 +1 @@
1
-wsdl.url=http://localhost:8080/dddsample/ws/RegisterEvent?wsdl
1
+wsdl.url=http://localhost:8080/dddsample/ws/RegisterEvent?wsdl

+ 6
- 10
register-app/src/main/resources/context-app.xml 查看文件

@@ -17,20 +17,16 @@
17 17
   </bean>
18 18
 
19 19
   <bean id="registerApp" class="se.citerus.registerapp.RegisterApp">
20
-    <property name="handlingEventService" ref="handlingEventServiceWs"/>
20
+    <property name="handlingReportService" ref="handlingReportService"/>
21 21
     <property name="debugUI" value="false" />
22 22
   </bean>
23 23
 
24
-  <bean id="handlingEventServiceWs" class="se.citerus.registerapp.service.HandlingEventServiceWs">
25
-    <property name="endPoint" ref="handlingEventWebServiceEndPoint"/>
26
-  </bean>
27
-
28
-  <bean id="handlingEventWebServiceEndPoint" class="org.springframework.remoting.jaxws.JaxWsPortProxyFactoryBean">
29
-    <property name="serviceInterface" value="se.citerus.dddsample.application.ws.HandlingEventServiceEndpoint" />
24
+  <bean id="handlingReportService" class="org.springframework.remoting.jaxws.JaxWsPortProxyFactoryBean">
25
+    <property name="serviceInterface" value="se.citerus.dddsample.interfaces.handling.ws.HandlingReportService" />
30 26
     <property name="wsdlDocumentUrl" value="${wsdl.url}" />
31
-    <property name="namespaceUri" value="http://ws.application.dddsample.citerus.se/" />
32
-    <property name="serviceName" value="HandlingEventServiceEndpointImplService" />
33
-    <property name="portName" value="HandlingEventServiceEndpointImplPort" />
27
+    <property name="namespaceUri" value="http://impl.ws.handling.interfaces.dddsample.citerus.se/" />
28
+    <property name="serviceName" value="HandlingReportServiceImplService" />
29
+    <property name="portName" value="HandlingReportServiceImplPort" />
34 30
   </bean>
35 31
 
36 32
 </beans>