1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/samples/componentinjection/src/org/apidesign/component/DefineInjectionSlot.java Sat Jun 14 09:53:43 2008 +0200
1.3 @@ -0,0 +1,23 @@
1.4 +package org.apidesign.component;
1.5 +
1.6 +import java.util.Collection;
1.7 +import org.openide.util.Lookup;
1.8 +
1.9 +public class DefineInjectionSlot {
1.10 + private DefineInjectionSlot() {
1.11 + }
1.12 +
1.13 + // BEGIN: lookup.define.slot
1.14 + public static <T> T singleSlot(Class<T> clazz) {
1.15 + // get one implementation
1.16 + T instance = Lookup.getDefault().lookup(clazz);
1.17 + return instance;
1.18 + }
1.19 +
1.20 + public static <T> Collection<? extends T> multiSlot(Class<T> clazz) {
1.21 + // get all registered implementations
1.22 + Collection<? extends T> all = Lookup.getDefault().lookupAll(clazz);
1.23 + return all;
1.24 + }
1.25 + // END: lookup.define.slot
1.26 +}