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.deploy.shared.AbstractArchive; 36 import com.sun.enterprise.deployment.interfaces.ClientJarMaker; 37 import com.sun.enterprise.deployment.RootDeploymentDescriptor; 38 import com.sun.enterprise.deployment.util.ModuleDescriptor; 39 import com.sun.enterprise.util.zip.ZipItem; 40 41 48 class ModuleClientJarMaker implements ClientJarMaker { 49 50 protected Properties props; 51 52 56 public ModuleClientJarMaker(Properties props) { 57 this.props = props; 58 } 59 60 70 public void create(RootDeploymentDescriptor descriptor, AbstractArchive source, 71 AbstractArchive target,ZipItem[] stubs, Properties props) 72 throws IOException { 73 create(descriptor, source, null, target, stubs, props); 74 } 75 76 87 public void create(RootDeploymentDescriptor descriptor, AbstractArchive source, 88 AbstractArchive source2, AbstractArchive target,ZipItem[] stubs, 89 Properties props) throws IOException { 90 91 ClientJarMakerUtils.populateStubs(target, stubs); 93 94 AbstractArchive appclientSource = null; 95 AbstractArchive appclientSource2 = null; 96 97 if (descriptor.isApplication()) { 99 100 List <String > libraries = ClientJarMakerUtils.getLibraryEntries( 104 Application.class.cast(descriptor), source); 105 106 for (String entryName : libraries) { 107 AbstractArchive subSource = null; 108 try { 109 subSource = source.getEmbeddedArchive(entryName); 110 for (Enumeration subEntries = subSource.entries(); 111 subEntries.hasMoreElements();) { 112 String subEntryName = 113 String .class.cast(subEntries.nextElement()); 114 ClientJarMakerUtils.copy( 115 subSource, target, subEntryName); 116 } 117 } finally { 118 if (subSource != null) { 119 source.closeEntry(subSource); 120 } 121 } 122 } 123 124 for (Iterator modules = Application.class.cast(descriptor).getModules(); 126 modules.hasNext();) { 127 ModuleDescriptor md = ModuleDescriptor.class.cast(modules.next()); 128 if (md.getModuleType().equals(ModuleType.CAR)) { 129 appclientSource = source.getEmbeddedArchive(md.getArchiveUri()); 130 if (source2 != null) { 131 appclientSource2 = 132 source2.getEmbeddedArchive(md.getArchiveUri()); 133 } 134 break; 135 } 136 } 137 } else { 138 appclientSource = source; 139 appclientSource2 = source2; 140 } 141 142 if (appclientSource != null) { 144 ClientJarMakerUtils.populateModuleJar( 145 appclientSource, appclientSource2, target); 146 } else { 147 ClientJarMakerUtils.copyDeploymentDescriptors( 152 new ApplicationArchivist(), source, source2, target); 153 } 154 155 if (descriptor.isApplication()) { 162 for (Iterator modules = Application.class.cast(descriptor).getModules(); 163 modules.hasNext();) { 164 ModuleDescriptor md = ModuleDescriptor.class.cast(modules.next()); 165 if (md.getModuleType().equals(ModuleType.EJB)) { 166 AbstractArchive subSource = 167 source.getEmbeddedArchive(md.getArchiveUri()); 168 for (Enumeration e = subSource.entries();e.hasMoreElements();) { 169 String entryName = String .class.cast(e.nextElement()); 170 if (!entryName.endsWith(".class")) { 171 continue; 172 } 173 try { 174 ClientJarMakerUtils.copy(subSource, target, entryName); 175 } catch(IOException ioe) { 176 } finally { 178 if (subSource != null) { 179 source.closeEntry(subSource); 180 } 181 } 182 } 183 } 184 } 185 } 186 } 187 } 188 | Popular Tags |