author | Jaroslav Tulach <jtulach@netbeans.org> |
Sat, 14 Jun 2008 09:53:43 +0200 | |
changeset 81 | fda142e38ae4 |
permissions | -rw-r--r-- |
jtulach@81 | 1 |
package org.apidesign.component; |
jtulach@81 | 2 |
|
jtulach@81 | 3 |
import java.util.Collection; |
jtulach@81 | 4 |
import org.openide.util.Lookup; |
jtulach@81 | 5 |
|
jtulach@81 | 6 |
public class DefineInjectionSlot { |
jtulach@81 | 7 |
private DefineInjectionSlot() { |
jtulach@81 | 8 |
} |
jtulach@81 | 9 |
|
jtulach@81 | 10 |
// BEGIN: lookup.define.slot |
jtulach@81 | 11 |
public static <T> T singleSlot(Class<T> clazz) { |
jtulach@81 | 12 |
// get one implementation |
jtulach@81 | 13 |
T instance = Lookup.getDefault().lookup(clazz); |
jtulach@81 | 14 |
return instance; |
jtulach@81 | 15 |
} |
jtulach@81 | 16 |
|
jtulach@81 | 17 |
public static <T> Collection<? extends T> multiSlot(Class<T> clazz) { |
jtulach@81 | 18 |
// get all registered implementations |
jtulach@81 | 19 |
Collection<? extends T> all = Lookup.getDefault().lookupAll(clazz); |
jtulach@81 | 20 |
return all; |
jtulach@81 | 21 |
} |
jtulach@81 | 22 |
// END: lookup.define.slot |
jtulach@81 | 23 |
} |