Author: ilya_shaikovsky
Date: 2011-01-05 07:51:57 -0500 (Wed, 05 Jan 2011)
New Revision: 20892
Added:
sandbox/trunk/examples/irc-client/
sandbox/trunk/examples/irc-client/pom.xml
sandbox/trunk/examples/irc-client/readme.txt
sandbox/trunk/examples/irc-client/src/
sandbox/trunk/examples/irc-client/src/main/
sandbox/trunk/examples/irc-client/src/main/java/
sandbox/trunk/examples/irc-client/src/main/java/org/
sandbox/trunk/examples/irc-client/src/main/java/org/ircclient/
sandbox/trunk/examples/irc-client/src/main/java/org/ircclient/controller/
sandbox/trunk/examples/irc-client/src/main/java/org/ircclient/controller/ChatBean.java
sandbox/trunk/examples/irc-client/src/main/java/org/ircclient/listeners/
sandbox/trunk/examples/irc-client/src/main/java/org/ircclient/listeners/HornetQInitializer.java
sandbox/trunk/examples/irc-client/src/main/java/org/ircclient/listeners/TopicsInitializer.java
sandbox/trunk/examples/irc-client/src/main/java/org/ircclient/view/
sandbox/trunk/examples/irc-client/src/main/java/org/ircclient/view/SkinBean.java
sandbox/trunk/examples/irc-client/src/main/webapp/
sandbox/trunk/examples/irc-client/src/main/webapp/WEB-INF/
sandbox/trunk/examples/irc-client/src/main/webapp/WEB-INF/faces-config.xml
sandbox/trunk/examples/irc-client/src/main/webapp/WEB-INF/jboss-scanning.xml
sandbox/trunk/examples/irc-client/src/main/webapp/WEB-INF/web.xml
sandbox/trunk/examples/irc-client/src/main/webapp/index.jsp
sandbox/trunk/examples/irc-client/src/main/webapp/templates/
sandbox/trunk/examples/irc-client/src/main/webapp/templates/includes/
sandbox/trunk/examples/irc-client/src/main/webapp/templates/includes/skin-chooser.xhtml
sandbox/trunk/examples/irc-client/src/main/webapp/templates/template.xhtml
sandbox/trunk/examples/irc-client/src/main/webapp/welcome.xhtml
Log:
https://issues.jboss.org/browse/RF-9160
Property changes on: sandbox/trunk/examples/irc-client
___________________________________________________________________
Name: svn:ignore
+ .project
.classpath
.checkstyle
.settings
target
Added: sandbox/trunk/examples/irc-client/pom.xml
===================================================================
--- sandbox/trunk/examples/irc-client/pom.xml (rev 0)
+++ sandbox/trunk/examples/irc-client/pom.xml 2011-01-05 12:51:57 UTC (rev 20892)
@@ -0,0 +1,158 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.demo</groupId>
+ <artifactId>irc-client</artifactId>
+ <name>irc-client</name>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>war</packaging>
+
+ <
url>http://jboss.org/richfaces</url>
+
+ <repositories>
+ <repository>
+ <id>jboss-public-repository-group</id>
+ <name>Jboss Repository for Maven</name>
+
<
url>https://repository.jboss.org/nexus/content/groups/public/</url>
+ </repository>
+ <repository>
+ <id>java-net</id>
+ <
name>Java.net Maven Repository</name>
+ <
url>http://download.java.net/maven/2</url>
+ </repository>
+ </repositories>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <hornetq.version>2.1.2.Final</hornetq.version>
+
<org.richfaces.bom.version>4.0.0-SNAPSHOT</org.richfaces.bom.version>
+ </properties>
+
+ <build>
+ <finalName>irc-client-${project.version}</finalName>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-war-plugin</artifactId>
+ <configuration>
+ <webResources>
+ <resource>
+ <directory>${basedir}/src/main/java</directory>
+ <targetPath>/WEB-INF/src</targetPath>
+ </resource>
+ </webResources>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.richfaces</groupId>
+ <artifactId>richfaces-bom</artifactId>
+ <version>${org.richfaces.bom.version}</version>
+ <scope>import</scope>
+ <type>pom</type>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.richfaces.ui</groupId>
+ <artifactId>richfaces-components-ui</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.richfaces.ui</groupId>
+ <artifactId>richfaces-components-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.richfaces.core</groupId>
+ <artifactId>richfaces-core-impl</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.faces</groupId>
+ <artifactId>jsf-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.faces</groupId>
+ <artifactId>jsf-impl</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet.jsp</groupId>
+ <artifactId>jsp-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.el</groupId>
+ <artifactId>el-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>jstl</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>net.sf.ehcache</groupId>
+ <artifactId>ehcache</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.hornetq</groupId>
+ <artifactId>hornetq-core</artifactId>
+ <version>${hornetq.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.hornetq</groupId>
+ <artifactId>hornetq-jms</artifactId>
+ <version>${hornetq.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.hornetq</groupId>
+ <artifactId>hornetq-logging</artifactId>
+ <version>${hornetq.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.netty</groupId>
+ <artifactId>netty</artifactId>
+ <version>3.2.2.Final</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.jms</groupId>
+ <artifactId>jms</artifactId>
+ <version>1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.atmosphere</groupId>
+ <artifactId>atmosphere-runtime</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>pircbot</groupId>
+ <artifactId>pircbot</artifactId>
+ <version>1.4.2</version>
+ </dependency>
+ <!-- Tests -->
+ <dependency>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ <version>5.10</version>
+ <classifier>jdk15</classifier>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
Added: sandbox/trunk/examples/irc-client/readme.txt
===================================================================
--- sandbox/trunk/examples/irc-client/readme.txt (rev 0)
+++ sandbox/trunk/examples/irc-client/readme.txt 2011-01-05 12:51:57 UTC (rev 20892)
@@ -0,0 +1,9 @@
+Project generated with richfaces-archetype-simpleapp
+
+To build this project for Tomcat 6 run
+
+ mvn clean package
+
+If you wan to create a binaries for both Tomcat 6 and JBoss 6 run
+
+ mvn clean package -P release
\ No newline at end of file
Added:
sandbox/trunk/examples/irc-client/src/main/java/org/ircclient/controller/ChatBean.java
===================================================================
---
sandbox/trunk/examples/irc-client/src/main/java/org/ircclient/controller/ChatBean.java
(rev 0)
+++
sandbox/trunk/examples/irc-client/src/main/java/org/ircclient/controller/ChatBean.java 2011-01-05
12:51:57 UTC (rev 20892)
@@ -0,0 +1,185 @@
+package org.ircclient.controller;
+
+import java.io.IOException;
+import java.io.Serializable;
+import java.text.MessageFormat;
+import java.util.Date;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.SessionScoped;
+import javax.faces.context.FacesContext;
+import javax.faces.event.ValueChangeEvent;
+
+import org.jibble.pircbot.IrcException;
+import org.jibble.pircbot.NickAlreadyInUseException;
+import org.jibble.pircbot.PircBot;
+import org.jibble.pircbot.User;
+import org.richfaces.application.push.MessageException;
+import org.richfaces.application.push.TopicKey;
+import org.richfaces.application.push.TopicsContext;
+import org.richfaces.log.LogFactory;
+import org.richfaces.log.Logger;
+
+@ManagedBean
+@SessionScoped
+public class ChatBean extends PircBot implements Serializable {
+
+ private static final long serialVersionUID = -4945680041914388092L;
+ private static final String SERVER_URL = "irc.freenode.org";
+ private static final int SERVER_PORT = 6667;
+ private static final String CHANNEL_PREFIX = "#";
+ private static final String DEFAULT_CHANNEL = "richfaces";
+ private static final Logger LOGGER = LogFactory.getLogger(ChatBean.class);
+
+ private String channelName;
+ private String message;
+ private transient TopicsContext topicsContext;
+
+ public ChatBean() {
+ LOGGER.info("TOPICS CONTEXT INITIALIZED");
+ topicsContext = TopicsContext.lookup();
+ }
+
+ public void connect() {
+ try {
+ this.connect(SERVER_URL, SERVER_PORT);
+ this.joinChannel(CHANNEL_PREFIX + DEFAULT_CHANNEL);
+ channelName = DEFAULT_CHANNEL;
+ } catch (NickAlreadyInUseException e) {
+ FacesContext.getCurrentInstance().addMessage(
+ null,
+ new FacesMessage(FacesMessage.SEVERITY_ERROR, this.getName() + "
nick already in use", this.getName()
+ + " nick already in use"));
+ } catch (IOException e) {
+ FacesContext.getCurrentInstance().addMessage(
+ null,
+ new FacesMessage(FacesMessage.SEVERITY_ERROR, "Sorry, server
unresponsible. Try again later.",
+ "Sorry, server unresponsible. Try again later."));
+ } catch (IrcException e) {
+ FacesContext.getCurrentInstance().addMessage(
+ null,
+ new FacesMessage(FacesMessage.SEVERITY_ERROR,
+ "Sorry, we encountered IRC services problems. Try again
later.",
+ "Sorry, we encountered IRC services problems. Try again
later."));
+ }
+ }
+
+ public void leave(){
+ this.disconnect();
+ }
+
+ @Override
+ protected void onMessage(String channel, String sender, String login, String
hostname, String message) {
+ String channelName = channel.replace(CHANNEL_PREFIX, "");
+ try {
+ topicsContext.publish(new TopicKey("chat", channelName),
+ MessageFormat.format("{0,time,medium} {1}: {2}", new Date(),
sender, message));
+ } catch (MessageException e) {
+ LOGGER.error(e.getMessage(), e);
+ }
+ }
+
+ @Override
+ protected void onUserList(String channel, User[] users) {
+ try {
+ topicsContext.publish(new TopicKey("chat", channelName +
"List"), null);
+ } catch (MessageException e) {
+ LOGGER.error(e.getMessage(), e);
+ }
+ }
+
+ @Override
+ protected void onJoin(String channel, String sender, String login, String hostname)
{
+ try {
+ topicsContext.publish(new TopicKey("chat", channelName +
"List"), null);
+ topicsContext.publish(new TopicKey("chat", channelName),
+ MessageFormat.format("{0,time,medium} {1}: {2}", new Date(),
sender, "joined channel"));
+ } catch (MessageException e) {
+ LOGGER.error(e.getMessage(), e);
+ }
+ }
+
+ @Override
+ protected void onPart(String channel, String sender, String login, String hostname)
{
+ try {
+ topicsContext.publish(new TopicKey("chat", channelName +
"List"), null);
+ topicsContext.publish(new TopicKey("chat", channelName),
+ MessageFormat.format("{0,time,medium} {1}: {2}", new Date(),
sender, "left channel"));
+ } catch (MessageException e) {
+ LOGGER.error(e.getMessage(), e);
+ }
+ }
+
+ @Override
+ protected void onNickChange(String oldNick, String login, String hostname, String
newNick) {
+ try {
+ topicsContext.publish(new TopicKey("chat", channelName +
"List"), null);
+ topicsContext.publish(new TopicKey("chat", channelName),
+ MessageFormat.format("{0,time,medium} {1}", new Date(), oldNick
+ " changed nick to " + newNick));
+ } catch (MessageException e) {
+ LOGGER.error(e.getMessage(), e);
+ }
+ }
+
+ @Override
+ protected void onQuit(String sourceNick, String sourceLogin, String sourceHostname,
String reason) {
+ try {
+ topicsContext.publish(new TopicKey("chat", channelName +
"List"), null);
+ topicsContext.publish(new TopicKey("chat", channelName),
+ MessageFormat.format("{0,time,medium} {1}: {2} {3}", new
Date(), sourceNick, "joined channel", reason));
+ } catch (MessageException e) {
+ LOGGER.error(e.getMessage(), e);
+ }
+ }
+
+ public User[] getUsers() {
+ return this.getUsers(CHANNEL_PREFIX + channelName);
+ }
+
+ public void send() {
+ this.sendMessage(CHANNEL_PREFIX + channelName, message);
+ try {
+ topicsContext.publish(new TopicKey("chat", channelName),
+ MessageFormat.format("{0,time,medium} {1}: {2}", new Date(),
this.getName(), message));
+ } catch (MessageException e) {
+ LOGGER.error(e.getMessage(), e);
+ }
+ }
+
+ public void changeNick(ValueChangeEvent event) {
+ this.changeNick((String) event.getNewValue());
+ }
+
+ public String getServerName() {
+ return SERVER_URL;
+ }
+
+ public void setUserName(String userName) {
+ this.setName(userName);
+ }
+
+ public String getUserName() {
+ if (this.getName().equalsIgnoreCase("PircBot")) {
+ return "";
+ } else {
+ return this.getName();
+ }
+ }
+
+ public String getChannelName() {
+ return channelName;
+ }
+
+ public void setChannelName(String channelName) {
+ this.channelName = channelName;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+}
Added:
sandbox/trunk/examples/irc-client/src/main/java/org/ircclient/listeners/HornetQInitializer.java
===================================================================
---
sandbox/trunk/examples/irc-client/src/main/java/org/ircclient/listeners/HornetQInitializer.java
(rev 0)
+++
sandbox/trunk/examples/irc-client/src/main/java/org/ircclient/listeners/HornetQInitializer.java 2011-01-05
12:51:57 UTC (rev 20892)
@@ -0,0 +1,118 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This 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.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.ircclient.listeners;
+
+import java.util.HashSet;
+
+import javax.faces.application.Application;
+import javax.faces.context.FacesContext;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.PostConstructApplicationEvent;
+import javax.faces.event.PreDestroyApplicationEvent;
+import javax.faces.event.SystemEvent;
+import javax.faces.event.SystemEventListener;
+import javax.naming.InitialContext;
+
+import org.hornetq.api.core.TransportConfiguration;
+import org.hornetq.core.config.Configuration;
+import org.hornetq.core.config.impl.ConfigurationImpl;
+import org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory;
+import org.hornetq.core.remoting.impl.netty.NettyConnectorFactory;
+import org.hornetq.core.server.HornetQServer;
+import org.hornetq.core.server.HornetQServers;
+import org.hornetq.jms.server.JMSServerManager;
+import org.hornetq.jms.server.impl.JMSServerManagerImpl;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class HornetQInitializer implements SystemEventListener {
+
+ private JMSServerManager serverManager;
+
+ public void processEvent(SystemEvent event) throws AbortProcessingException {
+ if (event instanceof PostConstructApplicationEvent) {
+ try {
+ startHornetQ();
+ } catch (Exception e) {
+ throw new AbortProcessingException(e);
+ }
+
+ Application application =
FacesContext.getCurrentInstance().getApplication();
+ application.subscribeToEvent(PreDestroyApplicationEvent.class, this);
+ } else {
+ try {
+ stopHornetQ();
+ } catch (Exception e) {
+ throw new AbortProcessingException(e);
+ }
+ }
+ }
+
+ /**
+ * @throws Exception
+ *
+ */
+ private void stopHornetQ() throws Exception {
+ serverManager.stop();
+ serverManager = null;
+ }
+
+ /**
+ * @throws Exception
+ *
+ */
+ private void startHornetQ() throws Exception {
+ // Step 2. Create the Configuration, and set the properties accordingly
+ Configuration configuration = new ConfigurationImpl();
+ configuration.setPersistenceEnabled(false);
+ configuration.setSecurityEnabled(false);
+
+ TransportConfiguration transpConf = new
TransportConfiguration(NettyAcceptorFactory.class.getName());
+
+ HashSet<TransportConfiguration> setTransp = new
HashSet<TransportConfiguration>();
+ setTransp.add(transpConf);
+
+ configuration.setAcceptorConfigurations(setTransp);
+
+ // Step 3. Create and start the server
+ HornetQServer server = HornetQServers.newHornetQServer(configuration);
+
+ serverManager = new JMSServerManagerImpl(server);
+
+ // if you want to use JNDI, simple inject a context here or don't call this
method and make sure the JNDI
+ // parameters are set.
+ serverManager.setContext(new InitialContext());
+ serverManager.start();
+
+ serverManager.createConnectionFactory("ConnectionFactory", new
TransportConfiguration(
+ NettyConnectorFactory.class.getName()), "ConnectionFactory");
+
+ serverManager.createTopic(false, "chat", "/topic/chat");
+ }
+
+ public boolean isListenerForSource(Object source) {
+ return true;
+ }
+
+}
Added:
sandbox/trunk/examples/irc-client/src/main/java/org/ircclient/listeners/TopicsInitializer.java
===================================================================
---
sandbox/trunk/examples/irc-client/src/main/java/org/ircclient/listeners/TopicsInitializer.java
(rev 0)
+++
sandbox/trunk/examples/irc-client/src/main/java/org/ircclient/listeners/TopicsInitializer.java 2011-01-05
12:51:57 UTC (rev 20892)
@@ -0,0 +1,92 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This 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.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.ircclient.listeners;
+
+import java.text.MessageFormat;
+
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.SystemEvent;
+import javax.faces.event.SystemEventListener;
+import javax.servlet.http.HttpServletRequest;
+
+import org.ircclient.controller.ChatBean;
+import org.richfaces.application.push.EventAbortedException;
+import org.richfaces.application.push.Session;
+import org.richfaces.application.push.SessionPreSubscriptionEvent;
+import org.richfaces.application.push.SessionSubscriptionEvent;
+import org.richfaces.application.push.SessionTopicListener;
+import org.richfaces.application.push.SessionUnsubscriptionEvent;
+import org.richfaces.application.push.Topic;
+import org.richfaces.application.push.TopicKey;
+import org.richfaces.application.push.TopicsContext;
+import org.richfaces.application.push.impl.DefaultMessageDataSerializer;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class TopicsInitializer implements SystemEventListener {
+
+ public void processEvent(SystemEvent event) throws AbortProcessingException {
+ TopicsContext topicsContext = TopicsContext.lookup();
+
+ Topic topic = topicsContext.getOrCreateTopic(new TopicKey("chat"));
+
+ topic.setMessageDataSerializer(DefaultMessageDataSerializer.instance());
+
+ topic.addTopicListener(new SessionTopicListener() {
+
+ public void processUnsubscriptionEvent(SessionUnsubscriptionEvent event)
throws EventAbortedException {
+ TopicKey topicKey = event.getTopicKey();
+ Session session = event.getSession();
+ System.out.println(MessageFormat.format("Session {0} disconnected
from {1}", session.getId(),
+ topicKey.getTopicAddress()));
+ }
+
+ public void processSubscriptionEvent(SessionSubscriptionEvent event) throws
EventAbortedException {
+ TopicKey topicKey = event.getTopicKey();
+ Session session = event.getSession();
+
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ HttpServletRequest hsr = (HttpServletRequest)
facesContext.getExternalContext().getRequest();
+
+ System.out.println(MessageFormat.format("Session {0} connected to
{1} from {2}", session.getId(),
+ topicKey.getTopicAddress(), hsr.getRemoteAddr()));
+ }
+
+ public void processPreSubscriptionEvent(SessionPreSubscriptionEvent event)
throws EventAbortedException {
+ ExternalContext externalContext =
FacesContext.getCurrentInstance().getExternalContext();
+ ChatBean chatBean = (ChatBean)
externalContext.getSessionMap().get("chatBean");
+ if (chatBean == null || !(chatBean.isConnected())) {
+ throw new EventAbortedException("We are not connected to
IRC");
+ }
+ }
+ });
+ }
+
+ public boolean isListenerForSource(Object source) {
+ return true;
+ }
+
+}
Added: sandbox/trunk/examples/irc-client/src/main/java/org/ircclient/view/SkinBean.java
===================================================================
--- sandbox/trunk/examples/irc-client/src/main/java/org/ircclient/view/SkinBean.java
(rev 0)
+++
sandbox/trunk/examples/irc-client/src/main/java/org/ircclient/view/SkinBean.java 2011-01-05
12:51:57 UTC (rev 20892)
@@ -0,0 +1,70 @@
+/**
+ *
+ */
+package org.ircclient.view;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.annotation.PostConstruct;
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.ManagedProperty;
+import javax.faces.bean.SessionScoped;
+import javax.faces.context.FacesContext;
+
+/**
+ * @author ishaikovsky
+ */
+@ManagedBean(name = "skinBean")
+@SessionScoped
+public class SkinBean implements Serializable {
+ /**
+ *
+ */
+ private static final long serialVersionUID = -2399884208294434812L;
+ private static final String SKIN_VIEW_PARAMETER = "skin";
+ @ManagedProperty(value = "blueSky")
+ private String skin;
+ private List<String> skins;
+
+ @PostConstruct
+ public void initialize() {
+ skins = new ArrayList<String>();
+ skins.add("blueSky");
+ skins.add("classic");
+ skins.add("deepMarine");
+ skins.add("emeraldTown");
+ skins.add("japanCherry");
+ skins.add("ruby");
+ skins.add("wine");
+ }
+
+ // TODO: move to utility class. used in navigator also.
+ private String getViewParameter(String name) {
+ FacesContext fc = FacesContext.getCurrentInstance();
+ String param = (String)
fc.getExternalContext().getRequestParameterMap().get(name);
+ if (param != null && param.trim().length() > 0) {
+ return param;
+ } else {
+ return null;
+ }
+ }
+
+ public String getSkin() {
+ String currentSkin = getViewParameter(SKIN_VIEW_PARAMETER);
+ if (currentSkin != null) {
+ skin = currentSkin;
+ }
+ return skin;
+ }
+
+ public void setSkin(String skin) {
+ this.skin = skin;
+ }
+
+ public List<String> getSkins() {
+ return skins;
+ }
+
+}
Added: sandbox/trunk/examples/irc-client/src/main/webapp/WEB-INF/faces-config.xml
===================================================================
--- sandbox/trunk/examples/irc-client/src/main/webapp/WEB-INF/faces-config.xml
(rev 0)
+++ sandbox/trunk/examples/irc-client/src/main/webapp/WEB-INF/faces-config.xml 2011-01-05
12:51:57 UTC (rev 20892)
@@ -0,0 +1,16 @@
+<?xml version="1.0"?>
+<faces-config version="2.0"
xmlns="http://java.sun.com/xml/ns/javaee"
+
xmlns:xi="http://www.w3.org/2001/XInclude"
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-facesconfig_2_0.xsd">
+
+ <application>
+ <system-event-listener>
+ <system-event-listener-class>org.ircclient.listeners.HornetQInitializer</system-event-listener-class>
+ <system-event-class>javax.faces.event.PostConstructApplicationEvent</system-event-class>
+ </system-event-listener>
+ <system-event-listener>
+ <system-event-listener-class>org.ircclient.listeners.TopicsInitializer</system-event-listener-class>
+ <system-event-class>javax.faces.event.PostConstructApplicationEvent</system-event-class>
+ </system-event-listener>
+ </application>
+</faces-config>
Added: sandbox/trunk/examples/irc-client/src/main/webapp/WEB-INF/jboss-scanning.xml
===================================================================
--- sandbox/trunk/examples/irc-client/src/main/webapp/WEB-INF/jboss-scanning.xml
(rev 0)
+++
sandbox/trunk/examples/irc-client/src/main/webapp/WEB-INF/jboss-scanning.xml 2011-01-05
12:51:57 UTC (rev 20892)
@@ -0,0 +1,11 @@
+<scanning xmlns="urn:jboss:scanning:1.0">
+<!--
+ For JBoss AS 6 integration there is a conflict with guava, and
+ google-collections. JBAS-8361
+-->
+ <path name="WEB-INF/classes"></path>
+
+ <path name="WEB-INF/lib/guava-r07.jar">
+ <exclude name="com.google.common.collect" />
+ </path>
+</scanning>
\ No newline at end of file
Added: sandbox/trunk/examples/irc-client/src/main/webapp/WEB-INF/web.xml
===================================================================
--- sandbox/trunk/examples/irc-client/src/main/webapp/WEB-INF/web.xml
(rev 0)
+++ sandbox/trunk/examples/irc-client/src/main/webapp/WEB-INF/web.xml 2011-01-05 12:51:57
UTC (rev 20892)
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
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-app_3_0.xsd"
+ id="WebApp_ID" version="3.0">
+ <display-name>IRC-Client Application</display-name>
+ <context-param>
+ <param-name>javax.faces.PROJECT_STAGE</param-name>
+ <param-value>Development</param-value>
+ </context-param>
+ <context-param>
+ <param-name>javax.faces.SKIP_COMMENTS</param-name>
+ <param-value>true</param-value>
+ </context-param>
+ <context-param>
+ <param-name>org.richfaces.skin</param-name>
+ <param-value>#{skinBean.skin}</param-value>
+ </context-param>
+ <filter>
+ <filter-name>PushFilter</filter-name>
+ <filter-class>org.richfaces.webapp.PushFilter</filter-class>
+ <async-supported>true</async-supported>
+ </filter>
+ <filter-mapping>
+ <filter-name>PushFilter</filter-name>
+ <servlet-name>Faces Servlet</servlet-name>
+ </filter-mapping>
+ <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>*.jsf</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>Faces Servlet</servlet-name>
+ <url-pattern>/faces/*</url-pattern>
+ </servlet-mapping>
+ <session-config>
+ <session-timeout>30</session-timeout>
+ </session-config>
+ <mime-mapping>
+ <extension>ecss</extension>
+ <mime-type>text/css</mime-type>
+ </mime-mapping>
+ <welcome-file-list>
+ <welcome-file>index.jsp</welcome-file>
+ </welcome-file-list>
+ <login-config>
+ <auth-method>BASIC</auth-method>
+ </login-config>
+</web-app>
Added: sandbox/trunk/examples/irc-client/src/main/webapp/index.jsp
===================================================================
--- sandbox/trunk/examples/irc-client/src/main/webapp/index.jsp
(rev 0)
+++ sandbox/trunk/examples/irc-client/src/main/webapp/index.jsp 2011-01-05 12:51:57 UTC
(rev 20892)
@@ -0,0 +1,7 @@
+<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head></head>
+ <body>
+ <jsp:forward page="/welcome.jsf" />
+ </body>
+</html>
\ No newline at end of file
Added:
sandbox/trunk/examples/irc-client/src/main/webapp/templates/includes/skin-chooser.xhtml
===================================================================
---
sandbox/trunk/examples/irc-client/src/main/webapp/templates/includes/skin-chooser.xhtml
(rev 0)
+++
sandbox/trunk/examples/irc-client/src/main/webapp/templates/includes/skin-chooser.xhtml 2011-01-05
12:51:57 UTC (rev 20892)
@@ -0,0 +1,25 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html
xmlns="http://www.w3.org/1999/xhtml"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:a4j="http://richfaces.org/a4j"
+
xmlns:rich="http://richfaces.org/rich">
+
+<ui:composition>
+ <h:form>
+ <rich:panel styleClass="skin-chooser">
+ <a4j:repeat var="skin" value="#{skinBean.skins}"
+ iterationStatusVar="iterStatus">
+ <h:link value="#{skin}" includeViewParams="true">
+ <f:param name="skin" value="#{skin}" />
+ <f:attribute name="style"
+ value="#{(skin==skinBean.skin) ? 'color:orange' : ''}"
/>
+ </h:link>
+ <h:outputText value=" | " rendered="#{not iterStatus.last}"
/>
+ </a4j:repeat>
+ </rich:panel>
+ </h:form>
+</ui:composition>
+
+</html>
\ No newline at end of file
Added: sandbox/trunk/examples/irc-client/src/main/webapp/templates/template.xhtml
===================================================================
--- sandbox/trunk/examples/irc-client/src/main/webapp/templates/template.xhtml
(rev 0)
+++ sandbox/trunk/examples/irc-client/src/main/webapp/templates/template.xhtml 2011-01-05
12:51:57 UTC (rev 20892)
@@ -0,0 +1,21 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html
xmlns="http://www.w3.org/1999/xhtml"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:a4j="http://richfaces.org/a4j">
+<f:view contentType="text/html">
+ <f:metadata>
+ <f:viewParam name="skin" value="#{skinBean.skin}" />
+ </f:metadata>
+ <h:head>
+ <title><ui:define name="title">Application
Title</ui:define></title>
+ <meta http-equiv="content-type" content="text/xhtml;
charset=UTF-8" />
+ </h:head>
+
+ <h:body>
+ <ui:include src="/templates/includes/skin-chooser.xhtml" />
+ <ui:insert name="body">Default content</ui:insert>
+ </h:body>
+</f:view>
+</html>
Added: sandbox/trunk/examples/irc-client/src/main/webapp/welcome.xhtml
===================================================================
--- sandbox/trunk/examples/irc-client/src/main/webapp/welcome.xhtml
(rev 0)
+++ sandbox/trunk/examples/irc-client/src/main/webapp/welcome.xhtml 2011-01-05 12:51:57
UTC (rev 20892)
@@ -0,0 +1,80 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<ui:composition
xmlns="http://www.w3.org/1999/xhtml"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:a4j="http://richfaces.org/a4j"
+
xmlns:rich="http://richfaces.org/rich"
+
xmlns:c="http://java.sun.com/jsp/jstl/core"
+ template="/templates/template.xhtml">
+ <ui:define name="body">
+ <style>
+.chatOutput {
+ overflow: auto;
+ width: 80%;
+ height: 200px;
+ float: left;
+}
+
+.chatList {
+ float: right;
+ width: 19%;
+ height: 200px;
+ overflow: auto;
+}
+</style>
+ <rich:panel header="Connect to IRC"
+ rendered="#{not chatBean.connected}">
+ <h:form>
+ <a4j:outputPanel ajaxRendered="true">
+ <h:messages style="color:red" />
+ </a4j:outputPanel>
+ <h:panelGrid columns="2">
+ <h:outputText value="Your nickname:" />
+ <h:inputText required="true" id="name"
value="#{chatBean.userName}" />
+ <h:outputText value="Channel:" />
+ <h:outputText value="RichFaces"
style="font-weight:bold"/>
+ <h:outputText value="Server:" />
+ <h:outputText value="irc.freenode.org"
style="font-weight:bold"/>
+ </h:panelGrid>
+ <a4j:commandButton value="Connect" execute="@form"
render="@all"
+ action="#{chatBean.connect}" />
+ </h:form>
+ </rich:panel>
+ <rich:panel
+ header="Welcome to #{chatBean.channelName} channel at
#{chatBean.serverName}"
+ rendered="#{chatBean.connected}" id="chatpanel">
+ <rich:panel styleClass="chatOutput"
+ bodyClass="#{chatBean.channelName}Output" />
+ <rich:panel styleClass="chatList">
+ <rich:list value="#{chatBean.users}" var="user"
id="users"
+ type="unordered">
+ #{user.nick}
+ </rich:list>
+ </rich:panel>
+ <br clear="all" />
+ <hr />
+ <h:form>
+ <a4j:push address="#{chatBean.channelName}List@chat"
+ onerror="alert(event.rf.data)">
+ <a4j:ajax event="dataavailable" render="users"
execute="@none" />
+ </a4j:push>
+ <a4j:push address="#{chatBean.channelName}@chat"
+ onerror="alert(event.rf.data)"
+ ondataavailable="jQuery('<div
/>').prependTo('.#{chatBean.channelName}Output').text(event.rf.data)"
/>
+ <h:inputTextarea value="#{chatBean.message}" rows="3"
+ style="width:80%" id="nm" />
+ <a4j:commandButton value="Send" action="#{chatBean.send}"
+ render="@none" execute="@form" />
+ </h:form>
+ <hr />
+ <h:form>
+ <rich:panel header="Change nickname:">
+ <h:inputText valueChangeListener="#{chatBean.changeNick}"
id="cn" />
+ <a4j:commandButton value="Change" execute="@form"
render="@none"/>
+ </rich:panel>
+ <a4j:commandButton value="disconnect"
action="#{chatBean.leave}" execute="@none"
render="@all"/>
+ </h:form>
+ </rich:panel>
+ </ui:define>
+</ui:composition>
\ No newline at end of file