Commits

Andy Moncsek  committed 8a995b5

projects renamed, clean up

  • Participants
  • Parent commits 5094160

Comments (0)

Files changed (28)

File EAR/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>EAR</artifactId>
-  <packaging>ear</packaging>
-  <name>EAR</name>
-  <build>
-		<plugins>
-			<plugin>
-				<groupId>org.apache.maven.plugins</groupId>
-				<artifactId>maven-ear-plugin</artifactId>
-				<version>2.8</version>
-				<configuration>
-					<version>6</version>
-					<modules>
-						<jarModule>
-							<groupId>${project.groupId}</groupId>
-							<artifactId>Domain</artifactId>
-							<bundleDir>/lib</bundleDir>
-						</jarModule>
-						<jarModule>
-							<groupId>${project.groupId}</groupId>
-							<artifactId>EJBClient</artifactId>
-							<bundleDir>/lib</bundleDir>
-						</jarModule>
-						<ejbModule>
-							<groupId>${project.groupId}</groupId>
-							<artifactId>EJB</artifactId>
-						</ejbModule>
-						<webModule>
-							<groupId>${project.groupId}</groupId>
-							<artifactId>WebClient</artifactId>
-						</webModule>
-					</modules>
-				</configuration>
-			</plugin>
-		</plugins>
-	</build>
-	<dependencies>
-		<dependency>
-			<groupId>${project.groupId}</groupId>
-			<artifactId>Domain</artifactId>
-			<version>${project.version}</version>
-		</dependency>
-		<dependency>
-			<groupId>${project.groupId}</groupId>
-			<artifactId>EJBClient</artifactId>
-			<version>${project.version}</version>
-		</dependency>
-		<dependency>
-			<groupId>${project.groupId}</groupId>
-			<artifactId>EJB</artifactId>
-			<version>${project.version}</version>
-			<type>ejb</type>
-		</dependency>
-		<dependency>
-			<groupId>${project.groupId}</groupId>
-			<artifactId>WebClient</artifactId>
-			<version>${project.version}</version>
-			<type>war</type>
-		</dependency>
-	</dependencies>
-</project>

File EAR/src/main/application/META-INF/glassfish-resources.xml

-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE resources PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Resource Definitions //EN" "http://glassfish.org/dtds/glassfish-resources_1_5.dtd">
-<resources>
-
-    <jdbc-resource jndi-name="jdbc/messageDS" pool-name="jdbc/newsAppDSPool" />
-
-    <jdbc-connection-pool name="jdbc/newsAppDSPool" datasource-classname="org.apache.derby.jdbc.EmbeddedDataSource" max-pool-size="5" pool-resize-quantity="1" res-type="javax.sql.DataSource" statement-timeout-in-seconds="60" steady-pool-size="0">
-        <property name="dataBaseName" value="NewsDB" />
-        <property name="User" value="APP" />
-        <property name="Password" value="APP" />
-        <property name="connectionAttributes" value=";create=true" />
-        <property name="driverType" value="4" />
-    </jdbc-connection-pool>
-
-</resources>

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

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

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

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

File JacpFXChatClient/src/main/java/org/jacp/chat/decoders/ChatMessageDecoder.java

-package org.jacp.chat.decoders;
-
-import org.apache.commons.lang.SerializationUtils;
-import org.jacp.jee.messages.ChatMessage;
-import org.jacp.jee.messages.Message;
-import org.jacp.jee.messages.MessageType;
-
-import javax.websocket.DecodeException;
-import javax.websocket.Decoder;
-import java.nio.ByteBuffer;
-
-/**
- * Created with IntelliJ IDEA.
- * User: ady
- * Date: 27.02.13
- * Time: 15:32
- * To change this template use File | Settings | File Templates.
- */
-public class ChatMessageDecoder implements Decoder.Binary<ChatMessage> {
-    @Override
-    public ChatMessage decode(ByteBuffer byteBuffer) throws DecodeException {
-        return (ChatMessage) SerializationUtils.deserialize(byteBuffer.array());  //To change body of implemented methods use File | Settings | File Templates.
-    }
-
-    @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;
-        return false;
-    }
-}
-
-

File JacpFXChatClient/src/main/java/org/jacp/chat/decoders/ClientAddUserDecoder.java

