|
22 | 22 | import org.osgi.service.component.annotations.Activate; |
23 | 23 | import org.osgi.service.component.annotations.Component; |
24 | 24 | import org.osgi.service.component.annotations.Reference; |
25 | | -import org.osgi.service.component.annotations.ReferencePolicyOption; |
26 | | -import org.osgi.service.component.annotations.ServiceScope; |
| 25 | +import org.osgi.service.component.annotations.ReferenceCardinality; |
| 26 | +import org.osgi.service.component.annotations.ReferencePolicy; |
27 | 27 |
|
28 | 28 | import java.lang.reflect.AnnotatedParameterizedType; |
29 | 29 | import java.lang.reflect.AnnotatedType; |
|
41 | 41 | import static graphql.annotations.util.NamingKit.toGraphqlName; |
42 | 42 | import static graphql.schema.GraphQLEnumType.newEnum; |
43 | 43 |
|
44 | | -@Component(scope = ServiceScope.SINGLETON, property = "type=default") |
| 44 | +@Component(property = "type=default") |
45 | 45 | public class DefaultTypeFunction implements TypeFunction { |
46 | 46 |
|
47 | | - @Reference(target = "(!(type=default))", |
48 | | - policyOption = ReferencePolicyOption.GREEDY) |
49 | 47 | protected List<TypeFunction> otherFunctions = new ArrayList<>(); |
50 | 48 |
|
51 | 49 | private CopyOnWriteArrayList<TypeFunction> typeFunctions; |
@@ -355,6 +353,18 @@ public DefaultTypeFunction() { |
355 | 353 | typeFunctions.add(new ObjectFunction()); |
356 | 354 | } |
357 | 355 |
|
| 356 | + @Reference(cardinality = ReferenceCardinality.MULTIPLE, |
| 357 | + policy = ReferencePolicy.DYNAMIC, |
| 358 | + service = TypeFunction.class, |
| 359 | + target = "(!(type=default))") |
| 360 | + void addFunction(TypeFunction function) { |
| 361 | + this.otherFunctions.add(function); |
| 362 | + } |
| 363 | + |
| 364 | + void removeFunction(TypeFunction function) { |
| 365 | + this.otherFunctions.remove(function); |
| 366 | + } |
| 367 | + |
358 | 368 | @Activate |
359 | 369 | protected void activate() { |
360 | 370 | for (TypeFunction function : otherFunctions) { |
|
0 commit comments