Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. Introduction to Spring Remoting Simplifying.

Slides:



Advertisements
Similar presentations
Message Passing Vs Distributed Objects
Advertisements

What is RMI? Remote Method Invocation –A true distributed computing application interface for Java, written to provide easy access to objects existing.
Web Service Ahmed Gamal Ahmed Nile University Bioinformatics Group
RPC Robert Grimm New York University Remote Procedure Calls.
RMI Varun SainiYing Chen. What is RMI? RMI is the action of invoking a method of a remote interface on a remote object. It is used to develop applications.
U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science Emery Berger University of Massachusetts Amherst Operating Systems CMPSCI 377 Lecture.
Copyright © 2001 Qusay H. Mahmoud RMI – Remote Method Invocation Introduction What is RMI? RMI System Architecture How does RMI work? Distributed Garbage.
Java Remote Method Invocation (RMI) In Java we implement object systems: O1O2 O3 thread 1thread 2 execution scheme JVM 1JVM 2 distribution scheme.
Remote Method Invocation
FONG CHAN SING (143334) WONG YEW JOON (143388). JAVA RMI is a distributive system programming interface introduced in JDK 1.1. A library that allows an.
Remote Method Invocation Chin-Chih Chang. Java Remote Object Invocation In Java, the object is serialized before being passed as a parameter to an RMI.
DISTRIBUTED FILE SYSTEM USING RMI
Advanced Java Class Network Programming. Network Protocols Overview Levels of Abstraction –HTTP protocol: spoken by Web Servers and Web Clients –TCP/IP:
1 HANDOUT 14 Remote Method Invocation (RMI) BY GEORGE KOUTSOGIANNAKIS THIS DOCUMENT CAN NOT BE REPRODUCED OR DISTRIBUTED WITHOUT TH E WRITTEN PERMISSION.
CS490T Advanced Tablet Platform Applications Network Programming Evolution.
Sockets  Defined as an “endpoint for communication.”  Concatenation of IP address + port.  Used for server-client communication.  Server waits for.
Introduction to Remote Method Invocation (RMI)
How Does Remote Method Invocation Work? –Systems that use RMI for communication typically are divided into two categories: clients and servers. A server.
Communication in Distributed Systems –Part 2
1 Lecture 22 George Koutsogiannakis Summer 2011 CS441 CURRENT TOPICS IN PROGRAMMING LANGUAGES.
1 Java Programming II Java Network II (Distributed Objects in Java)
1 3. Implementing Web Services 1.Create SOAP proxy interfaces and WSDL based service descriptions 2.Register/publish services 3.Stores service descriptions.
Enterprise Java Beans Java for the Enterprise Server-based platform for Enterprise Applications Designed for “medium-to-large scale business, enterprise-wide.
+ A Short Java RMI Tutorial Usman Saleem
Cli/Serv.: rmiCORBA/131 Client/Server Distributed Systems v Objectives –introduce rmi and CORBA , Semester 1, RMI and CORBA.
Comparison of Web Services, RMI, CORBA, DCOM Usha, Lecturer MCA Department of Computer Science and Engineering.
11 September 2008CIS 340 # 1 Topics To examine the variety of approaches to handle the middle- interaction (continued) 1.RPC-based systems 2.TP monitors.
1 Java RMI G53ACC Chris Greenhalgh. 2 Contents l Java RMI overview l A Java RMI example –Overview –Walk-through l Implementation notes –Argument passing.
Spring/2002 Distributed Software Engineering C:\unocourses\4350\slides\DefiningThreads 1 RMI.
Silberschatz, Galvin, and Gagne  1999 Applied Operating System Concepts Chapter 15: Distributed Communication Sockets Remote Procedure Calls (RPCs) Remote.
Java Remote Method Invocation RMI. Idea If objects communicate with each other on one JVM why not do the same on several JVM’s? If objects communicate.
RMI remote method invocation. Traditional network programming The client program sends data to the server in some intermediary format and the server has.
RMI Remote Method Invocation Distributed Object-based System and RPC Together 2-Jun-16.
 Remote Method Invocation  A true distributed computing application interface for Java, written to provide easy access to objects existing on remote.
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved Chapter 43 Remote Method Invocation.
XML and Web Services (II/2546)
Java Programming: Advanced Topics 1 Networking Programming Chapter 11.
1 Engineering Web Based Legacy Systems By Kanchana Eramudugoda Distributed Computing – CS843.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 JSP Application Models.
 Java RMI Distributed Systems IT332. Outline  Introduction to RMI  RMI Architecture  RMI Programming and a Sample Example:  Server-Side RMI programming.
Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. Overview of the Spring Framework Introducing.
Remote Method Invocation A Client Server Approach.
(C) 2003 University of ManchesterCS31010 Lecture 14: CORBA.
UMBC Distributed Computing with Objects RMI/Corba CMSC 432 Shon Vick.
Java RMI. RMI Any object whose methods can be invoked from another Java VM is called a remote object.
1 RMI Russell Johnston Communications II. 2 What is RMI? Remote Method Invocation.
1 Lecture 15 Remote Method Invocation Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung Institute of Technology.
Distributed programming in Java Faculty:Nguyen Ngoc Tu Session 5 - RMI.
CSC 480 Software Engineering Lab 6 – RMI Nov 8, 2002.
Netprog Java RMI1 Remote Method Invocation.
Liang, Introduction to Java Programming, Fifth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 29 Remote Method.
Distributed Web Systems Distributed Objects and Remote Method Invocation Lecturer Department University.
Java Distributed Computing
Java Distributed Object System
Java Distributed Computing
Java Remote Method Invocation (RMI)
Broker in practice: Middleware
Remote Method Invocation
Java RMI CS-328 Internet Programming.
What is RMI? Remote Method Invocation
Knowledge Byte In this section, you will learn about:
Inventory of Distributed Computing Concepts and Web services
Inventory of Distributed Computing Concepts
Chapter 40 Remote Method Invocation
Chapter 46 Remote Method Invocation
WebServices Using JAX-RPC
Chapter 46 Remote Method Invocation
J2EE Lecture 13: JMS and WebSocket
Java Remote Method Invocation
Presentation transcript:

Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. Introduction to Spring Remoting Simplifying Distributed Applications

Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 2 Topics in this Session Goals of Spring Remoting Spring Remoting Overview Supported Protocols –RMI –EJB –HttpInvoker –Hessian/Burlap

Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 3 Topics in this Session Goals of Spring Remoting Spring Remoting Overview Supported Protocols –RMI –EJB –HttpInvoker –Hessian/Burlap

Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 4 Goals of Spring Remoting Hide “plumbing” code Configure and expose services declaratively Support multiple protocols in a consistent way

Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 5 The Problem with Plumbing Code Remoting mechanisms provide an abstraction over transport details These abstractions are often leaky –The code must conform to a particular model For example, with RMI: –Service interface extends Remote –Service class extends UnicastRemoteObject –Client must catch RemoteExceptions Violates separation of concerns Couples business logic to remoting

Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 6 Hiding the Plumbing with Spring Spring provides exporters to handle server- side requirements –Binding to registry or exposing an endpoint –Conforming to a programming model if necessary Spring provides FactoryBeans that generate proxies to handle client-side requirements –Communicate with the server-side endpoint –Convert remote exceptions to a runtime hierarchy

Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 7 The Declarative Approach Spring’s abstraction uses a configuration-based approach On the server side –Expose existing services with NO code changes On the client side –Invoke remote methods from existing code –Take advantage of polymorphism by using dependency injection

Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 8 Consistency across Protocols Spring’s exporters and proxy FactoryBeans bring the same approach to multiple protocols –Provides flexibility –Promotes ease of adoption On the server side –Expose a single service over multiple protocols On the client side –Switch easily between protocols –Migrate between remote vs. local deployments

Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 9 Topics in this Session Goals of Spring Remoting Spring Remoting Overview Supported Protocols –RMI –EJB –HttpInvoker –Hessian/Burlap

Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 10 Service Exporters Spring provides service exporters to enable declarative exposing of existing services transfer(..) Spring ServiceExporter > TransferService TransferServiceImpl Teller Controller Accessible from remote clients

Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 11 Client Proxies Dynamic proxies generated by Spring communicate with the service exporter Spring ServiceExporter Server Process TransferServiceImpl Generated by a Spring FactoryBean > TransferService transfer(..)Spring Proxy Client Process > TransferService Teller Desktop UI

Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 12 Topics in this Session Goals of Spring Remoting Spring Remoting Overview Supported Protocols –RMI –EJB –HttpInvoker –Hessian/Burlap

Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 13 The RMI Protocol Standard Java remoting protocol Server-side exposes a skeleton Client-side invokes methods on a stub (proxy) Java serialization is used for marshalling

Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 14 Traditional RMI The RMI model is invasive - server and client code is coupled to the framework transfer(..) Skeleton Server Process TransferServiceImpl Stub Client Process RemoteUnicastRemoteObject > TransferService Teller Desktop UI client must catch RemoteExceptions Required to extend RMI interface/class

Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 15 Spring’s RMI Service Exporter Transparently expose an existing POJO service to the RMI registry –No need to write the binding code Avoid traditional RMI requirements –Service interface does not extend Remote –Service class is a POJO

Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 16 Configuring the RMI Service Exporter Start with an existing POJO service Define a bean to export it Can also specify ‘registryPort’ (default is 1099) Binds to rmiRegistry as “transferService”

Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 17 Spring’s RMI Proxy Generator Spring provides a FactoryBean implementation that generates an RMI client-side proxy It is simpler to use than a traditional RMI stub –Converts checked RemoteExceptions into Spring’s runtime hierarchy of RemoteAccessExceptions –Dynamically implements the business interface Proxy is a drop-in replacement for a local implementation (especially convenient with dependency injection)

Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 18 Configuring the RMI Proxy Define a factory bean to generate the proxy Inject it into the client <bean id=“transferService” class=“org.springframework.remoting.rmi.RmiProxyFactoryBean”> <bean id=“transferService” class=“org.springframework.remoting.rmi.RmiProxyFactoryBean”> TellerDesktopUI only depends on the TransferService interface

Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 19 RMI-IIOP for Interoperability: Service Generate IIOP stubs and ties –Use RMI compiler with IIOP flag: rmic –iiop Define the service interface –Must extend the RMI Remote interface –All methods must throw RemoteException Implement the service class –All methods must throw RemoteException Leverage Spring to expose the service to a CORBA Object Request Broker via JNDI –Use Spring’s JndiRmiServiceExporter –Provide jndiName and jndiEnvironment properties

Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 20 RMI-IIOP for Interoperability: Client Spring also provides a JndiRmiProxyFactoryBean The generated proxy can implement any interface –No need to throw RemoteExceptions –The proxy will convert to the runtime hierarchy Client-side code is decoupled from RMI even when accessing an IIOP-based CORBA service

Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 21 Accessing EJBs Spring generates p roxies to access Stateless Session Beans –Conceals JNDI lookup (and retry logic) –Caches the EJB home –Converts RemoteExceptions to runtime hierarchy Bean definitions can use the jee namespace –

Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 22 Accessing an EJB with a Spring Proxy Server Process TransferService Bean TransferService Remote > TransferService extends implements TransferService Home creates SLSB Proxy Client Process Teller Desktop UI implements > TransferService

Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 23 Configuring the EJB Proxy Use the jee namespace to generate the proxy Inject it into the client <jee:remote-slsb id=“transferService” jndi-name=“java:comp/env/ejb/transferService” business-interface=“foo.TradeService”> java.naming.provider.url=t3://remoteserver:7001 java.naming.factory.initial=weblogic.jndi.WLInitialContextFactory <jee:remote-slsb id=“transferService” jndi-name=“java:comp/env/ejb/transferService” business-interface=“foo.TradeService”> java.naming.provider.url=t3://remoteserver:7001 java.naming.factory.initial=weblogic.jndi.WLInitialContextFactory InitialContext settings are not necessary if co-located

Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 24 Spring’s HttpInvoker A lightweight HTTP-based remoting protocol –Method invocation is converted to an HTTP POST –Method result is returned as an HTTP response –Method parameters and return values are marshalled with standard Java serialization HTTP POST request HttpInvoker ServiceExporter Server Process HttpInvoker Proxy Client Process HTTP response Java serialization

Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 25 Configuring the HttpInvoker Service Exporter Start with an existing POJO service Define a bean to export it <bean name =“/transfer” class=“org.springframework.remoting.httpinvoker. HttpInvokerServiceExporter”> <bean name =“/transfer” class=“org.springframework.remoting.httpinvoker. HttpInvokerServiceExporter”> endpoint for HTTP request handling

Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 26 Configuring the HttpInvoker Proxy Define a factory bean to generate the proxy Inject it into the client <bean id=“transferService” class=“org.springframework.remoting.httpinvoker. HttpInvokerProxyFactoryBean”> <bean id=“transferService” class=“org.springframework.remoting.httpinvoker. HttpInvokerProxyFactoryBean”> HTTP POST requests will be sent to this URL

Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 27 Hessian and Burlap Caucho created these two lightweight protocols for sending XML over HTTP –Hessian uses binary XML (more efficient) Implementations for many languages –Burlap uses textual XML (human readable) The Object/XML serialization/deserialization relies on a proprietary mechanism –Better performance than Java serialization –Less predictable when working with complex types

Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 28 Hessian and Burlap Configuration Service exporter configuration is identical to HttpInvokerServiceExporter except class names –org.springframework.remoting.caucho.HessianServiceExporter –org.springframework.remoting.caucho.BurlapServiceExporter Proxy configuration is identical to HttpInvokerProxyFactoryBean except class names –org.springframework.remoting.caucho.HessianProxyFactoryBean –org.springframework.remoting.caucho.BurlapProxyFactoryBean

Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 29 Choosing a Remoting Protocol (1) Spring on server and client? –HttpInvoker Java environment but no web server? –RMI Interop with other languages using HTTP? –Hessian Interop with other languages without HTTP? –RMI-IIOP (CORBA)

Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 30 Choosing a Remoting Protocol (2) Also consider the relationship between server and client All of the protocols discussed here are based upon Remote Procedure Calls (RPC) –Clients need to know details of method invocation Name, parameters, and return value –When using Java serialization Classes/interfaces must be available on client Versions must match If serving public clients beyond your control, Web Services are usually a better option –Document-based messaging promotes loose coupling

Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. LAB Simplifying Distributed Applications with Spring Remoting