-package org.jacp.chat.decoders;
-
-import org.apache.commons.lang.SerializationUtils;
-import org.jacp.jee.messages.Message;
-import org.jacp.jee.messages.MessageType;
-import org.jacp.jee.messages.UserAddMessage;
-
-import javax.websocket.DecodeException;
-import javax.websocket.Decoder;
-import java.nio.ByteBuffer;
-
-/**
- * Created with IntelliJ IDEA.
- * User: ady
- * Date: 05.03.13
- * Time: 22:11
- * To change this template use File | Settings | File Templates.
- */
-public class ClientAddUserDecoder implements Decoder.Binary<UserAddMessage> {
-    @Override
-    public UserAddMessage decode(ByteBuffer byteBuffer) throws DecodeException {
-        return (UserAddMessage) SerializationUtils.deserialize(byteBuffer.array());  //To change body of implemented methods use File | Settings | File Templates.
-    }
-
-    @Override
-    public boolean willDecode(ByteBuffer byteBuffer) {
-        Message message = (Message) SerializationUtils.deserialize(byteBuffer.array());
-        if (message == null) return false;
-        if (message.getType().equals(MessageType.ADD_USER)) return true;
-        return false;
-    }
-}
-
-
-
-

File JacpFXChatClient/src/main/java/org/jacp/chat/dialogs/LoginDialog.java

-package org.jacp.chat.dialogs;
-
-import javafx.fxml.FXML;
-import javafx.scene.control.TextField;
-import org.jacp.api.annotations.Dialog;
-import org.jacp.api.annotations.Resource;
-import org.jacp.api.dialog.Scope;
-import org.jacp.javafx.rcp.component.AFXComponent;
-import org.jacp.javafx.rcp.components.modalDialog.JACPModalDialog;
-import org.jacp.jee.messages.LoginMessage;
-
-/**
- * Created with IntelliJ IDEA.
- * User: Andy moncsek
- * Date: 06.03.13
- * Time: 15:43
- * To change this template use File | Settings | File Templates.
- */
-@Dialog(id = "id100", viewLocation = "/fxml/LoginDialog.fxml", resourceBundleLocation = "bundles.languageBundle", localeID = "en_US", scope = Scope.SINGLETON)
-public class LoginDialog {
-
-    @FXML
-    private TextField login;
-    @Resource
-    private AFXComponent parent;
-
-    @FXML
-    public void login(){
-        if(login.getText()!=null && !login.getText().isEmpty()) {
-            parent.getActionListener("id003",new LoginMessage(login.getText())).performAction(null);
-            parent.getActionListener("id002",new LoginMessage(login.getText())).performAction(null);
-            JACPModalDialog.getInstance().hideModalMessage();
-        }
-
-    }
-}

File JacpFXChatClient/src/main/java/org/jacp/chat/encoders/ChatMessageEncoder.java

-package org.jacp.chat.encoders;
-
-import org.apache.commons.lang.SerializationUtils;
-import org.jacp.jee.messages.ChatMessage;
-
-import javax.websocket.EncodeException;
-import javax.websocket.Encoder;
-import java.nio.ByteBuffer;
-
-/**
- * Created with IntelliJ IDEA.
- * User: ady
- * Date: 06.03.13
- * Time: 10:14
- * To change this template use File | Settings | File Templates.
- */
-public class ChatMessageEncoder implements Encoder.Binary<ChatMessage> {
-    @Override
-    public ByteBuffer encode(ChatMessage message) throws EncodeException {
-        return ByteBuffer.wrap(SerializationUtils.serialize(message));
-    }
-}

File JacpFXChatClient/src/main/java/org/jacp/chat/encoders/ClientLoginEncoder.java

-package org.jacp.chat.encoders;
-
-import org.apache.commons.lang.SerializationUtils;
-import org.jacp.jee.messages.LoginMessage;
-
-import javax.websocket.EncodeException;
-import javax.websocket.Encoder;
-import java.nio.ByteBuffer;
-
-/**
- * Created with IntelliJ IDEA.
- * User: ady
- * Date: 28.02.13
- * Time: 09:50
- * To change this template use File | Settings | File Templates.
- */
-public class ClientLoginEncoder implements Encoder.Binary<LoginMessage> {
-    @Override
-    public ByteBuffer encode(LoginMessage loginMessage) throws EncodeException {
-        return ByteBuffer.wrap(SerializationUtils.serialize(loginMessage));
-    }
-}

File JacpFXChatClient/src/main/java/org/jacp/chat/entities/User.java

-package org.jacp.chat.entities;
-
-/**
- * Created with IntelliJ IDEA.
- * User: ady
- * Date: 06.03.13
- * Time: 11:48
- * To change this template use File | Settings | File Templates.
- */
-public class User {
-    private final String userName;
-    public User(final String userName){
-              this.userName = userName;
-    }
-
-    public String getUserName() {
-        return this.userName;
-    }
-}

