Skip to content

Commit 190a5a2

Browse files
committed
Remove remaining pseudo dependency of E4-Injector to jakarta annotations
This ensures that the E4-Injector does not work with any specific annotation class.
1 parent 771d533 commit 190a5a2

5 files changed

Lines changed: 25 additions & 42 deletions

File tree

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@ Export-Package: org.eclipse.e4.core.di;version="1.7.0",
1515
org.eclipse.e4.core.internal.di.osgi;x-internal:=true,
1616
org.eclipse.e4.core.internal.di.shared;x-friends:="org.eclipse.e4.core.contexts,org.eclipse.e4.core.di.extensions.supplier"
1717
Require-Bundle: org.eclipse.e4.core.di.annotations;bundle-version="[1.4.0,2.0.0)";visibility:=reexport
18-
Import-Package: jakarta.annotation;version="[2.0.0,4.0.0)",
19-
jakarta.inject;version="[2,3)",
20-
org.eclipse.osgi.framework.log;version="1.1.0",
18+
Import-Package: org.eclipse.osgi.framework.log;version="1.1.0",
2119
org.osgi.framework;version="[1.8.0,2.0.0)",
2220
org.osgi.util.tracker;version="[1.5.1,2.0.0)"
2321
Automatic-Module-Name: org.eclipse.e4.core.di

runtime/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/di/IInjector.java

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2010, 2017 IBM Corporation and others.
2+
* Copyright (c) 2010, 2026 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -14,10 +14,6 @@
1414
*******************************************************************************/
1515
package org.eclipse.e4.core.di;
1616

17-
import jakarta.annotation.PostConstruct;
18-
import jakarta.annotation.PreDestroy;
19-
import jakarta.inject.Scope;
20-
import jakarta.inject.Singleton;
2117
import java.lang.annotation.Annotation;
2218
import org.eclipse.e4.core.di.suppliers.PrimaryObjectSupplier;
2319

