'. '

Lookup

From APIDesign

(Difference between revisions)
Jump to: navigation, search
Line 10: Line 10:
On the other hand, looking from a local point of view, there can be many ''pools'' to fish for an interface. Almost any object can implement [http://hudson.apidesign.org/hudson/job/lookup/org.apidesign$lookup/javadoc/org/openide/util/Lookup.Provider.html Lookup.Provider] interface and thus give access to its adaptable features to everyone.
On the other hand, looking from a local point of view, there can be many ''pools'' to fish for an interface. Almost any object can implement [http://hudson.apidesign.org/hudson/job/lookup/org.apidesign$lookup/javadoc/org/openide/util/Lookup.Provider.html Lookup.Provider] interface and thus give access to its adaptable features to everyone.
-
Using the same interface to play two different roles ([[Injection|component injection]] and [[Adaptable]] pattern) shows the common properties of both. The [[Lookup]] can serve as a assembly language to provide ''pool'' of objects to use during real dependency injection. The [http://wiki.netbeans.org/view/SpringAndNetBeans bridge between Lookup and Spring] provides more details about this area.
+
Using the same interface to play two different roles ([[Injection|component injection]] and [[Adaptable]] pattern) shows the common properties of both. The [[Lookup]] can serve as a assembly language to provide ''pool'' of objects to use during real [[Dependency Injection]]. The [http://wiki.netbeans.org/view/SpringAndNetBeans bridge between Lookup and Spring] provides more details about this area.

Revision as of 10:36, 28 April 2009

Lookup is a library that provides API that unifies component injection with adaptable pattern. It is based on long time JDK standard for registering instances of services in JAR files which has been formalized as ServiceLoader in JDK 6. Lookup extends this area and allows local pools of objects that can be queries for certain capability. Lookup is also suited for dynamic environment as it supports notification of changes. Lookup bridges the classical injection pattern with local adaptable pattern.

The basic idea, in its ServiceLoader incarnation is that it is enough to compose an application from various JAR files and let these JAR files communicate. This is achieved by defining well-known location inside the JAR file META-INF/services/nameoftype that is read from all available libraries JARs on the classpath.

This greatly simplifies final assembly and deployment of the application. It is enough to drop the JARs with an implementation available in the system and all the pieces can work suddenly cooperate by mutually discovering themselves via Lookup.getDefault().lookup(...).

On the other hand, looking from a local point of view, there can be many pools to fish for an interface. Almost any object can implement Lookup.Provider interface and thus give access to its adaptable features to everyone.

Using the same interface to play two different roles (component injection and Adaptable pattern) shows the common properties of both. The Lookup can serve as a assembly language to provide pool of objects to use during real Dependency Injection. The bridge between Lookup and Spring provides more details about this area.

Personal tools
buy