Search in sources :

Example 1 with IBeanDecorationFactory

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

the class BeanManagerImplementor method getDecoratedBeans.

protected <T> List<IBean<T>> getDecoratedBeans(List<IBean<T>> beans, Class<T> beanClazz) {
    IBeanDecorationFactory beanDecorationFactory = getBeanDecorationFactory();
    if (beanDecorationFactory == null || !beanClazz.isInterface()) {
        return beans;
    }
    // apply decorations
    List<IBean<T>> result = new ArrayList<IBean<T>>(beans.size());
    for (IBean<T> bean : beans) {
        result.add(getDecoratedBean(bean, beanClazz, beanDecorationFactory));
    }
    return result;
}
Also used : IBeanDecorationFactory(org.eclipse.scout.rt.platform.IBeanDecorationFactory) ArrayList(java.util.ArrayList) IBean(org.eclipse.scout.rt.platform.IBean)

Example 2 with IBeanDecorationFactory

use of org.eclipse.scout.rt.platform.IBeanDecorationFactory 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 3 with IBeanDecorationFactory

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

the class PlatformImplementor method initBeanDecorationFactory.

protected void initBeanDecorationFactory() {
    if (m_beanManager.getBeanDecorationFactory() != null) {
        return;
    }
    IBean<IBeanDecorationFactory> bean = m_beanManager.optBean(IBeanDecorationFactory.class);
    if (bean != null) {
        m_beanManager.setBeanDecorationFactory(bean.getInstance());
        return;
    }
    LOG.warn("Using {}. Please verify that this application really has no client or server side {}", SimpleBeanDecorationFactory.class.getName(), IBeanDecorationFactory.class.getSimpleName());
    m_beanManager.setBeanDecorationFactory(new SimpleBeanDecorationFactory());
}
Also used : IBeanDecorationFactory(org.eclipse.scout.rt.platform.IBeanDecorationFactory) SimpleBeanDecorationFactory(org.eclipse.scout.rt.platform.SimpleBeanDecorationFactory)

Aggregations

IBeanDecorationFactory (org.eclipse.scout.rt.platform.IBeanDecorationFactory)3 ArrayList (java.util.ArrayList)1 BeanMetaData (org.eclipse.scout.rt.platform.BeanMetaData)1 IBean (org.eclipse.scout.rt.platform.IBean)1 SimpleBeanDecorationFactory (org.eclipse.scout.rt.platform.SimpleBeanDecorationFactory)1 BeanImplementor (org.eclipse.scout.rt.platform.internal.BeanImplementor)1