Commit 33ad1d63 authored by Christophe Demarey's avatar Christophe Demarey
Browse files

Move the chat example with other examples.

parent 1514272d
<?xml version="1.0"?>
<!--
* OW2 FraSCAti Examples: Chat client.
*
* Copyright (c) 2009 INRIA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-->
<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.ow2.frascati.examples</groupId>
<artifactId>chat-parent</artifactId>
<version>1.1-SNAPSHOT</version>
</parent>
<groupId>org.ow2.frascati.examples</groupId>
<artifactId>chat-client</artifactId>
<packaging>jar</packaging>
<name>OW2 FraSCAti Examples: Chat client</name>
<repositories>
<repository>
<id>maven2-repository.dev.java.net</id>
<name>Java.net Repository for Maven</name>
<url>http://download.java.net/maven/2/</url>
<layout>default</layout>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.jdesktop</groupId>
<artifactId>appframework</artifactId>
<version>1.0.3</version>
</dependency>
</dependencies>
<profiles>
<!-- Run the chat client GUI. -->
<profile>
<id>run</id>
<build>
<defaultGoal>compile</defaultGoal>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>exec</goal>
</goals>
<phase>compile</phase>
</execution>
</executions>
<configuration>
<executable>java</executable>
<arguments>
<argument>-classpath</argument>
<!-- automatically creates the classpath using all project dependencies,
also adding the project build directory -->
<classpath/>
<argument>examples.chat.client.gui.ChatGUI</argument>
</arguments>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<!-- Run the chat basic command line client. -->
<!-- Note: This is the same profile as the run profile defined in examples parent pom,
but we need to redefine it as 'run.cmd' to let the GUI client as default. -->
<profile>
<id>run.cmd</id>
<properties>
<composite.file>chat-cmdline-client</composite.file>
<service.name>r</service.name>
<method.name>run</method.name>
</properties>
<build>
<defaultGoal>org.ow2.frascati.factory:frascati-factory-plugin:1.1-SNAPSHOT:exec</defaultGoal>
<plugins>
<plugin>
<groupId>org.ow2.frascati.factory</groupId>
<artifactId>frascati-factory-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<loggingConfFile>${logging.conf.file}</loggingConfFile>
<composite>${composite.file}</composite>
<service>${service.name}</service>
<method>${method.name}</method>
<methodParams>${method.params}</methodParams>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
/***
* OW2 FraSCAti examples: chat
* Copyright (C) 2008 INRIA, USTL
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Contact: frascati@ow2.org
*
* Author(s): Christophe Demarey
*/
package examples.chat;
/**
* The chat Server interface.
*
* @author Christophe Demarey.
*/
public interface Chat {
/**
* Initialize a connection with the chat server.
*/
public void connect();
/**
* Leave the chat.
*/
public void disconnect();
/**
* Get all messages received by the chat server.
*
* @return The list of received messages.
*/
public String getMessages();
/**
* Send a message to the chat server
*
* @param pseudo - The pseudo of the sender.
* @param msg - The message to send.
*/
public void sendMessage(String pseudo, String msg);
}
/***
* OW2 FraSCAti Examples: Chat
* Copyright (C) 2008-2009 INRIA, USTL
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Contact: frascati@ow2.org
*
* Author(s): Christophe Demarey
*/
package examples.chat;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import org.osoa.sca.annotations.Property;
import org.osoa.sca.annotations.Reference;
import org.osoa.sca.annotations.Scope;
/**
* A chat client.
*
* @author Christophe Demarey.
*/
@Scope("COMPOSITE")
public class ClientImpl implements Runnable {
// Attributes
/** The header that will be displayed in front of each message. */
@Property
private String header = "> ";
@Reference
public Chat chatService;
// Constructors
public ClientImpl() { }
// Methods
private void printMessages(String messages) {
StringTokenizer st = new StringTokenizer(messages, "\n");
while (st.hasMoreTokens()) {
System.out.println(this.header + st.nextToken());
}
}
/**
* Run method launching the application.
*/
public void run() {
// open up standard input
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String msg = null,
previousMessages = "";
System.out.println("Chat client ready!");
do {
// read the message from the command-line
try {
msg = br.readLine();
chatService.sendMessage( System.getProperty("user.name"), msg);
} catch (IOException ioe) {
System.out.println("IO error!");
System.exit(1);
}
msg = chatService.getMessages();
printMessages( msg.substring(previousMessages.length()) );
previousMessages = msg;
} while(msg != null);
}
}
/***
* OW2 FraSCAti Examples: Chat
* Copyright (C) 2008-2009 INRIA, USTL
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Contact: frascati@ow2.org
*
* Author(s): Christophe Demarey
*/
package examples.chat;
import org.osoa.sca.annotations.Property;
import org.osoa.sca.annotations.Reference;
import org.osoa.sca.annotations.Scope;
/**
* This component acts like a proxy for the Chat service.
* This is necessary because SwingAppFramework has its own
* instantiation mechanism, confusing with the SCA scope/instantiation
* mechanism.
*
* @author Christophe Demarey.
*/
@Scope("COMPOSITE")
public class GuiClientImpl implements Chat {
// Attributes
/** The header that will be displayed in front of each message. */
@Property
private String header;
@Reference
public Chat chatService;
// Constructors
public GuiClientImpl() { }
// Methods from the ChatClient interface
/**
* @see examples.chat.Chat#connect(String)
*/
public void connect() {
chatService.connect();
}
/**
* @see examples.chat.Chat#disconnect()
*/
public void disconnect() {
chatService.disconnect();
}
/**
* @see examples.chat.Chat#getMessages()
*/
public String getMessages() {
return chatService.getMessages();
}
/**
* @see examples.chat.Chat#sendMessage(String)
*/
public void sendMessage(String pseudo, String msg) {
chatService.sendMessage(pseudo, msg);
}
}
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.5" maxVersion="1.5" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
<Properties>
<Property name="defaultCloseOperation" type="int" value="2"/>
<Property name="title" type="java.lang.String" resourceKey="title"/>
<Property name="modal" type="boolean" value="true"/>
<Property name="name" type="java.lang.String" value="aboutBox" noResource="true"/>
<Property name="resizable" type="boolean" value="false"/>
</Properties>
<SyntheticProperties>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
</SyntheticProperties>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="2"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="imageLabel" min="-2" max="-2" attributes="0"/>
<EmptySpace type="separate" min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="versionLabel" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="vendorLabel" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="homepageLabel" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="appVersionLabel" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="appVendorLabel" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="appHomepageLabel" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<Component id="appTitleLabel" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="appDescLabel" alignment="0" pref="266" max="32767" attributes="0"/>
<Component id="closeButton" alignment="1" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="imageLabel" min="-2" max="32767" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="appTitleLabel" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="appDescLabel" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="versionLabel" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="appVersionLabel" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="vendorLabel" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="appVendorLabel" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="homepageLabel" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="appHomepageLabel" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="19" max="32767" attributes="0"/>
<Component id="closeButton" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JButton" name="closeButton">
<Properties>
<Property name="action" type="javax.swing.Action" editor="org.netbeans.modules.swingapp.ActionEditor">
<action class="examples.chat.clien.gui.ChatAboutBox" id="closeAboutBox" methodName="closeAboutBox"/>
</Property>
<Property name="name" type="java.lang.String" value="closeButton" noResource="true"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="appTitleLabel">
<Properties>
<Property name="font" type="java.awt.Font" noResource="true" editor="org.netbeans.modules.form.editors2.FontEditor">
<FontInfo relative="true">
<Font bold="true" component="appTitleLabel" property="font" relativeSize="true" size="4"/>
</FontInfo>
</Property>
<Property name="text" type="java.lang.String" resourceKey="Application.title"/>
<Property name="name" type="java.lang.String" value="appTitleLabel" noResource="true"/>
</Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="true"/>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
</AuxValues>
</Component>
<Component class="javax.swing.JLabel" name="versionLabel">
<Properties>
<Property name="font" type="java.awt.Font" noResource="true" editor="org.netbeans.modules.form.editors2.FontEditor">
<FontInfo relative="true">
<Font bold="true" component="versionLabel" property="font" relativeSize="true" size="0"/>
</FontInfo>
</Property>
<Property name="text" type="java.lang.String" resourceKey="versionLabel.text"/>
<Property name="name" type="java.lang.String" value="versionLabel" noResource="true"/>
</Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="true"/>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
</AuxValues>
</Component>
<Component class="javax.swing.JLabel" name="appVersionLabel">
<Properties>
<Property name="text" type="java.lang.String" resourceKey="Application.version"/>
<Property name="name" type="java.lang.String" value="appVersionLabel" noResource="true"/>
</Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="true"/>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
</AuxValues>
</Component>
<Component class="javax.swing.JLabel" name="vendorLabel">
<Properties>
<Property name="font" type="java.awt.Font" noResource="true" editor="org.netbeans.modules.form.editors2.FontEditor">
<FontInfo relative="true">
<Font bold="true" component="vendorLabel" property="font" relativeSize="true" size="0"/>
</FontInfo>
</Property>
<Property name="text" type="java.lang.String" resourceKey="vendorLabel.text"/>
<Property name="name" type="java.lang.String" value="vendorLabel" noResource="true"/>
</Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="true"/>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
</AuxValues>
</Component>
<Component class="javax.swing.JLabel" name="appVendorLabel">
<Properties>
<Property name="text" type="java.lang.String" resourceKey="Application.vendor"/>
<Property name="name" type="java.lang.String" value="appVendorLabel" noResource="true"/>
</Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="true"/>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
</AuxValues>
</Component>
<Component class="javax.swing.JLabel" name="homepageLabel">
<Properties>
<Property name="font" type="java.awt.Font" noResource="true" editor="org.netbeans.modules.form.editors2.FontEditor">
<FontInfo relative="true">
<Font bold="true" component="homepageLabel" property="font" relativeSize="true" size="0"/>
</FontInfo>
</Property>
<Property name="text" type="java.lang.String" resourceKey="homepageLabel.text"/>
<Property name="name" type="java.lang.String" value="homepageLabel" noResource="true"/>
</Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="true"/>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
</AuxValues>
</Component>
<Component class="javax.swing.JLabel" name="appHomepageLabel">
<Properties>
<Property name="text" type="java.lang.String" resourceKey="Application.homepage"/>
<Property name="name" type="java.lang.String" value="appHomepageLabel" noResource="true"/>
</Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="true"/>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
</AuxValues>
</Component>
<Component class="javax.swing.JLabel" name="appDescLabel">
<Properties>
<Property name="text" type="java.lang.String" resourceKey="appDescLabel.text"/>
<Property name="name" type="java.lang.String" value="appDescLabel" noResource="true"/>
</Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="true"/>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
</AuxValues>
</Component>
<Component class="javax.swing.JLabel" name="imageLabel">
<Properties>
<Property name="icon" type="javax.swing.Icon" resourceKey="imageLabel.icon"/>
<Property name="name" type="java.lang.String" value="imageLabel" noResource="true"/>
</Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="true"/>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
</AuxValues>
</Component>
</SubComponents>
</Form>
/***
* OW2 FraSCAti Examples: chat
* Copyright (C) 2008-2009 INRIA, USTL
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Contact: frascati@ow2.org
*
* Author(s): Christophe Demarey
*/
package examples.chat.client.gui;