/*
 * JBoss, the OpenSource J2EE webOS
 *
 * Distributable under LGPL license.
 * See terms of license at gnu.org.
 */

package org.jboss.test.jbossnet.ejbsimple.server;

import javax.ejb.EJBException;

import org.jboss.test.util.ejb.SessionSupport;

import org.jboss.test.jbossnet.ejbsimple.HelloData;
import org.w3c.dom.Element;

/**
 * The typical Hello Session Bean this time
 * as a web-service.
 * @author jung
 * @version $Revision: 1.1.1.1.4.1 $
 * @ejb.bean name="Hello"
 *           display-name="Hello World Bean"
 *           type="Stateless"
 *           view-type="both"
 *           jndi-name="hello/HelloBothRemote"
 *           local-jndi-name="hello/HelloBothLocal"
 *           extends
 * @ejb.transaction type="Required"
 * @jboss-net.web-service urn="HelloBoth"
 * @ejb.interface remote-class="org.jboss.test.jbossnet.ejbsimple.HelloRemote" local-class="org.jboss.test.jbossnet.ejbsimple.server.HelloLocal" extends="javax.ejb.EJBObject" local-extends="javax.ejb.EJBLocalObject"
 * @ejb.home remote-class="org.jboss.test.jbossnet.ejbsimple.HelloRemoteHome" local-class="org.jboss.test.jbossnet.ejbsimple.server.HelloLocalHome" extends="javax.ejb.EJBHome" local-extends="javax.ejb.EJBLocalHome"
 */

public class HelloBothBean
   extends SessionSupport
   implements javax.ejb.SessionBean {
   /**
    * @jboss-net.web-method
    * @ejb.interface-method view-type="both"
    */

   public String hello(String name) {
      return "Hello " + name + "!";
   }

   /**
    * @jboss-net.web-method
    * @ejb.interface-method view-type="both"
    */

   public String howdy(HelloData name) {
      return "Howdy " + name.getName() + "!";
   }

   /**
    * @jboss-net.web-method
    * @ejb.interface-method view-type="both"
    */

   public void throwException() {
      throw new EJBException("Something went wrong");
   }

   /**
    * @jboss-net:web-method
    * @ejb:interface-method view-type="both"
    */
   public Object[] arrays(Object[] values) {
      return values;
   }

   /**
    * @jboss-net:web-method
    * @ejb:interface-method view-type="both"
    */
   public Object[] reverse(Object[] values) {
      Object[] result = new Object[values.length];
      for (int i = 0; i < values.length; ++i)
         result[i] = values[values.length - i - 1];
      return result;
   }

   /**
    * @jboss-net:web-method
    * @ejb:interface-method view-type="both"
    */
   public HelloData[] typedArrays(HelloData[] values) {
      return values;
   }
   
   /**
    * @jboss-net.web-method
    * @ejb.interface-method view-type="both"
    */

   public Element element(Element in) {
      return in;
   }
   
}
