Upload
robin-leon
View
219
Download
2
Tags:
Embed Size (px)
Citation preview
Transparent Filter ObjectsTransparent Filter Objects
Rushikesh K. JoshiRushikesh K. JoshiDepartment of Computer Science & EngineeringDepartment of Computer Science & Engineering
Indian Institute of Technology, BombayIndian Institute of Technology, Bombay
Mumbai - 400 076Mumbai - 400 076
About the AuthorAbout the Author
R.K. Joshi is with the Department of Computer Science and Engineering at IIT R.K. Joshi is with the Department of Computer Science and Engineering at IIT Bombay as Assistant Professor, where he has introduced a course on Object Bombay as Assistant Professor, where he has introduced a course on Object Oriented Systems. He currently teaches courses on Object Oriented Systems Oriented Systems. He currently teaches courses on Object Oriented Systems and Operating Systems. He has provided consultancy and teaching in Object and Operating Systems. He has provided consultancy and teaching in Object Oriented Technologies to academia and the Indian Industry. He has designed Oriented Technologies to academia and the Indian Industry. He has designed various programming paradigms focused on the principle of separation of various programming paradigms focused on the principle of separation of concerns, among them are the Anonymous Remote Computing (IEEE TSE, concerns, among them are the Anonymous Remote Computing (IEEE TSE, 1999) for parallel computing on loaded heterogeneous fail-stop workstations, 1999) for parallel computing on loaded heterogeneous fail-stop workstations, Filter objects (SPE 1997), and Replicated Services (JPDC 1999). Filter objects (SPE 1997), and Replicated Services (JPDC 1999).
He completed his PhD thesis from Indian Institute of Technology, Madras in He completed his PhD thesis from Indian Institute of Technology, Madras in 1996. He is with IIT Bombay since 1997. His current interests are software 1996. He is with IIT Bombay since 1997. His current interests are software architectures, paradigms for evolution, interclass and interobject relationships architectures, paradigms for evolution, interclass and interobject relationships and distributed object systems.and distributed object systems.
Outline of the TalkOutline of the Talk
Messages in the conventional object modelMessages in the conventional object model The filtered message delivery modelThe filtered message delivery model The filter object programming model and its The filter object programming model and its
implementation for C++implementation for C++ Filter configurationsFilter configurations Filter Objects for CORBAFilter Objects for CORBA Filter Objects for Software EvolutionFilter Objects for Software Evolution
Interacting ObjectsInteracting Objects
Objects are the building blocks in an object Objects are the building blocks in an object oriented softwareoriented software
Objects interact with each other through Objects interact with each other through message invocations on each othermessage invocations on each other
e.g. to get something done by an object o2, e.g. to get something done by an object o2, o1 invokes a method defined by o2o1 invokes a method defined by o2
o1 o2
m
The Direct Delivery Message The Direct Delivery Message ModelModel
A message is directly delivered to the receiver A message is directly delivered to the receiver object specified by the source objectobject specified by the source object
e.g. {O2.m} in object o1 specifies a message e.g. {O2.m} in object o1 specifies a message invocation m on o2; o2 is identified by o1.invocation m on o2; o2 is identified by o1.
A message invocation on the receiver object is A message invocation on the receiver object is the immediate consequence of message the immediate consequence of message generation at message sourcegeneration at message source
Message Control and Message Message Control and Message ProcessingProcessing
Message ProcessingMessage Processing: The actual code at the : The actual code at the receiver provides the functionality desired by the receiver provides the functionality desired by the callercaller
Message ControlMessage Control: Intermediate manipulations on : Intermediate manipulations on messagesmessages
In the direct delivery model, message In the direct delivery model, message manipulations cannot be performed on-the-fly manipulations cannot be performed on-the-fly and they must be taken care of by the message and they must be taken care of by the message processing code itselfprocessing code itself
The Filtered Delivery ModelThe Filtered Delivery Model
Messages can be trapped by intermediate Messages can be trapped by intermediate filter objects which are transparentfilter objects which are transparent
Filter objects are also conventional objects Filter objects are also conventional objects and in addition to the conventional and in addition to the conventional properties of object orientation, they properties of object orientation, they possess message filtering capabilities possess message filtering capabilities
Transparency Property of Filter Transparency Property of Filter ObjectsObjects
Clients are unaware of the existence of filter Clients are unaware of the existence of filter objects, i.e. clients still identify the desired objects, i.e. clients still identify the desired receiver objects as in the conventional receiver objects as in the conventional object modelobject model
Server.m mf
Object ServerObject Client Object Filter
Properties of Filter ObjectsProperties of Filter Objects
Interception of upward messagesInterception of upward messages Interception of downward resultsInterception of downward results Manipulation of message argumentsManipulation of message arguments Pass and Bounce capabilitiesPass and Bounce capabilities Capabilities of conventional objectsCapabilities of conventional objects Selective FilteringSelective Filtering Dynamic binding at instance levelDynamic binding at instance level Modular developmentModular development
The Core Filter Object ModelThe Core Filter Object Model
Server.m Invoke m ()
another
pass
return
bounce
downfilter
upfilter
Client
Filter
Server
Interclass Filter RelationshipInterclass Filter Relationship
An instance of a class C1 that is in filter An instance of a class C1 that is in filter relationship with class C2 has the ability to relationship with class C2 has the ability to transparently intercept the messages sent to transparently intercept the messages sent to an instance of class C2. an instance of class C2.
Class Dictionary {…}Class Dictionary {…} Class Cache: filter Dictionary {….}Class Cache: filter Dictionary {….}
Dynamic Plugging of Filter Dynamic Plugging of Filter ObjectsObjects
Filter relationships are statically established Filter relationships are statically established at class level but dynamically at the instance at class level but dynamically at the instance levellevel
The plug and unplug operationsThe plug and unplug operationsmain ( ) {main ( ) {
Dictionary *d=..;Dictionary *d=..;
Cache *c=..;Cache *c=..;plug d c;plug d c;
……
unplug d;unplug d;
} }
Organization of a Filter Class: Organization of a Filter Class: The Filter Interface The Filter Interface
Class Dictionary {Class Dictionary {public: public: Meaning SearchWord( Word);Meaning SearchWord( Word);
}}
class Cache : filter Dictionary {class Cache : filter Dictionary {
upfilterupfilter::Meaning SearchCache(Word) filters SearchWord;Meaning SearchCache(Word) filters SearchWord;
downfilterdownfilter: : Meaning ReplaceCacheEntry (Meaning) filters SearchWord;Meaning ReplaceCacheEntry (Meaning) filters SearchWord;
publicpublic:: double hitRatio ( );double hitRatio ( );
}}
An Application of Filter Objects An Application of Filter Objects (D Janaki Ram et. al, IEEE SMC march 1997)(D Janaki Ram et. al, IEEE SMC march 1997)
Piston object Crank object
Constraint object Constraint objectApparentpath
Real Path
notify
A Collaborative Designing ScenarioDESIGNER1
DESIGNER2
notify
Extended Properties of Filter Extended Properties of Filter ObjectsObjects
Group FilteringGroup Filtering• Many instances of a server object may be Many instances of a server object may be
plugged with a filter object which is an instance plugged with a filter object which is an instance of a filter class in filter relationship with the of a filter class in filter relationship with the server classserver class
Layered FilteringLayered Filtering• Filters to filters may be specified to achieve Filters to filters may be specified to achieve
layered filteringlayered filtering
Implementing Filter Objects for Implementing Filter Objects for C++C++
Class Server
Class AbstractFilter
Class ConcreteFilter1 Class ConcreteFilter2
filterB
filterA
filterAfilterB
filterA
filterB
serviceA
serviceB
filt
Filter ConfigurationsFilter Configurations
ReplacerReplacer RouterRouter RepeaterRepeater Value TransformerValue Transformer Message TransformerMessage Transformer Request LoggerRequest Logger
ReplacerReplacer
A filter member function operates as a replacement function to its A filter member function operates as a replacement function to its corresponding server member functioncorresponding server member function
FastServer | oldServer =FastServer | oldServer =
filter interface:filter interface:
funcReplacer (in) upfilters oldServer :: func (in)funcReplacer (in) upfilters oldServer :: func (in)
= [v <-- self.func (in); bounce (v); ]= [v <-- self.func (in); bounce (v); ]
client filter server
RouterRouter
A filter member function operates as a router functionA filter member function operates as a router function
balancer | searchEngine =balancer | searchEngine =
filter interface:filter interface:
searchRouter (item) upfilters SearchEngine ::search (item)searchRouter (item) upfilters SearchEngine ::search (item)
= [newDest <-- self.nextDest();= [newDest <-- self.nextDest();
v<--newDest.search(item); bounce (v); ]v<--newDest.search(item); bounce (v); ]
client filter server server2
RepeaterRepeater
A filter member function dispatches the filtered invocation to multiple A filter member function dispatches the filtered invocation to multiple serversservers
enrollFilter | centralEnroller =enrollFilter | centralEnroller =
filter interface:filter interface:
libEnroll (student) upfilters centralEnroller :: enroll (student)libEnroll (student) upfilters centralEnroller :: enroll (student)
= [ if (student.dept == civil) civilLib-->enroll (student);= [ if (student.dept == civil) civilLib-->enroll (student);
if (student.status == minor) minorBody-->enroll(student);if (student.status == minor) minorBody-->enroll(student);
pass; ]pass; ]
client filter server1 server2 server3
Transformers and LoggerTransformers and Logger
Value TransformerValue Transformer• Message contents are changed before the message is Message contents are changed before the message is
delivered to the server e.g. to handle encryptiondelivered to the server e.g. to handle encryption Message TransformerMessage Transformer
• A different message is called on the server e.g. to A different message is called on the server e.g. to support clients that know of an older interfacesupport clients that know of an older interface
LoggerLogger• A message is invoked on a different object and the A message is invoked on a different object and the
member function is passed on to the actual server e.g. member function is passed on to the actual server e.g. to implement the decorator design patternto implement the decorator design pattern
Filter Objects for Distributed Filter Objects for Distributed Object Systems Object Systems
Need-to-filter principle: A server is declared as Need-to-filter principle: A server is declared as Filterable ServerFilterable Server
A filter object cannot be plugged to a server that A filter object cannot be plugged to a server that is not declared as filterableis not declared as filterable
interface Filterable {interface Filterable {attach (in Object filter)attach (in Object filter)
detach ();detach ();
};};
interface Server : Filterable {interface Server : Filterable {
service ();service ();
}}
Implementation of IDL FilterableImplementation of IDL Filterable
A standard implementation of Filterable is A standard implementation of Filterable is provided in class Filterable_impl provided in class Filterable_impl
class Filterable_impl : public Filterable_skel {class Filterable_impl : public Filterable_skel {// library implementations of attach and detach// library implementations of attach and detach
}}
Implementing Filterable ServersImplementing Filterable Servers
An implementation of a filterable server An implementation of a filterable server must inherit the standard implementation of must inherit the standard implementation of IDL FilterableIDL Filterable
class Dictionary_impl : public Filterable_impl, class Dictionary_impl : public Filterable_impl, public Dictionary_skel {public Dictionary_skel {
// implementations of Dictionary IDL// implementations of Dictionary IDL
}}
Implementing Filter ObjectsImplementing Filter Objects IDL precompiler generates a IDL precompiler generates a Filter Base Filter Base
InterfaceInterface for each filterable server interface for each filterable server interface The The Filter base interfaceFilter base interface is implemented by is implemented by
the filter object implementerthe filter object implementerinterface Dictionary_Filter {interface Dictionary_Filter {
// up and down filter member declarations// up and down filter member declarations
}}
A post-translator is also required to modify A post-translator is also required to modify the dispatcher the dispatcher
Activation and Deactivaton of Activation and Deactivaton of Filter ObjectsFilter Objects
A CORBA Object that acquires handles to a filter A CORBA Object that acquires handles to a filter object and its corresponding filterable server object and its corresponding filterable server object may carry out the plug and unplug object may carry out the plug and unplug operationsoperationsmain ( ) {main ( ) {
……..
server_obj-->attach (filter_obj);server_obj-->attach (filter_obj);
……
server_obj-->detach ( );server_obj-->detach ( );
}}
Filter Netwoks for Software Filter Netwoks for Software EvolutionEvolution
Inject a network of collaborating filter Inject a network of collaborating filter objects into an existing object oriented objects into an existing object oriented software system to satisfy evolution software system to satisfy evolution requirementsrequirements
Object1Object3
Object2
Object4
Filter Object Network
Properties of the Injection Properties of the Injection ApproachApproach
No need to modify the existing code: No need to modify the existing code: Modified functionalities can be handled Modified functionalities can be handled separately by the collaborating filter objectsseparately by the collaborating filter objects
Evolution is reversible: By lifting the filter Evolution is reversible: By lifting the filter networknetwork
Original object oriented design must be Original object oriented design must be filter-awarefilter-aware
An Example of Filter Based An Example of Filter Based Evolution: Evolution: Readers and WritersReaders and Writers[R.K. Joshi, PhD Thesis, IIT Madras, India, 1996][R.K. Joshi, PhD Thesis, IIT Madras, India, 1996]
Original Code (Hansen 1978)Original Code (Hansen 1978)process resource process resource
s: ints: int
proc StartRead proc StartRead when s>0 : s++; endwhen s>0 : s++; end
proc EndRead proc EndRead if s >1: s--; endif s >1: s--; end
proc StartWrite proc StartWrite when s==1: s--; endwhen s==1: s--; end
proc EndWrite proc EndWrite if s==0: s++; endif s==0: s++; end
s=1;s=1;
Evolution RequirementEvolution Requirement
Solve the same problem with additional Solve the same problem with additional constraint that further reader requests constraint that further reader requests should be delayed as long as there are should be delayed as long as there are writers waiting or using the resourcewriters waiting or using the resource
A filter object based solution is provided to A filter object based solution is provided to solve this problem without modifying the solve this problem without modifying the existing codeexisting code
The ApproachThe Approach
Old monitor Old reading and writing clients
Old monitor Old reading and writing clients
Injected Filter
Evolution using Filter ObjectEvolution using Filter Object
process problemSolver: filter resourceprocess problemSolver: filter resource
www : intwww : int
upfilter:upfilter:
SW_Ufilter filters StartWriteSW_Ufilter filters StartWrite
SR_Ufilter filters StartReadSR_Ufilter filters StartRead
downfilter:downfilter:
EW_Dfilter filters EndWriteEW_Dfilter filters EndWrite
proc SW_Ufilter:proc SW_Ufilter: www++; pass; endwww++; pass; end
proc EW_Dfilter:proc EW_Dfilter: www---; endwww---; end
proc SR_Ufilter: proc SR_Ufilter: when www==0: pass; endwhen www==0: pass; end
www=0;www=0;
Our PredictionOur Prediction
Transparent Filter Objects will be Transparent Filter Objects will be recognized as important architectural recognized as important architectural components in object oriented software components in object oriented software systems systems
Implementations of some kind of filtering Implementations of some kind of filtering capabilities will be widely available as capabilities will be widely available as through integration into today’s commercial through integration into today’s commercial object oriented software technologies.object oriented software technologies.
ConclusionsConclusions
Transparent Filter Objects can be integrated into Transparent Filter Objects can be integrated into the well established model of object oriented the well established model of object oriented programming.programming.
Filter Objects are powerful tools for Software Filter Objects are powerful tools for Software EvolutionEvolution
Filter object implementations for C++ and Filter object implementations for C++ and CORBA based object oriented systems have been CORBA based object oriented systems have been designed and implemented (Recently, We have designed and implemented (Recently, We have also integrated the First Class Filter Object Model also integrated the First Class Filter Object Model into JAVA).into JAVA).
Conclusions ..Conclusions ..
Some of the Filter Configurations have been Some of the Filter Configurations have been identified as elementary building blocks for identified as elementary building blocks for filter-based architectures.filter-based architectures.
Filter Configurations have interesting Filter Configurations have interesting consequences when applied to software consequences when applied to software evolution evolution
Future/Ongoing WorkFuture/Ongoing Work
Further explorations on Programming Further explorations on Programming models, efficient implementation models, efficient implementation mechanisms and applications of mechanisms and applications of Transparent InterceptionTransparent Interception
Methodology for software evolution based Methodology for software evolution based on filter objectson filter objects
Understand the capabilities and limitations Understand the capabilities and limitations of filter objectsof filter objects
Available Results on Filter Available Results on Filter ObjectsObjects
[1] Rushikesh K. Joshi, N. Vivekananda, D Janaki Ram, Software Practice and [1] Rushikesh K. Joshi, N. Vivekananda, D Janaki Ram, Software Practice and Experience, June 1997, pp. 677-699Experience, June 1997, pp. 677-699
[2] Rushikesh K. Joshi, Filter Configurations for Structuring Distributed [2] Rushikesh K. Joshi, Filter Configurations for Structuring Distributed Object Systems, To appear in Journal of Object Oriented Programming.Object Systems, To appear in Journal of Object Oriented Programming.
[3] Rushikesh K. Joshi, On-the-fly Evolution of Object Oriented Systems [3] Rushikesh K. Joshi, On-the-fly Evolution of Object Oriented Systems using Filter Objects, Technical Report, Feb. 1999, IIT Bombay. (result using Filter Objects, Technical Report, Feb. 1999, IIT Bombay. (result submitted for publication).submitted for publication).
[4] G. Sriram Reddy, Rushikesh K. Joshi, Filter Objects for Distributed Object [4] G. Sriram Reddy, Rushikesh K. Joshi, Filter Objects for Distributed Object Systems, To Appear in Journal of Object Oriented Programming (January Systems, To Appear in Journal of Object Oriented Programming (January 2001)2001)..
[5] R. K. Joshi, Modeling with Filter Objects in Distributed Systems, To be [5] R. K. Joshi, Modeling with Filter Objects in Distributed Systems, To be presented at EDO 2000, UC Davis, Nov 2-3, 2000presented at EDO 2000, UC Davis, Nov 2-3, 2000
[6] Maureen Mascarenhas, R. K. Joshi, Design and Implementation of Filter [6] Maureen Mascarenhas, R. K. Joshi, Design and Implementation of Filter Objects for JAVA, Technical Report, IIT Bombay October 2000. (result Objects for JAVA, Technical Report, IIT Bombay October 2000. (result submitted for Publication).submitted for Publication).