Search in sources :

Example 1 with ScriptInstanceService

use of org.meveo.service.script.ScriptInstanceService in project meveo by meveo-org.

the class MeveoFunctionMapper method getScriptInstanceService.

@SuppressWarnings("unchecked")
private static ScriptInstanceService getScriptInstanceService() {
    if (scriptInstanceService == null) {
        try {
            InitialContext initialContext = new InitialContext();
            BeanManager beanManager = (BeanManager) initialContext.lookup("java:comp/BeanManager");
            Bean<ScriptInstanceService> bean = (Bean<ScriptInstanceService>) beanManager.resolve(beanManager.getBeans(ScriptInstanceService.class));
            scriptInstanceService = (ScriptInstanceService) beanManager.getReference(bean, bean.getBeanClass(), beanManager.createCreationalContext(bean));
        } catch (NamingException e) {
            Logger log = LoggerFactory.getLogger(MeveoFunctionMapper.class);
            log.error("Unable to access ScriptInstanceService", e);
            throw new RuntimeException(e);
        }
    }
    return scriptInstanceService;
}
Also used : ScriptInstanceService(org.meveo.service.script.ScriptInstanceService) NamingException(javax.naming.NamingException) Logger(org.slf4j.Logger) BeanManager(javax.enterprise.inject.spi.BeanManager) InitialContext(javax.naming.InitialContext) ParamBean(org.meveo.commons.utils.ParamBean) Bean(javax.enterprise.inject.spi.Bean)

Aggregations

Bean (javax.enterprise.inject.spi.Bean)1 BeanManager (javax.enterprise.inject.spi.BeanManager)1 InitialContext (javax.naming.InitialContext)1 NamingException (javax.naming.NamingException)1 ParamBean (org.meveo.commons.utils.ParamBean)1 ScriptInstanceService (org.meveo.service.script.ScriptInstanceService)1 Logger (org.slf4j.Logger)1