cpsc 410. build on previous connector lectures learn how to implement flexible connector...

12
CPSC 410

Upload: sharlene-griffith

Post on 28-Dec-2015

217 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CPSC 410.  Build on previous Connector lectures  Learn how to implement flexible connector implementations  Learn the Dependency Injection pattern

CPSC 410

Page 2: CPSC 410.  Build on previous Connector lectures  Learn how to implement flexible connector implementations  Learn the Dependency Injection pattern

Build on previous Connector lectures

Learn how to implement flexible connector implementations

Learn the Dependency Injection pattern

Learn the basics of Java Reflection

Page 3: CPSC 410.  Build on previous Connector lectures  Learn how to implement flexible connector implementations  Learn the Dependency Injection pattern
Page 4: CPSC 410.  Build on previous Connector lectures  Learn how to implement flexible connector implementations  Learn the Dependency Injection pattern

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

Page 5: CPSC 410.  Build on previous Connector lectures  Learn how to implement flexible connector implementations  Learn the Dependency Injection pattern

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◦ …

Page 6: CPSC 410.  Build on previous Connector lectures  Learn how to implement flexible connector implementations  Learn the Dependency Injection pattern

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

Page 7: CPSC 410.  Build on previous Connector lectures  Learn how to implement flexible connector implementations  Learn the Dependency Injection pattern

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

Page 8: CPSC 410.  Build on previous Connector lectures  Learn how to implement flexible connector implementations  Learn the Dependency Injection pattern

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

Page 9: CPSC 410.  Build on previous Connector lectures  Learn how to implement flexible connector implementations  Learn the Dependency Injection pattern

implements some application type T

forwards responsibility for implementation of T over a network

example: AccountRemoteProxy

Page 10: CPSC 410.  Build on previous Connector lectures  Learn how to implement flexible connector implementations  Learn the Dependency Injection pattern

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

Page 11: CPSC 410.  Build on previous Connector lectures  Learn how to implement flexible connector implementations  Learn the Dependency Injection pattern

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

Page 12: CPSC 410.  Build on previous Connector lectures  Learn how to implement flexible connector implementations  Learn the Dependency Injection pattern

INPUT:◦ A sequence of Java class names: C0 … Cn

PRE-CONDITION:◦ forall(Ci): i < n

Ci is a delegator for Ci+1

IMPLEMENTATION:◦ Use java.lang.Class to instantiate all C and link

delegators to delegates OUTPUT:

◦ An instance of C0