Java Code Examples for org.apache.webbeans.config.WebBeansFinder#setSingletonService()

The following examples show how to use org.apache.webbeans.config.WebBeansFinder#setSingletonService() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HammockInitializer.java    From hammock with Apache License 2.0 5 votes vote down vote up
@Override
protected SeContainer newContainer(WebBeansContext context) {
    SingletonService<WebBeansContext> singletonService = WebBeansFinder.getSingletonService();
    if(singletonService instanceof HolderSingletonService) {
        ((HolderSingletonService) singletonService).register(context);
    } else {
        try {
            WebBeansFinder.setSingletonService(new HolderSingletonService(context));
        } catch (Exception e) {
            logger.info("Unable to override OWB SingletonService", e);
        }
    }
    return super.newContainer(context);
}
 
Example 2
Source File: CdiBuilder.java    From tomee with Apache License 2.0 5 votes vote down vote up
public static synchronized ThreadSingletonService initializeOWB() {
    logger.info("Created new singletonService " + SINGLETON_SERVICE);
    SystemInstance.get().addObserver(SINGLETON_SERVICE);
    SystemInstance.get().setComponent(ThreadSingletonService.class, SINGLETON_SERVICE);
    try {
        WebBeansFinder.setSingletonService(SINGLETON_SERVICE);
        logger.info("Succeeded in installing singleton service");
    } catch (final Exception e) {
        //ignore
        // not logging the exception since it is nto an error
        logger.debug("Could not install our singleton service");
    }

    return SINGLETON_SERVICE;
}