File WebClient/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>WebClient</artifactId>
-  <packaging>war</packaging>
-  <repositories>
-		<repository>
-			<id>prime-repo</id>
-			<name>PrimeFacesMaven Repository</name>
-			<url>http://repository.primefaces.org</url>
-			<layout>default</layout>
-		</repository>
-  </repositories>
-  <dependencies>
-      <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>
-		<dependency>
-		<groupId>${project.groupId}</groupId>
-		<artifactId>EJBClient</artifactId>
-		<version>${project.version}</version>
-	</dependency>
-	      
-    <dependency>
-		<groupId>org.primefaces</groupId>
-		<artifactId>primefaces</artifactId>
-		<version>2.2.1</version>
-	</dependency>
-
-  </dependencies>
-<!--  <build>
-    <finalName>WebClient</finalName>
-  </build>-->
-</project>

File WebClient/src/main/java/org/jacp/beans/SimpleWebsocket.java

-package org.jacp.beans;
-
-import org.jacp.beans.ejb.SimpleStateless;
-import org.jacp.jee.api.MessageEJBInterface;
-import org.jacp.jee.entity.ClientMessage;
-
-import javax.ejb.EJB;
-import javax.inject.Inject;
-import javax.websocket.Session;
-import javax.websocket.WebSocketMessage;
-import javax.websocket.server.DefaultServerConfiguration;
-import javax.websocket.server.WebSocketEndpoint;
-import java.io.IOException;
-import java.util.List;
-import java.util.Set;
-
-
-@WebSocketEndpoint(value = "/echo", configuration=DefaultServerConfiguration.class)
-public class SimpleWebsocket {
-    @EJB(name="SimpleMessagingBean",beanName = "SimpleMessagingBean")
-    private MessageEJBInterface bean;
-
-	@WebSocketMessage
-    public String sayHello(String name, Session session) throws IOException {
-		System.out.println("hallo"+session+" :: "+this+"::: bean::  "+bean);
-		Set<Session> sessions = session.getOpenSessions();
-		
-		StringBuffer buffer = new StringBuffer("sessions: ");
-		for(Session s:sessions){
-		    buffer.append(s.hashCode()).append(",");
-           if(!s.getId().equals(session.getId())) s.getRemote().sendString("hello from an other session: "+name);
-		}
-//        List<ClientMessage> result = bean.findAll();
-        String returnVal ="<ul>";
-//        for(ClientMessage c :result) {
-//            returnVal +="<li>"+c.getBody()+"</li>";
-//        }
-        returnVal +="</ul>:::";
-        return buffer.toString()+" :::: "+returnVal;
-    }
-}

File WebClient/src/main/java/org/jacp/beans/WebSocketWithMessageHandler.java

-package org.jacp.beans;
-
-import java.io.IOException;
-import java.io.Serializable;
-import java.util.Set;
-
-import javax.annotation.PostConstruct;
-import javax.annotation.Resource;
-import javax.ejb.*;
-import javax.websocket.MessageHandler;
-import javax.websocket.Session;
-
-import javax.websocket.WebSocketOpen;
-import javax.websocket.server.DefaultServerConfiguration;
-import javax.websocket.server.WebSocketEndpoint;
-
-import org.jacp.beans.ejb.SimpleStateless;
-import org.jacp.jee.api.MessageEJBInterface;
-
-
-
-
-@WebSocketEndpoint(value = "/handler", configuration = DefaultServerConfiguration.class)
-public class WebSocketWithMessageHandler implements Serializable{
-
-   
-   // private ServerContainer container = ContainerProvider.getServerContainer();
-    
-    @PostConstruct
-    public void init() {
-
-    }
-
-    @WebSocketOpen
-    public void onOpen(final Session session) {
-	System.out.println("open connection ");
-
-	session.addMessageHandler(new MessageHandler.Basic<String>(){
-
-	    @Override
-	    public void onMessage(String text) {
-		try {
-		    System.out.println("handler: " + this + " Thread:"
-			    + Thread.currentThread()+" bean: ");
-		    session.getRemote().sendString("Hello: ");
-		} catch (IOException e) {
-		    // TODO Auto-generated catch block
-		   ;e.printStackTrace();
-		}
-
-	    }
-	});
-    }
-}

File WebClient/src/main/java/org/jacp/beans/ejb/SimpleStateless.java

