Commits

Andy Moncsek committed 41b9f69

reformat code, update to b79

  • Participants
  • Parent commits 03b41d4

Comments (0)

Files changed (68)

File Domain/pom.xml

 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-  <modelVersion>4.0.0</modelVersion>
-	<parent>
-		<groupId>org.jacp.jee</groupId>
-		<artifactId>JEE7-websocket</artifactId>
-		<version>1.0</version>
-	</parent>
-	<artifactId>Domain</artifactId>
-	<dependencies>
-		<!-- JPA api -->
-		<dependency>
-			<groupId>org.eclipse.persistence</groupId>
-			<artifactId>javax.persistence</artifactId>
-			<version>${javax.persistence.version}</version>
-			<scope>provided</scope>
-		</dependency>
-	</dependencies>
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.jacp.jee</groupId>
+        <artifactId>JEE7-websocket</artifactId>
+        <version>1.0</version>
+    </parent>
+    <artifactId>Domain</artifactId>
+    <dependencies>
+        <!-- JPA api -->
+        <dependency>
+            <groupId>org.eclipse.persistence</groupId>
+            <artifactId>javax.persistence</artifactId>
+            <version>${javax.persistence.version}</version>
+            <scope>provided</scope>
+        </dependency>
+    </dependencies>
 
 </project>

File Domain/src/main/java/org/jacp/jee/App.java

 
 /**
  * Hello world!
- *
  */
