FileDocCategorySizeDatePackage
MakeDD.javaAPI DocExample2568Sun Mar 07 08:39:48 GMT 1999com.titan.travelagent

MakeDD.java

package com.titan.travelagent;

import javax.ejb.deployment.SessionDescriptor;
import javax.ejb.deployment.ControlDescriptor;
import javax.naming.CompoundName;
import com.titan.cabin.CabinBean;
import java.util.Properties;
import java.io.FileOutputStream;
import java.io.ObjectOutputStream;
import java.lang.reflect.Field;


public class MakeDD {

    public static void main(String args [] ){
        try{

        if(args.length <1){
            System.out.println("must specify target directory");
            return;
        }

        SessionDescriptor sd = new SessionDescriptor();

        sd.setEnterpriseBeanClassName(
            "com.titan.travelagent.TravelAgentBean");
        sd.setHomeInterfaceClassName(
            "com.titan.travelagent.TravelAgentHome");
        sd.setRemoteInterfaceClassName(
            "com.titan.travelagent.TravelAgent");

        sd.setSessionTimeout(60);
        sd.setStateManagementType(SessionDescriptor.STATEFUL_SESSION);

        ControlDescriptor cd = new ControlDescriptor();
        cd.setIsolationLevel(ControlDescriptor.TRANSACTION_READ_COMMITTED);
        cd.setMethod(null);
        cd.setRunAsMode(ControlDescriptor.CLIENT_IDENTITY);
        cd.setTransactionAttribute(ControlDescriptor.TX_REQUIRED);
        ControlDescriptor [] cdArray = {cd};
        sd.setControlDescriptors(cdArray);

        //Set enterprise Bean's environment properties
        Properties ep = new Properties();
        ep.put("jndiName_CruiseHome","CruiseHome");
        ep.put("jndiName_CabinHome","CabinHome");
        ep.put("jndiName_ReservationHome","ReservationHome");
        ep.put("jndiName_ProcessPaymentHome","ProcessPaymentHome");
        ep.put("jndiName_ShipHome","ShipHome");
        ep.put("jdbcURL","jdbc:<subprotocol>:<subname>");
        sd.setEnvironmentProperties(ep);

        Properties jndiProps = new Properties();
        CompoundName jndiName = jndiName
        = new CompoundName("TravelAgentHome",jndiProps);
        sd.setBeanHomeName(jndiName);

        String fileSeparator =
            System.getProperties().getProperty("file.separator");
        if(! args[0].endsWith(fileSeparator))
            args[0] += fileSeparator;

        FileOutputStream fis =
            new FileOutputStream(args[0]+"TravelAgentDD.ser");
        ObjectOutputStream oos = new ObjectOutputStream(fis);
        oos.writeObject(sd);
        oos.flush();
        oos.close();
        fis.close();
        }catch(Throwable t){t.printStackTrace();}
    }
}