-package org.jacp.beans.ejb;
-
-import java.util.List;
-
-import javax.annotation.PostConstruct;
-import javax.ejb.EJB;
-import javax.ejb.PostActivate;
-import javax.ejb.Stateless;
-
-import org.jacp.beans.WebSocketWithMessageHandler;
-import org.jacp.jee.api.MessageEJBInterface;
-import org.jacp.jee.entity.ClientMessage;
-
-@Stateless(mappedName="simple",name="simple")
-public class SimpleStateless {
-    @EJB(mappedName="SimpleMessagingBean")
-	private MessageEJBInterface bean;
-
-    
-    @PostConstruct
-    @PostActivate
-    public void init() {
-	System.out.println("POSTCONSTRUCT: SimpleStateless");
-    }
-    public String sayHello() {
-	List<ClientMessage> result = bean.findAll();
-	String returnVal ="<ul>";
-	for(ClientMessage c :result) {
-		returnVal +="<li>"+c.getBody()+"</li>";
-	}
-	returnVal +="</ul>";
-	return "Hello:::"+returnVal;
-    }
-}

File WebClient/src/main/java/org/jacp/beans/managed/MessageBean.java

-package org.jacp.beans.managed;
-
-import java.util.List;
-
-import javax.ejb.EJB;
-import javax.faces.bean.ApplicationScoped;
-import javax.faces.bean.ManagedBean;
-
-import org.jacp.beans.ejb.SimpleStateless;
-import org.jacp.jee.api.MessageEJBInterface;
-import org.jacp.jee.entity.ClientMessage;
-
-@ManagedBean
-@ApplicationScoped
-public class MessageBean {
-    @EJB(name="SimpleMessagingBean",beanName = "SimpleMessagingBean")
-	private MessageEJBInterface bean;
-
-
-	public String getMessage() {
-		List<ClientMessage> result = bean.findAll();
-		if(result==null || result.isEmpty()) {
-			return "no messages";
-		} else {
-			String returnVal ="<ul>";
-			for(ClientMessage c :result) {
-				returnVal +="<li>"+c.getBody()+"</li>";
-			}
-			returnVal +="</ul>:::";
-			return returnVal;
-		}
-	}
-
-}
-

File WebClient/src/main/java/org/jacp/beans/websocket/chat/ChatEndpoint.java

-package org.jacp.beans.websocket.chat;
-
-import org.jacp.beans.websocket.chat.decoder.ChatMessageDecoder;
-import org.jacp.beans.websocket.chat.decoder.LoginMessageDecoder;
-import org.jacp.beans.websocket.chat.encoder.ChatMessageEncoder;
-import org.jacp.beans.websocket.chat.encoder.UserAddMessageEncoder;
-import org.jacp.jee.messages.ChatMessage;
-import org.jacp.jee.messages.LoginMessage;
-import org.jacp.jee.messages.UserAddMessage;
-
-import javax.websocket.EncodeException;
-import javax.websocket.Session;
-import javax.websocket.WebSocketMessage;
-import javax.websocket.WebSocketOpen;
-import javax.websocket.server.DefaultServerConfiguration;
-import javax.websocket.server.WebSocketEndpoint;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.logging.Logger;
-
-/**
- * Created with IntelliJ IDEA.
- * User: Andy Moncsek
- * Date: 26.02.13
- * Time: 15:57
- * To change this template use File | Settings | File Templates.
- */
-@WebSocketEndpoint(value = "/chat", decoders = {
-        ChatMessageDecoder.class,
-        LoginMessageDecoder.class
-},
-        encoders = {
-                UserAddMessageEncoder.class,
-                ChatMessageEncoder.class, UserAddMessageEncoder.class
-        },
-        configuration = DefaultServerConfiguration.class)
-public class ChatEndpoint {
-    final static Logger logger = Logger.getLogger("application");
-
-    @WebSocketOpen
-    public void init(Session s) {
-        logger.info("############Someone connected..." + s.getId() + "  socket: " + this);
-    }
-
-
-    @WebSocketMessage
-    public void handleLoginRequest(LoginMessage lrm, Session session) {
-        logger.info("############login..." + lrm.getUserName() + "  socket: " + this);
-        session.getUserProperties().put("user", new UserAddMessage(lrm.getUserName()));
-        broadcastNewUser(lrm.getUserName(), session);
-    }
-
-    @WebSocketMessage
-    public void handleChatMessage(ChatMessage cm, Session session) {
-        broadcastMessage(cm, session);
-    }
-
-    private void broadcastMessage(ChatMessage cm, Session session) {
-        for (Session s : session.getOpenSessions()) {
-            try {
-                System.out.println("send message : " + cm.getMessage());
-                s.getRemote().sendObject(cm);
-            } catch (IOException e) {
-                e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
-            } catch (EncodeException e) {
-                e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
-            }
-        }
-    }
-
-    private void broadcastNewUser(String newUsername, Session session) {
-        try {
-            for (Session s : session.getOpenSessions()) {
-                s.getRemote().sendObject(new UserAddMessage(newUsername));
-                if (!s.getId().equals(session.getId())){
-                    System.out.println("Send: "+((UserAddMessage)s.getUserProperties().get("user")).getUserName());
-                    session.getRemote().sendObject(s.getUserProperties().get("user"));
-                }
-            }
-        } catch (IOException e) {
-            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
-        } catch (EncodeException e) {
-            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
-        }
-    }
-}

