JavaBeans Enterprise

Paso 2: Especificar el Interface Remoto de JavaBeans Enterprise TM

En este paso crearemos un interface remoto JavaBean Enterprise.

El interface remoto es la vista del cliente de los JavaBeans Enterprise, y las tareas que desarrolla nuestro javaBean se declaran en este interface usando las síntaxis RMI de JavaTM. Es responsabilidad del proveedor de las herramientas de contenedores de JavaBeans Enterprise generar el código para este interface.

Nota: Hay algunas limitaciones sobre lo que se puede especificar en este interface. Para una lista completa puedes ver la sección 16 de la Especificación de JavaBeans Enterprise. Es importante que, todos los objetos usados, los parámetros, los valores de retorno y las excepciones sean tipos válidos en la "especificación de mapeo de Java a IDL".

Aquí tenemos el código fuente del interface remoto para el sencillo DemoBean. Debemos grabarlo en un fichero llamado Demo.java.

  /**
  * Demo -- this is the "remote" interface of
  * our enterprise JavaBean, it
  * defines only one simple method called
  * demoSelect(). As this is meant to be
  * the simplest of examples demoSelect()
  * never goes to a database, it just
  * returns a string
  *
  * Note: The implementation of this interface is
  * provided by the container tools
  * but the demoSelect() method and any
  * other methods in this interface
  * will need to have equivalent
  * implementations in the demobean.java
  * which is supplied by the bean writer
  * ..i.e., you!
  */
  
package ejb.demo;
  
import java.rmi.RemoteException;
import java.rmi.Remote;
import javax.ejb.*;
  
public interface Demo extends EJBObject, Remote {
  
  // NB this simple example does not even do a
  // lookup in the database
  public String demoSelect() throws RemoteException;
  
  }

Ozito