Skip to content

Commit 7854621

Browse files
author
Reza Rahman
committed
WebSocket server
1 parent 059bf0b commit 7854621

10 files changed

Lines changed: 459 additions & 12 deletions

File tree

actionbazaar/nb-configuration.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,13 @@ Any value defined here will override the pom.xml file value but is only applicab
1515
-->
1616
<org-netbeans-modules-maven-jaxws.rest_2e_config_2e_type>ide</org-netbeans-modules-maven-jaxws.rest_2e_config_2e_type>
1717
<org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_deploy_2e_server>WebLogic9</org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_deploy_2e_server>
18+
<org-netbeans-modules-projectapi.jsf_2e_language>Facelets</org-netbeans-modules-projectapi.jsf_2e_language>
19+
<org-netbeans-modules-css-prep.sass_2e_compiler_2e_options/>
20+
<org-netbeans-modules-css-prep.less_2e_mappings>/less:/css</org-netbeans-modules-css-prep.less_2e_mappings>
21+
<org-netbeans-modules-css-prep.less_2e_enabled>false</org-netbeans-modules-css-prep.less_2e_enabled>
22+
<org-netbeans-modules-css-prep.sass_2e_mappings>/scss:/css</org-netbeans-modules-css-prep.sass_2e_mappings>
23+
<org-netbeans-modules-css-prep.sass_2e_enabled>false</org-netbeans-modules-css-prep.sass_2e_enabled>
24+
<org-netbeans-modules-css-prep.less_2e_compiler_2e_options/>
25+
<org-netbeans-modules-web-clientproject-api.js_2e_libs_2e_folder>js/libs</org-netbeans-modules-web-clientproject-api.js_2e_libs_2e_folder>
1826
</properties>
1927
</project-shared-configuration>

actionbazaar/nbactions.xml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<actions>
3+
<action>
4+
<actionName>run</actionName>
5+
<packagings>
6+
<packaging>war</packaging>
7+
<packaging>ear</packaging>
8+
<packaging>ejb</packaging>
9+
</packagings>
10+
<goals>
11+
<goal>package</goal>
12+
</goals>
13+
<properties>
14+
<netbeans.deploy>true</netbeans.deploy>
15+
<netbeans.deploy.clientUrlPart>/add_bid.jsf</netbeans.deploy.clientUrlPart>
16+
</properties>
17+
</action>
18+
<action>
19+
<actionName>debug</actionName>
20+
<packagings>
21+
<packaging>war</packaging>
22+
<packaging>ear</packaging>
23+
<packaging>ejb</packaging>
24+
</packagings>
25+
<goals>
26+
<goal>package</goal>
27+
</goals>
28+
<properties>
29+
<netbeans.deploy.debugmode>true</netbeans.deploy.debugmode>
30+
<netbeans.deploy>true</netbeans.deploy>
31+
<netbeans.deploy.clientUrlPart>/add_bid.jsf</netbeans.deploy.clientUrlPart>
32+
</properties>
33+
</action>
34+
<action>
35+
<actionName>profile</actionName>
36+
<packagings>
37+
<packaging>ejb</packaging>
38+
<packaging>ear</packaging>
39+
<packaging>war</packaging>
40+
</packagings>
41+
<goals>
42+
<goal>package</goal>
43+
</goals>
44+
<properties>
45+
<netbeans.deploy>true</netbeans.deploy>
46+
<netbeans.deploy.profilemode>true</netbeans.deploy.profilemode>
47+
<netbeans.deploy.clientUrlPart>/add_bid.jsf</netbeans.deploy.clientUrlPart>
48+
</properties>
49+
</action>
50+
</actions>

actionbazaar/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,14 @@
106106
<configuration>
107107
<failOnMissingWebXml>false</failOnMissingWebXml>
108108
<!-- <filteringDeploymentDescriptors>true</filteringDeploymentDescriptors> -->
109-
<!-- <warName>actionbazaar</warName> -->
109+
<warName>actionbazaar</warName>
110110
</configuration>
111111
</plugin>
112112
<plugin>
113113
<artifactId>maven-surefire-plugin</artifactId>
114114
<version>2.15</version>
115115
<configuration>
116-
<skipTests>false</skipTests>
116+
<skipTests>true</skipTests>
117117
</configuration>
118118
</plugin>
119119
</plugins>