File WebClient/src/main/java/org/jacp/beans/websocket/chat/decoder/ChatMessageDecoder.java

-package org.jacp.beans.websocket.chat.decoder;
-
-import org.apache.commons.lang.SerializationUtils;
-import org.jacp.jee.messages.ChatMessage;
-import org.jacp.jee.messages.LoginMessage;
-import org.jacp.jee.messages.Message;
-import org.jacp.jee.messages.MessageType;
-
-import javax.websocket.DecodeException;
-import javax.websocket.Decoder;
-import java.nio.ByteBuffer;
-
-/**
- * Created with IntelliJ IDEA.
- * User: ady
- * Date: 27.02.13
- * Time: 15:32
- * To change this template use File | Settings | File Templates.
- */
-public class ChatMessageDecoder implements Decoder.Binary<ChatMessage> {
-    @Override
-    public ChatMessage decode(ByteBuffer byteBuffer) throws DecodeException {
-        return (ChatMessage) SerializationUtils.deserialize(byteBuffer.array());  //To change body of implemented methods use File | Settings | File Templates.
-    }
-
-    @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;
-        return false;
-    }
-}
-
-

File WebClient/src/main/java/org/jacp/beans/websocket/chat/decoder/LoginMessageDecoder.java

-package org.jacp.beans.websocket.chat.decoder;
-
-import org.apache.commons.lang.SerializationUtils;
-import org.jacp.jee.messages.LoginMessage;
-import org.jacp.jee.messages.Message;
-import org.jacp.jee.messages.MessageType;
-
-import javax.websocket.DecodeException;
-import javax.websocket.Decoder;
-import java.io.ByteArrayInputStream;
-import java.io.ObjectInput;
-import java.io.ObjectInputStream;
-import java.nio.ByteBuffer;
-
-/**
- * Created with IntelliJ IDEA.
- * User: ady
- * Date: 27.02.13
- * Time: 12:53
- * To change this template use File | Settings | File Templates.
- */
-public class LoginMessageDecoder implements Decoder.Binary<LoginMessage> {
-    @Override
-    public LoginMessage decode(ByteBuffer byteBuffer) throws DecodeException {
-        return (LoginMessage) SerializationUtils.deserialize(byteBuffer.array());  //To change body of implemented methods use File | Settings | File Templates.
-    }
-
-    @Override
-    public boolean willDecode(ByteBuffer byteBuffer) {
-        Message message = (Message)SerializationUtils.deserialize(byteBuffer.array()) ;
-        if(message==null) return false;
-        if(message.getType().equals(MessageType.LOGIN)) return true;
-        return false;
-    }
-}

File WebClient/src/main/java/org/jacp/beans/websocket/chat/encoder/ChatMessageEncoder.java

-package org.jacp.beans.websocket.chat.encoder;
-
-import org.apache.commons.lang.SerializationUtils;
-import org.jacp.jee.messages.ChatMessage;
-import org.jacp.jee.messages.LoginMessage;
-
-import javax.websocket.EncodeException;
-import javax.websocket.Encoder;
-import java.nio.ByteBuffer;
-
-/**
- * Created with IntelliJ IDEA.
- * User: ady
- * Date: 06.03.13
- * Time: 09:40
- * To change this template use File | Settings | File Templates.
- */
-public class ChatMessageEncoder implements Encoder.Binary<ChatMessage>{
-    @Override
-    public ByteBuffer encode(ChatMessage message) throws EncodeException {
-        return ByteBuffer.wrap(SerializationUtils.serialize(message));
-    }
-}

File WebClient/src/main/java/org/jacp/beans/websocket/chat/encoder/UserAddMessageEncoder.java

