本文整理了Java中info.magnolia.objectfactory.Components.getComponentWithAnnotation()
方法的一些代码示例,展示了Components.getComponentWithAnnotation()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Components.getComponentWithAnnotation()
方法的具体详情如下:
包路径:info.magnolia.objectfactory.Components
类名称:Components
方法名:getComponentWithAnnotation
暂无
代码示例来源:origin: info.magnolia.cache/magnolia-cache-core
/**
* @deprecated since 5.4.5 - use {@link CacheModule#CacheModule(CacheMonitor, EventBus)} instead.
*/
@Deprecated
public CacheModule(CacheMonitor cacheMonitor) {
this(cacheMonitor, Components.getComponentWithAnnotation(EventBus.class, Components.named(SystemEventBus.NAME)));
}
代码示例来源:origin: info.magnolia/magnolia-core
/**
* @deprecated since 5.4.5 use {@link #CommandsManager(ModuleRegistry, Node2BeanProcessor, EventBus)}
*/
@Deprecated
public CommandsManager(Node2BeanProcessor nodeToBean) {
this(Components.getComponent(ModuleRegistry.class), nodeToBean, Components.getComponentWithAnnotation(EventBus.class, Components.named(SystemEventBus.NAME)));
}
代码示例来源:origin: info.magnolia/magnolia-core
@Test(expected = NoSuchComponentException.class)
public void getComponentWithAnnotationThrowsExceptionIfComponentProviderIsNotAGuiceComponentProvider() {
// WHEN
Components.getComponentWithAnnotation(String.class, Components.named("third"));
}
}
代码示例来源:origin: info.magnolia/magnolia-core
EventBus systemEventBus = Components.getComponentWithAnnotation(EventBus.class, Components.named(SystemEventBus.NAME));
systemEventBus.fireEvent(new ModulesStartedEvent());
代码示例来源:origin: info.magnolia.ui/magnolia-ui-framework
private void createEagerSingletons() {
final List<UiContextReference> availableContextKeys = CurrentUiContextReference.get().getAvailableContextReferences();
for (final Key<?> singletonKey : eagerSingletons) {
// We need to ensure that the instance of the type actually needs to be eagerly initialised in _current_ context.
// Example of when we should _not_ try to create an instance:
// - current context is e.g. app 'FOO'
// - the key is bound with annotation relevant to app 'BAR'
// - the current scope may be the eager app scope, but the binding is not relevant in current context
// If binding is not annotated with Ui context annotation - means that it is not picky about the
// current UI context and always needs to be initialised;
boolean isUiContextAgnostic = !(singletonKey.getAnnotation() instanceof UiContextAnnotation);
// Otherwise we make sure that the binding is relevant to the current context
boolean shouldEagerlyInitialise = isUiContextAgnostic || matchingUiContextKeyExists(availableContextKeys, singletonKey.getAnnotation());
if (shouldEagerlyInitialise) {
if (singletonKey.getAnnotation() == null) {
Components.getComponent(singletonKey.getTypeLiteral().getRawType());
} else {
Components.getComponentWithAnnotation(singletonKey.getTypeLiteral().getRawType(), singletonKey.getAnnotation());
}
}
}
}
代码示例来源:origin: info.magnolia/magnolia-core
@Test
public void getComponentWithAnnotationReturnsCorrectInstance() {
// GIVEN
GuiceComponentProviderBuilder builder = new GuiceComponentProviderBuilder();
builder.addModule(new AbstractModule() {
@Override
protected void configure() {
bind(String.class).annotatedWith(Components.named("first")).toInstance("first");
bind(String.class).annotatedWith(Components.named("second")).toInstance("second");
}
});
builder.exposeGlobally();
builder.build();
// THEN
assertEquals("first", Components.getComponentWithAnnotation(String.class, Components.named("first")));
assertEquals("second", Components.getComponentWithAnnotation(String.class, Components.named("second")));
}
代码示例来源:origin: info.magnolia.ui/magnolia-ui-framework
@Before
public void setUp() throws Exception {
initAppRegistry();
final MockWebContext ctx = new MockWebContext();
MgnlContext.setInstance(ctx);
this.eventCollector = new AppEventCollector();
this.vaadinSession.start(prepareComponentConfigurations());
Components.getComponentWithAnnotation(EventBus.class, Names.named(AdmincentralEventBus.NAME)).addHandler(AppLifecycleEvent.class, eventCollector);
this.appController = (AppControllerImpl) Components.getComponent(AppController.class);
appController.setViewport(mock(Viewport.class));
}
代码示例来源:origin: info.magnolia/magnolia-core
@Test(expected = NoSuchComponentException.class)
public void getComponentWithAnnotationThrowsExceptionIfComponentNotConfigured() {
// GIVEN
GuiceComponentProviderBuilder builder = new GuiceComponentProviderBuilder();
builder.addModule(new AbstractModule() {
@Override
protected void configure() {
bind(String.class).annotatedWith(Components.named("first")).toInstance("first");
bind(String.class).annotatedWith(Components.named("second")).toInstance("second");
}
});
builder.exposeGlobally();
builder.build();
// WHEN
Components.getComponentWithAnnotation(String.class, Components.named("third"));
}
代码示例来源:origin: info.magnolia.ui/magnolia-ui-framework
@Before
public void setUp() throws Exception {
WebContext ctx = new MockWebContext();
MgnlContext.setInstance(ctx);
initAppRegistry();
EventBus systemEventBus = eventBus.get();
this.eventCollector = new AppEventCollector();
systemEventBus.addHandler(AppLifecycleEvent.class, eventCollector);
this.vaadinSession.start(prepareComponentConfigurations());
this.locationController = Components.getComponent(LocationController.class);
Components.getComponentWithAnnotation(EventBus.class, Names.named(AdmincentralEventBus.NAME)).addHandler(AppLifecycleEvent.class, eventCollector);
appController = (AppControllerImpl) Components.getComponent(AppController.class);
appController.setViewport(mock(Viewport.class));
}
内容来源于网络,如有侵权,请联系作者删除!