/*
 * JBoss, the OpenSource EJB server
 *
 * Distributable under LGPL license.
 * See terms of license at gnu.org.
 */
package org.jboss.ejb3.test.service;

import javax.annotation.EJB;
import javax.ejb.AroundInvoke;
import javax.ejb.InvocationContext;
import org.jboss.annotation.ejb.Depends;
import org.jboss.annotation.ejb.Service;

/**
 * @author <a href="mailto:kabir.khan@jboss.org">Kabir Khan</a>
 * @version $Revision: 1.4.2.4 $
 */
@Service (objectName = "jboss.ejb3:management=interface,with=customName,is=serviceThree")
@Depends ({"jboss.j2ee:service=EJB3,name=org.jboss.ejb3.test.service.ServiceTwo","jboss.j2ee:service=EJB3,name=org.jboss.ejb3.test.service.ServiceOne,type=service"})
public class ServiceThree implements ServiceThreeManagement
{
   @EJB
   private ServiceOneRemote serviceOne;

   int intercepted;

   public boolean getInjected()
   {
      return serviceOne != null;
   }

   public int getIntercepted()
   {
      return intercepted;
   }

   @AroundInvoke
   public Object intercept(InvocationContext ctx) throws Exception
   {
      System.out.println("Interceptor");
      intercepted++;
      return ctx.proceed();
   }

   public void create() throws Exception
   {
      System.out.println("ServiceThree - CREATE");
      Tester.creates.add("3");
   }

   public void start() throws Exception
   {
      System.out.println("ServiceThree - START");
      Tester.starts.add("3");      
   }

   public void stop()
   {
      System.out.println("ServiceThree - STOP");
   }

   public void destroy()
   {
      System.out.println("ServiceThree - DESTROY");
   }
}