-package org.jacp.beans.websocket.chat.encoder;
-
-import org.apache.commons.lang.SerializationUtils;
-import org.jacp.jee.messages.LoginMessage;
-import org.jacp.jee.messages.UserAddMessage;
-
-import javax.websocket.EncodeException;
-import javax.websocket.Encoder;
-import java.nio.ByteBuffer;
-
-/**
- * Created with IntelliJ IDEA.
- * User: ady
- * Date: 27.02.13
- * Time: 12:51
- * To change this template use File | Settings | File Templates.
- */
-public class UserAddMessageEncoder implements Encoder.Binary<UserAddMessage>{
-    @Override
-    public ByteBuffer encode(UserAddMessage userAddMessage) throws EncodeException {
-        return ByteBuffer.wrap(SerializationUtils.serialize(userAddMessage));
-    }
-}

File WebClient/src/main/webapp/WEB-INF/beans.xml

-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
-    DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
-
-    Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
-
-    The contents of this file are subject to the terms of either the GNU
-    General Public License Version 2 only ("GPL") or the Common Development
-    and Distribution License("CDDL") (collectively, the "License").  You
-    may not use this file except in compliance with the License.  You can
-    obtain a copy of the License at
-    http://glassfish.java.net/public/CDDL+GPL_1_1.html
-    or packager/legal/LICENSE.txt.  See the License for the specific
-    language governing permissions and limitations under the License.
-
-    When distributing the software, include this License Header Notice in each
-    file and include the License file at packager/legal/LICENSE.txt.
-
-    GPL Classpath Exception:
-    Oracle designates this particular file as subject to the "Classpath"
-    exception as provided by Oracle in the GPL Version 2 section of the License
-    file that accompanied this code.
-
-    Modifications:
-    If applicable, add the following below the License Header, with the fields
-    enclosed by brackets [] replaced by your own identifying information:
-    "Portions Copyright [year] [name of copyright owner]"
-
-    Contributor(s):
-    If you wish your version of this file to be governed by only the CDDL or
-    only the GPL Version 2, indicate your decision by adding "[Contributor]
-    elects to include this software in this distribution under the [CDDL or GPL
-    Version 2] license."  If you don't indicate a single choice of license, a
-    recipient has the option to distribute your version of this file under
-    either the CDDL, the GPL Version 2 or to extend the choice of license to
-    its licensees as provided above.  However, if you add GPL Version 2 code
-    and therefore, elected the GPL Version 2 license, then the option applies
-    only if the new code is made subject to such option by the copyright
-    holder.
-
--->
-<beans/>

File WebClient/src/main/webapp/WEB-INF/faces-config.xml

-<?xml version="1.0" encoding="utf-8"?>
-<faces-config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-    version="2.0"
-    xmlns="http://java.sun.com/xml/ns/javaee"
-    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd" >
-
-<!-- No ManagedBean declarations here as we are using @ManagedBean Annotations. -->
-
-</faces-config>

File WebClient/src/main/webapp/WEB-INF/glassfish-web.xml

-<!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Servlet 3.0//EN" "http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd">
-<glassfish-web-app error-url="">
-    <context-root>/WebClient</context-root>
-    <class-loader delegate="true"/>
-    <jsp-config>
-        <property name="keepgenerated" value="true">
-            <description>Keep a copy of the generated servlet class' java code.</description>
-        </property>
-    </jsp-config>
-</glassfish-web-app>

File WebClient/src/main/webapp/WEB-INF/web.xml

