Thank you, Tom.
To use instance as the common method argument, I have the easiest way
to do it.
Object[] getHandler(Class cls);
For example, to get all PluginFileAdapter, just need an instance
PluginFileAdapter adapter = new PluginFileAdapter();
Object[] fileAdapters = manager.getHandler(adapter.getClass);
I use these lines to check type:
Iterator itr = registerVector.iterator();
...
Object entry = iterator.next();
if (cls == entry.getClass()) {
// add to returned array
}
The only inconvenient thing is to have an PluginFileAdapter instance.
> > In my PluginRegisterManager class, there is a Vector registerVector
> > which stores all kinds of registered handlers as Object type. So I
[quoted text clipped - 49 lines]
>
> tom
Tom Forsmo - 18 Oct 2006 10:51 GMT
> Thank you, Tom.
>
> To use instance as the common method argument, I have the easiest way
> to do it.
>
> Object[] getHandler(Class cls);
I would recommend using an interface (with a common set of methods) as
the data type instead of a class, such as done with Collections, e.g.
Handlers[] getHandler(Class cls);
> For example, to get all PluginFileAdapter, just need an instance
> PluginFileAdapter adapter = new PluginFileAdapter();
[quoted text clipped - 10 lines]
>
> The only inconvenient thing is to have an PluginFileAdapter instance.
I am not sure I understand what you mean here. Is the problem that you
in addition to having a set of handlers, also have an an adapter in the
vector? How is it a problem?
tom