Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Communications Framework (ECF) » Query adapters without creating a container?
Query adapters without creating a container? [message #607493] Sun, 13 August 2006 20:20 Go to next message
Erkki Lindpere is currently offline Erkki LindpereFriend
Messages: 90
Registered: July 2009
Member
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.

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. I thought of calling dispose() for each container in the loop, but
the contract for IContainer.dispose() says that it shouldn't be called
by clients.

Erkki
Re: Query adapters without creating a container? [message #607494 is a reply to message #607493] Wed, 16 August 2006 00:31 Go to previous messageGo to next message
Scott Lewis is currently offline Scott LewisFriend
Messages: 1038
Registered: July 2009
Senior Member
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
Re: Query adapters without creating a container? [message #607496 is a reply to message #607494] Wed, 16 August 2006 19:49 Go to previous message
Erkki Lindpere is currently offline Erkki LindpereFriend
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
Previous Topic:Sending a big file with FileShare
Next Topic:Propagation of user id
Goto Forum:
  


Current Time: Sun Aug 09 18:22:42 GMT 2020

Powered by FUDForum. Page generated in 0.01394 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top