actionbazaar/src/main/java/com/actionbazaar/application/BidService.java

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,43 @@
1+
/*
2+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3+
*
4+
* Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
5+
*
6+
* The contents of this file are subject to the terms of either the GNU
7+
* General Public License Version 2 only ("GPL") or the Common Development
8+
* and Distribution License("CDDL") (collectively, the "License"). You
9+
* may not use this file except in compliance with the License. You can
10+
* obtain a copy of the License at
11+
* http://glassfish.java.net/public/CDDL+GPL_1_1.html
12+
* or packager/legal/LICENSE.txt. See the License for the specific
13+
* language governing permissions and limitations under the License.
14+
*
15+
* When distributing the software, include this License Header Notice in each
16+
* file and include the License file at packager/legal/LICENSE.txt.
17+
*
18+
* GPL Classpath Exception:
19+
* Oracle designates this particular file as subject to the "Classpath"
20+
* exception as provided by Oracle in the GPL Version 2 section of the License
21+
* file that accompanied this code.
22+
*
23+
* Modifications:
24+
* If applicable, add the following below the License Header, with the fields
25+
* enclosed by brackets [] replaced by your own identifying information:
26+
* "Portions Copyright [year] [name of copyright owner]"
27+
*
28+
* Contributor(s):
29+
* If you wish your version of this file to be governed by only the CDDL or
30+
* only the GPL Version 2, indicate your decision by adding "[Contributor]
31+
* elects to include this software in this distribution under the [CDDL or GPL
32+
* Version 2] license." If you don't indicate a single choice of license, a
33+
* recipient has the option to distribute your version of this file under
34+
* either the CDDL, the GPL Version 2 or to extend the choice of license to
35+
* its licensees as provided above. However, if you add GPL Version 2 code
36+
* and therefore, elected the GPL Version 2 license, then the option applies
37+
* only if the new code is made subject to such option by the copyright
38+
* holder.
39+
*/
40+
141
package com.actionbazaar.application;
242

343
import com.actionbazaar.domain.Bid;

actionbazaar/src/main/java/com/actionbazaar/application/DefaultBidService.java

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,43 @@
1+
/*
2+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3+
*
4+
* Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
5+
*
6+
* The contents of this file are subject to the terms of either the GNU
7+
* General Public License Version 2 only ("GPL") or the Common Development
8+
* and Distribution License("CDDL") (collectively, the "License"). You
9+
* may not use this file except in compliance with the License. You can
10+
* obtain a copy of the License at
11+
* http://glassfish.java.net/public/CDDL+GPL_1_1.html
12+
* or packager/legal/LICENSE.txt. See the License for the specific
13+
* language governing permissions and limitations under the License.
14+
*
15+
* When distributing the software, include this License Header Notice in each
16+
* file and include the License file at packager/legal/LICENSE.txt.
17+
*
18+
* GPL Classpath Exception:
19+
* Oracle designates this particular file as subject to the "Classpath"
20+
* exception as provided by Oracle in the GPL Version 2 section of the License
21+
* file that accompanied this code.
22+
*
23+
* Modifications:
24+
* If applicable, add the following below the License Header, with the fields
25+
* enclosed by brackets [] replaced by your own identifying information:
26+
* "Portions Copyright [year] [name of copyright owner]"
27+
*
28+
* Contributor(s):
29+
* If you wish your version of this file to be governed by only the CDDL or
30+
* only the GPL Version 2, indicate your decision by adding "[Contributor]
31+
* elects to include this software in this distribution under the [CDDL or GPL
32+
* Version 2] license." If you don't indicate a single choice of license, a
33+
* recipient has the option to distribute your version of this file under
34+
* either the CDDL, the GPL Version 2 or to extend the choice of license to
35+
* its licensees as provided above. However, if you add GPL Version 2 code
36+
* and therefore, elected the GPL Version 2 license, then the option applies
37+
* only if the new code is made subject to such option by the copyright
38+
* holder.
39+
*/
40+
141
package com.actionbazaar.application;
242

343
import javax.ejb.Stateless;

actionbazaar/src/main/java/com/actionbazaar/domain/Bid.java

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,43 @@
1+
/*
2+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3+
*
4+
* Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
5+
*
6+
* The contents of this file are subject to the terms of either the GNU
7+
* General Public License Version 2 only ("GPL") or the Common Development
8+
* and Distribution License("CDDL") (collectively, the "License"). You
9+
* may not use this file except in compliance with the License. You can
10+
* obtain a copy of the License at
11+
* http://glassfish.java.net/public/CDDL+GPL_1_1.html
12+
* or packager/legal/LICENSE.txt. See the License for the specific
13+
* language governing permissions and limitations under the License.
14+
*
15+
* When distributing the software, include this License Header Notice in each
16+
* file and include the License file at packager/legal/LICENSE.txt.
17+
*
18+
* GPL Classpath Exception:
19+
* Oracle designates this particular file as subject to the "Classpath"
20+
* exception as provided by Oracle in the GPL Version 2 section of the License
21+
* file that accompanied this code.
22+
*
23+
* Modifications:
24+
* If applicable, add the following below the License Header, with the fields
25+
* enclosed by brackets [] replaced by your own identifying information:
26+
* "Portions Copyright [year] [name of copyright owner]"
27+
*
28+
* Contributor(s):
29+
* If you wish your version of this file to be governed by only the CDDL or
30+
* only the GPL Version 2, indicate your decision by adding "[Contributor]
31+
* elects to include this software in this distribution under the [CDDL or GPL
32+
* Version 2] license." If you don't indicate a single choice of license, a
33+
* recipient has the option to distribute your version of this file under
34+
* either the CDDL, the GPL Version 2 or to extend the choice of license to
35+
* its licensees as provided above. However, if you add GPL Version 2 code
36+
* and therefore, elected the GPL Version 2 license, then the option applies
37+
* only if the new code is made subject to such option by the copyright
38+
* holder.
39+
*/
40+
141
package com.actionbazaar.domain;
242

