Download presentation
Presentation is loading. Please wait.
Published bySharlene Griffith Modified over 9 years ago
1
CPSC 410
2
Build on previous Connector lectures Learn how to implement flexible connector implementations Learn the Dependency Injection pattern Learn the basics of Java Reflection
4
A methodology for software design to provide plugin-based extensibility Each application class (i.e. domain type) refers to (depends on) other application classes only through interfaces Classes use Factory to obtain references to dependencies
5
Concrete types of interfaces are decided by configuration files Allows the wrapper-oriented patterns to be applied at any time Wrapper-oriented patterns: ◦ Decorator ◦ Adaptor ◦ Proxy ◦ …
6
a class that provides methods which generally forwards responsibility for application- specific feature implementation to another object called the delegate has a delegate application-generic connector features are implemented by the delegator ◦ before forwarding to the delegate ◦ after forwarding to the delegate
7
extends Delegator implements the same interface as it’s delegate ◦ implements T where T is the type of the delegate acts as a transparent layer where connector features can be inserted example: AccountSecurityDecorator
8
extends Delegator implements a different interface as it’s delegate ◦ implements T where T is not the type of the delegate mediates between connector differences of T and the delegate type Example: AccountAdaptor
9
implements some application type T forwards responsibility for implementation of T over a network example: AccountRemoteProxy
10
Creates instances of an application type that are wrapped by any number of Delegators given in a configuration file Provides plug-and-play connector features without changing source code Forms the basis of extensibility features ◦ Eclipse Plugins ◦ Firefox plugins ◦ etc… example: SimpleDependencyInjectionFactory
11
the class for objects that represent Java classes part of the Java Reflection API ◦ helps implements programs that work on programs ◦ forms the basis for meta-programming in Java static Class forName(String name) ◦ get an object representing the class called name Object newInstance() ◦ automagically calls the no-arg constructor for the class and returns a new instance of the class
12
INPUT: ◦ A sequence of Java class names: C 0 … C n PRE-CONDITION: ◦ forall(C i ): i < n C i is a delegator for C i+1 IMPLEMENTATION: ◦ Use java.lang.Class to instantiate all C and link delegators to delegates OUTPUT: ◦ An instance of C 0
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.