I use Spring to start up OpenEJB
(org.apache.openejb.spring.ClassPathApplication) and I needed network
services. I didin't found any way to set openejb.embedded.remotable=true to
this application and then I used the following bean to start up the network
services:

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

import org.apache.openejb.client.LocalInitialContext;
import org.apache.openejb.server.ServiceManager;
import org.apache.openejb.util.LogCategory;
import org.apache.openejb.util.Logger;

public class NetworkServices {

    private static Logger logger =
Logger.getInstance(LogCategory.OPENEJB_STARTUP, LocalInitialContext.class);

    private ServiceManager manager;

    @PostConstruct
    public void startNetworkServices() throws Exception {

        if (ServiceManager.get() != null) {

            return;
        }

        logger.info("Starting network services");

        manager = ServiceManager.getManager();

        manager.init();
        manager.start(false);
    }

    @PreDestroy
    public void stopNetworkServices() throws Exception {

        logger.info("Stopping network services");

        manager.stop();
        Thread.sleep(3000);
    }
}

I hope this post helps people with the same problem.


-- 
View this message in context: 
http://www.nabble.com/Spring-%2B-NetworkServices-tp24219590p24219590.html
Sent from the OpenEJB Dev mailing list archive at Nabble.com.

Reply via email to