|
|
Re: Query adapters without creating a container? [message #607496 is a reply to message #607494] |
Wed, 16 August 2006 19:49 |
Erkki Lindpere Messages: 90 Registered: July 2009 |
Member |
|
|
Yes, I was thinking of adding some kind of metadata. But I think that
duplication wouldn't be very nice, though. And if simply creating a
number of containers is not meant to be an expensive operation, then I
can live with creating all that are available. And the operation where I
need to get a list of containers that only adapt to a more specific
container doesn't come up that often anyway (in fact, it should be
invoked quite seldom).
I'll report the bug about the specific container soon.
Scott Lewis wrote:
> Hi Erkki,
>
> Erkki Lindpere wrote:
>> In a BBAPI example client, I'm adding a Wizard to create a Bulletin
>> Board connection and I want to show the user a list of IContainers
>> that can adapt to IBulletinBoard.
>>
>> I think it would be great if it could be know which container types an
>> IContainer adapts to before actually creating the container.
>
>
> I'm not immediately sure how this would be accomplished. Part of the
> adapter pattern is the usage of an instance implementing
> IAdaptable...rather than a static method...as this makes it possible for
> providers to implement IContainer (and any/all adapter interfaces) via
> whatever type they wish.
>
> I suppose it may be possible to add a method to ContainerTypeDescription
> like this:
>
> public boolean hasAdapter(Class clazz);
>
> Then you could use ContainerFactory like this:
>
> ContainerTypeDescription desc =
> ContainerFactory.getDefault().getDescriptionByName("providername ");
>
> if (desc.hasAdapter(IBulletinBoard.class)) // do something
>
> How does this sound?
>
> I've been contemplating enhancing the ContainerTypeDescription (and
> perhaps the underlying IContainerInstantiator implemented by providers)
> to expose other meta-information about a Container (e.g. types of
> required creation parameters, etc). Maybe this could be fit into such a
> reworking of ContainerTypeDescription. Comments welcome.
>
>>
>> Right now I did this by looping through all containers and creating
>> them, then calling getAdapter(IBulletinBoard.class) to see if they are
>> BB containers. But this doesn't seem very efficient, and it also
>> created a problem:
>> one of the containers (I'll check which one if necessary) threw a
>> ContainerInstantiationException when the wizard was run for the second
>> time.
>
>
> This is a bug in the provider...could you let us know which one...and
> perhaps file a bug report on this?
>
> Thanks,
>
> Scott
|
|
|
Powered by
FUDForum. Page generated in 0.03796 seconds