-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow interfacing with other adapter frameworks by using a proxy
While the Eclipse Adapter Framework is very powerful it currently does not allow to interface with other adaption techniques (e.g. OSGi Converter Specification). This adds a new way to adapt a class of objects to a proxy that then is asked for further adaption.
- Loading branch information
Showing
3 changed files
with
50 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/AdapterProxy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package org.eclipse.core.runtime; | ||
|
||
/** | ||
* <p> | ||
* An {@link AdapterProxy} can be used to interface the Eclipse Adapter | ||
* Framework with other techniques. To do so one has to provide a generic | ||
* {@link IAdapterFactory} that adapts this other frameworks objects to the | ||
* {@link AdapterProxy} interface, then as a last resort, the Eclipse Adapter | ||
* Framework will ask this proxy as if the original object would have | ||
* implemented {@link IAdaptable}. | ||
* </p> | ||
* <p> | ||
* One example is the OSGi <a href= | ||
* "https://docs.osgi.org/specification/osgi.cmpn/7.0.0/util.converter.html">Converter | ||
* Specification</a> that allows to adapt/convert objects in an extensible way, | ||
* therefore it is not possible to register a "classic" {@link IAdapterFactory} | ||
* because the types that are probably convertible are unknown in advance. Also | ||
* the objects itself can't be made to implement the {@link IAdaptable} | ||
* interface. An implementation then might look like this: | ||
* </p> | ||
* | ||
* <pre> | ||
* @Component | ||
* @AdapterTypes(adaptableClass = Object.class, adapterNames = AdapterProxy.class) | ||
* public class OSGiConverterProxyFactory implements IAdapterFactory { | ||
* | ||
* @Reference | ||
* private Converter converter; | ||
* | ||
* public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) { | ||
* Converting converting = converter.convert(adaptableObject); | ||
* return converting.to(adapterType); | ||
* } | ||
* | ||
* } | ||
* </pre> | ||
* | ||
* @since 3.20 | ||
*/ | ||
public interface AdapterProxy extends IAdaptable { | ||
// This is a specialized type that do not define any methods | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters