Search in sources :

Example 46 with BeanMetaData

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));
}
Also used : NotificationHandlerRegistry(org.eclipse.scout.rt.shared.notification.NotificationHandlerRegistry) BeanMetaData(org.eclipse.scout.rt.platform.BeanMetaData) IBeanManager(org.eclipse.scout.rt.platform.IBeanManager) Before(org.junit.Before)

Example 47 with BeanMetaData

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));
}
Also used : BeanMetaData(org.eclipse.scout.rt.platform.BeanMetaData) Test(org.junit.Test)

Example 48 with BeanMetaData

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();
}
Also used : BeanMetaData(org.eclipse.scout.rt.platform.BeanMetaData) Test(org.junit.Test)

Example 49 with BeanMetaData

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();
}
Also used : BeanMetaData(org.eclipse.scout.rt.platform.BeanMetaData) PlatformEvent(org.eclipse.scout.rt.platform.PlatformEvent) PlatformException(org.eclipse.scout.rt.platform.exception.PlatformException) CountDownLatch(java.util.concurrent.CountDownLatch) IPlatformListener(org.eclipse.scout.rt.platform.IPlatformListener) Test(org.junit.Test)

Example 50 with BeanMetaData

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()));
}
Also used : BeanMetaData(org.eclipse.scout.rt.platform.BeanMetaData)

Aggregations

BeanMetaData (org.eclipse.scout.rt.platform.BeanMetaData)53 Test (org.junit.Test)18 Before (org.junit.Before)11 IBean (org.eclipse.scout.rt.platform.IBean)9 IBeanManager (org.eclipse.scout.rt.platform.IBeanManager)6 TestEnvironmentClientSession (org.eclipse.scout.rt.client.testenvironment.TestEnvironmentClientSession)5 Callable (java.util.concurrent.Callable)3 JobCompletionDelayOnSessionShutdown (org.eclipse.scout.rt.client.ClientConfigProperties.JobCompletionDelayOnSessionShutdown)3 IRunnable (org.eclipse.scout.rt.platform.util.concurrent.IRunnable)3 After (org.junit.After)3 ArrayList (java.util.ArrayList)2 Subject (javax.security.auth.Subject)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 HttpServletResponse (javax.servlet.http.HttpServletResponse)2 HttpSession (javax.servlet.http.HttpSession)2 IMomImplementor (org.eclipse.scout.rt.mom.api.IMomImplementor)2 NullMomImplementor (org.eclipse.scout.rt.mom.api.NullMomImplementor)2 PlatformException (org.eclipse.scout.rt.platform.exception.PlatformException)2 JaxWsImplementorSpecifics (org.eclipse.scout.rt.server.jaxws.implementor.JaxWsImplementorSpecifics)2 IClusterSynchronizationService (org.eclipse.scout.rt.server.services.common.clustersync.IClusterSynchronizationService)2