1 23 24 package com.sun.enterprise.appclient; 25 26 import com.sun.enterprise.deployment.annotation.AnnotationProcessorException; 27 import com.sun.enterprise.deployment.archivist.AppClientArchivist; 28 import com.sun.enterprise.deployment.archivist.ApplicationArchivist; 29 import com.sun.enterprise.deployment.archivist.Archivist; 30 import com.sun.enterprise.deployment.archivist.ArchivistFactory; 31 import com.sun.enterprise.deployment.deploy.shared.AbstractArchive; 32 import com.sun.enterprise.deployment.deploy.shared.ArchiveFactory; 33 import com.sun.enterprise.util.i18n.StringManager; 34 import java.io.File ; 35 import java.io.IOException ; 36 import java.net.URISyntaxException ; 37 import java.util.logging.Level ; 38 import java.util.logging.Logger ; 39 import org.xml.sax.SAXParseException ; 40 41 47 public class AppClientInfoFactory { 48 49 50 protected static StringManager localStrings = 51 StringManager.getManager(AppClientInfoFactory.class); 52 53 59 public static AppClientInfo buildAppClientInfo( 60 boolean isJWS, 61 Logger logger, 62 File locationFile, 63 String mainClassFromCommandLine, 64 String displayNameFromCommandLine, 65 String classFileFromCommandLine) 66 throws IOException , SAXParseException , ClassNotFoundException , 67 URISyntaxException , AnnotationProcessorException, 68 Exception { 69 AppClientInfo result = null; 70 71 74 if (classFileFromCommandLine != null) { 75 80 Archivist archivist = new AppClientArchivist(); 81 result = new ClassFileAppClientInfo( 82 isJWS, 83 logger, 84 locationFile, 85 archivist, 86 mainClassFromCommandLine, 87 classFileFromCommandLine); 88 } else { 89 94 Archivist archivist = prepareArchivist(locationFile); 95 96 if (archivist != null) { 97 101 if (archivist instanceof AppClientArchivist) { 102 result = new StandAloneAppClientInfo( 103 isJWS, 104 logger, 105 locationFile, 106 archivist, 107 mainClassFromCommandLine); 108 } else if (archivist instanceof ApplicationArchivist) { 109 113 result = new NestedAppClientInfo( 114 isJWS, 115 logger, 116 locationFile, 117 archivist, 118 mainClassFromCommandLine, 119 displayNameFromCommandLine); 120 } else { 121 126 throw new IllegalArgumentException (localStrings.getString("appclient.unexpectedArchive", locationFile.getAbsolutePath())); 127 } 128 } else { 129 133 throw new IllegalArgumentException (localStrings.getString("appclient.invalidArchive", locationFile.getAbsolutePath())); 134 } 135 } 136 result.completeInit(); 137 if (logger.isLoggable(Level.FINE)) { 138 logger.fine(result.toString()); 139 } 140 return result; 141 } 142 143 151 private static Archivist prepareArchivist(File file) throws IOException { 152 Archivist result = null; 153 result = ArchivistFactory.getArchivistForArchive(file); 154 return result; 155 } 156 } 157 | Popular Tags |