You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomee.apache.org by Leopa <le...@gmail.com> on 2009/06/26 14:40:05 UTC

Spring + NetworkServices

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.


Re: Spring + NetworkServices

Posted by David Blevins <da...@visi.com>.
It's been a bit since you posted, but just wanted to say thanks for  
this email.

We could definitely use another developer on the Spring integration,  
so if you have other ideas we are more than happy to have you on the  
team.


-David

On Jun 26, 2009, at 5:40 AM, Leopa wrote:

>
> 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.
>
>