本文整理汇总了Java中org.jboss.msc.inject.Injector.uninject方法的典型用法代码示例。如果您正苦于以下问题:Java Injector.uninject方法的具体用法?Java Injector.uninject怎么用?Java Injector.uninject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jboss.msc.inject.Injector
的用法示例。
在下文中一共展示了Injector.uninject方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test_1
import org.jboss.msc.inject.Injector; //导入方法依赖的package包/类
static void test_1(){
final AtomicReference<String> reference = new AtomicReference<String>();
final Injector<String> injector = new AtomicReferenceInjector<String>(reference);
injector.inject("Hello World");
System.out.println(reference.get());
injector.uninject();
}
示例2: test_2
import org.jboss.msc.inject.Injector; //导入方法依赖的package包/类
static void test_2() throws NoSuchFieldException, SecurityException {
final Field field = SimplePojo.class.getField("description");
final SimplePojo pojo = new SimplePojo();
final Injector<String> injector = new FieldInjector<String>(Values.immediateValue(pojo), field);
injector.inject("Injection of description field");
System.out.println(pojo.description);
injector.uninject();
}
示例3: test_4
import org.jboss.msc.inject.Injector; //导入方法依赖的package包/类
static void test_4() throws NoSuchMethodException, SecurityException {
Value<SimplePojo> target = new ImmediateValue<>(new SimplePojo());
Method method = SimplePojo.class.getMethod("setId", Integer.class);
final Injector<Integer> injector = SetMethodInjector.<Integer>create(target, method);
injector.inject(1000);
System.out.println(target.getValue().getId());
injector.uninject();
}
示例4: main
import org.jboss.msc.inject.Injector; //导入方法依赖的package包/类
public static void main(String[] args) throws NoSuchFieldException, SecurityException, NoSuchMethodException {
final Field field = SimplePojo.class.getField("listField");
List<String> list = new ArrayList<>();
SimplePojo pojo = new SimplePojo();
list.add("Hello World");
final Injector<List> fieldInjector = new FieldInjector<>(Values.immediateValue(pojo), field);
final Injector<Object> castingInjector = Injectors.cast(fieldInjector, List.class);
castingInjector.inject(list);
System.out.println(pojo.listField.get(0));
castingInjector.uninject();
}