1 23 24 package com.sun.enterprise.deployment.backend; 25 26 import java.io.IOException ; 27 import java.util.Enumeration ; 28 import java.util.Iterator ; 29 import java.util.List ; 30 import java.util.Properties ; 31 import javax.enterprise.deploy.shared.ModuleType ; 32 33 import com.sun.enterprise.deployment.Application; 34 import com.sun.enterprise.deployment.archivist.ApplicationArchivist; 35 import com.sun.enterprise.deployment.archivist.Archivist; 36 import com.sun.enterprise.deployment.archivist.ArchivistFactory; 37 import com.sun.enterprise.deployment.deploy.shared.AbstractArchive; 38 import com.sun.enterprise.deployment.interfaces.ClientJarMaker; 39 import com.sun.enterprise.deployment.RootDeploymentDescriptor; 40 import com.sun.enterprise.deployment.util.ModuleDescriptor; 41 import com.sun.enterprise.util.zip.ZipItem; 42 43 50 class ApplicationClientJarMaker implements ClientJarMaker { 51 52 protected Properties props; 53 54 58 public ApplicationClientJarMaker(Properties props) { 59 this.props = props; 60 } 61 62 72 public void create(RootDeploymentDescriptor descriptor, AbstractArchive source, 73 AbstractArchive target,ZipItem[] stubs, Properties props) 74 throws IOException { 75 create(descriptor, source, null, target, stubs, props); 76 } 77 78 89 public void create(RootDeploymentDescriptor descriptor, AbstractArchive source, 90 AbstractArchive source2, AbstractArchive target,ZipItem[] stubs, 91 Properties props) throws IOException { 92 93 ClientJarMakerUtils.populateStubs(target, stubs); 95 96 if (!descriptor.isApplication()) { 98 ClientJarMakerUtils.populateModuleJar(source, source2, target); 100 return; 101 } 102 103 Application app = Application.class.cast(descriptor); 104 for (Iterator modules = app.getModules(); modules.hasNext();) { 105 ModuleDescriptor md = ModuleDescriptor.class.cast(modules.next()); 106 107 if (md.getModuleType().equals(ModuleType.WAR) 109 || md.getModuleType().equals(ModuleType.RAR)) { 110 continue; 111 } 112 113 AbstractArchive subSource = source.getEmbeddedArchive(md.getArchiveUri()); 114 AbstractArchive subSource2 = null; 115 if (source2 != null) { 116 subSource2 = source2.getEmbeddedArchive(md.getArchiveUri()); 117 } 118 AbstractArchive subTarget = target.getEmbeddedArchive(md.getArchiveUri()); 119 120 ClientJarMakerUtils.populateModuleJar(subSource, subSource2, subTarget); 122 123 target.closeEntry(subTarget); 124 source.closeEntry(subSource); 125 if (source2 != null) { 126 source2.closeEntry(subSource2); 127 } 128 129 if (md.getAlternateDescriptor() != null) { 131 String ddPath = md.getAlternateDescriptor(); 132 String runtimeDDPath = "sun-" + ddPath; 133 if (source2 != null) { 134 ClientJarMakerUtils.copy(source2, target, ddPath); 135 ClientJarMakerUtils.copy(source2, target, runtimeDDPath); 136 } else { 137 ClientJarMakerUtils.copy(source, target, ddPath); 138 ClientJarMakerUtils.copy(source, target, runtimeDDPath); 139 } 140 } 141 } 142 143 List <String > libraries = 145 ClientJarMakerUtils.getLibraryEntries(app, source); 146 for (String library : libraries) { 147 ClientJarMakerUtils.copy(source, target, library); 148 } 149 150 ClientJarMakerUtils.copyDeploymentDescriptors( 152 new ApplicationArchivist(), source, source2, target); 153 } 154 } 155 | Popular Tags |