Author: jpapouse
Date: 2011-08-04 09:19:06 -0400 (Thu, 04 Aug 2011)
New Revision: 22593
Added:
modules/tests/metamer/branches/push-from-showcase/application/src/main/java/org/richfaces/tests/metamer/push/
modules/tests/metamer/branches/push-from-showcase/application/src/main/java/org/richfaces/tests/metamer/push/AbstractMessageProducer.java
modules/tests/metamer/branches/push-from-showcase/application/src/main/java/org/richfaces/tests/metamer/push/CapabilityInitializer.java
modules/tests/metamer/branches/push-from-showcase/application/src/main/java/org/richfaces/tests/metamer/push/JMSCounterMessageProducer.java
modules/tests/metamer/branches/push-from-showcase/application/src/main/java/org/richfaces/tests/metamer/push/JMSInitializer.java
modules/tests/metamer/branches/push-from-showcase/application/src/main/java/org/richfaces/tests/metamer/push/MessageProduceInitializer.java
modules/tests/metamer/branches/push-from-showcase/application/src/main/java/org/richfaces/tests/metamer/push/MessageProducer.java
modules/tests/metamer/branches/push-from-showcase/application/src/main/java/org/richfaces/tests/metamer/push/MessageProducerRunnable.java
modules/tests/metamer/branches/push-from-showcase/application/src/main/java/org/richfaces/tests/metamer/push/TopicsContextMessageProducer.java
modules/tests/metamer/branches/push-from-showcase/application/src/main/java/org/richfaces/tests/metamer/push/TopicsInitializer.java
modules/tests/metamer/branches/push-from-showcase/application/src/main/java/org/richfaces/tests/metamer/push/provider/
modules/tests/metamer/branches/push-from-showcase/application/src/main/java/org/richfaces/tests/metamer/push/provider/AS6MessagingProviderManagement.java
modules/tests/metamer/branches/push-from-showcase/application/src/main/java/org/richfaces/tests/metamer/push/provider/AS7MessagingProviderManagement.java
modules/tests/metamer/branches/push-from-showcase/application/src/main/java/org/richfaces/tests/metamer/push/provider/CustomMessagingServerManagement.java
modules/tests/metamer/branches/push-from-showcase/application/src/main/java/org/richfaces/tests/metamer/push/provider/InitializationFailedException.java
modules/tests/metamer/branches/push-from-showcase/application/src/main/java/org/richfaces/tests/metamer/push/provider/MessagingProviderManagement.java
modules/tests/metamer/branches/push-from-showcase/application/src/main/webapp/components/a4jPush/topicsContext.xhtml
Log:
RFPL-1572: forgotten files
Added:
modules/tests/metamer/branches/push-from-showcase/application/src/main/java/org/richfaces/tests/metamer/push/AbstractMessageProducer.java
===================================================================
---
modules/tests/metamer/branches/push-from-showcase/application/src/main/java/org/richfaces/tests/metamer/push/AbstractMessageProducer.java
(rev 0)
+++
modules/tests/metamer/branches/push-from-showcase/application/src/main/java/org/richfaces/tests/metamer/push/AbstractMessageProducer.java 2011-08-04
13:19:06 UTC (rev 22593)
@@ -0,0 +1,54 @@
+/**
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.richfaces.tests.metamer.push;
+
+import java.util.concurrent.atomic.AtomicBoolean;
+
+/**
+ * @author <a href="mailto:jpapouse@redhat.com">Jan Papousek</a>
+ *
+ */
+public abstract class AbstractMessageProducer implements MessageProducer {
+
+ private AtomicBoolean enabled;
+
+ public AbstractMessageProducer() {
+ this(false);
+ }
+
+ public AbstractMessageProducer(boolean enabled) {
+ this.enabled = new AtomicBoolean(enabled);
+ }
+
+ public void disable() {
+ this.enabled.set(false);
+ }
+
+ public void enable() {
+ this.enabled.set(true);
+ }
+
+ public boolean isEnabled() {
+
+ return this.enabled.get();
+ }
+}
Added:
modules/tests/metamer/branches/push-from-showcase/application/src/main/java/org/richfaces/tests/metamer/push/CapabilityInitializer.java
===================================================================
---
modules/tests/metamer/branches/push-from-showcase/application/src/main/java/org/richfaces/tests/metamer/push/CapabilityInitializer.java
(rev 0)
+++
modules/tests/metamer/branches/push-from-showcase/application/src/main/java/org/richfaces/tests/metamer/push/CapabilityInitializer.java 2011-08-04
13:19:06 UTC (rev 22593)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.richfaces.tests.metamer.push;
+
+/**
+ * Initialize and finalize capability.
+ *
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ */
+public interface CapabilityInitializer {
+ /**
+ * Initializes provided capability.
+ *
+ * @throws Exception
+ */
+ void initializeCapability() throws Exception;
+
+ /**
+ * Finalizes provided capability and frees allocated resources.
+ *
+ * @throws Exception
+ */
+ void finalizeCapability() throws Exception;
+}
Added:
modules/tests/metamer/branches/push-from-showcase/application/src/main/java/org/richfaces/tests/metamer/push/JMSCounterMessageProducer.java
===================================================================
---
modules/tests/metamer/branches/push-from-showcase/application/src/main/java/org/richfaces/tests/metamer/push/JMSCounterMessageProducer.java
(rev 0)
+++
modules/tests/metamer/branches/push-from-showcase/application/src/main/java/org/richfaces/tests/metamer/push/JMSCounterMessageProducer.java 2011-08-04
13:19:06 UTC (rev 22593)
@@ -0,0 +1,109 @@
+/**
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.richfaces.tests.metamer.push;
+
+import java.io.Serializable;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.jms.JMSException;
+import javax.jms.ObjectMessage;
+import javax.jms.Session;
+import javax.jms.Topic;
+import javax.jms.TopicConnection;
+import javax.jms.TopicConnectionFactory;
+import javax.jms.TopicPublisher;
+import javax.jms.TopicSession;
+import javax.naming.InitialContext;
+import javax.naming.NameNotFoundException;
+import javax.naming.NamingException;
+
+import org.apache.commons.lang.Validate;
+
+/**
+ * Sends message to JMS topic.
+ *
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ */
+public class JMSCounterMessageProducer extends AbstractMessageProducer {
+
+ private static final Logger LOGGER =
Logger.getLogger(JMSCounterMessageProducer.class.getName());
+ private Topic topic;
+ private String topicName;
+ private TopicConnection connection = null;
+ private TopicSession session = null;
+ private TopicPublisher publisher = null;
+ private int counter = 0;
+
+ public JMSCounterMessageProducer(String topicName) {
+ Validate.notNull(topicName);
+ this.topicName = topicName;
+ }
+
+ public void sendMessage() throws Exception {
+ try {
+ initializeMessaging();
+ ObjectMessage message = session.createObjectMessage(createMessage());
+ publisher.publish(message);
+ } catch (NameNotFoundException e) {
+ LOGGER.fine(e.getMessage());
+ } catch (JMSException e) {
+ LOGGER.log(Level.SEVERE, e.getMessage(), e);
+ }
+ }
+
+ private Serializable createMessage() {
+ return counter++;
+ }
+
+ private void initializeMessaging() throws JMSException, NamingException {
+ if (connection == null) {
+ TopicConnectionFactory tcf = getTopicConnectionFactory();
+ connection = tcf.createTopicConnection();
+ }
+ if (session == null) {
+ session = connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
+ }
+ if (topic == null) {
+ topic = InitialContext.doLookup("topic/" + topicName);
+ }
+ if (publisher == null) {
+ publisher = session.createPublisher(topic);
+ }
+ }
+
+ public int getInterval() {
+ return 5000;
+ }
+
+ private TopicConnectionFactory getTopicConnectionFactory() {
+ try {
+ return (TopicConnectionFactory)
InitialContext.doLookup("java:/ConnectionFactory");
+ } catch (NamingException e) {
+ try {
+ return (TopicConnectionFactory)
InitialContext.doLookup("ConnectionFactory");
+ } catch (NamingException e2) {
+ throw new IllegalStateException("Can't find registered
ConnectionFactory");
+ }
+ }
+ }
+}
Added:
modules/tests/metamer/branches/push-from-showcase/application/src/main/java/org/richfaces/tests/metamer/push/JMSInitializer.java
===================================================================
---
modules/tests/metamer/branches/push-from-showcase/application/src/main/java/org/richfaces/tests/metamer/push/JMSInitializer.java
(rev 0)
+++
modules/tests/metamer/branches/push-from-showcase/application/src/main/java/org/richfaces/tests/metamer/push/JMSInitializer.java 2011-08-04
13:19:06 UTC (rev 22593)
@@ -0,0 +1,121 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.richfaces.tests.metamer.push;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.naming.InitialContext;
+import javax.naming.NameNotFoundException;
+import javax.naming.NamingException;
+
+
+import org.apache.commons.lang.Validate;
+import org.richfaces.tests.metamer.push.provider.AS6MessagingProviderManagement;
+import org.richfaces.tests.metamer.push.provider.AS7MessagingProviderManagement;
+import org.richfaces.tests.metamer.push.provider.CustomMessagingServerManagement;
+import org.richfaces.tests.metamer.push.provider.InitializationFailedException;
+import org.richfaces.tests.metamer.push.provider.MessagingProviderManagement;
+
+
+/**
+ * Initializes JMS server and creates requested topics.
+ *
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @author <a href="mailto:jpapouse@redhat.com">Jan Papousek</a>
+ */
+public class JMSInitializer implements CapabilityInitializer {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(JMSInitializer.class);
+ private MessagingProviderManagement provider;
+ private String[] topics;
+
+ public JMSInitializer(String[] topics) {
+ Validate.notNull(topics);
+ this.topics = topics;
+ }
+
+ public void initializeCapability() throws Exception {
+ LOGGER.info("starting initializing capabality");
+ provider = initializeCurrentProvider();
+ for (String topic : topics) {
+ LOGGER.info("creating topic <" + topic + ">.");
+ provider.createTopic(topic, "/topic/" + topic);
+ }
+ LOGGER.info("finishing initializing capabality");
+ }
+
+ public void finalizeCapability() throws Exception {
+ provider.finalizeProvider();
+ }
+
+ /**
+ * Returns all providers which are available from current context
+ *
+ * @return all providers which are available from current context
+ */
+ @SuppressWarnings("unchecked")
+ private Class<? extends MessagingProviderManagement>[] getAvailableProviders()
{
+ if (isConnectionFactoryRegistered()) {
+ return new Class[] { AS7MessagingProviderManagement.class,
AS6MessagingProviderManagement.class };
+ } else {
+ return new Class[] { CustomMessagingServerManagement.class };
+ }
+ }
+
+ /**
+ * Returns one of providers available from current context which are able to
initialize successfully
+ *
+ * @return one of providers available from current context which are able to
initialize successfully
+ */
+ private MessagingProviderManagement initializeCurrentProvider() {
+ for (Class<? extends MessagingProviderManagement> c :
getAvailableProviders()) {
+ try {
+ MessagingProviderManagement provider = c.newInstance();
+ provider.initializeProvider();
+ return provider;
+ } catch (InitializationFailedException e) {
+ LOGGER.warn("initailizing failed", e);
+ // TODO
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ }
+ throw new IllegalStateException("no management provider has been
successfully initialized");
+ }
+
+ /**
+ * Returns true if ConnectionFactory is already registered
+ *
+ * @return true if ConnectionFactory is already registered
+ */
+ private boolean isConnectionFactoryRegistered() {
+ try {
+ return null != InitialContext.doLookup("java:/ConnectionFactory");
+ } catch (NamingException e) {
+ if (!(e instanceof NameNotFoundException)) {
+ LOGGER.error("Can't access naming context", e);
+ }
+ return false;
+ }
+ }
+}
\ No newline at end of file
Added:
modules/tests/metamer/branches/push-from-showcase/application/src/main/java/org/richfaces/tests/metamer/push/MessageProduceInitializer.java
===================================================================
---
modules/tests/metamer/branches/push-from-showcase/application/src/main/java/org/richfaces/tests/metamer/push/MessageProduceInitializer.java
(rev 0)
+++
modules/tests/metamer/branches/push-from-showcase/application/src/main/java/org/richfaces/tests/metamer/push/MessageProduceInitializer.java 2011-08-04
13:19:06 UTC (rev 22593)
@@ -0,0 +1,73 @@
+/**
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.richfaces.tests.metamer.push;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.apache.commons.lang.Validate;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class MessageProduceInitializer implements CapabilityInitializer {
+
+ private static final Logger LOGGER =
LoggerFactory.getLogger(MessageProduceInitializer.class);
+ private MessageProducer[] messageProducers;
+ private Collection<MessageProducerRunnable> messageProducersRunnable;
+ private Collection<Thread> threads = new ArrayList<Thread>();
+ private int interval;
+
+ public MessageProduceInitializer(MessageProducer[] messageProducers, int interval) {
+ Validate.notNull(messageProducers);
+ this.messageProducers = messageProducers;
+ this.interval = interval;
+ }
+
+ @Override
+ public void initializeCapability() throws Exception {
+ LOGGER.info("starting initializing <" +
getMessageProducuersRunnable().size() + "> message producers.");
+ for(Runnable runnable : getMessageProducuersRunnable()) {
+ Thread thread = new Thread(runnable);
+ thread.setDaemon(true);
+ thread.start();
+ threads.add(thread);
+ }
+ LOGGER.info("finishing initializing");
+ }
+
+ @Override
+ public void finalizeCapability() throws Exception {
+ for(MessageProducerRunnable messageProducerRunnable :
getMessageProducuersRunnable()) {
+ messageProducerRunnable.stop();
+ }
+ }
+
+ private Collection<MessageProducerRunnable> getMessageProducuersRunnable() {
+ if (messageProducersRunnable == null) {
+ messageProducersRunnable = new ArrayList<MessageProducerRunnable>();
+ for(MessageProducer messageProducer : messageProducers) {
+ messageProducersRunnable.add(new MessageProducerRunnable(messageProducer,
interval));
+ }
+ }
+ return messageProducersRunnable;
+ }
+}
Added:
modules/tests/metamer/branches/push-from-showcase/application/src/main/java/org/richfaces/tests/metamer/push/MessageProducer.java
===================================================================
---
modules/tests/metamer/branches/push-from-showcase/application/src/main/java/org/richfaces/tests/metamer/push/MessageProducer.java
(rev 0)
+++
modules/tests/metamer/branches/push-from-showcase/application/src/main/java/org/richfaces/tests/metamer/push/MessageProducer.java 2011-08-04
13:19:06 UTC (rev 22593)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.richfaces.tests.metamer.push;
+
+/**
+ * Interface for implementations producing messages.
+ *
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @author <a href="mailto:jpapouse@redhat.com">Jan Papousek</a>
+ */
+public interface MessageProducer {
+
+ /**
+ * Disables the message producing
+ */
+ void disable();
+
+ /**
+ * Enables the message producing
+ */
+ void enable();
+
+ /**
+ * Checks whether the message producing is enabled
+ * @return true if the message producing is enabled, false otherwise
+ */
+ boolean isEnabled();
+
+ /**
+ * Sends a message.
+ *
+ * @throws Exception any exception which was thrown when trying to send message.
+ */
+ void sendMessage() throws Exception;
+}
Added:
modules/tests/metamer/branches/push-from-showcase/application/src/main/java/org/richfaces/tests/metamer/push/MessageProducerRunnable.java
===================================================================
---
modules/tests/metamer/branches/push-from-showcase/application/src/main/java/org/richfaces/tests/metamer/push/MessageProducerRunnable.java
(rev 0)
+++
modules/tests/metamer/branches/push-from-showcase/application/src/main/java/org/richfaces/tests/metamer/push/MessageProducerRunnable.java 2011-08-04
13:19:06 UTC (rev 22593)
@@ -0,0 +1,98 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.richfaces.tests.metamer.push;
+
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Runnable which are periodically sending messages until it is stopped or underlying
thread is interrupted.
+ *
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @author <a href="mailto:jpapouse@redhat.com">Jan Papousek</a>
+ */
+public class MessageProducerRunnable implements Runnable {
+
+ private static final Logger LOGGER =
LoggerFactory.getLogger(MessageProducerRunnable.class);
+
+ private AtomicBoolean runFlag = new AtomicBoolean(true);
+ private AtomicInteger interval;
+ private MessageProducer messageProducer;
+
+ /**
+ * Creates runnable with associated message producer.
+ *
+ * @param messageProducer will be associated with this runnable
+ */
+ public MessageProducerRunnable(MessageProducer messageProducer, int interval) {
+ this.messageProducer = messageProducer;
+ this.interval = new AtomicInteger(interval);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Runnable#run()
+ */
+ public void run() {
+ while (runFlag.get()) {
+ try {
+ if (messageProducer.isEnabled()) {
+ LOGGER.info("Message has beean sent.");
+ messageProducer.sendMessage();
+ }
+ } catch (Exception e) {
+ LOGGER.info(e.getMessage(), e);
+ }
+
+ try {
+ Thread.sleep(getInterval());
+ } catch (InterruptedException e) {
+ LOGGER.error("MessageProducer has been interrupted", e);
+ break;
+ }
+ }
+ }
+
+ /**
+ * Interval which will be producer sleeping after last message sent before start of
sending of next message.
+ *
+ * @return interval in miliseconds
+ */
+ public int getInterval() {
+ return interval.get();
+ }
+
+ public void setInterval(int interval) {
+ this.interval.set(interval);
+ }
+
+ /**
+ * Stops the cycle with body sending messages.
+ */
+ public void stop() {
+ runFlag.set(false);
+ }
+}
Added:
modules/tests/metamer/branches/push-from-showcase/application/src/main/java/org/richfaces/tests/metamer/push/TopicsContextMessageProducer.java
===================================================================
---
modules/tests/metamer/branches/push-from-showcase/application/src/main/java/org/richfaces/tests/metamer/push/TopicsContextMessageProducer.java
(rev 0)
+++
modules/tests/metamer/branches/push-from-showcase/application/src/main/java/org/richfaces/tests/metamer/push/TopicsContextMessageProducer.java 2011-08-04
13:19:06 UTC (rev 22593)
@@ -0,0 +1,61 @@
+/**
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.richfaces.tests.metamer.push;
+
+import org.apache.commons.lang.Validate;
+import org.richfaces.application.push.MessageException;
+import org.richfaces.application.push.TopicKey;
+import org.richfaces.application.push.TopicsContext;
+
+/**
+ * Sends message to topic using TopicsContext.
+ *
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @author <a href="mailto:jpapouse@redhat.com">Jan Papousek</a>
+ */
+public class TopicsContextMessageProducer extends AbstractMessageProducer {
+
+ public static final String DEFAULT_DATA = "message";
+ private String topic;
+
+ public TopicsContextMessageProducer(String topic) {
+ Validate.notNull(topic);
+ this.topic = topic;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.richfaces.demo.push.MessageProducer#sendMessage()
+ */
+ public void sendMessage() throws Exception {
+ try {
+ TopicKey topicKey = new TopicKey(topic);
+ TopicsContext topicsContext = TopicsContext.lookup();
+ topicsContext.publish(topicKey, DEFAULT_DATA);
+ } catch (MessageException e) {
+ if (!e.getMessage().matches("^Topic .* not found$")) {
+ throw e;
+ }
+ }
+ }
+}
Added:
modules/tests/metamer/branches/push-from-showcase/application/src/main/java/org/richfaces/tests/metamer/push/TopicsInitializer.java
===================================================================
---
modules/tests/metamer/branches/push-from-showcase/application/src/main/java/org/richfaces/tests/metamer/push/TopicsInitializer.java
(rev 0)
+++
modules/tests/metamer/branches/push-from-showcase/application/src/main/java/org/richfaces/tests/metamer/push/TopicsInitializer.java 2011-08-04
13:19:06 UTC (rev 22593)
@@ -0,0 +1,115 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.richfaces.tests.metamer.push;
+
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import javax.naming.InitialContext;
+import javax.naming.NameNotFoundException;
+import javax.naming.NamingException;
+
+import org.apache.commons.lang.Validate;
+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;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Registers topics in RichFaces subsytem.
+ *
+ * @author Nick Belaevski
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @author <a href="mailto:jpapouse@redhat.com">Jan Papousek</a>
+ */
+public class TopicsInitializer implements CapabilityInitializer {
+
+ private static final Logger LOGGER =
LoggerFactory.getLogger(TopicsInitializer.class.getName());
+ private String[] topics;
+ private Collection<Thread> threads = new ArrayList<Thread>();
+
+ public TopicsInitializer(String[] topics) {
+ Validate.notNull(topics);
+ this.topics = topics;
+ }
+
+ public void initializeCapability() throws Exception {
+ LOGGER.info("starting initializing");
+ TopicsContext.lookup();
+ for (String topic : topics) {
+ Thread thread = new RegisterTopicThread(topic);
+ threads.add(thread);
+ thread.setDaemon(true);
+ thread.start();
+ LOGGER.info("register thread for topic <" + topic + ">
started.");
+ }
+ }
+
+ @Override
+ public void finalizeCapability() throws Exception {
+ for (Thread thread : threads) {
+ thread.interrupt();
+ }
+ }
+
+ private class RegisterTopicThread extends Thread {
+
+ public RegisterTopicThread(final String topicName) {
+ super(new Runnable() {
+
+ public void run() {
+ waitForJmsTopicReady();
+
+ TopicsContext topicsContext = TopicsContext.lookup();
+ Topic pushJmsTopic = topicsContext.getOrCreateTopic(new
TopicKey(topicName));
+
pushJmsTopic.setMessageDataSerializer(DefaultMessageDataSerializer.instance());
+ }
+
+ private void waitForJmsTopicReady() {
+ while (!isJmsTopicReady()) {
+ try {
+ LOGGER.warn("topic " + topicName + " not ready
yet, sleeping");
+ Thread.sleep(500);
+ } catch (InterruptedException e) {
+ throw new IllegalStateException(e);
+ }
+ }
+ }
+
+ private boolean isJmsTopicReady() {
+ try {
+ InitialContext.doLookup("topic/" + topicName);
+ return true;
+ } catch (NameNotFoundException e) {
+ return false;
+ } catch (NamingException e) {
+ LOGGER.warn(e.getMessage());
+ }
+ return false;
+ }
+ }, "RegisterTopicThread");
+ }
+ }
+}
Added:
modules/tests/metamer/branches/push-from-showcase/application/src/main/java/org/richfaces/tests/metamer/push/provider/AS6MessagingProviderManagement.java
===================================================================
---
modules/tests/metamer/branches/push-from-showcase/application/src/main/java/org/richfaces/tests/metamer/push/provider/AS6MessagingProviderManagement.java
(rev 0)
+++
modules/tests/metamer/branches/push-from-showcase/application/src/main/java/org/richfaces/tests/metamer/push/provider/AS6MessagingProviderManagement.java 2011-08-04
13:19:06 UTC (rev 22593)
@@ -0,0 +1,78 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.richfaces.tests.metamer.push.provider;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.logging.Logger;
+
+import javax.management.MBeanServerConnection;
+import javax.management.MBeanServerInvocationHandler;
+import javax.management.ObjectName;
+import javax.management.remote.JMXConnector;
+import javax.management.remote.JMXConnectorFactory;
+import javax.management.remote.JMXServiceURL;
+
+import org.hornetq.api.core.management.ObjectNameBuilder;
+import org.hornetq.api.jms.management.JMSServerControl;
+
+/**
+ * Connects to JMS RMI interface and creates topics using {@link JMSServerControl}.
+ *
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ */
+public class AS6MessagingProviderManagement implements MessagingProviderManagement {
+
+ private static final Logger LOGGER =
Logger.getLogger(AS7MessagingProviderManagement.class.getName());
+ private JMSServerControl serverControl;
+
+ public void initializeProvider() throws InitializationFailedException {
+ try {
+ LOGGER.info("starting initializing");
+ ObjectName on = ObjectNameBuilder.DEFAULT.getJMSServerObjectName();
+ JMXConnector connector = JMXConnectorFactory.connect(new JMXServiceURL(
+ "service:jmx:rmi:///jndi/rmi://localhost:1090/jmxrmi"), new
HashMap<String, Object>());
+ MBeanServerConnection mbsc = connector.getMBeanServerConnection();
+ serverControl = (JMSServerControl)
MBeanServerInvocationHandler.newProxyInstance(mbsc, on,
+ JMSServerControl.class, false);
+ LOGGER.info("successfully initialized");
+ } catch (Exception e) {
+ throw new InitializationFailedException();
+ }
+ }
+
+ public void finalizeProvider() {
+ }
+
+ public void createTopic(String topicName, String jndiName) throws Exception {
+ if (getAvailableTopics().contains(topicName)) {
+ serverControl.createTopic(topicName, jndiName);
+ }
+ }
+
+ private Set<String> getAvailableTopics() {
+ String[] topicNames = serverControl.getTopicNames();
+ return new HashSet<String>(Arrays.asList(topicNames));
+ }
+}
Added:
modules/tests/metamer/branches/push-from-showcase/application/src/main/java/org/richfaces/tests/metamer/push/provider/AS7MessagingProviderManagement.java
===================================================================
---
modules/tests/metamer/branches/push-from-showcase/application/src/main/java/org/richfaces/tests/metamer/push/provider/AS7MessagingProviderManagement.java
(rev 0)
+++
modules/tests/metamer/branches/push-from-showcase/application/src/main/java/org/richfaces/tests/metamer/push/provider/AS7MessagingProviderManagement.java 2011-08-04
13:19:06 UTC (rev 22593)
@@ -0,0 +1,79 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.richfaces.tests.metamer.push.provider;
+
+import java.io.IOException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.jboss.as.controller.client.ModelControllerClient;
+import org.jboss.dmr.ModelNode;
+
+/**
+ * Manages AS7 to create JMS topics using ModelControllerClient.
+ *
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ */
+public class AS7MessagingProviderManagement implements MessagingProviderManagement {
+
+ private static final Logger LOGGER =
Logger.getLogger(AS7MessagingProviderManagement.class.getName());
+
+ private ModelControllerClient client;
+
+ public void initializeProvider() throws InitializationFailedException {
+ LOGGER.info("starting initializing");
+ try {
+ client = ModelControllerClient.Factory.create("127.0.0.1", 9999);
+ } catch (Exception e) {
+ throw new InitializationFailedException("The initialization of the
messaging provider failed.", e);
+ } catch (NoClassDefFoundError e) {
+ throw new InitializationFailedException("The initialization of the
messaging provider failed.", e);
+ }
+ LOGGER.info("successfully initialized");
+ }
+
+ public void finalizeProvider() {
+ try {
+ client.close();
+ } catch (IOException e) {
+ LOGGER.log(Level.SEVERE, "wasn't able to finalize AS7 messaging
management");
+ }
+ }
+
+ public void createTopic(String topicName, String jndiName) throws Exception {
+ jndiName = jndiName.replaceFirst("/", "");
+
+ ModelNode operation = new ModelNode();
+ operation.get("operation").set("read-resource");
+ operation.get("address").add("subsystem",
"messaging");
+ ModelNode result = client.execute(operation, null);
+
+ if
(!result.get("result").get("jms-topic").toString().contains("\""
+ topicName + "\"")) {
+ operation = new ModelNode();
+ operation.get("operation").set("add");
+ operation.get("address").add("subsystem",
"messaging");
+ operation.get("address").add("jms-topic", topicName);
+ operation.get("entries").add("topic/" + topicName);
+ client.executeAsync(operation, null);
+ }
+ }
+}
Added:
modules/tests/metamer/branches/push-from-showcase/application/src/main/java/org/richfaces/tests/metamer/push/provider/CustomMessagingServerManagement.java
===================================================================
---
modules/tests/metamer/branches/push-from-showcase/application/src/main/java/org/richfaces/tests/metamer/push/provider/CustomMessagingServerManagement.java
(rev 0)
+++
modules/tests/metamer/branches/push-from-showcase/application/src/main/java/org/richfaces/tests/metamer/push/provider/CustomMessagingServerManagement.java 2011-08-04
13:19:06 UTC (rev 22593)
@@ -0,0 +1,130 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.richfaces.tests.metamer.push.provider;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+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.config.ConnectionFactoryConfiguration;
+import org.hornetq.jms.server.config.impl.ConnectionFactoryConfigurationImpl;
+import org.hornetq.jms.server.impl.JMSServerManagerImpl;
+
+/**
+ * Starts HornetQ, binds ConnectionFactory to the context and create topics.
+ *
+ * @author Nick Belaevski
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ */
+public class CustomMessagingServerManagement implements MessagingProviderManagement {
+
+ private static final Logger LOGGER =
Logger.getLogger(CustomMessagingServerManagement.class.getName());
+
+ private HornetQServer jmsServer;
+ private JMSServerManager jmsServerManager;
+
+ public void initializeProvider() throws InitializationFailedException {
+ try {
+ LOGGER.info("starting initializing");
+ startJMSServer();
+ startJMSServerManager();
+ createJMSConnectionFactory();
+ LOGGER.info("successfully initialized");
+ } catch (Exception e) {
+ throw new InitializationFailedException(e);
+ }
+ }
+
+ public void createTopic(String topicName, String jndiName) throws Exception {
+ jmsServerManager.createTopic(false, topicName, jndiName);
+ }
+
+ public void finalizeProvider() {
+ try {
+ stopJMSServerManager();
+ stopJMSServer();
+ } catch (Exception e) {
+ LOGGER.log(Level.SEVERE, "wasn't able to finalize custom
messaging");
+ }
+ }
+
+ private void startJMSServer() throws Exception {
+ jmsServer = HornetQServers.newHornetQServer(createHornetQConfiguration());
+ }
+
+ private void startJMSServerManager() throws Exception {
+ jmsServerManager = new JMSServerManagerImpl(jmsServer);
+
+ InitialContext context = new InitialContext();
+ jmsServerManager.setContext(context);
+ jmsServerManager.start();
+ }
+
+ private void createJMSConnectionFactory() throws Exception {
+ List<String> connectors = Arrays.asList(new String[] { "netty"
});
+
+ ConnectionFactoryConfiguration connectionFactoryConfiguration = new
ConnectionFactoryConfigurationImpl(
+ "ConnectionFactory", false, connectors, (String) null);
+ connectionFactoryConfiguration.setUseGlobalPools(false);
+
+ jmsServerManager.createConnectionFactory(false, connectionFactoryConfiguration,
"ConnectionFactory");
+ }
+
+ private void stopJMSServer() throws Exception {
+ jmsServer.stop();
+ jmsServer = null;
+ }
+
+ private void stopJMSServerManager() throws Exception {
+ jmsServerManager.stop();
+ jmsServerManager = null;
+ }
+
+ private Configuration createHornetQConfiguration() {
+ Configuration configuration = new ConfigurationImpl();
+ configuration.setPersistenceEnabled(false);
+ configuration.setSecurityEnabled(false);
+
+ TransportConfiguration transportationConfiguration = new TransportConfiguration(
+ NettyAcceptorFactory.class.getName());
+ HashSet<TransportConfiguration> setTransp = new
HashSet<TransportConfiguration>();
+ setTransp.add(transportationConfiguration);
+ configuration.setAcceptorConfigurations(setTransp);
+ configuration.getConnectorConfigurations().put("netty",
+ new TransportConfiguration(NettyConnectorFactory.class.getName()));
+
+ return configuration;
+ }
+
+}
\ No newline at end of file
Added:
modules/tests/metamer/branches/push-from-showcase/application/src/main/java/org/richfaces/tests/metamer/push/provider/InitializationFailedException.java
===================================================================
---
modules/tests/metamer/branches/push-from-showcase/application/src/main/java/org/richfaces/tests/metamer/push/provider/InitializationFailedException.java
(rev 0)
+++
modules/tests/metamer/branches/push-from-showcase/application/src/main/java/org/richfaces/tests/metamer/push/provider/InitializationFailedException.java 2011-08-04
13:19:06 UTC (rev 22593)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.richfaces.tests.metamer.push.provider;
+
+/**
+ * Thrown when messaging provider management initialization fails.
+ *
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ */
+public class InitializationFailedException extends Exception {
+ private static final long serialVersionUID = 1L;
+
+ public InitializationFailedException() {
+ super();
+ }
+
+ public InitializationFailedException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public InitializationFailedException(String message) {
+ super(message);
+ }
+
+ public InitializationFailedException(Throwable cause) {
+ super(cause);
+ }
+
+}
\ No newline at end of file
Added:
modules/tests/metamer/branches/push-from-showcase/application/src/main/java/org/richfaces/tests/metamer/push/provider/MessagingProviderManagement.java
===================================================================
---
modules/tests/metamer/branches/push-from-showcase/application/src/main/java/org/richfaces/tests/metamer/push/provider/MessagingProviderManagement.java
(rev 0)
+++
modules/tests/metamer/branches/push-from-showcase/application/src/main/java/org/richfaces/tests/metamer/push/provider/MessagingProviderManagement.java 2011-08-04
13:19:06 UTC (rev 22593)
@@ -0,0 +1,56 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.richfaces.tests.metamer.push.provider;
+
+/**
+ * Interface for management of messaging provider.
+ *
+ * Is able to initialize, createTopic and finalize.
+ *
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ */
+public interface MessagingProviderManagement {
+ /**
+ * Initializes messaging management, called at application startup.
+ *
+ * @throws InitializationFailedException
+ * when initialize of provider fails
+ */
+ void initializeProvider() throws InitializationFailedException;
+
+ /**
+ * Creates JMS topic using this provider
+ *
+ * @param topicName
+ * the name of the topic
+ * @param jndiName
+ * the JNDI binding to use for given topic
+ * @throws Exception
+ * when creating of topic fails
+ */
+ void createTopic(String topicName, String jndiName) throws Exception;
+
+ /**
+ * Finalizes messaging provider management at on application tear down.
+ */
+ void finalizeProvider();
+}
Added:
modules/tests/metamer/branches/push-from-showcase/application/src/main/webapp/components/a4jPush/topicsContext.xhtml
===================================================================
---
modules/tests/metamer/branches/push-from-showcase/application/src/main/webapp/components/a4jPush/topicsContext.xhtml
(rev 0)
+++
modules/tests/metamer/branches/push-from-showcase/application/src/main/webapp/components/a4jPush/topicsContext.xhtml 2011-08-04
13:19:06 UTC (rev 22593)
@@ -0,0 +1,59 @@
+<?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: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
+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="component">
+ <a4j:push
address="#{a4jPushBean.attributes['address'].value}"
+ id="pushJms"
+ onerror="#{a4jPushBean.attributes['onerror'].value}"
+ >
+ <a4j:ajax event="dataavailable" render="output" />
+ </a4j:push>
+ <h:panelGrid columns="2">
+ <h:outputLabel value="Output:" />
+ <h:outputText value="#{a4jPushBean.counter}"
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>
+
+ The attribute <strong>ondataavailable</strong> is not used here.
+ </ui:define>
+
+ <ui:define name="outOfTemplateAfter">
+ <h2>A4J Push Attributes</h2>
+ <metamer:attributes value="#{a4jPushBean.attributes}"
id="attributes" />
+ </ui:define>
+
+</ui:composition>
+</html>
\ No newline at end of file