Search in sources :

Example 41 with BeanMetaData

use of org.eclipse.scout.rt.platform.BeanMetaData in project scout.rt by eclipse.

the class JandexJacksonAnnotationIntrospectorTest method beforeClass.

@BeforeClass
public static void beforeClass() {
    // Note AbstractBeanBaseClass is not registered in bean manager, since abstract classes are also excluded from bean manager registration in real Scout platform implementation (see BeanFilter class)
    TestingUtility.registerBean(new BeanMetaData(BeanBaseClass.class));
    TestingUtility.registerBean(new BeanMetaData(BeanChildClassA.class));
    TestingUtility.registerBean(new BeanMetaData(BeanChildClassB.class));
    TestingUtility.registerBean(new BeanMetaData(BeanChildClassBSub.class).withReplace(true));
    TestingUtility.registerBean(new BeanMetaData(BeanChildClassC.class));
    TestingUtility.registerBean(new BeanMetaData(BeanChildClassCSub1.class));
    TestingUtility.registerBean(new BeanMetaData(BeanChildClassCSub2.class).withReplace(true));
}
Also used : BeanMetaData(org.eclipse.scout.rt.platform.BeanMetaData) BeforeClass(org.junit.BeforeClass)

Example 42 with BeanMetaData

use of org.eclipse.scout.rt.platform.BeanMetaData in project scout.rt by eclipse.

the class SelectIntoTest method before.

@Before
public void before() throws Exception {
    SqlServiceMock sqlService = new SqlServiceMock();
    m_beans = TestingUtility.registerBeans(new BeanMetaData(ISqlService.class).withInitialInstance(sqlService).withApplicationScoped(true));
}
Also used : BeanMetaData(org.eclipse.scout.rt.platform.BeanMetaData) SqlServiceMock(org.eclipse.scout.rt.server.jdbc.fixture.SqlServiceMock) Before(org.junit.Before)

Example 43 with BeanMetaData

use of org.eclipse.scout.rt.platform.BeanMetaData in project scout.rt by eclipse.

the class ServiceTunnelUtility method createProxy.

public static <T> T createProxy(Class<T> serviceInterfaceClass) {
    ServiceTunnelProxyProducer<?> tunnelProxyProducer = new ServiceTunnelProxyProducer<>(serviceInterfaceClass);
    BeanMetaData metaData = new BeanMetaData(serviceInterfaceClass).withApplicationScoped(true).withProducer(tunnelProxyProducer);
    IBean<T> bean = new BeanImplementor<>(metaData);
    IBeanDecorationFactory factory = BEANS.opt(IBeanDecorationFactory.class);
    if (factory == null) {
        return bean.getInstance();
    }
    IBeanDecorator<T> decorator = factory.decorate(bean, serviceInterfaceClass);
    if (decorator == null) {
        return bean.getInstance();
    }
    return new BeanProxyImplementor<T>(bean, decorator, serviceInterfaceClass).getProxy();
}
Also used : IBeanDecorationFactory(org.eclipse.scout.rt.platform.IBeanDecorationFactory) BeanMetaData(org.eclipse.scout.rt.platform.BeanMetaData) BeanImplementor(org.eclipse.scout.rt.platform.internal.BeanImplementor)

Example 44 with BeanMetaData

use of org.eclipse.scout.rt.platform.BeanMetaData in project scout.rt by eclipse.

the class CodeTypeRegistrator method stateChanged.

@Override
public void stateChanged(PlatformEvent e) {
    if (e.getState() == IPlatform.State.BeanManagerPrepared) {
        IBeanManager beanManager = e.getSource().getBeanManager();
        Set<Class<? extends ICodeType<?, ?>>> classes = BEANS.get(CodeTypeClassInventory.class).getClasses();
        for (Class<? extends ICodeType<?, ?>> c : classes) {
            LOG.debug("Register {}", c.getName());
            beanManager.registerBean(new BeanMetaData(c).withProducer(new CodeTypeProducer()));
        }
        LOG.info("{} code type classes registered.", classes.size());
    }
}
Also used : BeanMetaData(org.eclipse.scout.rt.platform.BeanMetaData) IBeanManager(org.eclipse.scout.rt.platform.IBeanManager)

Example 45 with BeanMetaData

use of org.eclipse.scout.rt.platform.BeanMetaData in project scout.rt by eclipse.

the class PreferencesTest method test.

@Test
public void test() throws Exception {
    Preferences prefs = new Preferences("X", null);
    prefs.put("any", "Any");
    prefs.putBoolean("bool", true);
    prefs.putByteArray("byte", new byte[] { (byte) 1, (byte) 2, (byte) 3 });
    prefs.putDouble("double", 1.23);
    prefs.putFloat("float", 1.23f);
    prefs.putInt("int", 123);
    prefs.putLong("long", 123L);
    assertEquals(true, prefs.isDirty());
    assertEquals("X", prefs.name());
    assertEquals(7, prefs.keys().size());
    assertEquals("Any", prefs.get("any", null));
    assertEquals("Xyz", prefs.get("xyz", "Xyz"));
    assertEquals(true, prefs.getBoolean("bool", false));
    assertEquals(true, prefs.getBoolean("xyz", true));
    assertArrayEquals(new byte[] { (byte) 1, (byte) 2, (byte) 3 }, prefs.getByteArray("byte", null));
    assertArrayEquals(new byte[] { (byte) 9 }, prefs.getByteArray("xyz", new byte[] { (byte) 9 }));
    assertEquals(1.23, prefs.getDouble("double", 0), 0.0);
    assertEquals(9.0, prefs.getDouble("xyz", 9.0), 0.0);
    assertEquals(1.23f, prefs.getFloat("float", 0), 0.0);
    assertEquals(9.0f, prefs.getFloat("xyz", 9.0f), 0.0);
    assertEquals(123, prefs.getInt("int", 0));
    assertEquals(9, prefs.getInt("xyz", 9));
    assertEquals(123L, prefs.getLong("long", 0));
    assertEquals(9L, prefs.getLong("xyz", 9L));
    prefs.put("double", "123");
    prefs.put("float", "123");
    prefs.put("int", "123");
    prefs.put("long", "123");
    assertEquals(123.0, prefs.getDouble("double", 0), 0.0);
    assertEquals(123f, prefs.getFloat("float", 0), 0.0);
    assertEquals(123, prefs.getInt("int", 0));
    assertEquals(123L, prefs.getLong("long", 0));
    TestingUserPreferencesStorageService svc = new TestingUserPreferencesStorageService();
    List<IBean<?>> registerServices = TestingUtility.registerBeans(new BeanMetaData(IUserPreferencesStorageService.class).withInitialInstance(svc).withApplicationScoped(true));
    try {
        prefs.flush();
    } finally {
        TestingUtility.unregisterBeans(registerServices);
    }
    assertFalse(prefs.isDirty());
    assertTrue(svc.m_flushed);
}
Also used : BeanMetaData(org.eclipse.scout.rt.platform.BeanMetaData) IBean(org.eclipse.scout.rt.platform.IBean) Test(org.junit.Test)

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