-public class App 
-{
-    public static void main( String[] args )
-    {
-        System.out.println( "Hello World!" );
+public class App {
+    public static void main(String[] args) {
+        System.out.println("Hello World!");
     }
 }

File Domain/src/main/java/org/jacp/jee/entity/ClientMessage.java

 //@Entity
 public class ClientMessage implements Serializable {
     /**
-     * 
+     *
      */
     private static final long serialVersionUID = -6569693529124061369L;
     @Id
     }
 
     public ClientMessage(String title, Serializable body) {
-	this.title = title;
-	this.body = body;
+        this.title = title;
+        this.body = body;
     }
 
     public Serializable getBody() {
-	return body;
+        return body;
     }
 
     public void setBody(Serializable body) {
-	this.body = body;
+        this.body = body;
     }
 
     public String getTitle() {
-	return title;
+        return title;
     }
 
     public void setTitle(String title) {
-	this.title = title;
+        this.title = title;
     }
 
     public Long getId() {
-	return id;
+        return id;
     }
 
     public void setId(Long id) {
-	this.id = id;
+        this.id = id;
     }
 
 }

File Domain/src/main/java/org/jacp/jee/messages/ChatMessage.java

  * Time: 12:41
  * To change this template use File | Settings | File Templates.
  */
-public class ChatMessage extends Message{
+public class ChatMessage extends Message {
 
-    private static String USERNAME_PROPERTY="USER";
-    private static String MESSAGE_PROPERTY="MESSAGE";
+    private static String USERNAME_PROPERTY = "USER";
+    private static String MESSAGE_PROPERTY = "MESSAGE";
 
-    public ChatMessage(String userName,String message) {
+    public ChatMessage(String userName, String message) {
         super(MessageType.MESSAGE);
-        super.addValue(USERNAME_PROPERTY,userName);
-        super.addValue(MESSAGE_PROPERTY,message);
+        super.addValue(USERNAME_PROPERTY, userName);
+        super.addValue(MESSAGE_PROPERTY, message);
     }
 
     public String getUserName() {

File Domain/src/main/java/org/jacp/jee/messages/LoginMessage.java

  */
 public class LoginMessage extends Message {
 
-    private static String USERNAME_PROPERTY="USER";
+    private static String USERNAME_PROPERTY = "USER";
 
     public LoginMessage(String userName) {
         super(MessageType.LOGIN);
-        super.addValue(USERNAME_PROPERTY,userName);
+        super.addValue(USERNAME_PROPERTY, userName);
     }
 
     public String getUserName() {

File Domain/src/main/java/org/jacp/jee/messages/Message.java

  */
 public class Message implements Serializable {
 
-    private final Map<String,Serializable > values = new HashMap<>() ;
+    private final Map<String, Serializable> values = new HashMap<>();
     private final MessageType type;
 
     public Message(MessageType type) {
         return type;
     }
 
-    public void addValue(String key, Serializable value) {this.values.put(key,value);}
+    public void addValue(String key, Serializable value) {
+        this.values.put(key, value);
+    }
 
     public Object getValue(String key) {
         return this.values.get(key);

File Domain/src/main/java/org/jacp/jee/messages/MessageType.java

  * To change this template use File | Settings | File Templates.
  */
 public enum MessageType {
-    LOGIN,LOGOUT, MESSAGE,ADD_USER;
+    LOGIN, LOGOUT, MESSAGE, ADD_USER;
 }

File Domain/src/main/java/org/jacp/jee/messages/UserAddMessage.java

  * To change this template use File | Settings | File Templates.
  */
 public class UserAddMessage extends Message {
-    private static String USERNAME_PROPERTY="USER";
+    private static String USERNAME_PROPERTY = "USER";
+
     public UserAddMessage() {
         super(MessageType.ADD_USER);
     }

File Domain/src/main/resources/META-INF/persistence.xml

 <?xml version="1.0" encoding="UTF-8"?>
 <persistence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-    version="2.0"
-    xmlns="http://java.sun.com/xml/ns/persistence"
-    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd" >
+             version="2.0"
+             xmlns="http://java.sun.com/xml/ns/persistence"
+             xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
 
     <persistence-unit
-        name="messagePU"
-        transaction-type="JTA" >
+            name="messagePU"
+            transaction-type="JTA">
 
         <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
 
         <exclude-unlisted-classes>false</exclude-unlisted-classes>
 
         <properties>
-           <!--  <property
-                name="eclipselink.ddl-generation"
-                value="drop-and-create-tables" /> -->
+            <!--  <property
+                 name="eclipselink.ddl-generation"
+                 value="drop-and-create-tables" /> -->
         </properties>
     </persistence-unit>
 
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
     <modelVersion>4.0.0</modelVersion>
-	<parent>
-		<groupId>org.jacp.jee</groupId>
-		<artifactId>JEE7-websocket</artifactId>
-		<version>1.0</version>
-	</parent>
-  <name>EJB</name>
-  <artifactId>EJB</artifactId>
-  <packaging>ejb</packaging>
-	<build>
-		<plugins>
-			<plugin>
-				<artifactId>maven-ejb-plugin</artifactId>
-				<configuration>
-					<ejbVersion>3.1</ejbVersion>
-				</configuration>
-			</plugin>
-		</plugins>
-	</build>
-	<dependencies>
-		<dependency>
-			<groupId>javax</groupId>
-			<artifactId>javaee-api</artifactId>
-			<version>${jee.version}</version>
-			<scope>provided</scope>
-		</dependency>
-		<dependency>
-			<groupId>${project.groupId}</groupId>
-			<artifactId>Domain</artifactId>
-			<version>${project.version}</version>
-			<scope>provided</scope>
-		</dependency>
-		<dependency>
-			<groupId>${project.groupId}</groupId>
-			<artifactId>EJBClient</artifactId>
-			<version>${project.version}</version>
-			<scope>provided</scope>
-		</dependency>
+    <parent>
+        <groupId>org.jacp.jee</groupId>
+        <artifactId>JEE7-websocket</artifactId>
+        <version>1.0</version>
+    </parent>
+    <name>EJB</name>
+    <artifactId>EJB</artifactId>
+    <packaging>ejb</packaging>
+    <build>
+        <plugins>
+            <plugin>
+                <artifactId>maven-ejb-plugin</artifactId>
+                <configuration>
+                    <ejbVersion>3.1</ejbVersion>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+    <dependencies>
+        <dependency>
+            <groupId>javax</groupId>
+            <artifactId>javaee-api</artifactId>
+            <version>${jee.version}</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>Domain</artifactId>
+            <version>${project.version}</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>EJBClient</artifactId>
+            <version>${project.version}</version>
+            <scope>provided</scope>
+        </dependency>
 
     </dependencies>
 </project>

File EJB/src/main/java/org/jacp/jee/App.java

 
 /**
  * Hello world!
- *
  */
-public class App 
-{
-    public static void main( String[] args )
-    {
-        System.out.println( "Hello World!" );
+public class App {
+    public static void main(String[] args) {
+        System.out.println("Hello World!");
     }
 }

File EJB/src/main/java/org/jacp/jee/beans/SimpleMessageBean.java

     private EntityManager em;
 
     @PostConstruct
-    public void init() {System.out.println("crete SimpleMessageBean" );}
+    public void init() {
+        System.out.println("crete SimpleMessageBean");
+    }
 
 
     @PreDestroy
-    public void close() {System.out.println("close SimpleMessageBean" );}
+    public void close() {
+        System.out.println("close SimpleMessageBean");
+    }
 
 
     @Override
     public void create(ClientMessage message) {
-	//em.persist(message);
+        //em.persist(message);
 
     }
 
 //	query.select(query.from(ClientMessage.class));
 //
 //	return em.createQuery(query).getResultList();
-	List<ClientMessage> result = new ArrayList<>();
-	for(int i=0; i<100;i++) {
-	    result.add(new ClientMessage("hallo"+i, "welt: "+i));
-	}
-	return result;
+        List<ClientMessage> result = new ArrayList<>();
+        for (int i = 0; i < 100; i++) {
+            result.add(new ClientMessage("hallo" + i, "welt: " + i));
+        }
+        return result;
     }
 
     @Override

File EJB/src/test/java/org/jacp/jee/AppTest.java

 /**
  * Unit test for simple App.
  */
-public class AppTest 
-    extends TestCase
-{
+public class AppTest
+        extends TestCase {
     /**
      * Create the test case
      *
      * @param testName name of the test case
      */
-    public AppTest( String testName )
-    {
-        super( testName );
+    public AppTest(String testName) {
+        super(testName);
     }
 
     /**
      * @return the suite of tests being tested
      */
-    public static Test suite()
-    {
-        return new TestSuite( AppTest.class );
+    public static Test suite() {
+        return new TestSuite(AppTest.class);
     }
 
     /**
      * Rigourous Test :-)
      */
-    public void testApp()
-    {
-        assertTrue( true );
+    public void testApp() {
+        assertTrue(true);
     }
 }

File EJBClient/pom.xml

 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-  <modelVersion>4.0.0</modelVersion>
-	<parent>
-		<groupId>org.jacp.jee</groupId>
-		<artifactId>JEE7-websocket</artifactId>
-		<version>1.0</version>
-	</parent>
-  <artifactId>EJBClient</artifactId>
-  <name>EJBClient</name>
-  <dependencies>
-		<!-- JEE api -->
-		<dependency>
-			<groupId>javax</groupId>
-			<artifactId>javaee-api</artifactId>
-			<version>${jee.version}</version>
-			<scope>provided</scope>
-		</dependency>
-		<!-- Project specific dependencies -->
-		<dependency>
-			<groupId>${project.groupId}</groupId>
-			<artifactId>Domain</artifactId>
-			<version>${project.version}</version>
-			<scope>provided</scope>
-		</dependency>
-	</dependencies>
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.jacp.jee</groupId>
+        <artifactId>JEE7-websocket</artifactId>
+        <version>1.0</version>
+    </parent>
+    <artifactId>EJBClient</artifactId>
+    <name>EJBClient</name>
+    <dependencies>
+        <!-- JEE api -->
+        <dependency>
+            <groupId>javax</groupId>
+            <artifactId>javaee-api</artifactId>
+            <version>${jee.version}</version>
+            <scope>provided</scope>
+        </dependency>
+        <!-- Project specific dependencies -->
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>Domain</artifactId>
+            <version>${project.version}</version>
+            <scope>provided</scope>
+        </dependency>
+    </dependencies>
 
 </project>

File EJBClient/src/main/java/org/jacp/jee/App.java

 
 /**
  * Hello world!
- *
  */
-public class App 
-{
-    public static void main( String[] args )
-    {
-        System.out.println( "Hello World!" );
+public class App {
+    public static void main(String[] args) {
+        System.out.println("Hello World!");
     }
 }

File EJBClient/src/main/java/org/jacp/jee/api/MessageEJBInterface.java

 
 /**
  * The remote interface
- * @author Andy Moncsek
  *
+ * @author Andy Moncsek
  */
 @Remote
 public interface MessageEJBInterface {

File JacpFXWebsocketChatClient/src/main/java/org/jacp/chat/main/Paint.java

                 path.getElements()
                         .add(new MoveTo(mouseEvent.getX(), mouseEvent.getY()));
             } else if (mouseEvent.getEventType() == MouseEvent.MOUSE_DRAGGED) {
-                System.out.println(mouseEvent.getX()+" : "+mouseEvent.getY());
+                System.out.println(mouseEvent.getX() + " : " + mouseEvent.getY());
                 path.getElements()
                         .add(new LineTo(mouseEvent.getX(), mouseEvent.getY()));
             }

File JavaClient/pom.xml

 
 
     <artifactId>JavaClient</artifactId>
-   <dependencies>
-       <dependency>
-           <groupId>org.glassfish.tyrus</groupId>
-           <artifactId>tyrus-client</artifactId>
-           <version>${tyrusWebsocket.version}</version>
-           <scope>compile</scope>
-       </dependency>
-       <dependency>
-           <groupId>org.glassfish.tyrus</groupId>
-           <artifactId>tyrus-core</artifactId>
-           <version>${tyrusWebsocket.version}</version>
-           <scope>compile</scope>
-       </dependency>
-       <dependency>
-           <groupId>org.glassfish.tyrus</groupId>
-           <artifactId>tyrus-server</artifactId>
-           <version>${tyrusWebsocket.version}</version>
-           <scope>compile</scope>
-       </dependency>
-       <dependency>
-           <groupId>org.glassfish.tyrus</groupId>
-           <artifactId>tyrus-spi</artifactId>
-           <version>${tyrusWebsocket.version}</version>
-           <scope>compile</scope>
-       </dependency>
-       <dependency>
-           <groupId>org.glassfish.tyrus</groupId>
-           <artifactId>tyrus-client</artifactId>
-           <version>${tyrusWebsocket.version}</version>
-           <scope>compile</scope>
-       </dependency>
-       <dependency>
-           <groupId>org.glassfish.tyrus</groupId>
-           <artifactId>tyrus-container-servlet</artifactId>
-           <version>${tyrusWebsocket.version}</version>
-           <scope>compile</scope>
-       </dependency>
-       <dependency>
-           <groupId>org.glassfish.tyrus</groupId>
-           <artifactId>tyrus-container-grizzly</artifactId>
-           <version>${tyrusWebsocket.version}</version>
-           <scope>compile</scope>
-       </dependency>
-       <dependency>
-           <groupId>org.glassfish.tyrus</groupId>
-           <artifactId>tyrus-websocket-core</artifactId>
-           <version>${tyrusWebsocket.version}</version>
-           <scope>compile</scope>
-       </dependency>
-       <dependency>
-           <groupId>org.glassfish.tyrus</groupId>
-           <artifactId>tyrus-container-glassfish-cdi</artifactId>
-           <version>${tyrusWebsocket.version}</version>
-           <scope>compile</scope>
-       </dependency>
-       <dependency>
-           <groupId>${project.groupId}</groupId>
-           <artifactId>Domain</artifactId>
-           <version>${project.version}</version>
-           <scope>provided</scope>
-       </dependency>
-   </dependencies>
+    <dependencies>
+        <dependency>
+            <groupId>org.glassfish.tyrus</groupId>
+            <artifactId>tyrus-client</artifactId>
+            <version>${tyrusWebsocket.version}</version>
+            <scope>compile</scope>
+        </dependency>
+        <!--       <dependency>
+                   <groupId>org.glassfish.tyrus</groupId>
+                   <artifactId>tyrus-websocket-core</artifactId>
+                   <version>${tyrusWebsocket.version}</version>
+                   <scope>compile</scope>
+               </dependency>-->
+        <dependency>
+            <groupId>org.glassfish.tyrus</groupId>
+            <artifactId>tyrus-server</artifactId>
+            <version>${tyrusWebsocket.version}</version>
+            <scope>compile</scope>
+        </dependency>
+        <!--       <dependency>
+                   <groupId>org.glassfish.tyrus</groupId>
+                   <artifactId>tyrus-spi</artifactId>
+                   <version>${tyrusWebsocket.version}</version>
+                   <scope>compile</scope>
+               </dependency>-->
+        <dependency>
+            <groupId>org.glassfish.tyrus</groupId>
+            <artifactId>tyrus-client</artifactId>
+            <version>${tyrusWebsocket.version}</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.glassfish.tyrus</groupId>
+            <artifactId>tyrus-container-servlet</artifactId>
+            <version>${tyrusWebsocket.version}</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.glassfish.tyrus</groupId>
+            <artifactId>tyrus-container-grizzly</artifactId>
+            <version>${tyrusWebsocket.version}</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.glassfish.tyrus</groupId>
+            <artifactId>tyrus-websocket-core</artifactId>
+            <version>${tyrusWebsocket.version}</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.glassfish.tyrus</groupId>
+            <artifactId>tyrus-container-glassfish-cdi</artifactId>
+            <version>${tyrusWebsocket.version}</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>Domain</artifactId>
+            <version>${project.version}</version>
+            <scope>provided</scope>
+        </dependency>
+    </dependencies>
 
 </project>

File JavaClient/src/main/java/org/jacp/chat/ChatClientEndpoit.java

 package org.jacp.chat;
 
 
-
 import org.jacp.jee.messages.ChatMessage;
 import org.jacp.jee.messages.LoginMessage;
 import org.jacp.jee.messages.UserAddMessage;
  * Time: 09:49
  * To change this template use File | Settings | File Templates.
  */
-@ClientEndpoint(encoders ={ClientLoginEncoder.class,ChatMessageEncoder.class}, decoders = {ClientAddUserDecoder.class, ChatMessageDecoder.class})
+@ClientEndpoint(encoders = {ClientLoginEncoder.class, ChatMessageEncoder.class}, decoders = {ClientAddUserDecoder.class, ChatMessageDecoder.class})
 public class ChatClientEndpoit {
     private Session session;
     CountDownLatch messageLatch;
     public ChatClientEndpoit(CountDownLatch messageLatch) {
         this.messageLatch = messageLatch;
     }
+
     public ChatClientEndpoit() {
 
     }
+
     @OnOpen
     public void onOpen(Session session) {
         this.session = session;
     }
 
     public void login() throws IOException, EncodeException {
-        System.out.println("myLogin"+session);
+        System.out.println("myLogin" + session);
         session.getBasicRemote().sendObject(new LoginMessage("anni"));
 
     }
 
     public void sendMessage(String message) throws IOException, EncodeException {
-        session.getBasicRemote().sendObject(new ChatMessage("anni",message));
+        session.getBasicRemote().sendObject(new ChatMessage("anni", message));
 
     }
 //    @OnMessage
 //    }
 
     @OnMessage
-    public void onUserAdd(UserAddMessage userAdd){
-        System.out.println("user add: "+userAdd.getUserName());
+    public void onUserAdd(UserAddMessage userAdd) {
+        System.out.println("user add: " + userAdd.getUserName());
     }
 
     @OnMessage
-    public void onChatMessage(ChatMessage chatMessage){
-        System.out.println("chat message: "+chatMessage.getMessage());
+    public void onChatMessage(ChatMessage chatMessage) {
+        System.out.println("chat message: " + chatMessage.getMessage());
     }
 
 }

File JavaClient/src/main/java/org/jacp/chat/ChatMessageDecoder.java

 
     @Override
     public boolean willDecode(ByteBuffer byteBuffer) {
-        Message message = (Message)SerializationUtils.deserialize(byteBuffer.array()) ;
-        if(message==null) return false;
-        if(message.getType().equals(MessageType.MESSAGE)) return true;
+        Message message = (Message) SerializationUtils.deserialize(byteBuffer.array());
+        if (message == null) return false;
+        if (message.getType().equals(MessageType.MESSAGE)) return true;
         return false;
     }
 }

File JavaClient/src/test/java/test/ConnectToEchoWebsocket.java

 package test;
 
 
-
-
 import org.glassfish.tyrus.client.ClientManager;
 import org.junit.BeforeClass;
 import org.junit.Test;
                         public void onMessage(String message) {
                             System.out.println("### Received: " + message);
 
-                            if(message.length()>5) {
+                            if (message.length() > 5) {
                                 messageLatch.countDown();
                             } else if (message.equals("onOpen")) {
                                 //                        onOpenLatch.countDown();
     public void connectToEcho() throws DeploymentException, IOException, InterruptedException {
 
         ClientManager client = ClientManager.createClient();
-        Session session = client.connectToServer(new MyClientEndpoint(),ClientEndpointConfigurationBuilder.create().build(), getURI());
+        Session session = client.connectToServer(new MyClientEndpoint(), ClientEndpointConfigurationBuilder.create().build(), getURI());
         System.out.println(session.isOpen());
         messageLatch1.await(100, TimeUnit.SECONDS);
     }
             return null;
         }
     }
+
     @ClientEndpoint
     public class MyClientEndpoint {
         @OnOpen

File WebClient-SSE/src/main/java/org/jacp/sse/SSEResource.java

+/*
+ * Copyright (c) 2013, Andy Moncsek, inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are permitted provided
+ * that the following conditions are met:
+ *
+ *    Redistributions of source code must retain the above copyright notice, this list of conditions and the
+ *    following disclaimer.
+ *
+ *    Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
+ *    the following disclaimer in the documentation and/or other materials provided with the distribution.
+ *
+ *    Neither the name of Andy Moncsek, inc. nor the names of its contributors may be used to endorse or
+ *    promote products derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
 package org.jacp.sse;
 
 import org.glassfish.jersey.media.sse.EventOutput;
 
 /**
  * Created with IntelliJ IDEA.
- * User: ady
+ * User: Andy Moncsek
  * Date: 07.03.13
  * Time: 16:04
  * To change this template use File | Settings | File Templates.

File WebClient-SSE/src/main/java/org/jacp/sse/WebClient.java

+/*
+ * Copyright (c) 2013, Andy Moncsek, inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are permitted provided
+ * that the following conditions are met:
+ *
+ *    Redistributions of source code must retain the above copyright notice, this list of conditions and the
+ *    following disclaimer.
+ *
+ *    Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
+ *    the following disclaimer in the documentation and/or other materials provided with the distribution.
+ *
+ *    Neither the name of Andy Moncsek, inc. nor the names of its contributors may be used to endorse or
+ *    promote products derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
 package org.jacp.sse;
 
 import net.sf.json.JSONArray;
 
 /**
  * Created with IntelliJ IDEA.
- * User: ady
+ * User: Andy Moncsek
  * Date: 08.03.13
  * Time: 09:30
- * To change this template use File | Settings | File Templates.
+ * A simple servlet that receives events and writes out the messages
  */
-@WebServlet(name = "WebClient", urlPatterns = {"/WebClient"} ,asyncSupported=true)
+@WebServlet(name = "WebClient", urlPatterns = {"/WebClient"}, asyncSupported = true)
 public class WebClient extends HttpServlet {
 
     private final static String TARGET_URI = "http://localhost:8080/WebClient-SSE/twittersse";
      * <code>GET</code> and
      * <code>POST</code> methods.
      *
-     * @param request servlet request
+     * @param request  servlet request
      * @param response servlet response
-     * @throws ServletException if a servlet-specific error occurs
+     * @throws ServletException    if a servlet-specific error occurs
      * @throws java.io.IOException if an I/O error occurs
      */
     @Override
                     public void onEvent(InboundEvent inboundEvent) {
                         try {
                             //get the JSON data and parse it
-                            JSONObject jsonObject = JSONObject.fromObject( inboundEvent.getData(String.class,
-                                    MediaType.APPLICATION_JSON_TYPE ));
+                            JSONObject jsonObject = JSONObject.fromObject(inboundEvent.getData(String.class,
+                                    MediaType.APPLICATION_JSON_TYPE));
                             JSONArray jsonArray = (((JSONArray) (jsonObject.get("results"))));
-                            for (int i = 0; i <jsonArray.size(); i++) {
-                                JSONObject o = ((JSONObject)jsonArray.get(i)) ;
-                                out.println( o.get("text"));
+                            for (int i = 0; i < jsonArray.size(); i++) {
+                                JSONObject o = ((JSONObject) jsonArray.get(i));
+                                out.println(o.get("text"));
                                 out.println("<br>");
                                 out.println("Created at " + o.get("created_at"));
                                 out.println("<br>");

File WebClient-SSE/src/main/java/org/jacp/sse/application/JerseyApplication.java

+/*
+ * Copyright (c) 2013, Andy Moncsek, inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are permitted provided
+ * that the following conditions are met:
+ *
+ *    Redistributions of source code must retain the above copyright notice, this list of conditions and the
+ *    following disclaimer.
+ *
+ *    Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
+ *    the following disclaimer in the documentation and/or other materials provided with the distribution.
+ *
+ *    Neither the name of Andy Moncsek, inc. nor the names of its contributors may be used to endorse or
+ *    promote products derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
 package org.jacp.sse.application;
 
-import org.glassfish.jersey.media.sse.OutboundEventWriter;
+import org.glassfish.jersey.media.sse.SseFeature;
 import org.jacp.sse.SSEResource;
 
 import javax.ws.rs.core.Application;
 
 /**
  * Created with IntelliJ IDEA.
- * User: ady
+ * User: Andy Moncsek
  * Date: 07.03.13
  * Time: 16:08
- * To change this template use File | Settings | File Templates.
+ * Defines the Jersey Application in Web context
  */
 public class JerseyApplication extends Application {
 
     Set<Class<?>> classes = new HashSet<Class<?>>() {
-        { add(SSEResource.class);
-            add(OutboundEventWriter.class);
-        }};
+        {
+            add(SSEResource.class);
+            add(SseFeature.class);
+        }
+    };
 
     @Override
     public Set<Class<?>> getClasses() {

File WebClient-SSE/src/main/java/org/jacp/sse/beans/TwitterTimerBean.java

 @Named
 public class TwitterTimerBean {
 
-    private final static String TARGET_URI= "http://localhost:8080/WebClient-SSE";
+    private final static String TARGET_URI = "http://localhost:8080/WebClient-SSE";
 
-    @Schedule(hour="*", minute="*", second="*/10")
+    @Schedule(hour = "*", minute = "*", second = "*/10")
     public void sendTweets() {
 
         Client client = ClientBuilder.newClient();
         try {
-            WebTarget webTarget= client.target(new URI(TARGET_URI)) ;
+            WebTarget webTarget = client.target(new URI(TARGET_URI));
             List<String> list = new ArrayList<String>();
             list.add("glassfish");
             list.add("gf_jersey");
             String randomElement;
             int listSize = list.size();
             randomElement = list.get(rg.nextInt(listSize));
-            System.out.println("String" +randomElement);
+            System.out.println("String" + randomElement);
             String message = getFeedData(randomElement);
             System.out.println("Posting message");
             webTarget.path("twittersse").request().post(Entity.text(message));
     }
 
 
-    private  String getFeedData(String input) {
+    private String getFeedData(String input) {
         StringBuilder sb = new StringBuilder();
-        String searchURL ="http://search.twitter.com/search.json?q="+input+"&rpp=5&include_entities=true" +
+        String searchURL = "http://search.twitter.com/search.json?q=" + input + "&rpp=5&include_entities=true" +
                 "&with_twitter_user_id=true&result_type=mixed";
         try {
             URL twitter = new URL(searchURL);
 
             while ((inputLine = in.readLine()) != null) {
                 System.out.println("Input line" + inputLine);
-                sb.append(inputLine)  ;
+                sb.append(inputLine);
 
             }
             in.close();
         } catch (IOException e) {
             e.printStackTrace();
         }
-        return new String("Error in getting data from the feeds ") ;
+        return new String("Error in getting data from the feeds ");
     }