343
import java.io.Serializable;
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
/*
2+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3+
*
4+
* Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
5+
*
6+
* The contents of this file are subject to the terms of either the GNU
7+
* General Public License Version 2 only ("GPL") or the Common Development
8+
* and Distribution License("CDDL") (collectively, the "License"). You
9+
* may not use this file except in compliance with the License. You can
10+
* obtain a copy of the License at
11+
* http://glassfish.java.net/public/CDDL+GPL_1_1.html
12+
* or packager/legal/LICENSE.txt. See the License for the specific
13+
* language governing permissions and limitations under the License.
14+
*
15+
* When distributing the software, include this License Header Notice in each
16+
* file and include the License file at packager/legal/LICENSE.txt.
17+
*
18+
* GPL Classpath Exception:
19+
* Oracle designates this particular file as subject to the "Classpath"
20+
* exception as provided by Oracle in the GPL Version 2 section of the License
21+
* file that accompanied this code.
22+
*
23+
* Modifications:
24+
* If applicable, add the following below the License Header, with the fields
25+
* enclosed by brackets [] replaced by your own identifying information:
26+
* "Portions Copyright [year] [name of copyright owner]"
27+
*
28+
* Contributor(s):
29+
* If you wish your version of this file to be governed by only the CDDL or
30+
* only the GPL Version 2, indicate your decision by adding "[Contributor]
31+
* elects to include this software in this distribution under the [CDDL or GPL
32+
* Version 2] license." If you don't indicate a single choice of license, a
33+
* recipient has the option to distribute your version of this file under
34+
* either the CDDL, the GPL Version 2 or to extend the choice of license to
35+
* its licensees as provided above. However, if you add GPL Version 2 code
36+
* and therefore, elected the GPL Version 2 license, then the option applies
37+
* only if the new code is made subject to such option by the copyright
38+
* holder.
39+
*/
40+
package com.actionbazaar.interfaces.socket;
41+
42+
import java.io.StringReader;
43+
import javax.json.Json;
44+
import javax.json.JsonObject;
45+
import javax.json.JsonReader;
46+
import javax.websocket.Decoder;
47+
import javax.websocket.Encoder;
48+
import javax.websocket.EndpointConfig;
49+
50+
public class ChatMessage
51+
implements Decoder.Text<ChatMessage>, Encoder.Text<ChatMessage> {
52+
53+
private String user;
54+
private String message;
55+
56+
public ChatMessage() {
57+
// Nothing to do.
58+
}
59+
60+
public ChatMessage(String user, String message) {
61+
this.user = user;
62+
this.message = message;
63+
}
64+
65+
@Override
66+
public void init(EndpointConfig config) {
67+
// Nothing to do.
68+
}
69+
70+
@Override
71+
public ChatMessage decode(String value) {
72+
try (JsonReader jsonReader = Json.createReader(
73+
new StringReader(value))) {
74+
JsonObject jsonObject = jsonReader.readObject();
75+
user = jsonObject.getString("user");
76+
message = jsonObject.getString("message");
77+
}
78+
79+
return this;
80+
}
81+
82+
@Override
83+
public boolean willDecode(String string) {
84+
return true; // Detect if it's a valid format.
85+
}
86+
87+
@Override
88+
public String encode(ChatMessage chatMessage) {
89+
JsonObject jsonObject = Json.createObjectBuilder()
90+
.add("user", chatMessage.user)
91+
.add("message", chatMessage.message)
92+
.build();
93+
94+
return jsonObject.toString();
95+
}
96+
97+
@Override
98+
public void destroy() {
99+
// Nothing to do.
100+
}
101+
102+
@Override
103+
public String toString() {
104+
return "ChatMessage{" + "user=" + user + ", message=" + message + '}';
105+
}
106+
}

0 commit comments

Comments
 (0)