spring portfolio: some highlights · –spring portfolio. title: springportfolio.ppt author:...
TRANSCRIPT
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited.
Spring Portfolio:Some Highlights
Eberhard Wolff
Regional Director
SpringSource
http://www.springsource.com
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 2
SpringSource: Our vision
• To deliver the clearly superior platform fordeveloping, testing and running enterprise Javaapplications
• Recognition that there is no one size fits allsolution
• Address critical unmet needs
• Power through simplicity
• Highly modular – not monolithic
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 3
The Spring Portfolio
• The Spring Framework as (just) thestart!
• Towards a complete Enterprise JavaInfrastructure.
• Enter the Spring Portfolio!
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 4
Topics: Some Highlights
• Spring Dynamic Modules for the OSGiService Platform
• Spring Integration
• Spring Subscriptions
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited.
Spring Dynamic Modules for theOSGi Platform
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 6
OSGi - The Dynamic ModuleSystem for Java
• Backed by the OSGi Alliancehttp://www.osgi.org
• Needed to be lightweight and dynamic fromday one– 1999 embedded Java and networked devices
– 2003 extended support to mobile devices
– 2004 significant open source community adoption
– 2006 server-side Java applications
• Implementations– Eclipse Equinox (foundation for Eclipse)
– Apache Felix
– Makewave Knopflerfish
– Prosyst mBedded Server Professional Edition
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 7
• Partition a system into a number ofmodules - "bundles"
• Strict visibility rules
• Resolution process
– satisfies dependencies of a module
• Understands versioning
OSGi: It’s a module system
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 8
• modules can be
– installed
– started
– stopped
– uninstalled
– updated
• ...all at runtime
It’s dynamic
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 9
• Bundles can publish services
– dynamically
• Service Registry allows other bundles tofind services
– and to bind to them
• Services come and go at runtime, alltaken care of for you
It’s even service-oriented
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 10
What makes OSGi special?
• Strong modularity (bundles export specificpackages and services)
• Version management
• Operational control
• Dynamic stop / start / update
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 11
Export-Package: a.b.c
private implementation
packages
Service interface typesexported [with versioninformation]
Service implementationlocked away
"Passive" contribution• types added to type space• bundles see new version on resolution after install/refresh
A service bundle…
Dealing with dynamics
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 12
"Active" contribution• services published in registry• bundles see service changes immediately
A service bundle…
Published services
Private implementationobjects
Dealing with dynamics
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 13
Versioning
• Packages areimported
–optionally withversioninformation
• Can have multipleversions of samepackageconcurrently
YourApplication
Lib A Lib B
Lib C v1 Lib C v2
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 14
Example: versioning
VersioningDemo
Import-Package: org.osgi.framework;version="1.3.0", com.springsource.printing.lib;version="2.0", com.springsource.datetime
PrintingLib v2
PrintingLib v1
Date/Time
Export-Package:com.springsource.printing.lib;version="2.0"
Export-Package:com.springsource.printing.lib;version="1.0"
Export-Package:com.springsource.datetimeImport-Package:com.springsource.printing.lib;version="[1.0.0,2.0.0)"
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 15
Vision: OSGi as a serverplatform
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 16
Application Design
• Application becomes a set of co-operatingbundles
– vertical decomposition first
– then horizontal
• Communication via service registry
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 17
Application wiring
Presentation PresentationPresentation
Service Service
Repository Repository Domain
Lib
Lib
Lib
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 18
Design considerations (rawOSGi) !
• Platform dynamics– Services may come and go at any time
• Asynchronous activation– Service dependency management
• Testing
• Concurrency and thread management
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 19
Enterprise Libraries underOSGi
• Class and resource-loading problems
– Class visibility
– Class.forName
– Context class loader
• Good news: Spring 2.5 is OSGi-ready
– Modules shipped as bundles
– All class loading behaves correctly under OSGi
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 20
Example: Class visibility
Data LayerBundle
Domain ModelBundle
<Export-Pkg>
HibernateBundle
<Export Pkg>
Import-Package Import-Package
domaintypes,mappingfiles
SessionFactory
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 21
Spring Dynamic Modules
• Objectives
• Bundles and application contexts
• Working with services
• Configuration administration
• Integration Testing
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 22
Objectives
• The simplicity and power of Spring...
• ...with the dynamic module system ofOSGi
• Modules need instantiating, configuring,decorating, assembling, ...
• Need an easy way to manage servicereferences between modules
• Easy unit and integration testing
Bring the benefits of OSGi to enterprise applications
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 23
Spring Dynamic Modules is...
• A open source project in the Springportfolio
• led by SpringSource
– committers from BEA and Oracle
– many non-code contributions from thecommunity and from the OSGi EEG and CPEG
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 24
Bundles and contexts
• Spring application context (modulecontext) per bundle (module)!
– created automatically for you by Springextender bundle
– no need to depend on any OSGi APIs
• META-INF/spring/*.xml
• or Spring-Context header in MANIFEST.MF
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 25
Spring Dynamic Modules
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 26
Spring-powered bundle
Spring configurationfiles
Published interfaces
Protected implementations
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 27
Services
• Your application is constructed as a set ofbundles, each with its ownApplicationContext
• How to reference beans across modules?
– use the OSGi Service Registry
– advertise public services
– import references to external services
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 28
Demo: service import/export
<bean id="printService" class="com.springsource.osgi.print.internal.PrintServiceImpl" init-method="init" destroy-method="destroy"/>
<osgi:service ref="printService" interface="com.springsource.osgi.print.PrintService"/>
<bean id="printClient" class="com.springsource.osgi.print.client.Client" init-method="init"> <property name="printService" ref="printService"/></bean>
<osgi:reference id="printService" interface="com.springsource.osgi.print.PrintService"/>
Exporting context:
Importing context:
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 29
Exporting a service
• any Spring bean can be exported as OSGi service
• offers access to the service registration
<bean id="printService"
class="com.springsource.osgi.print.internal.PrintServiceImpl" init-method="init" destroy-method="destroy"/>
<osgi:service ref="printService" interface="com.springsource.osgi.print.PrintService"/>
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 30
Importing a service
• locates the OSGi service that matches thedescription best
• handles the service dynamics internally
<bean id="printClient" class="com.springsource.osgi.print.client.Client" init-method="init"> <property name="printService" ref="printService"/></bean>
<osgi:reference id="printService" interface="com.springsource.osgi.print.PrintService"/>
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 31
<bean id="printClient" class="com.springsource.osgi.print.client.Client" init-method="init"> <property name="printService" ref="printService"/></bean>
<osgi:set id="printServices" interface="com.springsource.osgi.print.PrintService"/>
Importing a set of services
• locates all OSGi service that match thedescription
• handles the service dynamics internally
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 32
Service Dynamics
• Context creation
– blocks until all mandatory service referencesare satisfied
– no threads are placed on hold
• Simply start your bundles and let SpringDynamic Modules figure it out
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 33
Service Dynamics
• What happens when a service goes away?
– osgi:reference cardinality=”0..1”
• track replacement and retarget proxy when suitabletarget found
• Buffer method calls (!)
• ServiceUnavailableException after timeout if invoked
– osgi:reference cardinality=”1..1” (default)
• as above, plus
• Block creation of ApplicationContext until Servicebecomes available
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 34
Listening
• You work with a constant reference
– Proxy / Set / List
• Spring Dynamic Modules manages the targetbacking service(s) for you
• I.e. buffer calls until service is available again
• You can optionally listen to bind / unbind events
• You can optionally listen to register / unregisterevents
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 35
Spring OSGi Summary
• OSGi: the dynamic module system for Java
• Benefits: modularity, versioning, operationalcontrol
• The server-side is coming to OSGi
• Spring Dynamic Modules brings the familiarSpring model to the OSGi platform
• Enterprise application development path to besmoothed during 2008
• Current version: 1.0.1
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited.
Spring Integration
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 37
Spring Integration
• Solves EAI-problems
• EAI: Messaging, Routing, Splitting,Transformation etc.
• Message Passing Concept (Pipes & Filters)
• Event-driven = runtime Inversion of Control– Framework handles message-listening
– Framework handles service-invoking
• Another Spring Technology:Simple, yet powerful
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 38
Philosophical Consistency
• Core API design based on interfaces
• Highly customizable via strategies
• Provide a framework for testing
• Support multiple metadata formats
– XML with ‘beans’
– XML with namespace-support
– Annotations
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 39
Seamless Integration
• Maximize leverage from the Spring foundation
– Lifecycle management
– Task execution abstraction
– Aspect-Oriented Programming
– Declarative transaction management
– Dynamic language support
– Spring remoting
– JMS support
– Scheduling
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 40
The Result
• Simplifies development of integration solutions byrelying on proven Spring best practices and well-known Enterprise Integration Patterns
• Facilitates incremental adoption for existing Springusers who are beginning to explore SOA and EDA
• Provides thoughtful compatibility and timelyco-evolution with the Spring portfolio
• Let’s look at the API
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 41
Message Channel: The Pipes
public interface MessageChannel {
String getName(); void setName(String name); boolean send(Message message);
boolean send(Message message, long timeout);
Message receive();
Message receive(long timeout); DispatcherPolicy getDispatcherPolicy(); List<Message<?>> clear(); List<Message<?>> purge(MessageSelector selector);
}
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 42
SimpleChannel Example
• Allows any number of consumers
• Publish/subscribe is configured using theDispatcherPolicy
• If capacity is reached, send method will block until aMessage is removed or the timeout elapses
• If empty, the receive method will block until aMessage is available or the timeout elapses
MessageChannel channel = new SimpleChannel(50,dispatcherPolicy);
channel.send(new TestMessage(“testing”), 100);
Message message = channel.receive(300);
timeout in milliseconds
capacity
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 43
Channel Adapters
• SourceAdapters can be used to send messagesfrom a source to a Channel
– E.g. JMS, Files (Polling), ApplicationEvents,Character/ByteStreams
• TargetAdapters can be used to forwardmessages from a Channel to a target
– e.g. to JMS, Files, ApplicationEvents,Character/ByteStreams
• Channel can be extended to outside the JVM
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 44
MessageHandler
• A generic interface defines the simple but commonbehavior of processing a received Message
• Many of the internal base messaging componentsimplement this top-level interface
– Routers, Transformers, Service Invokers
• Implementations do not necessarily return a replyMessage (routers, void-returning service invokers)!
public interface MessageHandler {
Message<?> handle(Message<?> message);
}
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 45
InterceptingMessageHandler
• An InterceptingMessageHandler can add behaviorbefore and/or after another handler
– The intercepting handler is responsible for calling handleon the next handler (or intentionally not proceeding) !
Handler2 Handler4Handler1
public Message handle(Message message, MessageHandler target) {
// do something before
message = target.handle(message);
// do something after
return message;
} Similar to AOP around advice
Handler3
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 46
MessageEndpoint: The Filter
• The MessageEndpoint connects aMessageHandler to a input channel and/or atarget channel
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 47
MessageEndpoint Example
...DefaultMessageEndpoint endpoint = new DefaultMessageEndpoint();endpoint.setDefaultOutputChannelName("outputChannel");endpoint.setSubscription(new Subscription("inputChannel"));endpoint.setHandler(new ReversingHandler());...inputChannel.send(new StringMessage("POJO"));Message result = outputChannel.receive();Assert.isTrue("OJOP".equals(result.getPayload()));
public class ReversingHandler implements MessageHandler {
public Message handle(Message message) {
return reverse(message.getPayload());
}
}
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 48
Configuration Options
• Integration components may be
configured in a number of ways
– Java with direct usage of the API
– XML with generic 'beans' elements
– XML with XSD namespace support
– Annotations
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 49
Java Configuration
MessageHandler handler = new ExampleHandler();
GenericMessageEndpoint endpoint = new GenericMessageEndpoint();endpoint.setInputChannelName("inputChannel");endpoint.setDefaultOutputChannelName("outputChannel");endpoint.setHandler(handler);
MessageBus bus = new MessageBus();bus.registerChannel("inputChannel", new PointToPointChannel());bus.registerEndpoint("testEndpoint", endpoint);bus.registerChannel("replyChannel", new PointToPointChannel());bus.start();
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 50
XML Configuration
<bean id="inputChannel" class="org.springframework.integration.channel. PointToPointChannel"/>
<bean id="endpoint" class="org.springframework.integration.endpoint. GenericMessageEndpoint"> <property name="inputChannelName" value="inputChannel"/> <property name="defaultOutputChannelName" value="outputChannel"/> <property name="handler" name="exampleHandler"/></bean>
<bean id="bus" class="org.springframework.integration.bus.MessageBus"/>
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 51
XML Schema-Based
Configuration
<integration:message-bus/>
<integration:channel id="quotes"/>
<integration:endpoint input-channel="quotes" handler-ref="logger" handler-method="log"> <integration:schedule period="1000"/></integration:endpoint>
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 52
Annotation Configuration
@MessageEndpoint(input="inputChannel", defaultOutput="outputChannel")!public class SimpleAnnotatedEndpoint {
@Handler public String sayHello(String name) { return "hello " + name; }
}
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 53
MessagePublishingInterceptor
• The interceptor can be customized or extended– Provide a MessageMapper strategy
– Subclass and implement
MessagePublishingInterceptor interceptor =
new MessagePublishingInterceptor();
interceptor.setDefaultChannel(testChannel);
ProxyFactory pf = new ProxyFactory(testService);
pf.addAdvice(interceptor);
TestService proxiedService = (TestService) pf.getProxy();
String result = proxiedService.test();
The return value is also sent to the channel
resolveChannel(MethodInvocation mi) !
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 54
Annotation-Driven Publisher
• Add the @Publisher annotation to anymethod of a Spring-managed object
• Register a bean post-processor
@Publisher(channel=“testChannel”) !
public String test() {
return “testing…”;
}
<bean class=“org.springframework.integration.config.
PublisherAnnotationPostProcessor”/>
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 55
Annotation-Driven Subscriber
• Add the @Subscriber annotation to anymethod of a Spring-managed object
• Register a bean post-processor
@Subscriber(channel=“testChannel”) !
public String test() {
return “testing…”;
}
<bean class=“org.springframework.integration.config.
SubscriberAnnotationPostProcessor”/>
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 56
Message Routing
• Routing can be simple
– Resolve and send to a single channel basedon the Message’s payload type
– Resolve and send to multiple channels basedon a property value in the MessageHeader
• Or complex
– Split a composite Message into itsconstituent parts and then send each as anew Message to a dedicated handler
– In a downstream endpoint, aggregate theresults into a single composite Message
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 57
Message Routing Strategies
• Routing logic can be implemented with thegeneric MessageHandler (forward & returnnull)!
• However, fine-grained strategy interfacesare more cohesive and reusable– PayloadTypeRouter
– Splitter
– Aggregator
public interface MessageHandler {
Message<?> handle(Message<?> message);
}
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 58
Message Routing Interfaces
• The base router implements MessageHandlerand delegates to these fine-grained strategies
public interface ChannelResolver {
MessageChannel resolve(Message message);
}
public interface MultiChannelResolver {
List<MessageChannel> resolve(Message message);
}
public interface ChannelNameResolver {
String resolve(Message message);
}
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 59
Routing Examples
• Routers can also be defined with annotations
– Low-level (working with message and channel)!
– High-level (working with domain objects)!
@Router
public MessageChannel[] (Message message) {
// resolve the channel or channels…
}
@Splitter
public OrderItem[] splitOrders(PurchaseOrder purchaseOrder) {
// split the purchase order into order items…
}
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 60
Sprint Integration: Summary
• Offers EAI infrastructure
• Based on messages, channels andthread pools - Pipes & Filters
• Can make integration as easy as justadding some Annotations
• Still full power of a Java API
• Integration of other systems throughJMS, Files etc.
• Current version: 1.0M2
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited.
Spring Subscriptions
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 62
Development Production
Subscription components
SpringSource Tool Suite
Developer support
SpringSource Application Management Suite
Production support
SpringSource Advanced Pack for Oracle
Certified and indemnified software
Knowledgebase
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 63
Developer and ProductionSupport
• Support from the source - the developers thatwrite the code– Virtually 100% of Spring committers and leading
Apache committers
• Support and subscriptions for Spring andApache technologies– Spring Portfolio
– Apache HTTP, Tomcat, Axis and ActiveMQ
– Enterprise Ready Server
• Tomcat, Apache HTTP, Modules, Perl/PHP, and more
• Add-on Hyperic HQ Subscriptions
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 64
Developer and ProductionSupport
• Highly responsive service capabilities– Development support
• Access to subject matter experts who can increasedeveloper productivity and effectiveness
– Production support• directly from the key committers when required
• fast turnaround bug-fixes and patches
– Patches and product enhancements• we can commit bug fixes and enhancements into
future product releases
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 65
Support Service Levels
1 hour4 hours2 businessdays
Responsetimes (basedon severity 1)
24 x 7 x 36524 x 7 x 3659am-5pm
Mon-Fri
Support times(customer timezone)
PlatinumGoldSilver
• Customer Support Portal and Knowledge Networks
• Unlimited incidents
• Optional: Technical Support Account Managers (SAMs)available
• Read now!
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 66
SpringSource ApplicationManagement Suite
• Monitor production deployments of Spring applications• Supports Tomcat, WebLogic, WebSphere & JBoss runtimes• Track application performance, utilization and resource
control• Define critical application alerts with automated corrective
controls• Control and record configuration changes• Compatible with enterprise wide management tools like
Hyperic, HP OpenView & IBM Tivoli• Current version: Internal beta
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 67
SpringSource Tool Suite
• Eclipse distribution for complete Spring application development– Includes Spring IDE, AJDT, WTP etc.– Integrated samples, cheat sheets, code guides
• Task based enterprise development based on Eclipse Mylyn– Easier to work on projects with multiple inter-related files
• Integrated access to SpringSource Knowledge Base– Collective community wisdom accessible in the tool– Suggest error fixes, test unit tracing, best practice
recommendations• Current version: Internal beta
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 68
SpringSource Advanced Packfor Oracle Database
• Oracle RAC Fast Connection Failover– Failover retry operations when RAC nodes fail
– Transaction integrity preserved during failover
• Oracle Streams Advanced Queuing– Single local transaction for messaging and database access
• XML and other Advanced Data Types– Access to Oracle native XML data type and transformers
– Access to Oracle native STRUCT & ARRAY for advanceddata types
• Oracle DataSource wrappers and pooling– Wrapper classes insulate code from database specific
features and setting.
• Current version: Beta
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 69
Certified and IndemnifiedSoftware
• Certified releases! Secure download from SpringSource.com
! Production ready versions only
! Certified to be virus-free, worm-free
! Legal indemnification at Gold and Platinum supportlevels
• Certified patches and upgrades! binary upgrades immediately available to all
subscribers
• Indemnification at Gold and Platinum supportlevels
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 70
Conclusion
• Spring DM for OSGi makes the platformof the future much easier to use
• Spring Integration simplifies EAIdevelopment
• Spring Subscriptions offer support andshared source components