1 Dynamic Proxies Explained Simply. 2 Dynamic Proxies License Copyright © 2008 Ciaran McHale. Permission is hereby granted, free of charge, to any person.

Slides:



Advertisements
Similar presentations
Chapter 6 Server-side Programming: Java Servlets
Advertisements

Introduction to Java Reflection
© 2006 Open Grid Forum OGF19 Federated Identity Rule-based data management Wed 11:00 AM Mountain Laurel Thurs 11:00 AM Bellflower.
Enabling Secure Internet Access with ISA Server
Win8 on Intel Programming Course Desktop : Sensors Cédric Andreolli Intel Software
© 2014 Microsoft Corporation. All rights reserved.
1 InTroToJCL Introduction to Java Class Loaders. 2 class loader l ia an object responsible for loading classes. The class ClassLoader is an abstract class.
Open Source Software – Lessons Learned
1 Configuring Internet- related services (April 22, 2015) © Abdou Illia, Spring 2015.
© 2006 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice Open Source Software A Commercial.
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.
Dynamic Proxies Amit Shabtay. March 3rd, 2004 Object Oriented Design Course 2 Dynamic Proxies Main idea: The proxy wraps objects and adds functionality.
EEC-681/781 Distributed Computing Systems Lecture 5 Wenbing Zhao Department of Electrical and Computer Engineering Cleveland State University
Dynamic Proxies David Rabinowitz. March 3rd, 2004 Object Oriented Design Course 2 Dynamic Proxies Support for creating classes at runtime Each such class.
Communication in Distributed Systems –Part 2
1/25/2000 Active Names: Flexible Location and Transport of Wide-Area Resources Luis Rivera.
 Proxy Servers are software that act as intermediaries between client and servers on the Internet.  They help users on private networks get information.
A Framework for Smart Proxies and Interceptors in RMI Nuno Santos P. Marques, L. Silva CISUC, University of Coimbra, Portugal
Content Management Systems …mostly Umbraco ALL ABOUT.
1 3. Implementing Web Services 1.Create SOAP proxy interfaces and WSDL based service descriptions 2.Register/publish services 3.Stores service descriptions.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 12 Communicating over.
Understanding the CORBA Model. What is CORBA?  The Common Object Request Broker Architecture (CORBA) allows distributed applications to interoperate.
1 Multi-threaded Performance Pitfalls Ciaran McHale.
Conditions and Terms of Use
© 2012 Microsoft Corporation. All rights reserved.
Energy Flow Through an Ecosystem
World Wide Web Hypertext model Use of hypertext in World Wide Web (WWW) WWW client-server model Use of TCP/IP protocols in WWW.
Blue Diamond Scott Auge Amduus Information Works, Inc.
Digital Intuition Cluster, Smart Geometry 2013, Stylianos Dritsas, Mirco Becker, David Kosdruy, Juan Subercaseaux Setup Instructions Overview 1. License.
Implementing Remote Procedure Calls Authored by Andrew D. Birrell and Bruce Jay Nelson Xerox Palo Alto Research Center Presented by Lars Larsson.
Overview of Microsoft ISA Server. Introducing ISA Server New Product—Proxy Server In 1996, Netscape had begun to sell a web proxy product, which optimized.
Client Call Back Client Call Back is useful for multiple clients to keep up to date about changes on the server Example: One auction server and several.
Designing the Architecture for Grid File System (GFS) Arun swaran Jagatheesan San Diego Supercomputer Center Global Grid Forum 12 Brussels, Belgium.
Resource Management in OGSA Authored by the CMM-WG.
International Telecommunication Union New Delhi, India, December 2011 ITU Workshop on Standards and Intellectual Property Rights (IPR) Issues Philip.
Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. Introduction to Spring Remoting Simplifying.
Unix Shell Basics Edited from Greg Wilson's "Software Carpentry"
Changing Databases This presentation gives a quick overview on how to change databases in Osprey.
1 Network Firewalls CSCI Web Security Spring 2003 Presented By Yasir Zahur.
National Alliance for Medical Image Computing Licensing in NAMIC 3 requirements from NCBC RFA (paraphrased)
Lecture 4 Mechanisms & Kernel for NOSs. Mechanisms for Network Operating Systems  Network operating systems provide three basic mechanisms that support.
Web Services An Introduction Copyright © Curt Hill.
Digital Intuition Cluster, Smart Geometry 2013, Stylianos Dritsas, Mirco Becker, David Kosdruy, Juan Subercaseaux Search Basics – Templates Tutorial Overview.
(1) Dynamic Proxies in Java And so on into winter Till even I have ceased To come as a foot printer, And only some slight beast So mousy or foxy Shall.
Nomenclature for the OGSA Platform document Fred Maciel.
UMBC Distributed Computing with Objects RMI/Corba CMSC 432 Shon Vick.
INTEL CONFIDENTIAL Intel® Smart Connect Technology Remote Wake with WakeMyPC November 2013 – Revision 1.2 CDI/IBP #:
1 of 26 For Oracle employees and authorized partners only. Do not distribute to third parties. © 2009 Oracle Corporation – Proprietary and Confidential.
CSC 480 Software Engineering Lab 6 – RMI Nov 8, 2002.
27.1 Chapter 27 WWW and HTTP Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
DEVELOPING WEB SERVICES WITH JAVA DESIGN WEB SERVICE ENDPOINT.
1 Example Uses of Java Reflection Explained Simply.
Spell Checker web service (you build a web client that interacts with the service) The client uses a servlet class and a JSP page. The user passes information.
The Java API for XML-Based Web Services. A Web Service example in Java SOAP-awareServlet (e.g. Apache Axis2) SOAP-awareServlet Any class processing the.
RMI1 Remote Method Invocation Adapted from “Core Java 2” by Cay Horstmann.
Models for Resources and Management
Resource Management in OGSA
WWW and HTTP King Fahd University of Petroleum & Minerals
Open Source Software: Top 10 Myths that Every In-House, Government, & Private Practice Lawyer Should Know 2017 NAPABA Convention Washington, D.C.
Mini Robot Chassis Top View
Chapter 5 Remote Procedure Call
Writing simple Java Web Services using Eclipse
Dynamic Proxy Proxy: Addition to the Java 1.3 reflection package:
Presentation on Object Oriented programming Topic
Designing the Architecture for Grid File System (GFS)
Knowledge Byte In this section, you will learn about:
Sampath Kumar S Assistant Professor, SECE/IT
WS/XML Service Utility Library (WS and LEGO?)
Distribution Infrastructures
© Healthcare Inspirations. All rights reserved
Presentation transcript:

