org.jboss.errai.ioc.client.container.IOC.getBeanManager()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(7.6k)|赞(0)|评价(0)|浏览(278)

本文整理了Java中org.jboss.errai.ioc.client.container.IOC.getBeanManager()方法的一些代码示例,展示了IOC.getBeanManager()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。IOC.getBeanManager()方法的具体详情如下:
包路径:org.jboss.errai.ioc.client.container.IOC
类名称:IOC
方法名:getBeanManager

IOC.getBeanManager介绍

[英]Returns a reference to the bean manager in the client.
[中]返回对客户端中bean管理器的引用。

代码示例

代码示例来源:origin: errai/errai

@IOCProducer
 public SyncBeanManager get() {
  return IOC.getBeanManager();
 }
}

代码示例来源:origin: errai/errai

@Override
 public void callback(final Foo beanInstance) {
  try {
   final Foo instance = IOC.getBeanManager().lookupBean(Foo.class).getInstance();
   assertEquals(beanInstance, instance);
   finishTest();
  } catch (IOCResolutionException e) {
   fail("Should have been able to perform sync lookup for instance of " + Foo.class.getSimpleName()
       + " after async loading.");
  }
 }
});

代码示例来源:origin: errai/errai

public void testTypeWithLoadAsyncIsNotAvailableThroughSyncLookup() throws Exception {
 try {
  IOC.getBeanManager().lookupBean(Foo.class);
  fail("Should not have been able to lookup " + Foo.class.getSimpleName() + " with " + LoadAsync.class.getSimpleName() + " annotation via the SyncBeanManager.");
 } catch (IOCResolutionException e) {
 }
}

代码示例来源:origin: errai/errai

public void testDependentBeanWithConstructorInjectionCausingCycyleDoesNotBlowUp() throws Exception {
 try {
  IOC.getBeanManager().lookupBean(DependentBeanWithConstructorCycle.class).getInstance();
 } catch (final RuntimeException e) {
  throw new AssertionError("Could not lookup the dependent bean without error: " + e.getMessage(), e);
 }
}

代码示例来源:origin: errai/errai

public void testDependentScopeWithPrivateConstr() throws Exception {
 try {
  IOC.getBeanManager().lookupBean(DependentWithPrivateConstr.class).getInstance();
 } catch (final Throwable t) {
  throw new AssertionError("Could not create instance of bean with private constructor.", t);
 }
}

代码示例来源:origin: errai/errai

public void testProducerMethodOfJsType() throws Exception {
 final ConsumesProducedJsType consumer = IOC.getBeanManager().lookupBean(ConsumesProducedJsType.class).getInstance();
 assertNotNull(consumer.instance);
 assertTrue(consumer.instance instanceof ProducedJsType);
 assertEquals(1, IOC.getBeanManager().lookupBeans(ProducedJsType.class).size());
}

代码示例来源:origin: errai/errai

public void testBlacklistedPackage() throws Exception {
  try {
   IOC.getBeanManager().lookupBean(BlacklistedPackageBean.class).getInstance();
   fail("Should not be able to resolve a bean in a blacklisted package!");
  }
  catch (IOCResolutionException e) {
   // expected
  }
 }
}

代码示例来源:origin: errai/errai

public void testSimpleLoggerFieldInjection() throws Exception {
 ClassWithLoggerField instance = IOC.getBeanManager().lookupBean(ClassWithLoggerField.class).getInstance();
 assertNotNull("Logger was not injected", instance.getLogger());
 assertEquals("Logger should have name of enclosing class", ClassWithLoggerField.class.getName(), instance
     .getLogger().getName());
}

代码示例来源:origin: errai/errai

public void testDestroyingProducedBeanOfDependentScopedProducerUsingFieldInjectedManagedInstance() throws Exception {
 final OtherDestructableClass producedBean = getBeanManager().lookupBean(OtherDestructableClass.class, c).getInstance();
 assertFalse(producedBean.isDestroyed());
 getBeanManager().destroyBean(producedBean);
 assertTrue(producedBean.isDestroyed());
}

代码示例来源:origin: errai/errai

public void testDisposerMethodCalledOnProviderWhenProvidedBeanIsDestroyed() throws Exception {
 final BeanWithProvidedBeansInjected module = IOC.getBeanManager().lookupBean(BeanWithProvidedBeansInjected.class).getInstance();
 assertFalse("Bean was prematurely destroyed.", module.providedBean.isDestroyed());
 IOC.getBeanManager().destroyBean(module.providedBean);
 assertTrue("Disposer method not called after bean was destroyed.", module.providedBean.isDestroyed());
}

代码示例来源:origin: errai/errai

