To access a component, call the fetchComponent
method as in the following
exmaple:
Cache quoteCache = (Cache) Lookup.getInstance().fetchComponent("/quote/QuoteCache");
Note that the fetchComponent
method returns a generic type of
Component
. This must be casted to the specific type of the component
you are requesting. The example assumes that the component is a Cache. This is
defined within the component's configuration.
The parameter to the fetchComponent
method is the logical name of the
component. This name must match the name of a configuration document.
The configuration document must contain a ComponentConfiguration
or an extension
of ComponentConfiguration
. If the
configuration is not found, the unchecked ComponentNotFoundException
is thrown.