Sampath Kumar S Assistant Professor, SECE/IT

Slides:



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

AspectWerkz 2 - and the road to AspectJ 5 Jonas Bonér Senior Software Engineer BEA Systems.
Exceptions CSE301 University of Sunderland Harry Erwin, PhD.
Lecture 23 Input and output with files –(Sections 2.13, 8.7, 8.8) Exceptions and exception handling –(Chapter 17)
1 Lecture 11 Interfaces and Exception Handling from Chapters 9 and 10.
Remote Method Invocation
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.
How Does Remote Method Invocation Work? –Systems that use RMI for communication typically are divided into two categories: clients and servers. A server.
Dynamic Proxies David Rabinowitz. March 3rd, 2004 Object Oriented Design Course 2 Dynamic Proxies Support for creating classes at runtime Each such class.
1 Memory Model of A Program, Methods Overview l Memory storage areas for an executing program l Introduction to methods and methods definitions l General.
Chapter 11: Handling Exceptions and Events J ava P rogramming: From Problem Analysis to Program Design, From Problem Analysis to Program Design, Fourth.
Protection of Agent Teamwork By Jeremy Hall. Agent Teamwork Overview ● Mobile agent framework  AgentTeamwork 2 is a mobile-agent based middleware system.
A Framework for Smart Proxies and Interceptors in RMI Nuno Santos P. Marques, L. Silva CISUC, University of Coimbra, Portugal
And other languages…. must remember to check return value OR, must pass label/exception handler to every function Caller Function return status Caller.
CIS 3301 C# Lesson 13 Interfaces. CIS 3302 Objectives Understand the Purpose of Interfaces. Define an Interface. Use an Interface. Implement Interface.
Java Dynamic Proxy Bibliography: reflection/proxy.html
Java Programming: From Problem Analysis to Program Design, 4e Chapter 11 Handling Exceptions and Events.
1 Chapter 6 Methods. 2 Motivation Find the sum of integers from 1 to 10, from 20 to 30, and from 35 to 45, respectively.
Exceptions and Assertions Chapter 15 – CSCI 1302.
Exceptions in Java. What is an exception? An exception is an error condition that changes the normal flow of control in a program Exceptions in Java separates.
Methods.
UMBC Distributed Computing with Objects RMI/Corba CMSC 432 Shon Vick.
Polymorphism and Virtual Functions One name many shapes behaviour Unit - 07.
1 Lecture 15 Remote Method Invocation Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung Institute of Technology.
COP 3330 Notes 3/7. Today’s Topics Exceptions Abstract Classes.
Reflections CSC207 – Software Design. Background Turing's great insight: programs are just another kind of data. Source code is text that is interpreted.
CSE 1020: Exceptions and A multiclass application Mark Shtern 1-1.
CSC 480 Software Engineering Lab 6 – RMI Nov 8, 2002.
And other languages…. must remember to check return value OR, must pass label/exception handler to every function Caller Function return status Caller.
Exception. Agenda Exception. Handling Exceptions. The finally Clause.
Exception and Exception Handling. Exception An abnormal event that is likely to happen during program is execution Computer could run out of memory Calling.
Throw, Throws & Try-Catch Statements Explanations and Pictures from: Reference:
Java Exceptions a quick review….
NESTED CLASSES REFLECTION PROXIES.
Principles of Software Development
The Java Dynamic Proxy.
Java Programming Language
Dynamic Proxy Proxy: Addition to the Java 1.3 reflection package:
Remote Method Invocation
Presentation on Object Oriented programming Topic
Testing and Exceptions
עקרונות תכנות מונחה עצמים תרגול 21: Generics
Advanced Programming in Java
Java Programming Language
Sampath Kumar S Assistant Professor, SECE
Lecture 16 - Interfaces Professor Adams.
Sampath Kumar S Assistant Professor, SECE
CMSC 202 Exceptions 2nd Lecture.
CMSC 202 Exceptions 2nd Lecture.
Sampath Kumar S Assistant Professor, SECE
Sampath Kumar.S Assistant Professor/IT, SECE
Method Overloading in JAVA
Sampath Kumar S Assistant Professor, SECE
Method Overriding in Java
Sampath Kumar S Assistant Professor, SECE
Input and Output Stream
Chapter 6 Methods.
Sampath Kumar S Assistant Professor, SECE
Lecture 11 Objectives Learn what an exception is.
Constructors, GUI’s(Using Swing) and ActionListner
CMSC 202 Exceptions 2nd Lecture.
Sampath Kumar S Assistant Professor, SECE
Tutorial Exceptions Handling.
Tutorial MutliThreading.
Java Remote Method Invocation
Sampath Kumar S Assistant Professor, SECE
Java Basics Exception Handling.
CMSC 202 Exceptions 2nd Lecture.
Java Programming: From Problem Analysis to Program Design, 4e
Presentation transcript:

Sampath Kumar S Assistant Professor, SECE/IT Proxies Sampath Kumar S Assistant Professor, SECE/IT

Proxies Sometime the interfaces need to be implemented during runtime. 1/3/2019 Proxies Sometime the interfaces need to be implemented during runtime. Some programmer place the required code in file and invoke the compiler when necessary and load the resulting class file. But this process is slow. Proxy technique is used as alternative for this, it create a new class at run-time that implements the desired interfaces. Sampath Kumar S, AP/IT

Methods in proxy class: 1/3/2019 Methods in proxy class: There are 2 methods present in the proxy class: The method specified by the interface. Methods defined in the object class. Sampath Kumar S, AP

newProxyInstance: The methods is called on the proxy object. 1/3/2019 newProxyInstance: The methods is called on the proxy object. For creating the proxy object newProxyInstance() method of Proxy class is used. newProxyInstance() has 3 parameters: Class loader. Array of class objects. Invocation handler. whenever particular method is called on proxy object, the invocation handler invokes the invoke() method with the object of the method being invoked. It is the invocation handler who directs how to handle the call for a method a run time. Proxy class are always public and final Sampath Kumar S, AP

1/3/2019 import java.lang.reflect.*; interface Gowtham { void MyFunction(); //Method is called at runtime } class InterfaceInstanse implements Gowtham public void MyFunction() //definition of the method Integer a = 10; Integer b = 20; Integer c = a + b; System.out.println("Sum of 2 nos is: "+c); Sampath Kumar S, AP/IT

1/3/2019 class MyProxy implements InvocationHandler { Object obj; public MyProxyClass(Object i) obj = i; } public Object invoke (Object proxy, Method m, Object[] args) throws Throwable Object result = null; System.out.println("Before invoking the Method"); result = m.invoke (obj, args); System.out.println("After invoking the method"); return result; Sampath Kumar S, AP

1/3/2019 Sampath Kumar S, AP

1/3/2019 Thank You  Sampath Kumar S, AP