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));
}
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));
}
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();
}
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());
}
}
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);
}
Aggregations