Webinar End State
The state of the project at the end of the webinar, use git log -p <this commit> to see what changed.
This commit is contained in:
committed by
Gunnar Hillert
parent
dbd1be3579
commit
e2dc83b725
@@ -44,6 +44,9 @@ public interface TwitterService {
|
||||
*/
|
||||
void stopTwitterAdapter();
|
||||
|
||||
/**
|
||||
* Performs an orderly shutdown of the Spring Integration twitter application.
|
||||
*/
|
||||
void shutdown();
|
||||
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package _org.springframework.integration;
|
||||
package org.springintegration;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
@@ -27,6 +27,9 @@ import org.springframework.jmx.export.annotation.ManagedResource;
|
||||
import org.springframework.util.StopWatch;
|
||||
|
||||
/**
|
||||
* A sample channel interceptor that illustrates a technique to capture elapsed times
|
||||
* based on message payload types.
|
||||
*
|
||||
* @author Gary Russell
|
||||
* @since 2.2
|
||||
*
|
||||
@@ -38,6 +41,11 @@ public class PayloadAwareTimingInterceptor extends ChannelInterceptorAdapter {
|
||||
|
||||
private Map<Class<?>, Stats> statsMap = new ConcurrentHashMap<Class<?>, PayloadAwareTimingInterceptor.Stats>();
|
||||
|
||||
/**
|
||||
*
|
||||
* @param classes An array of types for which statistics will be captured; if
|
||||
* not supplied {@link Object} will be added as a catch-all.
|
||||
*/
|
||||
public PayloadAwareTimingInterceptor(Class<?>[] classes) {
|
||||
for (Class<?> clazz : classes) {
|
||||
this.statsMap.put(clazz, new Stats());
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package _org.springframework.integration.service.impl;
|
||||
package org.springintegration.service.impl;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedHashMap;
|
||||
@@ -25,21 +25,20 @@ import org.springframework.integration.Message;
|
||||
import org.springframework.integration.MessageChannel;
|
||||
import org.springframework.integration.endpoint.SourcePollingChannelAdapter;
|
||||
import org.springframework.integration.model.TwitterMessage;
|
||||
import org.springframework.integration.monitor.IntegrationMBeanExporter;
|
||||
import org.springframework.integration.service.TwitterService;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
import org.springframework.jmx.export.annotation.ManagedMetric;
|
||||
import org.springframework.jmx.export.annotation.ManagedResource;
|
||||
import org.springframework.jmx.support.MetricType;
|
||||
import org.springframework.social.twitter.api.Tweet;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* Implementation of the TwitterService interface.
|
||||
* In the _org package because SI excludes all org.springframework.integration.*
|
||||
* In the org.springintegration package because SI excludes all org.springframework.integration.*
|
||||
* classes from MBean export.
|
||||
*/
|
||||
@Service
|
||||
|
||||
@ManagedResource
|
||||
public class DefaultTwitterService implements TwitterService {
|
||||
|
||||
/** Holds a collection of polled Twitter messages */
|
||||
@@ -12,22 +12,54 @@
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/integration/twitter http://www.springframework.org/schema/integration/twitter/spring-integration-twitter.xsd
|
||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
|
||||
|
||||
|
||||
<bean id="mbeanServer"
|
||||
class="org.springframework.jmx.support.MBeanServerFactoryBean"/>
|
||||
|
||||
<int-jmx:mbean-export id="integrationMBeanExporter" default-domain="spring.application"/>
|
||||
<context:mbean-export default-domain="spring.application"/>
|
||||
|
||||
<int:message-history/>
|
||||
|
||||
<context:component-scan base-package="org.springframework.integration.service" />
|
||||
|
||||
<int-twitter:search-inbound-channel-adapter id="twitter" query="#springintegration"
|
||||
channel="twitterChannel" auto-startup="true">
|
||||
<int:poller fixed-rate="30000" max-messages-per-poll="10" />
|
||||
</int-twitter:search-inbound-channel-adapter>
|
||||
|
||||
<int:service-activator id="twitterServiceActivator" input-channel="twitterChannel"
|
||||
|
||||
<int:inbound-channel-adapter id="dummyAdapter" channel="twitterChannel" method="getTweet">
|
||||
<bean class="org.springframework.integration.service.impl.DummyTwitter"/>
|
||||
<int:poller fixed-delay="5000"/>
|
||||
</int:inbound-channel-adapter>
|
||||
|
||||
<int:header-enricher id="addFooHeader" input-channel="twitterChannel" output-channel="twitterChannel2">
|
||||
<int:correlation-id value="foo"/>
|
||||
</int:header-enricher>
|
||||
|
||||
<int:transformer id="noopButSlowTransformer" input-channel="twitterChannel2" output-channel="twitterChannel3">
|
||||
<int-groovy:script>
|
||||
Thread.sleep(1000)
|
||||
payload
|
||||
</int-groovy:script>
|
||||
</int:transformer>
|
||||
|
||||
<int:service-activator id="twitterServiceActivator" input-channel="twitterChannel3"
|
||||
ref="twitterService" method="addTwitterMessages" />
|
||||
|
||||
<bean id="twitterService" class="_org.springframework.integration.service.impl.DefaultTwitterService"/>
|
||||
<bean id="twitterService" class="org.springintegration.service.impl.DefaultTwitterService"/>
|
||||
|
||||
<int:channel id="twitterChannel">
|
||||
<int:interceptors>
|
||||
<int:wire-tap channel="logger" />
|
||||
<bean class="org.springintegration.PayloadAwareTimingInterceptor">
|
||||
<constructor-arg>
|
||||
<array>
|
||||
<value>java.lang.String</value>
|
||||
<value>org.springframework.social.twitter.api.Tweet</value>
|
||||
</array>
|
||||
</constructor-arg>
|
||||
</bean>
|
||||
</int:interceptors>
|
||||
</int:channel>
|
||||
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
Manifest-Version: 1.0
|
||||
Class-Path:
|
||||
Class-Path:
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2010 the original author or authors.
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,20 +16,19 @@
|
||||
|
||||
package org.springframework.integration;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
|
||||
/**
|
||||
* Run this class to run the sample from the command line.
|
||||
* @author Gary Russell
|
||||
*/
|
||||
public class SpringIntegrationTest {
|
||||
|
||||
@Test
|
||||
public void testSpringIntegrationContextStartup() throws Exception{
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
final ApplicationContext context = new ClassPathXmlApplicationContext("/META-INF/spring/integration/spring-integration-context.xml", SpringIntegrationTest.class);
|
||||
new ClassPathXmlApplicationContext("/META-INF/spring/integration/spring-integration-context.xml", SpringIntegrationTest.class);
|
||||
System.out.println("Hit Enter to terminate");
|
||||
System.in.read();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user