FileDocCategorySizeDatePackage
AppClientInfoFactory.javaAPI DocGlassfish v2 API7401Fri May 04 22:34:12 BST 2007com.sun.enterprise.appclient

AppClientInfoFactory

public class AppClientInfoFactory extends Object
Factory class for creating the appropriate subtype of AppClientInfo based on various factors.
author
tjquinn

Fields Summary
protected static final com.sun.enterprise.util.i18n.StringManager
localStrings
access to the localizable strings
Constructors Summary
Methods Summary
public static AppClientInfobuildAppClientInfo(boolean isJWS, java.util.logging.Logger logger, java.io.File locationFile, java.lang.String mainClassFromCommandLine, java.lang.String displayNameFromCommandLine, java.lang.String classFileFromCommandLine, java.net.URL[] persistenceURLs)
Factory merhod that creates an object of the correct concrete type for the given location and content.

param
locationFile File where the client is
param
mainClassFromCommandLine the main class as specified on the command line

    
                                        
       
             
             
              
              
              
             
              
                    
                         
                         
        AppClientInfo result = null;

        /*
         *Check if the user specified a .class file on the command line.
         */
        if (classFileFromCommandLine != null) {
            /*
             *Yes, it's a .class file.  Use an app client archivist and, from 
             *it, get the default app client descriptor.  Then create the
             *new app client info instance.
             */
            Archivist archivist = new AppClientArchivist();
            result = new ClassFileAppClientInfo(
                    isJWS, 
                    logger, 
                    locationFile, 
                    archivist,
                    mainClassFromCommandLine, 
                    classFileFromCommandLine);
        } else {
            /*
             *The user did not specify a .class file on the command line, so
             *the locationFile argument refers to a valid module.
             *Construct an Archivist for the location file.
             */
            Archivist archivist = prepareArchivist(locationFile);
            
            if (archivist != null) {
                /*
                 *Choose which type of concrete AppClientInfo class is 
                 *suitable for this app client execution.
                 */
                if (archivist instanceof AppClientArchivist) {
                    result = new StandAloneAppClientInfo(
                            isJWS,
                            logger,
                            locationFile,
                            archivist,
                            mainClassFromCommandLine);
                } else if (archivist instanceof ApplicationArchivist) {
                    /*
                     *The descriptor should be of an application if it is not an
                     *app client descriptor.
                     */
                    result = new NestedAppClientInfo(
                            isJWS,
                            logger,
                            locationFile,
                            archivist,
                            mainClassFromCommandLine, 
                            displayNameFromCommandLine);
                } else {
                    /*
                     *The archivist factory recognized the archive as a valid
                     *one but it is not an app client or an application.  
                     *Reject it.
                     */
                    throw new UserError(localStrings.getString("appclient.unexpectedArchive", locationFile.getAbsolutePath()));
                }
            } else {
                /*
                 *The archivist is null, which means the user-provided location is
                 *not recognized as a known type of module.
                 */
                throw new UserError(localStrings.getString("appclient.invalidArchive", locationFile.getAbsolutePath()));
            }
        }
        result.completeInit(persistenceURLs);
        if (logger.isLoggable(Level.FINE)) {
            logger.fine(result.toString());
        }
        return result;
    
private static com.sun.enterprise.deployment.archivist.ArchivistprepareArchivist(java.io.File file)
Returns an archivist of the correct concrete type (app client or application) given the contents of the archive.

param
archive the archive that contains the module
param
className
return
concrete Archivist of the correct type given the contents of the archive
exeception
IOException in case of error getting an archivist for the archive

        Archivist result = null;
        result = ArchivistFactory.getArchivistForArchive(file);
        return result;