1 Dynamic Proxies Explained Simply

2 Dynamic Proxies License Copyright © 2008 Ciaran McHale. Permission is hereby granted, free of charge, to any person obtaining a copy of this training course and associated documentation files (the Training Course"), to deal in the Training Course without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Training Course, and to permit persons to whom the Training Course is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Training Course. THE TRAINING COURSE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE TRAINING COURSE OR THE USE OR OTHER DEALINGS IN THE TRAINING COURSE.

3 Dynamic Proxies What is a proxy? Dictionary definition: a person authorized to act for another - Example: if you ask a friend to vote on your behalf then you are voting by proxy In computer terms, a proxy is a delegation object (or process) Used in remote procedure call (RPC) mechanisms: - Client invokes on a (local) proxy object - Proxy object sends request across the network to a server and waits for a reply Some companies set up a HTTP proxy server: - Firewall prevents outgoing connections to port 80 - So web browsers cannot connect to remote web sites directly - Web browsers are configured to connect via the companys proxy server - Proxy server can be configured to disallow access to eBay, Amazon, …

4 Dynamic Proxies Dynamic proxies in Java Java 1.3 introduced dynamic proxies - The API is defined in the java.lang.reflect package class Proxy { public static Object newProxyInstance( ClassLoader loader, Class[] interfaces, InvocationHandler h) throws } interface InvocationHandler { Object invoke(Object proxy, Method m, Object[] args) throws Throwable; }

5 Dynamic Proxies Steps required to create a dynamic proxy Step 1: - Write a class that implements InvocationHandler - Your implementation of invoke() should: -Use Method.invoke() to delegate to the target object -Provide some added value logic Step 2: - Call Proxy.newInstance(), with the following parameters: -targetObj.getClass().getClassLoader() -targetObj.getClass.getInterfaces() -InvocationHandler object wrapper around the target object Step 3: - Typecast the result of Proxy.newInstance() to an interface implemented by the target object

6 Dynamic Proxies How does this work? The Proxy.newProxyInstance() method: - Uses runtime code generation techniques - Generates a hidden class with a name of the form $Proxy (Use of $ prevents namespace pollution) - Generated class: -Implements the specified interfaces -Each method puts parameters into Object[] and calls InvocationHandler.invoke() Can use a dynamic proxy only if a class implements 1+ interfaces - Use of interfaces is a good programming practice - So this requirement is not a problem in practice

7 Dynamic Proxies Sample code public class Handler implements InvocationHandler { private Object target; private Handler(Object target) { this.target = target; } public Object invoke(Object proxy, Method m, Object[] args) throws Throwable { Object result = null; try {... // added-value code result = m.invoke(target, args); } catch(InvocationTargetException ex) {... // added-value code throw ex.getCause(); } return result; }... // continued on the next slide The proxy parameter is usually ignored

8 Dynamic Proxies Sample code (cont)... // continued from the previous slide public static Object createProxy(Object target) { return Proxy.newProxyInstance( target.getClass().getClassLoader(), target.getClass().getInterfaces(), new Handler(target)); } }

9 Dynamic Proxies Example uses for dynamic proxies Added-value code might: - Enforce security checks - Begin and commit or rollback a transaction - Use reflection & recursion to print details of all parameters (for debugging) In a testing system, a proxy might pretend to be target object - Returns test values instead of delegating to a real object - EasyMock ( makes it easy to write tests in this way