@Override public String getName() { return file.getName(); }
@Override public boolean accepts(final VirtualFile file) { for(Pattern p: this.patterns){ if(p.matcher(file.getName()).matches()){ return false; } } return true; }
private static boolean isWar(final VirtualFile deploymentRoot) { // TODO: Is there a better way to do this? return deploymentRoot.getName().toLowerCase(Locale.ENGLISH).endsWith(WAR_FILE_EXTENSION); }
@Override public boolean accepts(final VirtualFile file) { return file.isFile() && file.getName().endsWith(".xml"); } }
public boolean accepts(VirtualFile vf) { if (vf == null) return false; if (vf.isFile()) { String fileName = vf.getName().toLowerCase(Locale.ENGLISH); if (fileName.endsWith(".a") || fileName.endsWith(".so") || fileName.endsWith(".dll")) { return true; } } return false; } }
@Override public boolean accepts(VirtualFile file) { for(WildcardPattern p: this.patterns){ if(p.matches(file.getName())){ return false; } } return true; }
@Override public String getContentType(final MimeMappings mimeMappings) { final String fileName = file.getName(); int index = fileName.lastIndexOf('.'); if (index != -1 && index != fileName.length() - 1) { return mimeMappings.getMimeType(fileName.substring(index + 1)); } return null; }
private static String name(VirtualFile file) { if (file == null) throw JPA_LOGGER.nullVar("file"); return file.getName(); }
@Override public String getUnqualifiedJarName(URL jarUrl) { VirtualFile file = getFile(jarUrl); return file.getName(); }
private boolean isTldFile(VirtualFile file) { return file.isFile() && file.getName().toLowerCase(Locale.ENGLISH).endsWith(TLD); }
@Override public boolean isRecurse(VirtualFile file) { // don't recurse into /lib if (file.equals(libDir)) { return false; } for (String suffix : CHILD_ARCHIVE_EXTENSIONS) { if (file.getName().endsWith(suffix)) { // don't recurse into sub deployments return false; } } return true; } })));
private static void addJobXmlFiles(final Map<String, VirtualFile> foundJobXmlFiles, final VirtualFile jobsDir) throws IOException { if (jobsDir != null && jobsDir.exists()) { // We may have some job XML files final Map<String, VirtualFile> xmlFiles = new HashMap<>(); for (VirtualFile f : jobsDir.getChildren(JobXmlFilter.INSTANCE)) { if (xmlFiles.put(f.getName(), f) != null) { throw new IllegalStateException("Duplicate key"); } } foundJobXmlFiles.putAll(xmlFiles); } }
private void append(VirtualFile f, String padding) { String baseName = f.getName(); String size = formatBytes(f.getSize()); buf.append(String.format(fmt, padding, "+-- ", size, baseName)); buf.append("\n"); }
@Override public InputStream accessInputStream() { try { return virtualFile.openStream(); } catch (IOException e) { throw JPA_LOGGER.cannotOpenVFSStream(e, virtualFile.getName()); } }
public boolean accepts(VirtualFile file) { String name = exact ? file.getName() : file.getPathName(); return accepts(name); }
private Set<VirtualFile> dataSources(final DeploymentUnit deploymentUnit) { final VirtualFile deploymentRoot = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT).getRoot(); if (deploymentRoot == null || !deploymentRoot.exists()) { return Collections.emptySet(); } final String deploymentRootName = deploymentRoot.getName().toLowerCase(Locale.ENGLISH); if (deploymentRootName.endsWith("-ds.xml")) { return Collections.singleton(deploymentRoot); } final Set<VirtualFile> ret = new HashSet<VirtualFile>(); for (String location : LOCATIONS) { final VirtualFile loc = deploymentRoot.getChild(location); if (loc.exists()) { for (final VirtualFile file : loc.getChildren()) { if (file.getName().endsWith("-ds.xml")) { ret.add(file); } } } } return ret; }
private void handleDirectory(VirtualFile file, String path) { WeldLogger.DEPLOYMENT_LOGGER.tracef("handling directory: %s", file); for (VirtualFile child : file.getChildren()) { String newPath = (path == null) ? child.getName() : (path + '/' + child.getName()); if (child.isDirectory()) { handleDirectory(child, newPath); } else { handleFile(newPath, () -> file.toURL().openStream()); } } }
private static VirtualFile getDescriptor(final VirtualFile deploymentRoot, final String descriptorName) { // Locate the descriptor final VirtualFile descriptor; // EJB 3.1 FR 20.4 Enterprise Beans Packaged in a .war if (isWar(deploymentRoot)) { // it's a .war file, so look for the ejb-jar.xml in WEB-INF descriptor = deploymentRoot.getChild(WEB_INF + "/" + descriptorName); } else if (deploymentRoot.getName().toLowerCase(Locale.ENGLISH).endsWith(JAR_FILE_EXTENSION)) { descriptor = deploymentRoot.getChild(META_INF + "/" + descriptorName); } else { // neither a .jar nor a .war. Return return null; } if (descriptor == null || !descriptor.exists()) { // no descriptor found, nothing to do! return null; } return descriptor; }
public static void process(VirtualFile deploymentRoot) throws DeploymentUnitProcessingException { if (deploymentRoot == null || !deploymentRoot.exists()) return; final String deploymentRootName = deploymentRoot.getName().toLowerCase(Locale.ENGLISH); if (!deploymentRootName.endsWith(".rar")) { return; } try { List<VirtualFile> libs = deploymentRoot.getChildrenRecursively(new LibraryFilter()); if (libs != null && libs.size() > 0) { for (VirtualFile vf : libs) { String fileName = vf.getName().toLowerCase(Locale.ENGLISH); ROOT_LOGGER.tracef("Processing library: %s", fileName); try { File f = vf.getPhysicalFile(); System.load(f.getAbsolutePath()); ROOT_LOGGER.debugf("Loaded library: %s", f.getAbsolutePath()); } catch (Throwable t) { ROOT_LOGGER.debugf("Unable to load library: %s", fileName); } } } } catch (Exception e) { throw ConnectorLogger.ROOT_LOGGER.failedToLoadNativeLibraries(e); } }
public static IronJacamarXmlDescriptor process(VirtualFile deploymentRoot, boolean resolveProperties) throws DeploymentUnitProcessingException { IronJacamarXmlDescriptor xmlDescriptor = null; if (deploymentRoot == null || !deploymentRoot.exists()) return null; final String deploymentRootName = deploymentRoot.getName().toLowerCase(Locale.ENGLISH); VirtualFile serviceXmlFile = null; if (deploymentRootName.endsWith(".rar")) { serviceXmlFile = deploymentRoot.getChild("/META-INF/ironjacamar.xml"); } if (serviceXmlFile == null || !serviceXmlFile.exists()) return null; InputStream xmlStream = null; Activation result = null; try { xmlStream = serviceXmlFile.openStream(); IronJacamarParser ironJacamarParser = new IronJacamarParser(); ironJacamarParser.setSystemPropertiesResolved(resolveProperties); result = ironJacamarParser.parse(xmlStream); if (result != null) { xmlDescriptor = new IronJacamarXmlDescriptor(result); } else throw ConnectorLogger.ROOT_LOGGER.failedToParseServiceXml(serviceXmlFile); } catch (Exception e) { throw ConnectorLogger.ROOT_LOGGER.failedToParseServiceXml(e, serviceXmlFile); } finally { VFSUtils.safeClose(xmlStream); } return xmlDescriptor; }