开发者

Entities and the adapter pattern

开发者 https://www.devze.com 2023-02-05 08:41 出处:网络
I was wondering what would be the right to go: I have an eclipse rcp application which uses some JPA entities. Now I\'ve w开发者_运维问答ould love to use the adapter pattern, which is provided through

I was wondering what would be the right to go: I have an eclipse rcp application which uses some JPA entities. Now I've w开发者_运维问答ould love to use the adapter pattern, which is provided through the IAdapterFactory and the IAdaptable interface. According to this article my entity has to implement the IAdaptable interface but I want to have clean entities and I also do not want write stupid ContentProvider. My question: Do I have any other choice then using ContentProvider?


Look at this

They say that it is not strictly necessary to implement IAdaptable.

It is also possible to do this

IAdapterManager manager = Platform.getAdapterManager();
... = manager.getAdapter(object, IResource.class);

e.g. WorkbenchLabelProvider uses org.eclipse.ui.internal.util.Util.getAdapter() which checks if object is IAdaptable later uses IAdapterManager.

IAdapterManager manages IAdapterFactories. Adapter factories can be registered programatically using the registerAdapters method. Alternatively, they can be registered declaratively using the org.eclipse.core.runtime.adapters extension point.

0

精彩评论

暂无评论...
验证码 换一张
取 消