Lecture 20 – April 2, 2002 Bond Objects.

Slides:



Advertisements
Similar presentations
 Specifies a set of methods (i.e., method headings) that any class that implements that interface must have.  An interface is a type (but is not a class).
Advertisements

METHOD OVERRIDING Sub class can override the methods defined by the super class. Overridden Methods in the sub classes should have same name, same signature.
15-May-15 RMI Remote Method Invocation. 2 “The network is the computer” Consider the following program organization: If the network is the computer, we.
6/10/2015C++ for Java Programmers1 Pointers and References Timothy Budd.
George Blank University Lecturer. CS 602 Java and the Web Object Oriented Software Development Using Java Chapter 4.
Road Map Introduction to object oriented programming. Classes
Lecture 27 Exam outline Boxing of primitive types in Java 1.5 Generic types in Java 1.5.
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.
Exceptions Three categories of errors: Syntax errors Runtime errors Logic errors Syntax errors: rules of the language have not been followed. Runtime error:
J.43 ARRAYS  A Java array is an Object that holds an ordered collection of elements.  Components of an array can be primitive types or may reference.
C#.NET C# language. C# A modern, general-purpose object-oriented language Part of the.NET family of languages ECMA standard Based on C and C++
Lecture 9 Concepts of Programming Languages
OOP in Java Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
From C++ to C#. Web programming The course is on web programming using ASP.Net and C# The course is on web programming using ASP.Net and C# ASP.Net is.
OOP Languages: Java vs C++
Using Data Active Server Pages Objectives In this chapter, you will: Learn about variables and constants Explore application and session variables Learn.
C++ / G4MICE Course Session 3 Introduction to Classes Pointers and References Makefiles Standard Template Library.
CS203 Java Object Oriented Programming Errors and Exception Handling.
Programming Languages and Paradigms Object-Oriented Programming.
Chapter 6 Class Inheritance F Superclasses and Subclasses F Keywords: super F Overriding methods F The Object Class F Modifiers: protected, final and abstract.
“is a”  Define a new class DerivedClass which extends BaseClass class BaseClass { // class contents } class DerivedClass : BaseClass { // class.
Chapter 12 Inheritance and Exceptions Lecture Slides to Accompany An Introduction to Computer Science Using Java (2nd Edition) by S.N. Kamin, D. Mickunas,
220 FINAL TEST REVIEW SESSION Omar Abdelwahab. INHERITANCE AND POLYMORPHISM Suppose you have a class FunClass with public methods show, tell, and smile.
MT311 Java Application Development and Programming Languages Li Tak Sing( 李德成 )
OOPs Object oriented programming. Based on ADT principles  Representation of type and operations in a single unit  Available for other units to create.
1 Java Inheritance. 2 Inheritance On the surface, inheritance is a code re-use issue. –we can extend code that is already written in a manageable manner.
CSC Programming I Lecture 8 September 9, 2002.
Programming With Java ICS Chapter 8 Polymorphism.
In the name of Allah The Proxy Pattern Elham moazzen.
RMI Remote Method Invocation Distributed Object-based System and RPC Together 2-Jun-16.
C++ Memory Overview 4 major memory segments Key differences from Java
1 COMS 261 Computer Science I Title: C++ Fundamentals Date: September 05, 2005 Lecture Number: 4.
OOPs Object oriented programming. Abstract data types  Representationof type and operations in a single unit  Available for other units to create variables.
SOEN 343 Software Design Section H Fall 2006 Dr Greg Butler
Interfaces F What is an Interface? F Creating an Interface F Implementing an Interface F What is Marker Interface?
Duke CPS From C++ to Java l Java history: Oak, toaster-ovens, internet language, panacea l What it is ä O-O language, not a hybrid (cf. C++)
Java Programming, Second Edition Chapter Twelve Advanced Inheritance Concepts.
Chapter 11: Advanced Inheritance Concepts. Objectives Create and use abstract classes Use dynamic method binding Create arrays of subclass objects Use.
1 Lecture 21 – April 4, 2002 Dynamic Loading Communication in Bond Message delivery Internal and external message format KQML Synchronous and asynchrounous.
Java & C++ Comparisons How important are classes and objects?? What mechanisms exist for input and output?? Are references and pointers the same thing??
Singleton Pattern. Problem Want to ensure a single instance of a class, shared by all uses throughout a program Context Need to address initialization.
Internet Computing Module II. Syllabus Creating & Using classes in Java – Methods and Classes – Inheritance – Super Class – Method Overriding – Packages.
Creating Java Applications (Software Development Life Cycle) 1. specify the problem requirements - clarify 2. analyze the problem - Input? Processes? Output.
MT311 Java Application Development and Programming Languages Li Tak Sing( 李德成 )
Classes CS 162 (Summer 2009). Parts of a Class Instance Fields Methods.
Object Lifetime and Pointers
Modern Programming Tools And Techniques-I
Lecture 22 – April 9, 2002 Subprotocols – static and dynamic.
Java Primer 1: Types, Classes and Operators
Java Programming Language
Week 4 Object-Oriented Programming (1): Inheritance
Java Review: Reference Types
Remote Method Invocation
Type Systems Terms to learn about types: Related concepts: Type
Comp 249 Programming Methodology
Introduction to C# AKEEL AHMED.
Lecture 9 Concepts of Programming Languages
Lecture 3 From process-oriented to agent-oriented programming.
Java Programming Language
MSIS 670 Object-Oriented Software Engineering
CptS 561 Computer Architecture
Packages & Random and Math Classes
CSC 220 – Processing Spring, 2017
Interfaces.
Java Programming Language
CMSC 202 Exceptions.
SPL – PS3 C++ Classes.
SPL – PS2 C++ Memory Handling.
Lecture 9 Concepts of Programming Languages
Java Chapter 5 (Estifanos Tilahun Mihret--Tech with Estif)
Presentation transcript:

Lecture 20 – April 2, 2002 Bond Objects

Bond objects extend Java objects Every Bond object is assigned a unique identifier for the lifetime of the object. An entire collection of Bond objects can be identified by an alias. Communication support: All Bond objects are capable of receiving messages. Active objects can also send messages.

Bond objects extend Java objects Bond objects are registered at the creation time with a local directory. They can be found using either the unique identifier or the alias. Lightweight Bond objects (messages and shadows) are registered on demand. All Bond objects are serializable and clonable, while only some Java objects are.

Bond objects extend Java objects Bond objects may have dynamic properties created at run-time, in addition to the regular fields of a Java object. The Bond system extends the Java object model with multiple inheritance using a preprocessor of Java files. All Bond objects can be visually edited.

Bond Identifiers bondID= ``bondID'' + bondIPaddress + commEnginePort + localMillisecondSinceStartOfResident + timeAndDate

Bond object registration public class bondObject implements Serializable, Cloneable { public bondObject() { maybeInformDirectory(); if (bondID != null) { setName(bondID); } } protected void maybeInformDirectory() { try { bondID = dir.getBondID(); dir.register(this); } catch (NullPointerException e) }

Bond Resident Initialization public static void initbond() { bondConfiguration.initSysProperties(); loader = new bondLoader(); dir = new bondDirectory(); com = new bondCommunicator(); conf = new bondConfiguration(); bondMessage.initMessage(); return; }

Bond shadows

Bond shadows /** Create shadow from bondID and address of object*/ public bondShadow(String remote_bondID, String rem_address){ super(false); this.remote_bondID= remote_bondID; remote_address = new bondIPAddress(rem_address); }

Make a local copy of a remote object public bondObject realize() { bondID = dir.getBondID(); dir.register(this); bondObject bo = null; if (local != null) { return local; } else { bondMessage m =new bondMessage( "(tell :content realize)", "PropertyAccess"); m.setNeedsReply(); say(m, this); m.waitReply(30000); return m.bo; } }

Reflection and Introspection in Java The compilers and linkers for programming languages such as C or C++ usually discard the names of the variables, keeping only their addresses in the compiled code. Java, keeps this information in the compiled class files and allows access to it through a mechanism called reflection. Introspection, the ability to change dynamically the static properties of an object. E.g. Java beans.

Dynamic Properties of Bond Objects Dynamic properties are important for software agents, their functionality makes it difficult to anticipate all the fields of an agent at the instance the agent is created. For efficiency reasons regular Java fields should be used whenever possible, and we should resort to dynamic fields only when the name and/or type of the field is not known at compile time. Dynamic properties have a longer access time than regular Java fields. For remote object}s this difference is masked by the network latency. Compile-time type checking cannot be done for dynamic properties; thus, the programmer looses important type-safety information.

Dynamic Properties of Bond Objects All dynamic properties are considered to be of type Object and any value can be set for them. To delete a dynamic property, the value is set to null. Bond objects implement a common interface with two methods: get and set to access static fields and dynamic properties.

get get(String name); -- returns the value of the field or dynamic property called ``name''. Numerical values, which are not objects in Java, are first converted to their object counterpart, e.g., an int is converted to an Integer object. The get function returns null when there is no object or field with the given name.

set set(String name, Object value);-- sets the value of the field or dynamic property called name to the value specified by value. If there is no field or dynamic property with the given name, a new dynamic property is created. If there is a field with the given name but its type conflicts with the type of the object value, a casting exception is thrown.

Example Assume we have a Bond object foo with boo as a field: foo.set(``boo.name'', ``hector'')}. String val =foo.get(``boo.name'')}