/*
 * JBoss, the OpenSource J2EE webOS
 *
 * Distributable under LGPL license.
 * See terms of license at gnu.org.
 */
package org.jboss.test.asynch;

import org.jboss.aop.Dispatcher;
import org.jboss.aspects.asynch.AsynchRemoting;
import org.jboss.aspects.jmx.MBean;
import org.jboss.remoting.InvokerLocator;

import javax.naming.InitialContext;

/**
 * Comment
 *
 * @author <a href="mailto:bill@jboss.org">Bill Burke</a>
 * @version $Revision: 1.2.8.3 $
 */
@MBean
public class Service
{
   public void start() throws Exception
   {
      InitialContext ctx = new InitialContext();
      POJO pojo = new POJO();
      Dispatcher.singleton.registerTarget("pojo", pojo);
      System.out.println("*** hello ***");

      ctx.rebind("pojo", AsynchRemoting.createRemoteProxy("pojo", POJO.class, new InvokerLocator("socket://localhost:5150")));
   }

   public void stop()
   {
      System.out.println("**** STOP ***");
      Dispatcher.singleton.unregisterTarget("pojo");
   }
}
