You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by re...@apache.org on 2008/07/30 12:18:05 UTC
svn commit: r680958 [1/2] - in
/cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample: ./ src/main/java/
src/main/java/org/ src/main/java/org/apache/
src/main/java/org/apache/cocoon/ src/main/java/org/apache/cocoon/acting/
src/main/java/org/apache/cocoon/jm...
Author: reinhard
Date: Wed Jul 30 03:18:02 2008
New Revision: 680958
URL: http://svn.apache.org/viewvc?rev=680958&view=rev
Log:
COCOON-2229
. provide JMS samples that use embedded ActiveMQ
. configure RCL for direct usage
Added:
cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/rcl.properties (with props)
cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/java/
cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/java/org/
cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/java/org/apache/
cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/java/org/apache/cocoon/
cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/java/org/apache/cocoon/acting/
cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/java/org/apache/cocoon/acting/JMSEventMessageListener.java (with props)
cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/java/org/apache/cocoon/jms/
cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/java/org/apache/cocoon/jms/SimpleMessageListener.java (with props)
cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/java/org/apache/cocoon/jms/SimpleTextMessagePublisher.java (with props)
cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/java/org/apache/cocoon/samples/
cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/java/org/apache/cocoon/samples/jms/ (props changed)
- copied from r680934, cocoon/trunk/blocks/cocoon-jms/cocoon-jms-impl/src/main/java/org/apache/cocoon/samples/jms/
cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/resources/COB-INF/eventcache/
cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/resources/COB-INF/eventcache/eventcache.xml (with props)
cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/resources/COB-INF/eventcache/sitemap.xmap (with props)
cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/resources/COB-INF/it/
cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/resources/COB-INF/it/it.xml (with props)
cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/resources/COB-INF/it/sitemap.xmap (with props)
cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/resources/META-INF/cocoon/spring/cocoon-jms-sample.xml (with props)
cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/
cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/java/
cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/java/org/
cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/java/org/apache/
cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/java/org/apache/cocoon/
cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/java/org/apache/cocoon/BaseSpringTest.java (with props)
cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/java/org/apache/cocoon/acting/
cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/java/org/apache/cocoon/acting/DummyTextMessage.java (with props)
cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/java/org/apache/cocoon/acting/JMSEventMessageListenerTest.java (with props)
cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/java/org/apache/cocoon/beans/
cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/java/org/apache/cocoon/beans/BaseMessageListenerTest.java (with props)
cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/java/org/apache/cocoon/beans/BaseMessagePublisherTest.java (with props)
cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/java/org/apache/cocoon/beans/TestHsql.java (with props)
cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/java/org/apache/cocoon/beans/TestQueueMessageListener.java (with props)
cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/java/org/apache/cocoon/beans/TestQueueMessagePublisher.java (with props)
cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/java/org/apache/cocoon/beans/TestTopicMessageListener.java (with props)
cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/java/org/apache/cocoon/beans/TestTopicMessagePublisher.java (with props)
cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/resources/
cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/resources/ddl/
cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/resources/ddl/hsql.sql (with props)
cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/resources/org/
cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/resources/org/apache/
cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/resources/org/apache/cocoon/
cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/resources/org/apache/cocoon/beans/
cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/resources/org/apache/cocoon/beans/spring-activemq-queue.xml (with props)
cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/resources/org/apache/cocoon/beans/spring-activemq-topic.xml (with props)
cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/resources/org/apache/cocoon/beans/spring-hsql.xml (with props)
Modified:
cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/pom.xml
cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/resources/COB-INF/database/sitemap.xmap
cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/resources/COB-INF/jms.xsamples
cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/resources/COB-INF/sitemap.xmap
Modified: cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/pom.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/pom.xml?rev=680958&r1=680957&r2=680958&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/pom.xml (original)
+++ cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/pom.xml Wed Jul 30 03:18:02 2008
@@ -7,9 +7,9 @@
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -46,5 +46,109 @@
<groupId>org.apache.cocoon</groupId>
<artifactId>cocoon-xsp-impl</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.cocoon</groupId>
+ <artifactId>cocoon-servlet-service-components</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>hsqldb</groupId>
+ <artifactId>hsqldb</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>activemq-core</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>activeio-core</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-jms</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.xbean</groupId>
+ <artifactId>xbean-spring</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-dbcp</groupId>
+ <artifactId>commons-dbcp</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-pool</groupId>
+ <artifactId>commons-pool</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-collections</groupId>
+ <artifactId>commons-collections</artifactId>
+ </dependency>
</dependencies>
+ <pluginRepositories>
+ <pluginRepository>
+ <id>codehaus.org</id>
+ <name>CodeHaus Plugin Snapshots</name>
+ <url>http://snapshots.repository.codehaus.org</url>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </pluginRepository>
+ </pluginRepositories>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>sql-maven-plugin</artifactId>
+ <version>1.1-SNAPSHOT</version>
+ <configuration>
+ <username>sa</username>
+ <password></password>
+ <driver>org.hsqldb.jdbcDriver</driver>
+ <skip>${maven.test.skip}</skip>
+ </configuration>
+ <dependencies>
+ <dependency>
+ <groupId>hsqldb</groupId>
+ <artifactId>hsqldb</artifactId>
+ <version>1.8.0.7</version>
+ </dependency>
+ </dependencies>
+ <executions>
+ <execution>
+ <id>create schema</id>
+ <phase>process-test-resources</phase>
+ <goals>
+ <goal>execute</goal>
+ </goals>
+ <configuration>
+ <url>jdbc:hsqldb:file:${basedir}/target/test</url>
+ <autocommit>true</autocommit>
+ <srcFiles>
+ <srcFile>${basedir}/src/test/resources/ddl/hsql.sql</srcFile>
+ </srcFiles>
+ </configuration>
+ </execution>
+ <execution>
+ <id>hsqldb shutdown</id>
+ <phase>process-test-resources</phase>
+ <goals>
+ <goal>execute</goal>
+ </goals>
+ <configuration>
+ <url>jdbc:hsqldb:file:${basedir}/target/test</url>
+ <sqlCommand>shutdown</sqlCommand>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
</project>
Added: cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/rcl.properties
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/rcl.properties?rev=680958&view=auto
==============================================================================
--- cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/rcl.properties (added)
+++ cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/rcl.properties Wed Jul 30 03:18:02 2008
@@ -0,0 +1,21 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+org.apache.cocoon.jms.sample.servlet%classes-dir=./target/classes
+
+# jms-impl
+%classes-dir=../cocoon-jms-impl/target/classes
+%exclude-lib=org.apache.cocoon:cocoon-jms-impl
Propchange: cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/rcl.properties
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/rcl.properties
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/rcl.properties
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/java/org/apache/cocoon/acting/JMSEventMessageListener.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/java/org/apache/cocoon/acting/JMSEventMessageListener.java?rev=680958&view=auto
==============================================================================
--- cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/java/org/apache/cocoon/acting/JMSEventMessageListener.java (added)
+++ cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/java/org/apache/cocoon/acting/JMSEventMessageListener.java Wed Jul 30 03:18:02 2008
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.acting;
+
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.TextMessage;
+
+import org.apache.cocoon.caching.EventAware;
+import org.apache.cocoon.caching.validity.Event;
+import org.apache.cocoon.caching.validity.NamedEvent;
+import org.apache.cocoon.components.jms.AbstractMessageListener;
+
+/**
+ * JMS listener will notify an {@link org.apache.cocoon.caching.EventAware} component of external events. This could be
+ * used for example to do external cache invalidation.
+ */
+public class JMSEventMessageListener extends AbstractMessageListener {
+
+ /**
+ * Cache injected by Spring.
+ */
+ private EventAware cache;
+
+ /**
+ * Default constructor.
+ *
+ * @throws JMSException In case, JMS initialization fails.
+ */
+ public JMSEventMessageListener() throws JMSException {
+ super();
+ }
+
+ /**
+ * Notifies the event cache of events occurred.
+ */
+ public synchronized void onMessage(Message message) {
+ if (getLogger().isDebugEnabled()) {
+ getLogger().debug("Receiving message: " + message);
+ }
+ Event event;
+ try {
+ event = eventFromTextMessage(message);
+ if (getLogger().isDebugEnabled()) {
+ getLogger().debug("Notifying of " + event);
+ }
+ this.cache.processEvent(event);
+ } catch (JMSException e) {
+ if (getLogger().isDebugEnabled()) {
+ getLogger().debug("Could not process message: " + message + ": " + e.getMessage());
+ }
+ }
+ }
+
+ /**
+ * Convert the message contents to (a series of) cache event. The default implementation assumes that the message
+ * contains the trigger name, a '|', and a table name. It extracts the tablename and creates a NamedEvent with it.
+ * Override this method to provide a custom message to event mapping.
+ *
+ * @param message the JMS message.
+ * @return the cache event.
+ */
+ protected Event eventFromTextMessage(Message message) throws JMSException {
+ String name = ((TextMessage) message).getText();
+ return new NamedEvent(name);
+ }
+
+ /**
+ * @param cache the cache to set
+ */
+ public final void setCache(final EventAware cache) {
+ this.cache = cache;
+ }
+}
\ No newline at end of file
Propchange: cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/java/org/apache/cocoon/acting/JMSEventMessageListener.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/java/org/apache/cocoon/acting/JMSEventMessageListener.java
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/java/org/apache/cocoon/acting/JMSEventMessageListener.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/java/org/apache/cocoon/jms/SimpleMessageListener.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/java/org/apache/cocoon/jms/SimpleMessageListener.java?rev=680958&view=auto
==============================================================================
--- cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/java/org/apache/cocoon/jms/SimpleMessageListener.java (added)
+++ cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/java/org/apache/cocoon/jms/SimpleMessageListener.java Wed Jul 30 03:18:02 2008
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.jms;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import javax.jms.JMSException;
+import javax.jms.Message;
+
+import org.apache.cocoon.components.jms.AbstractMessageListener;
+
+/**
+ * Provides a simple message consumer for test reasons. Incoming messages are stored in a {@link List}.
+ */
+public final class SimpleMessageListener extends AbstractMessageListener {
+
+ /**
+ * The list of messages received.
+ */
+ private List messages;
+
+ /**
+ * Default constructor.
+ *
+ * @throws JMSException If setup fails.
+ */
+ public SimpleMessageListener() throws JMSException {
+ super();
+ this.messages = new LinkedList();
+ }
+
+ /**
+ * Callback method for message receipt called by the broker.
+ *
+ * @see javax.jms.MessageListener#onMessage(javax.jms.Message)
+ */
+ public void onMessage(Message message) {
+ try {
+ this.messages.add(message);
+ message.acknowledge();
+ } catch (JMSException e) {
+ e.printStackTrace();
+ }
+
+ }
+
+ /**
+ * Clears all received messages.
+ */
+ public void flushMessages() {
+ this.messages.clear();
+ }
+
+ /**
+ * Returns all received messages.
+ *
+ * @return The received messages.
+ */
+ public final List getMessages() {
+ return this.messages;
+ }
+}
Propchange: cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/java/org/apache/cocoon/jms/SimpleMessageListener.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/java/org/apache/cocoon/jms/SimpleMessageListener.java
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/java/org/apache/cocoon/jms/SimpleMessageListener.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/java/org/apache/cocoon/jms/SimpleTextMessagePublisher.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/java/org/apache/cocoon/jms/SimpleTextMessagePublisher.java?rev=680958&view=auto
==============================================================================
--- cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/java/org/apache/cocoon/jms/SimpleTextMessagePublisher.java (added)
+++ cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/java/org/apache/cocoon/jms/SimpleTextMessagePublisher.java Wed Jul 30 03:18:02 2008
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.jms;
+
+import javax.jms.JMSException;
+import javax.jms.TextMessage;
+
+import org.apache.activemq.command.ActiveMQTextMessage;
+import org.apache.cocoon.components.jms.AbstractMessagePublisher;
+
+/**
+ * Provides a simple text message publisher for test reasons.
+ */
+public final class SimpleTextMessagePublisher extends AbstractMessagePublisher {
+
+ /**
+ * Publishes a simple text message.
+ *
+ * @throws JMSException In case, publish fails.
+ */
+ public void publish(String text) throws JMSException {
+ TextMessage message = new ActiveMQTextMessage();
+ message.setText(text);
+ super.publishMessage(message);
+ }
+}
\ No newline at end of file
Propchange: cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/java/org/apache/cocoon/jms/SimpleTextMessagePublisher.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/java/org/apache/cocoon/jms/SimpleTextMessagePublisher.java
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/java/org/apache/cocoon/jms/SimpleTextMessagePublisher.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Propchange: cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/java/org/apache/cocoon/samples/jms/
------------------------------------------------------------------------------
eol-style = native
Propchange: cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/java/org/apache/cocoon/samples/jms/
------------------------------------------------------------------------------
svn:mergeinfo =
Modified: cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/resources/COB-INF/database/sitemap.xmap
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/resources/COB-INF/database/sitemap.xmap?rev=680958&r1=680957&r2=680958&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/resources/COB-INF/database/sitemap.xmap (original)
+++ cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/resources/COB-INF/database/sitemap.xmap Wed Jul 30 03:18:02 2008
@@ -6,9 +6,9 @@
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -29,29 +29,30 @@
<map:components>
<!-- =========================== Matchers =================================== -->
-
- <map:matchers default="wildcard">
+ <!--
+ <map:matchers default="wildcard">
<map:matcher name="host-matcher" logger="sitemap.matcher.wildcard" src="org.apache.cocoon.matching.modular.CachingWildcardMatcher">
- <input-module name="request" />
- <parameter-name>serverName</parameter-name>
+ <input-module name="request" />
+ <parameter-name>serverName</parameter-name>
</map:matcher>
- </map:matchers>
-
+ </map:matchers>
+ -->
<!-- =========================== Actions =================================== -->
-
- <map:actions>
+ <!--
+ <map:actions>
<map:action name="cacheevent" src="org.apache.cocoon.acting.CacheEventAction" />
<map:action name="jmsevent" src="org.apache.cocoon.acting.JMSPublisherAction" logger="sitemap.actions.jms">
- <parameter name="connection" value="local-topics" />
- <parameter name="topic" value="topic1" />
+ <parameter name="connection" value="local-topics" />
+ <parameter name="topic" value="topic1" />
</map:action>
- </map:actions>
-
+ </map:actions>
+ -->
<!-- =========================== Pipes =================================== -->
<map:pipes default="caching">
- <!-- A pipe must be defined configured to use the EventAware cache. -->
- <map:pipe name="event-aware" src="org.apache.cocoon.components.pipeline.impl.CachingProcessingPipeline">
+
+ <map:pipe name="event-aware"
+ src="org.apache.cocoon.components.pipeline.impl.CachingProcessingPipeline">
<parameter name="cache-role" value="org.apache.cocoon.caching.Cache/EventAware" />
</map:pipe>
</map:pipes>
@@ -70,17 +71,26 @@
<map:pipelines>
- <!-- Our content must occur in a pipeline configured to use our Event Aware cache -->
- <map:pipeline type="event-aware">
- <map:match pattern="eventcache">
- <map:generate type="serverpages" src="{0}.xsp" />
- <!-- Make use of servlet services -->
- <map:serialize type="servletService">
- <map:parameter name="service" value="servlet:style-default:/service/blocks/dynamic-page2html" />
- </map:serialize>
+ <map:pipeline>
+ <map:match pattern="test">
+ <map:generate src="test.xml" type="file" />
+ <map:serialize type="xml" />
</map:match>
</map:pipeline>
+ <!-- Our content must occur in a pipeline configured to use our Event Aware cache -->
+ <!--
+ <map:pipeline type="event-aware">
+ <map:match pattern="eventcache">
+ <map:generate type="serverpages" src="{0}.xsp" />
+
+ <map:serialize type="servletService">
+ <map:parameter name="service" value="servlet:style-default:/service/blocks/dynamic-page2html" />
+ </map:serialize>
+ </map:match>
+ </map:pipeline>
+ -->
+<!--
<map:pipeline>
<map:match pattern="">
@@ -109,13 +119,14 @@
<map:match pattern="*">
<map:generate type="serverpages" src="{1}.xsp" />
- <!-- Make use of servlet services -->
+
<map:serialize type="servletService">
- <map:parameter name="service" value="servlet:style-default:/service/blocks/dynamic-page2html" />
+ <map:parameter name="service"
+ value="servlet:style-default:/service/blocks/dynamic-page2html" />
</map:serialize>
</map:match>
</map:pipeline>
-
+ -->
</map:pipelines>
</map:sitemap>
Added: cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/resources/COB-INF/eventcache/eventcache.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/resources/COB-INF/eventcache/eventcache.xml?rev=680958&view=auto
==============================================================================
--- cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/resources/COB-INF/eventcache/eventcache.xml (added)
+++ cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/resources/COB-INF/eventcache/eventcache.xml Wed Jul 30 03:18:02 2008
@@ -0,0 +1,70 @@
+<?xml version="1.0"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!--+
+ | event-based cache sample.
+ |
+ | @version $Id$
+ +-->
+<page>
+ <title>Demonstrating Event-Aware Cache Invalidation via JMS</title>
+ <content>
+ <para>
+ This page is a sample for publishing JMS messages. If you don't already understand at
+ least the basics of caching in Cocoon, you should probably start there, not here. Read the
+ text below, and the sitemap and source for more details.
+ </para>
+ <para>
+ I pause for ${cocoon.parameters.DELAY_SECS} seconds during generation, so
+ that you can tell if I'm being served from the cache or not.
+ <br/>
+ What you see here was generated on <b>${cocoon.parameters.DATE}</b>.
+ </para>
+
+ <para>
+ I'm cached for each unique value of request parameter 'pageKey'. Other
+ parameters do not matter.
+ <br/>
+ Here the value is:
+ <b>${cocoon.parameters.KEY}</b>.
+ <br/>
+ If this is not the same as the 'pageKey' parameter in the page URL, we have a problem.
+ </para>
+
+ <para>
+ Unlike other cacheable pages in Cocoon, I can be un-cached by events external
+ to Cocoon - for instance, when a JMS message is received.
+ <br/>
+ My cache entry will be invalidated (actually, removed) when an event named
+ <i>${cocoon.parameters.KEY}</i> occurs. Such an event can be triggered by
+ clicking the "uncache" links below.
+ </para>
+ <para>Test links:
+ <ul>
+ <li><a href="?pageKey=one">pageKey=one</a>
+ (<a href="action?pageKey=one&event=one">uncache with jms message</a>)</li>
+ <li><a href="?pageKey=two">pageKey=two</a>
+ (<a href="action?pageKey=two&event=two">uncache with jms message</a>)</li>
+ </ul>
+ Note: the random numbers you see included in the url after an uncache link
+ serve two purposes in the example, making it easier to see the effect of the
+ cache invalidation. They prevent browser caching and they demonstrate that
+ only our designated key matters in the retrieval from cache.
+ </para>
+ </content>
+</page>
Propchange: cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/resources/COB-INF/eventcache/eventcache.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/resources/COB-INF/eventcache/eventcache.xml
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/resources/COB-INF/eventcache/eventcache.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added: cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/resources/COB-INF/eventcache/sitemap.xmap
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/resources/COB-INF/eventcache/sitemap.xmap?rev=680958&view=auto
==============================================================================
--- cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/resources/COB-INF/eventcache/sitemap.xmap (added)
+++ cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/resources/COB-INF/eventcache/sitemap.xmap Wed Jul 30 03:18:02 2008
@@ -0,0 +1,66 @@
+<?xml version="1.0"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
+
+ <map:components>
+ <map:pipes default="caching">
+ <map:pipe logger="core.sitemap" name="event-aware"
+ src="org.apache.cocoon.components.pipeline.impl.CachingProcessingPipeline">
+ <parameter name="cache-role" value="org.apache.cocoon.caching.Cache/EventAware" />
+ </map:pipe>
+ </map:pipes>
+ </map:components>
+
+ <!-- =========================== Views =================================== -->
+
+ <map:views>
+ <map:view name="content" from-label="content">
+ <map:serialize type="xml" />
+ </map:view>
+ <map:view from-label="content" name="pretty-content">
+ <map:serialize type="servletService">
+ <map:parameter name="service" value="servlet:style-default:/service/system/xml2html" />
+ </map:serialize>
+ </map:view>
+ </map:views>
+
+ <!-- =========================== Pipelines =================================== -->
+
+ <map:pipelines>
+ <map:pipeline type="event-aware">
+ <map:match pattern="action">
+ <map:act type="JMSPublisherAction">
+ <map:parameter name="message" value="{request-param:event}" />
+ </map:act>
+ <map:redirect-to uri="demo?pageKey={request-param:pageKey}&rand={random:x}" />
+ </map:match>
+ <map:match pattern="*">
+ <map:generate src="eventcache.xml" type="EventCacheSample">
+ <map:parameter name="DELAY_SECS" value="2" />
+ <map:parameter name="DATE" value="{date:date}" />
+ <map:parameter name="KEY" value="{request-param:pageKey}" />
+ </map:generate>
+ <map:serialize type="servletService">
+ <map:parameter name="service"
+ value="servlet:style-default:/service/blocks/dynamic-page2html" />
+ </map:serialize>
+ </map:match>
+ </map:pipeline>
+ </map:pipelines>
+</map:sitemap>
+
Propchange: cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/resources/COB-INF/eventcache/sitemap.xmap
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/resources/COB-INF/eventcache/sitemap.xmap
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/resources/COB-INF/eventcache/sitemap.xmap
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added: cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/resources/COB-INF/it/it.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/resources/COB-INF/it/it.xml?rev=680958&view=auto
==============================================================================
--- cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/resources/COB-INF/it/it.xml (added)
+++ cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/resources/COB-INF/it/it.xml Wed Jul 30 03:18:02 2008
@@ -0,0 +1,22 @@
+<?xml version="1.0"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<!-- $Id$ -->
+<eventcache>
+ <key>${cocoon.parameters.KEY}</key>
+ <date>${cocoon.parameters.DATE}</date>
+</eventcache>
\ No newline at end of file
Propchange: cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/resources/COB-INF/it/it.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/resources/COB-INF/it/it.xml
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/resources/COB-INF/it/it.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added: cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/resources/COB-INF/it/sitemap.xmap
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/resources/COB-INF/it/sitemap.xmap?rev=680958&view=auto
==============================================================================
--- cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/resources/COB-INF/it/sitemap.xmap (added)
+++ cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/resources/COB-INF/it/sitemap.xmap Wed Jul 30 03:18:02 2008
@@ -0,0 +1,58 @@
+<?xml version="1.0"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
+
+ <map:components>
+ <map:pipes default="caching">
+ <map:pipe logger="core.sitemap" name="event-aware"
+ src="org.apache.cocoon.components.pipeline.impl.CachingProcessingPipeline">
+ <parameter name="cache-role" value="org.apache.cocoon.caching.Cache/EventAware" />
+ </map:pipe>
+ </map:pipes>
+ </map:components>
+
+ <!-- =========================== Views =================================== -->
+
+ <map:views>
+ <map:view name="content" from-label="content">
+ <map:serialize type="xml" />
+ </map:view>
+ </map:views>
+
+ <!-- =========================== Pipelines =================================== -->
+
+ <map:pipelines>
+ <map:pipeline type="event-aware">
+ <map:match pattern="action">
+ <map:act type="JMSPublisherAction">
+ <map:parameter name="message" value="{request-param:event}" />
+ </map:act>
+ <map:redirect-to uri="demo?pageKey={request-param:pageKey}&rand={random:x}" />
+ </map:match>
+ <map:match pattern="*">
+ <map:generate src="it.xml" type="EventCacheSample">
+ <map:parameter name="DELAY_SECS" value="2" />
+ <map:parameter name="DATE" value="{date:date}" />
+ <map:parameter name="KEY" value="{request-param:pageKey}" />
+ </map:generate>
+ <map:serialize type="xml" />
+ </map:match>
+ </map:pipeline>
+ </map:pipelines>
+</map:sitemap>
+
Propchange: cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/resources/COB-INF/it/sitemap.xmap
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/resources/COB-INF/it/sitemap.xmap
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/resources/COB-INF/it/sitemap.xmap
------------------------------------------------------------------------------
svn:mime-type = text/xml
Modified: cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/resources/COB-INF/jms.xsamples
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/resources/COB-INF/jms.xsamples?rev=680958&r1=680957&r2=680958&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/resources/COB-INF/jms.xsamples (original)
+++ cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/resources/COB-INF/jms.xsamples Wed Jul 30 03:18:02 2008
@@ -24,11 +24,11 @@
<group name="Backend Components">
<sample name="JMS Block" href="/cocoon-jms-sample/database/">
JMS invalidated Event Based Cache.
- A sample showing external cache invalidation using database triggers
- emitting either JMS messages or HTTP requests. For this sample, the
- HSQLDB block and the databases block need to be present. For the JMS
- part, a JMS service and libraries e.g. OpenJMS needs to be present and running.
- JMS connection parameters are set in a way to work with the OpenJMS demo.
+ A sample showing external cache invalidation using JMS messages in
+ combination with events or database triggers (broken) emitting either
+ JMS messages or HTTP requests. For this sample, the HSQLDB block and
+ the databases block need to be present. In this sample,
+ we use ActiveMQ as message broker, which runs in embedded mode.
</sample>
</group>
Modified: cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/resources/COB-INF/sitemap.xmap
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/resources/COB-INF/sitemap.xmap?rev=680958&r1=680957&r2=680958&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/resources/COB-INF/sitemap.xmap (original)
+++ cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/resources/COB-INF/sitemap.xmap Wed Jul 30 03:18:02 2008
@@ -6,9 +6,9 @@
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Added: cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/resources/META-INF/cocoon/spring/cocoon-jms-sample.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/resources/META-INF/cocoon/spring/cocoon-jms-sample.xml?rev=680958&view=auto
==============================================================================
--- cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/resources/META-INF/cocoon/spring/cocoon-jms-sample.xml (added)
+++ cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/resources/META-INF/cocoon/spring/cocoon-jms-sample.xml Wed Jul 30 03:18:02 2008
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<!-- $Id$ -->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:amq="http://activemq.apache.org/schema/core"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+ http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core-5.1.0.xsd">
+
+ <!-- Event aware generator bean inherits from the jx generator -->
+ <bean name="org.apache.cocoon.generation.Generator/EventCacheSample"
+ class="org.apache.cocoon.samples.EventAwareGenerator" scope="prototype"
+ parent="org.apache.cocoon.generation.Generator/jx" />
+
+ <!-- Action bean -->
+ <bean name="org.apache.cocoon.acting.Action/JMSPublisherAction"
+ class="org.apache.cocoon.acting.JMSPublisherAction" scope="prototype">
+ <property name="template" ref="myJmsTemplate" />
+ <property name="destination" ref="topic" />
+ </bean>
+
+ <!-- lets create an embedded ActiveMQ Broker -->
+ <amq:broker useJmx="false" persistent="false">
+ <amq:transportConnectors>
+ <amq:transportConnector uri="tcp://localhost:0" />
+ </amq:transportConnectors>
+ </amq:broker>
+
+ <amq:topic id="topic" physicalName="org.apache.activemq.spring.Test.spring.embedded" />
+
+ <!-- JMS ConnectionFactory to use, configuring the embedded broker using XML -->
+ <amq:connectionFactory id="jmsFactory" brokerURL="vm://localhost" />
+
+ <!-- Spring JMS Template -->
+ <bean id="myJmsTemplate" class="org.springframework.jms.core.JmsTemplate">
+ <property name="connectionFactory">
+ <!-- lets wrap in a pool to avoid creating a connection per send -->
+ <bean class="org.springframework.jms.connection.SingleConnectionFactory">
+ <property name="targetConnectionFactory">
+ <ref local="jmsFactory" />
+ </property>
+ </bean>
+ </property>
+ </bean>
+
+ <bean id="consumerJmsTemplate" class="org.springframework.jms.core.JmsTemplate">
+ <property name="connectionFactory" ref="jmsFactory" />
+ </bean>
+
+ <bean id="JMSEventMessageListener" class="org.apache.cocoon.acting.JMSEventMessageListener"
+ init-method="init" destroy-method="destroy" scope="singleton">
+ <property name="template" ref="consumerJmsTemplate" />
+ <property name="subscriptionId" value="topicconsumer" />
+ <property name="destination" ref="topic" />
+ <property name="cache" ref="org.apache.cocoon.caching.Cache/EventAware" />
+ </bean>
+
+</beans>
\ No newline at end of file
Propchange: cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/resources/META-INF/cocoon/spring/cocoon-jms-sample.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/resources/META-INF/cocoon/spring/cocoon-jms-sample.xml
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/main/resources/META-INF/cocoon/spring/cocoon-jms-sample.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added: cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/java/org/apache/cocoon/BaseSpringTest.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/java/org/apache/cocoon/BaseSpringTest.java?rev=680958&view=auto
==============================================================================
--- cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/java/org/apache/cocoon/BaseSpringTest.java (added)
+++ cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/java/org/apache/cocoon/BaseSpringTest.java Wed Jul 30 03:18:02 2008
@@ -0,0 +1,44 @@
+package org.apache.cocoon;
+
+import junit.framework.TestCase;
+
+import org.springframework.beans.factory.BeanFactory;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+/**
+ * A basic Spring test case.
+ */
+public abstract class BaseSpringTest extends TestCase {
+
+ /**
+ * Spring {@link BeanFactory}.
+ */
+ protected BeanFactory factory;
+
+ /**
+ * Returns the Spring config file name.
+ *
+ * @return Config file name.
+ */
+ protected abstract String getSpringConfigFile();
+
+ /**
+ * Bring up Spring IoC container.
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ ApplicationContext context = new ClassPathXmlApplicationContext(
+ getClass().getResource(getSpringConfigFile()).toExternalForm());
+ factory = context;
+ }
+
+ /**
+ * Tear down disposes Spring container.
+ */
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ factory = null;
+ }
+
+}
\ No newline at end of file
Propchange: cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/java/org/apache/cocoon/BaseSpringTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/java/org/apache/cocoon/BaseSpringTest.java
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/java/org/apache/cocoon/BaseSpringTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/java/org/apache/cocoon/acting/DummyTextMessage.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/java/org/apache/cocoon/acting/DummyTextMessage.java?rev=680958&view=auto
==============================================================================
--- cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/java/org/apache/cocoon/acting/DummyTextMessage.java (added)
+++ cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/java/org/apache/cocoon/acting/DummyTextMessage.java Wed Jul 30 03:18:02 2008
@@ -0,0 +1,463 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.acting;
+
+import java.util.Enumeration;
+
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.TextMessage;
+
+/**
+ * Provides a dummy {@link TextMessage} class to serve simple text messages,
+ * which means, only methods of TextMessage are implemented. Invocation of other
+ * methods will be rejected by throwing a {@link JMSException.
+ */
+class DummyTextMessage implements TextMessage {
+
+ /**
+ * The text to store.
+ */
+ private String text = "";
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.jms.TextMessage#getText()
+ */
+ public String getText() throws JMSException {
+ return text;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.jms.TextMessage#setText(java.lang.String)
+ */
+ public void setText(String arg0) throws JMSException {
+ this.text = arg0;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.jms.Message#acknowledge()
+ */
+ public void acknowledge() throws JMSException {
+ throw new JMSException("Not implemented!");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.jms.Message#clearBody()
+ */
+ public void clearBody() throws JMSException {
+ throw new JMSException("Not implemented!");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.jms.Message#clearProperties()
+ */
+ public void clearProperties() throws JMSException {
+ throw new JMSException("Not implemented!");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.jms.Message#getBooleanProperty(java.lang.String)
+ */
+ public boolean getBooleanProperty(String arg0) throws JMSException {
+ throw new JMSException("Not implemented!");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.jms.Message#getByteProperty(java.lang.String)
+ */
+ public byte getByteProperty(String arg0) throws JMSException {
+ throw new JMSException("Not implemented!");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.jms.Message#getDoubleProperty(java.lang.String)
+ */
+ public double getDoubleProperty(String arg0) throws JMSException {
+ throw new JMSException("Not implemented!");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.jms.Message#getFloatProperty(java.lang.String)
+ */
+ public float getFloatProperty(String arg0) throws JMSException {
+ throw new JMSException("Not implemented!");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.jms.Message#getIntProperty(java.lang.String)
+ */
+ public int getIntProperty(String arg0) throws JMSException {
+ throw new JMSException("Not implemented!");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.jms.Message#getJMSCorrelationID()
+ */
+ public String getJMSCorrelationID() throws JMSException {
+ throw new JMSException("Not implemented!");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.jms.Message#getJMSCorrelationIDAsBytes()
+ */
+ public byte[] getJMSCorrelationIDAsBytes() throws JMSException {
+ throw new JMSException("Not implemented!");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.jms.Message#getJMSDeliveryMode()
+ */
+ public int getJMSDeliveryMode() throws JMSException {
+ throw new JMSException("Not implemented!");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.jms.Message#getJMSDestination()
+ */
+ public Destination getJMSDestination() throws JMSException {
+ throw new JMSException("Not implemented!");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.jms.Message#getJMSExpiration()
+ */
+ public long getJMSExpiration() throws JMSException {
+ throw new JMSException("Not implemented!");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.jms.Message#getJMSMessageID()
+ */
+ public String getJMSMessageID() throws JMSException {
+ throw new JMSException("Not implemented!");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.jms.Message#getJMSPriority()
+ */
+ public int getJMSPriority() throws JMSException {
+ throw new JMSException("Not implemented!");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.jms.Message#getJMSRedelivered()
+ */
+ public boolean getJMSRedelivered() throws JMSException {
+ throw new JMSException("Not implemented!");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.jms.Message#getJMSReplyTo()
+ */
+ public Destination getJMSReplyTo() throws JMSException {
+ throw new JMSException("Not implemented!");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.jms.Message#getJMSTimestamp()
+ */
+ public long getJMSTimestamp() throws JMSException {
+ throw new JMSException("Not implemented!");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.jms.Message#getJMSType()
+ */
+ public String getJMSType() throws JMSException {
+ throw new JMSException("Not implemented!");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.jms.Message#getLongProperty(java.lang.String)
+ */
+ public long getLongProperty(String arg0) throws JMSException {
+ throw new JMSException("Not implemented!");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.jms.Message#getObjectProperty(java.lang.String)
+ */
+ public Object getObjectProperty(String arg0) throws JMSException {
+ throw new JMSException("Not implemented!");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.jms.Message#getPropertyNames()
+ */
+ public Enumeration getPropertyNames() throws JMSException {
+ throw new JMSException("Not implemented!");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.jms.Message#getShortProperty(java.lang.String)
+ */
+ public short getShortProperty(String arg0) throws JMSException {
+ throw new JMSException("Not implemented!");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.jms.Message#getStringProperty(java.lang.String)
+ */
+ public String getStringProperty(String arg0) throws JMSException {
+ throw new JMSException("Not implemented!");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.jms.Message#propertyExists(java.lang.String)
+ */
+ public boolean propertyExists(String arg0) throws JMSException {
+ throw new JMSException("Not implemented!");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.jms.Message#setBooleanProperty(java.lang.String, boolean)
+ */
+ public void setBooleanProperty(String arg0, boolean arg1)
+ throws JMSException {
+ throw new JMSException("Not implemented!");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.jms.Message#setByteProperty(java.lang.String, byte)
+ */
+ public void setByteProperty(String arg0, byte arg1) throws JMSException {
+ throw new JMSException("Not implemented!");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.jms.Message#setDoubleProperty(java.lang.String, double)
+ */
+ public void setDoubleProperty(String arg0, double arg1) throws JMSException {
+ throw new JMSException("Not implemented!");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.jms.Message#setFloatProperty(java.lang.String, float)
+ */
+ public void setFloatProperty(String arg0, float arg1) throws JMSException {
+ throw new JMSException("Not implemented!");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.jms.Message#setIntProperty(java.lang.String, int)
+ */
+ public void setIntProperty(String arg0, int arg1) throws JMSException {
+ throw new JMSException("Not implemented!");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.jms.Message#setJMSCorrelationID(java.lang.String)
+ */
+ public void setJMSCorrelationID(String arg0) throws JMSException {
+ throw new JMSException("Not implemented!");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.jms.Message#setJMSCorrelationIDAsBytes(byte[])
+ */
+ public void setJMSCorrelationIDAsBytes(byte[] arg0) throws JMSException {
+ throw new JMSException("Not implemented!");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.jms.Message#setJMSDeliveryMode(int)
+ */
+ public void setJMSDeliveryMode(int arg0) throws JMSException {
+ throw new JMSException("Not implemented!");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.jms.Message#setJMSDestination(javax.jms.Destination)
+ */
+ public void setJMSDestination(Destination arg0) throws JMSException {
+ throw new JMSException("Not implemented!");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.jms.Message#setJMSExpiration(long)
+ */
+ public void setJMSExpiration(long arg0) throws JMSException {
+ throw new JMSException("Not implemented!");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.jms.Message#setJMSMessageID(java.lang.String)
+ */
+ public void setJMSMessageID(String arg0) throws JMSException {
+ throw new JMSException("Not implemented!");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.jms.Message#setJMSPriority(int)
+ */
+ public void setJMSPriority(int arg0) throws JMSException {
+ throw new JMSException("Not implemented!");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.jms.Message#setJMSRedelivered(boolean)
+ */
+ public void setJMSRedelivered(boolean arg0) throws JMSException {
+ throw new JMSException("Not implemented!");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.jms.Message#setJMSReplyTo(javax.jms.Destination)
+ */
+ public void setJMSReplyTo(Destination arg0) throws JMSException {
+ throw new JMSException("Not implemented!");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.jms.Message#setJMSTimestamp(long)
+ */
+ public void setJMSTimestamp(long arg0) throws JMSException {
+ throw new JMSException("Not implemented!");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.jms.Message#setJMSType(java.lang.String)
+ */
+ public void setJMSType(String arg0) throws JMSException {
+ throw new JMSException("Not implemented!");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.jms.Message#setLongProperty(java.lang.String, long)
+ */
+ public void setLongProperty(String arg0, long arg1) throws JMSException {
+ throw new JMSException("Not implemented!");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.jms.Message#setObjectProperty(java.lang.String,
+ * java.lang.Object)
+ */
+ public void setObjectProperty(String arg0, Object arg1) throws JMSException {
+ throw new JMSException("Not implemented!");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.jms.Message#setShortProperty(java.lang.String, short)
+ */
+ public void setShortProperty(String arg0, short arg1) throws JMSException {
+ throw new JMSException("Not implemented!");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.jms.Message#setStringProperty(java.lang.String,
+ * java.lang.String)
+ */
+ public void setStringProperty(String arg0, String arg1) throws JMSException {
+ throw new JMSException("Not implemented!");
+ }
+
+}
Propchange: cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/java/org/apache/cocoon/acting/DummyTextMessage.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/java/org/apache/cocoon/acting/DummyTextMessage.java
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/java/org/apache/cocoon/acting/DummyTextMessage.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/java/org/apache/cocoon/acting/JMSEventMessageListenerTest.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/java/org/apache/cocoon/acting/JMSEventMessageListenerTest.java?rev=680958&view=auto
==============================================================================
--- cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/java/org/apache/cocoon/acting/JMSEventMessageListenerTest.java (added)
+++ cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/java/org/apache/cocoon/acting/JMSEventMessageListenerTest.java Wed Jul 30 03:18:02 2008
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.acting;
+
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.TextMessage;
+
+import junit.framework.TestCase;
+
+import org.apache.cocoon.caching.validity.Event;
+import org.apache.cocoon.caching.validity.NamedEvent;
+
+/**
+ * Unit test for {@link JMSEventMessageListener}.
+ */
+public class JMSEventMessageListenerTest extends TestCase {
+
+ /**
+ * Inner class for unit testing.
+ */
+ public final class TestJMSEventMessageListener extends
+ JMSEventMessageListener {
+ /**
+ * Default constructor.
+ *
+ * @throws JMSException
+ * In case, errors occur.
+ */
+ public TestJMSEventMessageListener() throws JMSException {
+ super();
+ }
+ }
+
+ /**
+ * Test extracting an {@link Event} out of a {@link Message}.
+ *
+ * @throws JMSException
+ * In case, some JMS action fails.
+ */
+ public void testEventsFromMessage() throws JMSException {
+ TestJMSEventMessageListener listener = new TestJMSEventMessageListener();
+ TextMessage msg = new DummyTextMessage();
+ msg.setText("one");
+ Event event = listener.eventFromTextMessage(msg);
+ assertNotNull(event);
+ assertEquals("NamedEvent[one]", ((NamedEvent) event).toString());
+ }
+}
Propchange: cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/java/org/apache/cocoon/acting/JMSEventMessageListenerTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/java/org/apache/cocoon/acting/JMSEventMessageListenerTest.java
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/java/org/apache/cocoon/acting/JMSEventMessageListenerTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/java/org/apache/cocoon/beans/BaseMessageListenerTest.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/java/org/apache/cocoon/beans/BaseMessageListenerTest.java?rev=680958&view=auto
==============================================================================
--- cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/java/org/apache/cocoon/beans/BaseMessageListenerTest.java (added)
+++ cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/java/org/apache/cocoon/beans/BaseMessageListenerTest.java Wed Jul 30 03:18:02 2008
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.beans;
+
+import java.util.List;
+
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+
+import org.apache.activemq.command.ActiveMQTextMessage;
+import org.apache.cocoon.BaseSpringTest;
+import org.apache.cocoon.components.jms.AbstractMessageListener;
+import org.apache.cocoon.jms.SimpleMessageListener;
+import org.springframework.jms.core.JmsTemplate;
+import org.springframework.jms.core.MessageCreator;
+
+/**
+ * Provides a base class to verify message delivery via JMS based on
+ * {@link AbstractMessageListener} including a Spring IoC container.
+ */
+public abstract class BaseMessageListenerTest extends BaseSpringTest {
+
+ /**
+ * Spring consumer bean name.
+ */
+ private static final String SIMPLE_CONSUMER = "simpleConsumer";
+
+ /**
+ * Spring producer bean name.
+ */
+ private static final String PRODUCER = "myJmsTemplate";
+
+ /**
+ * Returns a JMS {@link Destination} (e.g. Topic or Queue) to use.
+ *
+ * @return A Destination.
+ */
+ protected abstract Destination getDestination();
+
+ /**
+ * Sends a simple text message to a {@link Destination} and verifies receipt
+ * by using a {@link SimpleMessageListener}.
+ *
+ * @throws JMSException
+ * In case, JMS delivery fails.
+ */
+ public void testMessageListener() throws JMSException {
+ SimpleMessageListener consumer = (SimpleMessageListener) factory
+ .getBean(SIMPLE_CONSUMER);
+ JmsTemplate template = (JmsTemplate) factory.getBean(PRODUCER);
+
+ MessageCreator creator = new MessageCreator() {
+ public Message createMessage(Session session) throws JMSException {
+ String text = "This is a message";
+ TextMessage message = session.createTextMessage(text);
+ return message;
+ }
+ };
+
+ consumer.flushMessages();
+
+ // Get the destination (e.g. Topic or Queue) from the superclass.
+ Destination destination = getDestination();
+ // Send a message.
+ template.send(destination, creator);
+
+ try {
+ Thread.sleep(1000L);
+ } catch (InterruptedException e) {
+ // Do nothing.
+ }
+
+ List messages = consumer.getMessages();
+ assertEquals(1, messages.size());
+ assertEquals("This is a message", ((ActiveMQTextMessage) messages
+ .get(0)).getText());
+
+ consumer.destroy();
+ }
+
+}
\ No newline at end of file
Propchange: cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/java/org/apache/cocoon/beans/BaseMessageListenerTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/java/org/apache/cocoon/beans/BaseMessageListenerTest.java
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/java/org/apache/cocoon/beans/BaseMessageListenerTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/java/org/apache/cocoon/beans/BaseMessagePublisherTest.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/java/org/apache/cocoon/beans/BaseMessagePublisherTest.java?rev=680958&view=auto
==============================================================================
--- cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/java/org/apache/cocoon/beans/BaseMessagePublisherTest.java (added)
+++ cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/java/org/apache/cocoon/beans/BaseMessagePublisherTest.java Wed Jul 30 03:18:02 2008
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.beans;
+
+import java.util.List;
+
+import javax.jms.Destination;
+import javax.jms.JMSException;
+
+import org.apache.activemq.command.ActiveMQTextMessage;
+import org.apache.cocoon.BaseSpringTest;
+import org.apache.cocoon.components.jms.AbstractMessageListener;
+import org.apache.cocoon.jms.SimpleMessageListener;
+import org.apache.cocoon.jms.SimpleTextMessagePublisher;
+
+/**
+ * Provides a base class to verify message delivery via JMS based on
+ * {@link AbstractMessageListener} including a Spring IoC container.
+ */
+public abstract class BaseMessagePublisherTest extends BaseSpringTest {
+
+ /**
+ * Spring consumer bean name.
+ */
+ private static final String SIMPLE_CONSUMER = "simpleConsumer";
+
+ /**
+ * Spring producer bean name.
+ */
+ private static final String SIMPLE_PRODUCER = "simpleProducer";
+
+ /**
+ * Returns a JMS {@link Destination} (e.g. Topic or Queue) to use.
+ *
+ * @return A Destination.
+ */
+ protected abstract Destination getDestination();
+
+ /**
+ * Sends a simple text message using a {@link SimpleTextMessagePublisher} to
+ * a {@link Destination} and verifies receipt by using a
+ * {@link SimpleMessageListener}.
+ *
+ * @throws JMSException
+ * In case, JMS delivery fails.
+ */
+ public void testMessagePublisher() throws JMSException {
+ SimpleMessageListener consumer = (SimpleMessageListener) factory
+ .getBean(SIMPLE_CONSUMER);
+ SimpleTextMessagePublisher publisher = (SimpleTextMessagePublisher) factory.getBean(SIMPLE_PRODUCER);
+
+ consumer.flushMessages();
+
+ // Send a message.
+ publisher.publish("A simple text message");
+
+ try {
+ Thread.sleep(1000L);
+ } catch (InterruptedException e) {
+ // Do nothing.
+ }
+
+ List messages = consumer.getMessages();
+ assertEquals(1, messages.size());
+ assertEquals("A simple text message", ((ActiveMQTextMessage) messages
+ .get(0)).getText());
+
+ consumer.destroy();
+ }
+
+}
\ No newline at end of file
Propchange: cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/java/org/apache/cocoon/beans/BaseMessagePublisherTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/java/org/apache/cocoon/beans/BaseMessagePublisherTest.java
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/java/org/apache/cocoon/beans/BaseMessagePublisherTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/java/org/apache/cocoon/beans/TestHsql.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/java/org/apache/cocoon/beans/TestHsql.java?rev=680958&view=auto
==============================================================================
--- cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/java/org/apache/cocoon/beans/TestHsql.java (added)
+++ cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/java/org/apache/cocoon/beans/TestHsql.java Wed Jul 30 03:18:02 2008
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.beans;
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.Statement;
+
+import javax.sql.DataSource;
+
+import junit.framework.TestCase;
+
+import org.springframework.beans.factory.BeanFactory;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+/**
+ * This test verifies correct startup of various components (Spring beans).
+ */
+public class TestHsql extends TestCase {
+
+ /**
+ * Spring config file.
+ */
+ private static final String SPRING_CONFIG = "spring-hsql.xml";
+
+ private static final String DATA_SOURCE = "dataSource";
+
+ private static final String SELECT_FROM_USER = "SELECT * FROM USER";
+
+ /**
+ * Spring {@link ApplicationContext}.
+ */
+ protected BeanFactory factory;
+
+ /**
+ * Constructor initializing Spring.
+ */
+ public TestHsql() {
+ ApplicationContext context = new ClassPathXmlApplicationContext(this.getClass().getResource(SPRING_CONFIG)
+ .toExternalForm());
+ this.factory = context;
+ }
+
+ /**
+ * Place a simple HSQLDB query to ensure, DB is up.
+ *
+ * @throws Exception If DB access fails.
+ */
+ public void testHsql() throws Exception {
+ DataSource ds = (DataSource) this.factory.getBean(DATA_SOURCE);
+ Connection connection = ds.getConnection();
+ Statement stmt = connection.createStatement();
+ ResultSet result = stmt.executeQuery(SELECT_FROM_USER);
+ assertEquals(1, result.getFetchSize());
+ }
+}
Propchange: cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/java/org/apache/cocoon/beans/TestHsql.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/java/org/apache/cocoon/beans/TestHsql.java
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/java/org/apache/cocoon/beans/TestHsql.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/java/org/apache/cocoon/beans/TestQueueMessageListener.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/java/org/apache/cocoon/beans/TestQueueMessageListener.java?rev=680958&view=auto
==============================================================================
--- cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/java/org/apache/cocoon/beans/TestQueueMessageListener.java (added)
+++ cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/java/org/apache/cocoon/beans/TestQueueMessageListener.java Wed Jul 30 03:18:02 2008
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.beans;
+
+import javax.jms.Destination;
+import javax.jms.Queue;
+
+/**
+ * This test verifies correct startup of various components (Spring beans).
+ */
+public class TestQueueMessageListener extends BaseMessageListenerTest {
+
+ /**
+ * Spring config file.
+ */
+ private static final String SPRING_CONFIG_FILE = "spring-activemq-queue.xml";
+
+ /**
+ * Spring {@link Queue} bean name.
+ */
+ private static final String QUEUE_BEAN = "queue";
+
+ /**
+ * Returns a {@link Queue} to use for JMS message transport.
+ *
+ * @return A Spring {@link Queue}.
+ */
+ protected Destination getDestination() {
+ return (Queue) factory.getBean(QUEUE_BEAN);
+ }
+
+ /**
+ * Returns the Spring config file name.
+ *
+ * @return Config file name.
+ * @see org.apache.cocoon.beans.BaseMessageListenerTest#getSpringConfigFile()
+ */
+ protected String getSpringConfigFile() {
+ return SPRING_CONFIG_FILE;
+ }
+
+}
Propchange: cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/java/org/apache/cocoon/beans/TestQueueMessageListener.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/java/org/apache/cocoon/beans/TestQueueMessageListener.java
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/java/org/apache/cocoon/beans/TestQueueMessageListener.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/java/org/apache/cocoon/beans/TestQueueMessagePublisher.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/java/org/apache/cocoon/beans/TestQueueMessagePublisher.java?rev=680958&view=auto
==============================================================================
--- cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/java/org/apache/cocoon/beans/TestQueueMessagePublisher.java (added)
+++ cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/java/org/apache/cocoon/beans/TestQueueMessagePublisher.java Wed Jul 30 03:18:02 2008
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.beans;
+
+import javax.jms.Destination;
+import javax.jms.Queue;
+
+/**
+ * This test verifies correct startup of various components (Spring beans).
+ */
+public class TestQueueMessagePublisher extends BaseMessagePublisherTest {
+
+ /**
+ * Spring config file.
+ */
+ private static final String SPRING_CONFIG_FILE = "spring-activemq-queue.xml";
+
+ /**
+ * Spring {@link Queue} bean name.
+ */
+ private static final String QUEUE_BEAN = "queue";
+
+ /**
+ * Returns a {@link Queue} to use for JMS message transport.
+ *
+ * @return A Spring {@link Queue}.
+ */
+ protected Destination getDestination() {
+ return (Queue) factory.getBean(QUEUE_BEAN);
+ }
+
+ /**
+ * Returns the Spring config file name.
+ *
+ * @return Config file name.
+ * @see org.apache.cocoon.beans.BaseMessageListenerTest#getSpringConfigFile()
+ */
+ protected String getSpringConfigFile() {
+ return SPRING_CONFIG_FILE;
+ }
+}
Propchange: cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/java/org/apache/cocoon/beans/TestQueueMessagePublisher.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/java/org/apache/cocoon/beans/TestQueueMessagePublisher.java
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: cocoon/trunk/blocks/cocoon-jms/cocoon-jms-sample/src/test/java/org/apache/cocoon/beans/TestQueueMessagePublisher.java
------------------------------------------------------------------------------
svn:mime-type = text/plain