1 22 package org.jboss.deployers.plugins.structure.vfs.jar; 23 24 import java.io.IOException ; 25 import java.util.Set ; 26 27 import org.jboss.deployers.plugins.structure.ContextInfoImpl; 28 import org.jboss.deployers.plugins.structure.vfs.AbstractStructureDeployer; 29 import org.jboss.deployers.spi.structure.vfs.StructureMetaData; 30 import org.jboss.deployers.spi.structure.vfs.StructuredDeployers; 31 import org.jboss.virtual.VirtualFile; 32 import org.jboss.virtual.plugins.context.jar.JarUtils; 33 34 40 public class JARStructure extends AbstractStructureDeployer 41 { 42 public JARStructure() 43 { 44 this(null); 45 } 46 47 51 public JARStructure(Set <String > suffixes) 52 { 53 if( suffixes != null ) 54 JarUtils.setJarSuffixes(suffixes); 55 setRelativeOrder(10000); 56 } 57 58 63 public Set <String > getSuffixes() 64 { 65 return JarUtils.getSuffixes(); 66 } 67 72 public void setSuffixes(Set <String > suffixes) 73 { 74 JarUtils.setJarSuffixes(suffixes); 75 } 76 77 public boolean determineStructure(VirtualFile root, StructureMetaData metaData, StructuredDeployers deployers) 78 { 79 String contextPath = null; 80 try 81 { 82 if (root.isLeaf() == false) 83 { 84 if (JarUtils.isArchive(root.getName()) == false) 87 { 88 if (isTopLevel(root, metaData) == false) 89 { 90 try 91 { 92 root.findChild("META-INF"); 93 log.trace("... ok - non top level directory has a META-INF subdirectory"); 94 } 95 catch (IOException e) 96 { 97 log.trace("... no - doesn't look like a jar and no META-INF subdirectory."); 98 return false; 99 } 100 } 101 else 102 { 103 log.trace("... ok - doesn't look like a jar but it is a top level directory."); 104 } 105 } 106 } 107 else if(JarUtils.isArchive(root.getName())) 108 { 109 log.trace("... ok - its an archive or at least pretending to be."); 110 } 111 else 112 { 113 log.trace("... no - not a directory or an archive."); 114 return false; 115 } 116 117 ContextInfoImpl context = new ContextInfoImpl(root.getPathName()); 119 context.setMetaDataPath("META-INF"); 121 122 super.addClassPath(root, root, true, true, context); 124 metaData.addContext(context); 125 contextPath = context.getVfsPath(); 126 127 addAllChildren(root, metaData, deployers); 129 return true; 130 } 131 catch (Exception e) 132 { 133 log.warn("Error determining structure: " + root.getName(), e); 134 if( contextPath != null ) 136 metaData.removeContext(contextPath); 137 return false; 138 } 139 } 140 } 141 | Popular Tags |