-<?xml version="1.0" encoding="UTF-8"?>
-<web-app xmlns="http://java.sun.com/xml/ns/javaee"
-      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
-      version="3.0">
-	<display-name>My Web Application</display-name>
-	<welcome-file-list>
-		<welcome-file>index.jsp</welcome-file>
-	</welcome-file-list>
-	<servlet>
-		<servlet-name>Faces Servlet</servlet-name>
-		<servlet-class>
-			javax.faces.webapp.FacesServlet
-		</servlet-class>
-		<load-on-startup>1</load-on-startup>
-	</servlet>
-	<servlet-mapping>
-		<servlet-name>Faces Servlet</servlet-name>
-		<url-pattern>*.xhtml</url-pattern>
-	</servlet-mapping>
-	<!--  <servlet>
-		<servlet-name>Jersey Web Application</servlet-name>
-		<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
-		<load-on-startup>1</load-on-startup>
-	</servlet>
-	<servlet-mapping>
-		<servlet-name>Jersey Web Application</servlet-name>
-		<url-pattern>/rest/*</url-pattern>
-	</servlet-mapping>-->
-</web-app>

File WebClient/src/main/webapp/index.jsp

-<%-- 
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
- *
- * The contents of this file are subject to the terms of either the GNU
- * General Public License Version 2 only ("GPL") or the Common Development
- * and Distribution License("CDDL") (collectively, the "License").  You
- * may not use this file except in compliance with the License.  You can
- * obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt.  See the License for the specific
- * language governing permissions and limitations under the License.
- *
- * When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
- *
- * GPL Classpath Exception:
- * Oracle designates this particular file as subject to the "Classpath"
- * exception as provided by Oracle in the GPL Version 2 section of the License
- * file that accompanied this code.
- *
- * Modifications:
- * If applicable, add the following below the License Header, with the fields
- * enclosed by brackets [] replaced by your own identifying information:
- * "Portions Copyright [year] [name of copyright owner]"
- *
- * Contributor(s):
- * If you wish your version of this file to be governed by only the CDDL or
- * only the GPL Version 2, indicate your decision by adding "[Contributor]
- * elects to include this software in this distribution under the [CDDL or GPL
- * Version 2] license."  If you don't indicate a single choice of license, a
- * recipient has the option to distribute your version of this file under
- * either the CDDL, the GPL Version 2 or to extend the choice of license to
- * its licensees as provided above.  However, if you add GPL Version 2 code
- * and therefore, elected the GPL Version 2 license, then the option applies
- * only if the new code is made subject to such option by the copyright
- * holder.
- */
---%>
-
-<%@page contentType="text/html" pageEncoding="UTF-8"%>
-<!DOCTYPE html>
-<html>
-    <head>
-        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
-        <title>Hello WebSocket</title>
-
-        <script language="javascript" type="text/javascript">
-            var wsUri = "ws://localhost:8080/WebClient/echo";
-            var websocket = new WebSocket(wsUri);
-            websocket.onopen = function(evt) { onOpen(evt) };
-            websocket.onmessage = function(evt) { onMessage(evt) };
-            websocket.onerror = function(evt) { onError(evt) };
-
-            function init() {
-                output = document.getElementById("output");
-            }
-
-            function say_hello() {
-                websocket.send(nameField.value);
-                writeToScreen("SENT: " + nameField.value);
-            }
-
-            function onOpen(evt) {
-                writeToScreen('<span style="color: red;">CONNECTED:</span>: ');
-            }
-
-            function onMessage(evt) {
-                writeToScreen('<span style="color: red;">RECEIVED:</span>: ' + evt.data);
-            }
-
-            function onError(evt) {
-                writeToScreen('<span style="color: red;">ERROR:</span> ' + evt.data);
-            }
-
-            function writeToScreen(message) {
-                var pre = document.createElement("p");
-                pre.style.wordWrap = "break-word";
-                pre.innerHTML = message;
-                output.appendChild(pre);
-            }
-
-            window.addEventListener("load", init, false);
-        </script>
-    </head>
-    <body>
-        <h1>Getting Started with WebSocket!!</h1>
-
-        <div style="text-align: center;">
-            <form action=""> 
-                <input onclick="say_hello()" value="Say Hello" type="button"> 
-                <input id="nameField" name="name" value="WebSocket" type="text"><br>
-            </form>
-        </div>
-        <div id="output"></div>
-    </body>
-</html>

File WebClient/src/main/webapp/indexHandler.jsp

