FileDocCategorySizeDatePackage
ClientConfigurationImpl.javaAPI DocGlassfish v2 API5043Fri May 04 22:34:28 BST 2007com.sun.enterprise.deployapi.actions

ClientConfigurationImpl

public class ClientConfigurationImpl extends Object implements javax.enterprise.deploy.spi.status.ClientConfiguration
This implementation of the ClientConfiguration interface allow for limited support of Application Client
author
Jerome Dochez

Fields Summary
com.sun.enterprise.deployapi.SunTargetModuleID
targetModuleID
String
originalArchivePath
private static com.sun.enterprise.util.LocalStringManagerImpl
localStrings
Constructors Summary
public ClientConfigurationImpl(com.sun.enterprise.deployapi.SunTargetModuleID targetModuleID)
Creates a new instance of ClientConfigurationImpl

    
    
           
       
        this.targetModuleID = targetModuleID;
    
Methods Summary
public voidexecute()
This method performs an exec and starts the application client running in another process.

throws
ClientExecuteException when the configuration is incomplete.

        if (targetModuleID==null) {
            throw new ClientExecuteException(localStrings.getLocalString(
                "enterprise.deployapi.actions.clientconfigurationimpl.nomoduleid", 
                "No moduleID for deployed application found"));
        }
        SunTarget target = (SunTarget) targetModuleID.getTarget();
        String moduleID;
        if (targetModuleID.getParentTargetModuleID()!=null) {            
            moduleID = targetModuleID.getParentTargetModuleID().getModuleID();
        } else {
            moduleID = targetModuleID.getModuleID();
        }
        
        
        try {
            // retrieve the stubs from the server
            String location = target.exportClientStubs(moduleID, 0,  System.getProperty("java.io.tmpdir"));
       
            // get the module id for the appclient
            String id = targetModuleID.getModuleID();
            if (id.indexOf('#")!=-1) {
                id = id.substring(id.indexOf('#")+1);
            }
        
            // invoke now the appclient...
            String j2eeHome = System.getProperty("com.sun.aas.installRoot");
            String appClientBinary = j2eeHome + File.separatorChar + "bin" + File.separatorChar + "appclient";
            String command = appClientBinary + " -client " + location;
            
            Process p = Runtime.getRuntime().exec(command);
            InputStream is = p.getInputStream();
            
        } catch(Exception e) {
            e.printStackTrace();
            throw new ClientExecuteException(localStrings.getLocalString(
                "enterprise.deployapi.actions.clientconfigurationimpl.exception", 
                "Exception while invoking application client : \n {0}", new Object[] { e.getMessage() }));
        }