Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[bpel-dev] Adapter Factories.

So this is kinda an interesting topic here ....

There are 2 kinds of adapter factories that we deal with.

(1) The workbench kind (via org.eclipse.core.runtime.IAdapterFactory which can be registered via an extension point in eclipse).
These factories return adapter objects for the requested interface. So as long as your objects implements IAdaptable you can ask it to getAdapter( <adapterClass> )

(2) The EMF adapters (via  AdapterFactoryImpl implements AdapterFactory)
The factories return adapter objects via the adapt() method of the adapter factory.

The differences between (1) and (2) to me are that
  in (2) the adapters are held on the EMF object and are never recreated if already attached [ so there is a back reference from an adapter to the object it adapts ].
  in (1) this may or may not the case [ adapters do not have a reference to the object they adapt and as soon as you loose a reference to the adapter it is gone and you will have to recreated it from scratch ]

In (1) the adapter manager just delegates to the adapter factory to get the adapter - if the app has some way of keeping the reference to the previously created adapter instance fine, otherwise new instances are returned.

Now I am under the assumption that (1) and (2) are not united any place in eclipse. That was the reason for writing AdapterRegistry in the model package which would act as the kitechen sink for adapters of the two kinds.

This is so that I can write ....

    AdapterRegistry.INSTANCE.adapt( target, SomeInterface.class )

from anywhere and get the right thing, whether its an EMF adapter or workbench adapter kind.

Having said that (1) can be registered as an extension point. But (2) .... I am under the impression they are not registrable via any extension points.

Anyone know otherwise ?

So Ralf, to answer your question, right now to register the factory you would have to call AdapterRegistry.INSTANCE.registerAdapterFactory() someplace to register your adapter factory.

There is no extension point that I know of ... but I could be wrong.

-michal

Ralf Weinand wrote:
Hi Michal,

was it possible to provide a simple example
of how to register an adapter factory for a custom extension element?
(Maybe within the Palette-Addition-Example.)

Cheers,
Ralf


-- 
Michal Chmielewski, CMTS, Oracle Corp, 
W:650-506-5952 / M:408-209-9321 

"Manuals ?! What manuals ? Son, it's Unix, you just gotta know." 

Back to the top