public void testInitializationStatementsInvoked() throws Exception {
 final MyDecoratedBean instance = IOC.getBeanManager().lookupBean(MyDecoratedBean.class).getInstance();
 // setFlag(true) should be called by init callback.
 assertTrue(instance.isFlag());
}

代码示例来源:origin: errai/errai

public void testBeanManagerInjectable() {
 final BeanManagerDependentBean bean = IOC.getBeanManager().lookupBean(BeanManagerDependentBean.class)
     .getInstance();
 final ClientBeanManager beanManager = (GWT.<IOCEnvironment>create(IOCEnvironment.class).isAsync() ? IOC.getAsyncBeanManager() : IOC.getBeanManager());
 assertSame(beanManager, Factory.maybeUnwrapProxy(bean.getBeanManager()));
}

代码示例来源:origin: errai/errai

public void testLocalBeanSatisfiesExternalJsTypeInterfaceForDefaultInjectionSite() throws Exception {
 final ExternalTestModule module = IOC.getBeanManager().lookupBean(ExternalTestModule.class).getInstance();
 assertNotNull(module.defaultExternalIface);
 assertEquals(ExternalJsTypeImpl.class.getSimpleName(), module.defaultExternalIface.message());
 assertTrue(module.defaultExternalIface instanceof ExternalJsTypeImpl);
}

代码示例来源:origin: errai/errai

public void testDisposerFailsToDestroyAppScope() {
 final SingletonBeanWithDisposer outerBean = IOC.getBeanManager().lookupBean(SingletonBeanWithDisposer.class).getInstance();
 assertNotNull(outerBean);
 assertNotNull(outerBean.getDependentBeanDisposer());
 final DependentBean innerBean = outerBean.getBean();
 assertNotNull(innerBean);
 outerBean.dispose();
 assertFalse("inner bean should have been disposed", IOC.getBeanManager().isManaged(innerBean));
 assertTrue("outer bean should not have been disposed", IOC.getBeanManager().isManaged(outerBean));
 assertTrue("bean's destructor should have been called", innerBean.isPreDestroyCalled());
}

代码示例来源:origin: errai/errai

public void testWindowContextBeanSatisfiesConcreteWindowScopedJsTypeForDefaultInjectionSite() throws Exception {
 final ExternalTestModule module = IOC.getBeanManager().lookupBean(ExternalTestModule.class).getInstance();
 assertNotNull(module.defaultConcreteWindowScopedJsType);
 assertEquals("external", module.defaultConcreteWindowScopedJsType.message());
}

代码示例来源:origin: errai/errai

public void testWindowContextBeanSatisfiesExternalJsTypeInterfaceForExternalInjectionSite() throws Exception {
 final ExternalTestModule module = IOC.getBeanManager().lookupBean(ExternalTestModule.class).getInstance();
 assertNotNull(module.externalExternalIface);
 assertEquals("external", module.externalExternalIface.message());
 assertFalse(module.externalExternalIface instanceof ExternalJsTypeImpl);
}

代码示例来源:origin: errai/errai

public void testInjectionFromProviderContextual() {
 final SimpleBean2 simpleBean2 = IOC.getBeanManager().lookupBean(SimpleBean2.class).getInstance();
 assertEquals("FOO", simpleBean2.getMessage());
 assertEquals("java.lang.String", simpleBean2.getbSvc().get());
}

代码示例来源:origin: errai/errai

public void testAlternativeBeanInjection() throws Exception {
 // AlternativeBeanA should be configured as an alternative in the ErraiApp.properties of this
 // test module.
 AlternativeDependentBean bean = IOC.getBeanManager().lookupBean(AlternativeDependentBean.class).getInstance();
 assertNotNull(bean);
 assertNotNull(bean.getCommonInterface());
 assertTrue("wrong instance of bean injected", bean.getCommonInterface() instanceof AlternativeBeanA);
}

代码示例来源:origin: errai/errai

public void testSetterMethodInjection() {
 final SetterInjectionBean bean = IOC.getBeanManager().lookupBean(SetterInjectionBean.class)
     .getInstance();
 assertNotNull(bean);
 assertNotNull(bean.getServiceA());
 assertNotNull(bean.getServiceB());
}

代码示例来源:origin: errai/errai

public void testProvidedValueLookup() {
 final TestProviderDependentBean dependentBean = IOC.getBeanManager().lookupBean(TestProviderDependentBean.class)
   .getInstance();
 assertNotNull(dependentBean);
 assertNotNull(dependentBean.getTestProvidedIface());
 assertEquals("foo", dependentBean.getTestProvidedIface().getText());
}

相关文章