FileDocCategorySizeDatePackage
GetClientStubsCommand.javaAPI DocGlassfish v2 API5315Fri May 04 22:25:10 BST 2007com.sun.enterprise.cli.commands

GetClientStubsCommand

public class GetClientStubsCommand extends S1ASCommand
This is the GetClientStubs command

Fields Summary
private String
downloadDir
private String
appName
public static final String
APP_NAME
Constructors Summary
Methods Summary
private java.lang.StringgetAppName()

        String name = getOption(APP_NAME);
        return name;
    
private java.lang.StringgetClientStub(javax.management.MBeanServerConnection mbsc)
retrieve client stub from server

	try 
	{

	    final String fileName = new JMXFileTransfer(mbsc).downloadClientStubs(
							 appName, 
							 downloadDir);
	    CLILogger.getInstance().printDebugMessage("Downloaded client stubs to: " + fileName);
        return fileName;
	}
	catch (Exception e)
	{
            Throwable t = e.getCause();
            while(t!=null && t.getCause()!=null)
                t=t.getCause();
            if(t==null)
                t=e;
	    throw new CommandException(t.getLocalizedMessage(),t);
	}
    
public voidrunCommand()
An abstract method that Executes the command

throws
CommandException


                    
       
              
    
        validateOptions();

	//use http connector
	final MBeanServerConnection mbsc = getMBeanServerConnection(getHost(), 
								    getPort(), 
								    getUser(), 
								    getPassword());

        String path = getClientStub(mbsc);

	// getClientStub(mbsc,retrievePath, type);

        CLILogger.getInstance().printDetailMessage(getLocalizedString(
        				     "CommandSuccessful",
	 				     new Object[] {name} ) );
    
private voidvalidateDirectory()
check if file path exist on the local file system

throws
CommandValidationExcetion if file not found

        File dlDir = new File(downloadDir);
	if (!dlDir.exists() )
        {
            dlDir.mkdirs();
        }
        if(!dlDir.exists() || !dlDir.canWrite() || !dlDir.isDirectory() ) {
            throw new CommandValidationException(getLocalizedString(
						 "InvalidDirectory",new Object [] {downloadDir}));
        }
    
public booleanvalidateOptions()
An abstract method that validates the options on the specification in the xml properties file This method verifies for the correctness of number of operands and if all the required options are supplied by the client.

return
boolean returns true if success else returns false

        super.validateOptions();
        downloadDir = (String) getOperands().get(0);
	validateDirectory();
        appName = getAppName();
	return true;