Skip to content

Commit e423bf1

Browse files
committed
Add IContextFunction.ServiceContextKey OSGi component property type
This annotation simplifies the specification of the 'service.context.key' service property for IContextFunction implementations and makes it type-safe and more robust: ''' @component(service = IContextFunction.class) @IContextFunction.ServiceContextKey(IProgressService.class) public class ProgressServiceCreationFunction extends ContextFunction { '''
1 parent 7fa51b7 commit e423bf1

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

runtime/bundles/org.eclipse.e4.core.contexts/META-INF/MANIFEST.MF

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Manifest-Version: 1.0
22
Bundle-ManifestVersion: 2
33
Bundle-SymbolicName: org.eclipse.e4.core.contexts
4-
Bundle-Version: 1.12.600.qualifier
4+
Bundle-Version: 1.13.0.qualifier
55
Bundle-Name: %pluginName
66
Bundle-Vendor: %providerName
77
Bundle-Localization: plugin

runtime/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/contexts/IContextFunction.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@
1414

1515
package org.eclipse.e4.core.contexts;
1616

17+
import java.lang.annotation.Retention;
18+
import java.lang.annotation.RetentionPolicy;
1719
import org.osgi.framework.BundleContext;
20+
import org.osgi.service.component.annotations.ComponentPropertyType;
1821

1922
/**
2023
* A context function encapsulates evaluation of some code within an
@@ -58,9 +61,23 @@ public interface IContextFunction {
5861
* should be registered in.
5962
*
6063
* @see BundleContext#getServiceReference(String)
64+
* @see ServiceContextKey
6165
*/
6266
String SERVICE_CONTEXT_KEY = "service.context.key"; //$NON-NLS-1$
6367

68+
/**
69+
* An OSGi service component property type used to indicate the context key this
70+
* function should be registered in.
71+
*
72+
* @since 1.13
73+
* @see IContextFunction#SERVICE_CONTEXT_KEY
74+
*/
75+
@ComponentPropertyType
76+
@Retention(RetentionPolicy.SOURCE)
77+
public @interface ServiceContextKey {
78+
Class<?> value();
79+
}
80+
6481
/**
6582
* Evaluates the function based on the provided arguments and context to
6683
* produce a consistent result.

0 commit comments

Comments
 (0)