Author: jpapouse
Date: 2011-08-04 09:17:50 -0400 (Thu, 04 Aug 2011)
New Revision: 22592
Added:
modules/tests/metamer/branches/push-from-showcase/
Removed:
modules/tests/metamer/branches/push-from-showcase/application/src/main/java/org/richfaces/tests/metamer/listener/
modules/tests/metamer/branches/push-from-showcase/application/src/main/webapp/components/a4jPush/simple.xhtml
Modified:
modules/tests/metamer/branches/push-from-showcase/application/pom.xml
modules/tests/metamer/branches/push-from-showcase/application/src/main/java/org/richfaces/tests/metamer/bean/a4j/A4JPushBean.java
modules/tests/metamer/branches/push-from-showcase/application/src/main/webapp/WEB-INF/faces-config.xml
modules/tests/metamer/branches/push-from-showcase/application/src/main/webapp/WEB-INF/web.xml
modules/tests/metamer/branches/push-from-showcase/application/src/main/webapp/components/a4jPush/list.xhtml
modules/tests/metamer/branches/push-from-showcase/application/src/main/webapp/components/a4jPush/messageProducer.xhtml
modules/tests/metamer/branches/push-from-showcase/build.sh
Log:
RFPL-1572: the first version of a new page with a4j:push component - can be deployed only
to JBoas AS 7 (mvn profile 'war-jbas7')
Modified: modules/tests/metamer/branches/push-from-showcase/application/pom.xml
===================================================================
--- modules/tests/metamer/trunk/application/pom.xml 2011-08-02 04:23:57 UTC (rev 22583)
+++ modules/tests/metamer/branches/push-from-showcase/application/pom.xml 2011-08-04
13:17:50 UTC (rev 22592)
@@ -44,10 +44,17 @@
<properties>
<jetty.port>8080</jetty.port>
- <hornetq.version>2.1.2.Final</hornetq.version>
+ <hornetq.version>2.2.6.Final</hornetq.version>
</properties>
<dependencies>
+ <!-- JBoss AS7 management -->
+ <dependency>
+ <groupId>org.jboss.as</groupId>
+ <artifactId>jboss-as-controller-client</artifactId>
+ <version>7.0.0.CR1</version>
+ <scope>provided</scope>
+ </dependency>
<!-- RichFaces 4 -->
<dependency>
<groupId>org.richfaces.ui</groupId>
@@ -91,6 +98,7 @@
<dependency>
<groupId>javax.jms</groupId>
<artifactId>jms</artifactId>
+ <version>1.1</version>
</dependency>
<dependency>
<groupId>org.hornetq</groupId>
@@ -337,6 +345,38 @@
</build>
</profile>
<profile>
+ <id>war-jbas7</id>
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.as</groupId>
+ <artifactId>jboss-as-controller-client</artifactId>
+ <version>7.0.0.CR1</version>
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-war-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>jbas7</id>
+ <phase>integration-test</phase>
+ <goals>
+ <goal>war</goal>
+ </goals>
+ <configuration>
+ <classifier>jbas7</classifier>
+
<packagingExcludes>WEB-INF/lib/jsf-api-*,WEB-INF/lib/jsf-impl-*,WEB-INF/lib/myfaces-api-*,WEB-INF/lib/myfaces-impl-*,WEB-INF/lib/validation-api-*,WEB-INF/lib/hibernate-validator-*,WEB-INF/lib/jsp-api*,WEB-INF/lib/slf4j*,WEB-INF/lib/log4j*</packagingExcludes>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ <profile>
<id>war-jee6-bundled-mojarra</id>
<build>
<plugins>
Modified:
modules/tests/metamer/branches/push-from-showcase/application/src/main/java/org/richfaces/tests/metamer/bean/a4j/A4JPushBean.java
===================================================================
---
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/a4j/A4JPushBean.java 2011-08-02
04:23:57 UTC (rev 22583)
+++
modules/tests/metamer/branches/push-from-showcase/application/src/main/java/org/richfaces/tests/metamer/bean/a4j/A4JPushBean.java 2011-08-04
13:17:50 UTC (rev 22592)
@@ -22,40 +22,45 @@
package org.richfaces.tests.metamer.bean.a4j;
import java.io.Serializable;
-import java.util.Date;
-
import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
-import org.richfaces.application.push.MessageException;
-import org.richfaces.application.push.TopicKey;
-
-import org.richfaces.application.push.TopicsContext;
import org.richfaces.component.UIPush;
import org.richfaces.tests.metamer.Attributes;
-import org.richfaces.tests.metamer.Message;
-import org.richfaces.tests.metamer.listener.HornetQInitializer;
-import org.richfaces.tests.metamer.listener.TopicsInitializer;
+import org.richfaces.tests.metamer.push.CapabilityInitializer;
+import org.richfaces.tests.metamer.push.JMSCounterMessageProducer;
+import org.richfaces.tests.metamer.push.JMSInitializer;
+import org.richfaces.tests.metamer.push.MessageProduceInitializer;
+import org.richfaces.tests.metamer.push.MessageProducer;
+import org.richfaces.tests.metamer.push.TopicsContextMessageProducer;
+import org.richfaces.tests.metamer.push.TopicsInitializer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Managed bean for a4j:push.
*
- * @author Nick Belaevski, <a href="mailto:ppitonak@redhat.com">Pavol
Pitonak</a>
- * @version $Revision$
+ * @author Nick Belaevski
+ * @author <a href="mailto:ppitonak@redhat.com">Pavol Pitonak</a>
+ * @author <a href="mailto:jpapouse@redhat.com">Jan Papousek</a>
*/
@ManagedBean(name = "a4jPushBean")
@SessionScoped
public class A4JPushBean implements Serializable {
- private static final long serialVersionUID = 4810889475400649809L;
+
+ public static final int PUSH_INTERVAL = 2000;
+ public static final String PUSH_JMS_TOPIC = "metamerPushJms";
+ public static final String PUSH_TOPICS_CONTEXT_TOPIC =
"meatmerPushTopicsContext";
+ private static final long serialVersionUID = -164870535795309594L;
private static Logger logger;
- private transient TopicsContext topicsContext;
private Attributes attributes;
- private String username;
- private String message;
-
+ private int counter;
+ private CapabilityInitializer[] initializers;
+ private boolean messageProducingEnabled = false;
+ private MessageProducer[] messageProducers;
+
/**
* Initializes the managed bean.
*/
@@ -63,25 +68,31 @@
public void init() {
logger = LoggerFactory.getLogger(getClass());
logger.debug("initializing bean " + getClass().getName());
-
- // TODO refactor
- // set up messaging
- new HornetQInitializer().processEvent(null);
- new TopicsInitializer().processEvent(null);
-
- topicsContext = TopicsContext.lookup();
-
+ try {
+ for (CapabilityInitializer initializer : getInitializers()) {
+ initializer.initializeCapability();
+ }
+ } catch(Exception e) {
+ logger.error("The initializing of the " + getClass().getName() +
" failed.", e);
+ }
attributes = Attributes.getComponentAttributesFromClass(UIPush.class,
getClass());
-// attributes.setAttribute("interval", 1000);
-// attributes.setAttribute("action",
"increaseCounterAction");
-// attributes.setAttribute("actionListener",
"increaseCounterActionListener");
-// attributes.setAttribute("rendered", true);
-// attributes.setAttribute("enabled", true);
-//
-// // will be set on page and cannot be changed
-// attributes.remove("eventProducer");
+ attributes.setAttribute("address", PUSH_JMS_TOPIC);
+ attributes.setAttribute("ondataavailable",
"$('span[id$=output]').text(event.rf.data)");
+ attributes.setAttribute("rendered", true);
}
+ @PreDestroy
+ public void destroy() {
+ logger.debug("destroying bean " + getClass().getName());
+ try {
+ for (CapabilityInitializer initializer : getInitializers()) {
+ initializer.finalizeCapability();
+ }
+ } catch(Exception e) {
+ logger.error("The finalizing of the " + getClass().getName() +
" failed.", e);
+ }
+ }
+
/**
* Getter for attributes.
*
@@ -91,6 +102,14 @@
return attributes;
}
+ public int getCounter() {
+ return counter++;
+ }
+
+ public boolean getMessageProducingEnabled() {
+ return messageProducingEnabled;
+ }
+
/**
* Setter for attributes.
*
@@ -100,41 +119,48 @@
public void setAttributes(Attributes attributes) {
this.attributes = attributes;
}
-
- public String getUsername() {
- return username;
+
+ public void startMessageProducing() {
+ logger.info("starting message producing");
+ for (MessageProducer producer : getMessageProducers()) {
+ producer.enable();
+ }
+ this.messageProducingEnabled = true;
}
-
- public void setUsername(String username) {
- this.username = username;
+
+ public void stopMessageProducing() {
+ logger.info("stopping message producing");
+ for (MessageProducer producer : getMessageProducers()) {
+ producer.disable();
+ }
+ this.messageProducingEnabled = false;
}
-
- public String getMessage() {
- return message;
- }
-
- public void setMessage(String message) {
- this.message = message;
- }
-
- public void setTopicsContext(TopicsContext topicsContext) {
- this.topicsContext = topicsContext;
- }
-
- private TopicsContext getTopicsContext() {
- if (topicsContext == null) {
- topicsContext = TopicsContext.lookup();
+
+ private CapabilityInitializer[] getInitializers() {
+ if (initializers == null) {
+ initializers = new CapabilityInitializer[] {
+ new JMSInitializer(getTopics()),
+ new TopicsInitializer(getTopics()),
+ new MessageProduceInitializer(getMessageProducers(), PUSH_INTERVAL)
+ };
}
- return topicsContext;
+ return initializers;
}
-
- public void send() {
- try {
- logger.info("sending message \"" + message + "\" by
user " + username);
- Message msg = new Message(message, username, new Date().toString());
- getTopicsContext().publish(new TopicKey("metamer",
"xxx"), msg);
- } catch (MessageException messageException) {
- logger.error("Could not send message \"" + message +
"\" by user " + username + ".", messageException);
+
+ private MessageProducer[] getMessageProducers() {
+ if (messageProducers == null) {
+ messageProducers = new MessageProducer[] {
+ new JMSCounterMessageProducer(PUSH_JMS_TOPIC),
+ new TopicsContextMessageProducer(PUSH_TOPICS_CONTEXT_TOPIC)
+ };
+ for (MessageProducer producer : messageProducers) {
+ producer.disable();
+ }
}
+ return messageProducers;
}
+
+ private String[] getTopics() {
+ return new String[] {PUSH_JMS_TOPIC, PUSH_TOPICS_CONTEXT_TOPIC};
+ }
}
Modified:
modules/tests/metamer/branches/push-from-showcase/application/src/main/webapp/WEB-INF/faces-config.xml
===================================================================
---
modules/tests/metamer/trunk/application/src/main/webapp/WEB-INF/faces-config.xml 2011-08-02
04:23:57 UTC (rev 22583)
+++
modules/tests/metamer/branches/push-from-showcase/application/src/main/webapp/WEB-INF/faces-config.xml 2011-08-04
13:17:50 UTC (rev 22592)
@@ -1,21 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
-<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.richfaces.tests.metamer.listener.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.richfaces.tests.metamer.listener.TopicsInitializer</system-event-listener-class>
-
<system-event-class>javax.faces.event.PostConstructApplicationEvent</system-event-class>
- </system-event-listener>
- -->
- </application>
-
+<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">
<lifecycle>
<phase-listener>org.richfaces.tests.metamer.RichPhaseListener</phase-listener>
</lifecycle>
Modified:
modules/tests/metamer/branches/push-from-showcase/application/src/main/webapp/WEB-INF/web.xml
===================================================================
--- modules/tests/metamer/trunk/application/src/main/webapp/WEB-INF/web.xml 2011-08-02
04:23:57 UTC (rev 22583)
+++
modules/tests/metamer/branches/push-from-showcase/application/src/main/webapp/WEB-INF/web.xml 2011-08-04
13:17:50 UTC (rev 22592)
@@ -1,13 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
-<web-app version="3.0"
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">
-
+<web-app version="3.0"
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">
+
<display-name>metamer</display-name>
-
+
<welcome-file-list>
<welcome-file>faces/index.xhtml</welcome-file>
</welcome-file-list>
-
+
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
@@ -36,7 +36,7 @@
<param-name>org.richfaces.push.jms.connectionPassword</param-name>
<param-value>guest</param-value>
</context-param>
-
+
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
@@ -51,6 +51,7 @@
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
+ <!-- START: registers push -->
<filter>
<filter-name>PushFilter</filter-name>
<filter-class>org.richfaces.webapp.PushFilter</filter-class>
@@ -60,6 +61,8 @@
<filter-name>PushFilter</filter-name>
<servlet-name>Faces Servlet</servlet-name>
</filter-mapping>
+ <!-- END: registers push -->
+
<filter>
<filter-name>Test Identity Filter</filter-name>
<filter-class>org.richfaces.tests.metamer.TestIdentityFilter</filter-class>
@@ -69,5 +72,5 @@
<filter-name>Test Identity Filter</filter-name>
<servlet-name>Faces Servlet</servlet-name>
</filter-mapping>
-
+
</web-app>
Modified:
modules/tests/metamer/branches/push-from-showcase/application/src/main/webapp/components/a4jPush/list.xhtml
===================================================================
---
modules/tests/metamer/trunk/application/src/main/webapp/components/a4jPush/list.xhtml 2011-08-02
04:23:57 UTC (rev 22583)
+++
modules/tests/metamer/branches/push-from-showcase/application/src/main/webapp/components/a4jPush/list.xhtml 2011-08-04
13:17:50 UTC (rev 22592)
@@ -30,15 +30,13 @@
<ui:define name="pageTitle">A4J Push</ui:define>
<ui:define name="links">
-
- <metamer:testPageLink id="simple" outcome="simple"
value="Simple">
- Simple page that contains <b>a4j:push</b> and input boxes for
all its attributes.
- </metamer:testPageLink>
-
<metamer:testPageLink id="messageProducer"
outcome="messageProducer" value="Message Producer">
- Page that is bind to application bean producing messages catched by
a4j:push.
+ Page that is bind to JMS message producer whose messages are catched by
<b>a4j:push</b>.
</metamer:testPageLink>
-
+ <metamer:testPageLink id="topicsContext"
outcome="topicsContext" value="Topic Context">
+ Page that is bind to topic context message producer whose message are
catched by <b>a4j:push</b>
+ containing <b>a4j:ajax</b> which rerenders output with
counter from an application bean.
+ </metamer:testPageLink>
</ui:define>
</ui:composition>
Modified:
modules/tests/metamer/branches/push-from-showcase/application/src/main/webapp/components/a4jPush/messageProducer.xhtml
===================================================================
---
modules/tests/metamer/trunk/application/src/main/webapp/components/a4jPush/messageProducer.xhtml 2011-08-02
04:23:57 UTC (rev 22583)
+++
modules/tests/metamer/branches/push-from-showcase/application/src/main/webapp/components/a4jPush/messageProducer.xhtml 2011-08-04
13:17:50 UTC (rev 22592)
@@ -1,9 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!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:ui="http://java.sun.com/jsf/facelets"
xmlns:a4j="http://richfaces.org/a4j"
+
xmlns:metamer="http://java.sun.com/jsf/composite/metamer">
- <!--
+<!--
JBoss, Home of Professional Open Source
Copyright 2010-2011, Red Hat, Inc. and individual contributors
by the @authors tag. See the copyright.txt in the distribution for a
@@ -25,28 +26,31 @@
02110-1301 USA, or see the FSF site:
http://www.fsf.org.
-->
- <ui:composition template="/templates/template.xhtml">
+<ui:composition template="/templates/template.xhtml">
- <ui:define name="head">
- </ui:define>
+ <ui:define name="component">
+ <a4j:push
address="#{a4jPushBean.attributes['address'].value}"
+ id="pushJms"
+
ondataavailable="#{a4jPushBean.attributes['ondataavailable'].value}"
+ onerror="#{a4jPushBean.attributes['onerror'].value}"
+ />
+ <h:panelGrid columns="2">
+ <h:outputLabel value="Output:" />
+ <h:outputText value="waiting for event"
id="output"/>
+ </h:panelGrid>
+
+ <h:panelGrid rendered="#{!a4jPushBean.messageProducingEnabled}">
+ <h:commandButton id="startMessageProducing"
action="#{a4jPushBean.startMessageProducing}" value="Start" />
+ </h:panelGrid>
+ <h:panelGrid rendered="#{a4jPushBean.messageProducingEnabled}">
+ <h:commandButton id="stopMessageProducing"
action="#{a4jPushBean.stopMessageProducing}" value="Stop" />
+ </h:panelGrid>
+ </ui:define>
- <ui:define name="outOfTemplateBefore">
- </ui:define>
+ <ui:define name="outOfTemplateAfter">
+ <h2>A4J Push Attributes</h2>
+ <metamer:attributes value="#{a4jPushBean.attributes}"
id="attributes" />
+ </ui:define>
- <ui:define name="component">
- <h:panelGrid id="inputs" columns="2">
- <h:outputLabel id="nameLabel" value="Your name:"
for="nameInput"/>
- <h:inputText id="nameInput"
value="#{a4jPushBean.username}" />
- <h:outputLabel id="messageLabel" value="Your
message:" for="messageInput"/>
- <h:inputText id="messageInput"
value="#{a4jPushBean.message}" />
- </h:panelGrid>
-
- <br/>
- <h:commandButton id="submitButton" value="Send
Message" action="#{a4jPushBean.send}" />
- </ui:define>
-
- <ui:define name="outOfTemplateAfter">
- </ui:define>
-
- </ui:composition>
+</ui:composition>
</html>
\ No newline at end of file
Deleted:
modules/tests/metamer/branches/push-from-showcase/application/src/main/webapp/components/a4jPush/simple.xhtml
===================================================================
---
modules/tests/metamer/trunk/application/src/main/webapp/components/a4jPush/simple.xhtml 2011-08-02
04:23:57 UTC (rev 22583)
+++
modules/tests/metamer/branches/push-from-showcase/application/src/main/webapp/components/a4jPush/simple.xhtml 2011-08-04
13:17:50 UTC (rev 22592)
@@ -1,59 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!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: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:metamer="http://java.sun.com/jsf/composite/metamer"
-
xmlns:h="http://java.sun.com/jsf/html">
-
- <!--
-JBoss, Home of Professional Open Source
-Copyright 2010-2011, 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.
- -->
-
- <ui:composition template="/templates/template.xhtml">
-
- <ui:define name="view">
- <f:metadata>
- <f:viewParam name="templates"
value="#{templateBean.templates}">
- <f:converter converterId="templatesListConverter" />
- </f:viewParam>
- </f:metadata>
- </ui:define>
-
- <ui:define name="head">
- <h:outputScript library="script" name="push.js"/>
- </ui:define>
-
- <ui:define name="component">
-
- <ul class="push-list"></ul>
-
- <a4j:push address="xxx@metamer" onerror="alert('Error:
' + event.rf.data)"
- ondataavailable="updateList(event.rf.data)" >
- </a4j:push>
-
- </ui:define>
-
- <ui:define name="outOfTemplateAfter">
- <ui:remove><metamer:attributes
value="#{a4jPushBean.attributes}" id="attributes"
/></ui:remove>
- </ui:define>
-
- </ui:composition>
-</html>
\ No newline at end of file
Modified: modules/tests/metamer/branches/push-from-showcase/build.sh
===================================================================
--- modules/tests/metamer/trunk/build.sh 2011-08-02 04:23:57 UTC (rev 22583)
+++ modules/tests/metamer/branches/push-from-showcase/build.sh 2011-08-04 13:17:50 UTC
(rev 22592)
@@ -1,2 +1,2 @@
#!/bin/bash
-mvn clean install -Pmyfaces,war-myfaces,war-jee6-bundled-mojarra,war-jee6-bundled-myfaces
-Dselenium.server.skip=true -Dselenium.test.skip=true $*
+mvn clean install
-Pmyfaces,war-myfaces,war-jee6-bundled-mojarra,war-jee6-bundled-myfaces,war-jbas7
-Dselenium.server.skip=true -Dselenium.test.skip=true $*