
package dant.test;

import java.rmi.*;
import java.rmi.registry.*;
import javax.ejb.*;

import com.sun.grid.jgrid.*;

/**
 * Created Oct 31, 2003 2:53:17 PM
 * Code generated by the Sun ONE Studio EJB Builder
 * @author dant
 */


public class GridEJBBean implements javax.ejb.SessionBean {
    private javax.ejb.SessionContext context;
		private ComputeEngine ce = null;
    
    
    /**
     * @see javax.ejb.SessionBean#setSessionContext(javax.ejb.SessionContext)
     */
    public void setSessionContext(javax.ejb.SessionContext aContext) {
        context=aContext;
    }
    
    
    /**
     * @see javax.ejb.SessionBean#ejbActivate()
     */
    public void ejbActivate() {
        
    }
    
    
    /**
     * @see javax.ejb.SessionBean#ejbPassivate()
     */
    public void ejbPassivate() {
        
    }
    
    
    /**
     * @see javax.ejb.SessionBean#ejbRemove()
     */
    public void ejbRemove() {
    }
    
    
    /**
     * See section 7.10.3 of the EJB 2.0 specification
     */
    public void ejbCreate() throws CreateException {
			try {
				Registry r = LocateRegistry.getRegistry("es-ergb01-01.germany");
				ce = (ComputeEngine)r.lookup ("ComputeEngine");
			}
			catch (NotBoundException e) {
				throw new CreateException ("Unable to connect to grid: grid not bound");
			}
			catch (RemoteException e) {
				throw new CreateException ("Unable to connect to grid: " + e.getMessage ());
			}
			
    }
    
		public java.io.Serializable compute (Computable job) throws ComputeException, RemoteException {
			return ce.compute (job);
		}
		
}
