Chapter FiveLookup

The Lookup class, which we introduced in Chapter 4, is used for much more than just dependency injection. In NetBeans-based applications, it is used for other purposes as well. All of these involve decoupling. This chapter will introduce some of the other ways Lookup is used in the NetBeans APIs.

The basic usage pattern remains the same for any Lookup instance, as shown in Example 5.1.

Example 5.1. Using Lookup

image

The code in Example 5.1 asks a Lookup for an instance of Foo. If there is at least one Foo in the Lookup, it will be returned; otherwise null will be returned.

Lookup is used pervasively in NetBeans. One way to think ...

Get Rich Client Programming: Plugging into the NetBeans Platform now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.