@@ -37,7 +33,8 @@
3733
* The injection of values is generally done as a number of calls. User objects
3834
* that want to finalize the injected data (for instance, to perform
3935
* calculations based on multiple injected values) can place such calculations
40-
* in a method with the {@link PostConstruct} annotation.
36+
* in a method with a {@code PostConstruct} annotation, e.g.
37+
* {@code jakarta.annotation.PostConstruct}
4138
* </p>
4239
* <p>
4340
* When injecting values, all fields are injected prior to injection of methods.
@@ -51,7 +48,8 @@
5148
* </p>
5249
* <p>
5350
* When supplier is disposed, the injector will attempt to notify all injected
54-
* objects by calling methods with the {@link PreDestroy} annotation.
51+
* objects by calling methods with a {@code PreDestroy} annotation, e.g.
52+
* {@code jakarta.annotation.PreDestroy}.
5553
*
5654
* @noimplement This interface is not intended to be implemented by clients.
5755
* @noextend This interface is not intended to be extended by clients.
@@ -151,13 +149,16 @@ void inject(Object object, PrimaryObjectSupplier objectSupplier, PrimaryObjectSu
151149

152150
/**
153151
* Obtain an instance of the specified class and inject it with the data from the supplier.
152+
* <p>
153+
* For examples, see also {@code jakarta.inject.Scope} or
154+
* {@code jakarta.inject.Singleton}.
155+
* </p>
156+
*
154157
* @param <T> the type of the object to be created
155158
* @param clazz the class to be instantiated
156159
* @param objectSupplier primary object supplier for the injection
157160
* @return an instance of the specified class
158161
* @throws InjectionException if an exception occurred while performing this operation
159-
* @see Scope
160-
* @see Singleton
161162
*/
162163
<T> T make(Class<T> clazz, PrimaryObjectSupplier objectSupplier) throws InjectionException;
163164

@@ -168,14 +169,17 @@ void inject(Object object, PrimaryObjectSupplier objectSupplier, PrimaryObjectSu
168169
* the static supplier are injected. Injected values from the static supplier are not tracked and no links
169170
* between the static supplier and the object are established.
170171
* </p>
172+
* <p>
173+
* For examples, see also {@code jakarta.inject.Scope} or
174+
* {@code jakarta.inject.Singleton}.
175+
* </p>
176+
*
171177
* @param <T> the type of the object to be created
172178
* @param clazz the class to be instantiated
173179
* @param objectSupplier primary object supplier for the injection
174180
* @param staticSupplier additional object supplier for the injection, changes in injected values are not tracked
175181
* @return an instance of the specified class
176182
* @throws InjectionException if an exception occurred while performing this operation
177-
* @see Scope
178-
* @see Singleton
179183
*/
180184
<T> T make(Class<T> clazz, PrimaryObjectSupplier objectSupplier, PrimaryObjectSupplier staticSupplier) throws InjectionException;
181185

runtime/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/di/suppliers/ExtendedObjectSupplier.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2009, 2010 IBM Corporation and others.
2+
* Copyright (c) 2009, 2026 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,8 +13,6 @@
1313
*******************************************************************************/
1414
package org.eclipse.e4.core.di.suppliers;
1515

16-
import org.osgi.framework.BundleContext;
17-
1816
/**
1917
* The base class for an "object supplier" - something that knows how to
2018
* instantiate objects corresponding to the object descriptor. Extended object
@@ -39,15 +37,15 @@ abstract public class ExtendedObjectSupplier {
3937
* The OSGi service name for an object provider service. This name can be used to obtain
4038
* instances of the service.
4139
*
42-
* @see BundleContext#getServiceReference(String)
40+
* @see org.osgi.framework.BundleContext#getServiceReference(String)
4341
*/
4442
public static final String SERVICE_NAME = ExtendedObjectSupplier.class.getName();
4543

4644
/**
4745
* An OSGi service property used to indicate the context key this function should be registered
4846
* in.
4947
*
50-
* @see BundleContext#getServiceReference(String)
48+
* @see org.osgi.framework.BundleContext#getServiceReference(String)
5149
*/
5250
public static final String SERVICE_CONTEXT_KEY = "dependency.injection.annotation"; //$NON-NLS-1$
5351

runtime/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/di/suppliers/IObjectDescriptor.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@
2222
* From the view point of the injector, objects are described by a type with a
2323
* set of optional qualifiers.
2424
* </p>
25+
* <p>
26+
* For example, see also {@code jakarta.inject.Qualifier}.
27+
* </p>
2528
*
26-
* @see jakarta.inject.Qualifier
2729
* @noextend This interface is not intended to be extended by clients.
2830
* @noimplement This interface is not intended to be implemented by clients.
2931
* @since 1.7
Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2010, 2015 IBM Corporation and others.
2+
* Copyright (c) 2010, 2026 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,11 +13,8 @@
1313
*******************************************************************************/
1414
package org.eclipse.e4.core.internal.di;
1515

16-
import jakarta.inject.Named;
17-
import java.lang.reflect.Field;
1816
import org.eclipse.e4.core.di.IInjector;
1917
import org.eclipse.e4.core.di.InjectionException;
20-
import org.eclipse.e4.core.di.annotations.Optional;
2118
import org.eclipse.e4.core.di.suppliers.IObjectDescriptor;
2219
import org.eclipse.e4.core.di.suppliers.PrimaryObjectSupplier;
2320

@@ -29,11 +26,7 @@
2926
*/
3027
public class ClassRequestor extends Requestor<Class<?>> {
3128

32-
@Optional
33-
@Named("e4.internal.injectionLink")
34-
final static public String pseudoVariable = null;
35-
36-
private static IObjectDescriptor[] pseudoVariableDescriptor;
29+
private static IObjectDescriptor[] pseudoVariableDescriptor = {};
3730

3831
public ClassRequestor(Class<?> clazz, IInjector injector, PrimaryObjectSupplier primarySupplier, PrimaryObjectSupplier tempSupplier, Object requestingObject, boolean track) {
3932
super(clazz, injector, primarySupplier, tempSupplier, requestingObject, track);
@@ -47,18 +40,6 @@ public Object execute() throws InjectionException {
4740

4841
@Override
4942
public IObjectDescriptor[] calcDependentObjects() {
50-
if (pseudoVariableDescriptor == null) {
51-
Field field = null;
52-
try {
53-
field = ClassRequestor.class.getField("pseudoVariable"); //$NON-NLS-1$
54-
} catch (SecurityException | NoSuchFieldException e) {
55-
e.printStackTrace(); // tested - not going to happen
56-
return null;
57-
}
58-
pseudoVariableDescriptor = new IObjectDescriptor[] {
59-
new ObjectDescriptor(field.getGenericType(), field.getAnnotations()) };
60-
}
61-
6243
return pseudoVariableDescriptor;
6344
}
6445

@@ -69,7 +50,7 @@ public String toString() {
6950
tmp.append(location.getSimpleName());
7051
}
7152
tmp.append('.');
72-
tmp.append(pseudoVariable);
53+
tmp.append("pseudoVariable"); //$NON-NLS-1$
7354
return tmp.toString();
7455
}
7556
}

0 commit comments

Comments
 (0)