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

import org.jboss.annotation.ejb.Service;
import org.jboss.annotation.ejb.Depends;
import org.jboss.annotation.ejb.Depends;
import org.jboss.annotation.ejb.Service;

import javax.management.ObjectName;

/**
 * @author <a href="mailto:kabir.khan@jboss.org">Kabir Khan</a>
 * @version $Revision: 1.3.2.4 $
 */
@Service
public class ServiceFive implements ServiceFiveManagement
{
   @Depends("jboss.j2ee:service=EJB3,name=org.jboss.ejb3.test.service.ServiceThree")
   public ServiceThreeManagement serviceThreeA;

   @Depends("jboss.j2ee:service=EJB3,name=org.jboss.ejb3.test.service.ServiceFour,type=service")
   public ObjectName serviceFourA;

   private ServiceThreeManagement serviceThreeB;
   private ObjectName serviceFourB;

   @Depends("jboss.j2ee:service=EJB3,name=org.jboss.ejb3.test.service.ServiceThree")
   public void setServiceThree(ServiceThreeManagement proxy)
   {
      serviceThreeB = proxy;
   }

   @Depends("jboss.j2ee:service=EJB3,name=org.jboss.ejb3.test.service.ServiceFour,type=service")
   public void setServiceFour(ObjectName on)
   {
      serviceFourB = on;
   }

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

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

   public boolean getInjectedProxyField()
   {
      return serviceThreeA != null;
   }

   public boolean getInjectedObjectNameField()
   {
      return serviceFourA != null;
   }

   public boolean getInjectedProxyMethod()
   {
      return serviceThreeB != null;
   }

   public boolean getInjectedObjectNameMethod()
   {
      return serviceFourB != null;
   }
}