-<%-- 
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
- *
- * The contents of this file are subject to the terms of either the GNU
- * General Public License Version 2 only ("GPL") or the Common Development
- * and Distribution License("CDDL") (collectively, the "License").  You
- * may not use this file except in compliance with the License.  You can
- * obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt.  See the License for the specific
- * language governing permissions and limitations under the License.
- *
- * When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
- *
- * GPL Classpath Exception:
- * Oracle designates this particular file as subject to the "Classpath"
- * exception as provided by Oracle in the GPL Version 2 section of the License
- * file that accompanied this code.
- *
- * Modifications:
- * If applicable, add the following below the License Header, with the fields
- * enclosed by brackets [] replaced by your own identifying information:
- * "Portions Copyright [year] [name of copyright owner]"
- *
- * Contributor(s):
- * If you wish your version of this file to be governed by only the CDDL or
- * only the GPL Version 2, indicate your decision by adding "[Contributor]
- * elects to include this software in this distribution under the [CDDL or GPL
- * Version 2] license."  If you don't indicate a single choice of license, a
- * recipient has the option to distribute your version of this file under
- * either the CDDL, the GPL Version 2 or to extend the choice of license to
- * its licensees as provided above.  However, if you add GPL Version 2 code
- * and therefore, elected the GPL Version 2 license, then the option applies
- * only if the new code is made subject to such option by the copyright
- * holder.
- */
---%>
-
-<%@page contentType="text/html" pageEncoding="UTF-8"%>
-<!DOCTYPE html>
-<html>
-    <head>
-        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
-        <title>Hello WebSocket</title>
-
-        <script language="javascript" type="text/javascript">
-            var wsUri = "ws://localhost:8080/WebClient/handler";
-            var websocket = new WebSocket(wsUri);
-            websocket.onopen = function(evt) { onOpen(evt) };
-            websocket.onmessage = function(evt) { onMessage(evt) };
-            websocket.onerror = function(evt) { onError(evt) };
-
-            function init() {
-                output = document.getElementById("output");
-            }
-
-            function say_hello() {
-                websocket.send(nameField.value);
-                writeToScreen("SENT: " + nameField.value);
-            }
-
-            function onOpen(evt) {
-                writeToScreen('<span style="color: red;">CONNECTED:</span>: ');
-            }
-
-            function onMessage(evt) {
-                writeToScreen('<span style="color: red;">RECEIVED:</span>: ' + evt.data);
-            }
-
-            function onError(evt) {
-                writeToScreen('<span style="color: red;">ERROR:</span> ' + evt.data);
-            }
-
-            function writeToScreen(message) {
-                var pre = document.createElement("p");
-                pre.style.wordWrap = "break-word";
-                pre.innerHTML = message;
-                output.appendChild(pre);
-            }
-
-            window.addEventListener("load", init, false);
-        </script>
-    </head>
-    <body>
-        <h1>Getting Started with WebSocket!!</h1>
-
-        <div style="text-align: center;">
-            <form action=""> 
-                <input onclick="say_hello()" value="Say Hello" type="button"> 
-                <input id="nameField" name="name" value="WebSocket" type="text"><br>
-            </form>
-        </div>
-        <div id="output"></div>
-    </body>
-</html>

File WebClient/src/main/webapp/page.xhtml

-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE html>
-<html xmlns="http://www.w3.org/1999/xhtml"
-	xmlns:h="http://java.sun.com/jsf/html"
-	xmlns:p="http://primefaces.prime.com.tr/ui">
-<body>
-	<p>
-		<p:layout style="width:400px;height:200px;">
-			<p:layoutUnit position="west" size="100">Hello</p:layoutUnit>
-			<p:layoutUnit position="center">
-				<h:outputText value="#{messageBean.message}" />
-			</p:layoutUnit>
-		</p:layout>
-	</p>
-</body>
-</html>
                 <module>Domain</module>
                 <module>EJBClient</module>
                 <module>EJB</module>
-                <module>WebClient</module>
-                <module>EAR</module>
+                <module>WebClient-Websocket</module>
+                <module>EAR-Websocket</module>
                 <module>JavaClient</module>
-                <module>JacpFXChatClient</module>
+                <module>JacpFXWebsocketChatClient</module>
+            </modules>
+        </profile>
+        <profile>
+            <id>Chat</id>
+            <modules>
+                <module>Domain</module>
+                <module>EJBClient</module>
+                <module>EJB</module>
+                <module>WebClient-Websocket</module>
+                <module>EAR-Websocket</module>
+                <module>JacpFXWebsocketChatClient</module>
             </modules>
         </profile>
     </profiles>
         <module>Domain</module>
         <module>EJBClient</module>
         <module>EJB</module>
-        <module>WebClient</module>
-        <module>EAR</module>
+        <module>WebClient-Websocket</module>
+        <module>EAR-Websocket</module>
         <module>JavaClient</module>
-        <module>JacpFXChatClient</module>
+        <module>JacpFXWebsocketChatClient</module>
     </modules>
     <properties>
         <javax.persistence.version>2.0.0</javax.persistence.version>
             </dependency>
             <dependency>
                 <groupId>${project.groupId}</groupId>
-                <artifactId>WebClient</artifactId>
+                <artifactId>WebClient-Websocket</artifactId>
                 <version>${project.version}</version>
                 <type>war</type>
             </dependency>
             <dependency>
                 <groupId>${project.groupId}</groupId>
-                <artifactId>EAR</artifactId>
+                <artifactId>EAR-Websocket</artifactId>
                 <version>${project.version}</version>
                 <type>ear</type>
             </dependency>
             </dependency>
             <dependency>
                 <groupId>${project.groupId}</groupId>
-                <artifactId>JacpFXChatClient</artifactId>
+                <artifactId>JacpFXWebsocketChatClient</artifactId>
                 <version>${project.version}</version>
                 <type>jar</type>
             </dependency>