Re: Best way to share object instances between modules?
> IncomeTaxCalculator calc =
> Lookup.getDefault().lookup(IncomeTaxCalculator.class);
>
> Note that you do not ever need to directly instantiate any type of
> IncomeTaxCalculator. No code, aside from that in Module 2, should
> even know the name of the IncomeTaxCalculator implementation class --
> everything should use the interface.
The way you're describing it implies that there has to be a module
with an interface and another with the implementation. I have no such
thing.
What I have is something in the lines of:
- Module Catalog provides the application logic, it exposes, through
public methods, all available actions.
- Module GUI provides all interface options, top components, dialogs,
actions, and so on. It must access the CatalogEngine class, inside the
module Catalog, in order to send user input and request all the data
to display.
- Module GUI depends on Module Catalog, that in turn depends on some
other modules that wrap various libraries I need.
I have tried to look for an instance of the class CatalogEngine, the
lives inside the Catalog module, in one of my TopComponent's subclass,
that lives inside the GUI module. I tried that because I read
somewhere, either in the wiki or the API docs, that I could pass an
Interface or a Class, but I always get null.
I have tried to get the instance in various places, an installer class
on the GUI module, various constructors for classes inside the GUI
module. The result is always null.
--
Sem mais e com os melhores cumprimentos,
Sérgio Lopes