use of org.eclipse.scout.rt.platform.BeanMetaData in project scout.rt by eclipse.
the class NotificationDispatcherTest method before.
@Before
public void before() throws Exception {
m_globalNotificationHanlder = mock(GlobalNotificationHandler.class);
m_groupNotificationHanlder = mock(GroupNotificationHandler.class);
m_serviceReg = TestingUtility.registerBeans(new BeanMetaData(GlobalNotificationHandler.class).withInitialInstance(m_globalNotificationHanlder).withApplicationScoped(true), new BeanMetaData(GroupNotificationHandler.class).withInitialInstance(m_groupNotificationHanlder).withApplicationScoped(true));
// ensure bean hander cache of notification dispatcher gets refreshed
IBeanManager beanManager = BEANS.getBeanManager();
IBean<NotificationHandlerRegistry> bean = beanManager.getBean(NotificationHandlerRegistry.class);
beanManager.unregisterBean(bean);
beanManager.registerBean(new BeanMetaData(bean));
}
use of org.eclipse.scout.rt.platform.BeanMetaData in project scout.rt by eclipse.
the class BeanHierarchyTest method testGetRegisteredBean.
@Test
public void testGetRegisteredBean() {
BeanHierarchy<AbstractBaseClass> h = new BeanHierarchy<>(AbstractBaseClass.class);
h.addBean(new BeanImplementor<AbstractBaseClass>(new BeanMetaData(SubClassA.class)));
h.addBean(new BeanImplementor<AbstractBaseClass>(new BeanMetaData(SubClassB.class)));
h.addBean(new BeanImplementor<AbstractBaseClass>(new BeanMetaData(SubClassB1.class).withReplace(true)));
h.addBean(new BeanImplementor<AbstractBaseClass>(new BeanMetaData(SubClassB2.class).withReplace(true).withOrder(IBean.DEFAULT_BEAN_ORDER - 1)));
assertEquals(SubClassA.class, h.getExactBean(SubClassA.class).getBeanClazz());
assertEquals(SubClassB.class, h.getExactBean(SubClassB.class).getBeanClazz());
assertEquals(SubClassB1.class, h.getExactBean(SubClassB1.class).getBeanClazz());
assertEquals(SubClassB2.class, h.getExactBean(SubClassB2.class).getBeanClazz());
assertNull(h.getExactBean(String.class));
}
use of org.eclipse.scout.rt.platform.BeanMetaData in project scout.rt by eclipse.
the class BeanHierarchyTest method testReplaceWithAbstractSuperClass.
@Test(expected = AssertionException.class)
public void testReplaceWithAbstractSuperClass() {
BeanHierarchy<InvalidReplaceWithAbstractSuperClass> h = new BeanHierarchy<InvalidReplaceWithAbstractSuperClass>(InvalidReplaceWithAbstractSuperClass.class);
BeanMetaData withReplace = new BeanMetaData(InvalidReplaceWithAbstractSuperClass.class).withReplace(true);
h.addBean(new BeanImplementor<InvalidReplaceWithAbstractSuperClass>(withReplace));
h.queryAll();
Assert.fail();
}
use of org.eclipse.scout.rt.platform.BeanMetaData in project scout.rt by eclipse.
the class PlatformImplementorTest method testAwaitPlatformStartedFailsInPlatformStopping.
@Test
public void testAwaitPlatformStartedFailsInPlatformStopping() throws Exception {
final CountDownLatch stoppingLatch = new CountDownLatch(1);
final CountDownLatch continueStoppingLatch = new CountDownLatch(1);
// crate platform listener that signals stopping state
BeanMetaData bean = new BeanMetaData(IPlatformListener.class).withApplicationScoped(true).withInitialInstance(new IPlatformListener() {
@Override
public void stateChanged(PlatformEvent event) {
if (event.getState() == State.PlatformStopping) {
stoppingLatch.countDown();
try {
continueStoppingLatch.await();
} catch (InterruptedException e) {
// nop
}
}
}
});
final TestingPlatformImplementor platform = new TestingPlatformImplementor(bean);
platform.start();
// expect platform started
platform.awaitPlatformStarted();
Future<?> platformStopFuture = s_executor.submit(new Runnable() {
@Override
public void run() {
platform.stop();
}
});
stoppingLatch.await();
try {
platform.awaitPlatformStarted();
} catch (PlatformException e) {
assertEquals("The platform is stopping.", e.getMessage());
}
continueStoppingLatch.countDown();
platformStopFuture.get();
}
use of org.eclipse.scout.rt.platform.BeanMetaData in project scout.rt by eclipse.
the class BeanManagerImplementor method getDecoratedBean.
protected <T> IBean<T> getDecoratedBean(IBean<T> bean, Class<T> beanClazz, IBeanDecorationFactory beanDecorationFactory) {
IBeanDecorator<T> decorator = beanDecorationFactory.decorate(bean, beanClazz);
if (decorator == null) {
return bean;
}
T proxy = new BeanProxyImplementor<T>(bean, decorator, beanClazz).getProxy();
return createBeanImplementor(new BeanMetaData(beanClazz).withInitialInstance(proxy).withAnnotations(bean.getBeanAnnotations().values()));
}
Aggregations