Refine search
private JBossAppMetaData handleJbossMetadata(VirtualFile deploymentFile, final PropertyReplacer propertyReplacer, final DeploymentUnit deploymentUnit) throws DeploymentUnitProcessingException { final VirtualFile applicationXmlFile = deploymentFile.getChild(JBOSS_APP_XML); if (!applicationXmlFile.exists()) { //may have been in jboss-all.xml return deploymentUnit.getAttachment(AppJBossAllParser.ATTACHMENT_KEY); } InputStream inputStream = null; try { inputStream = applicationXmlFile.openStream(); final XMLInputFactory inputFactory = XMLInputFactory.newInstance(); inputFactory.setXMLResolver(NoopXMLResolver.create()); XMLStreamReader xmlReader = inputFactory.createXMLStreamReader(inputStream); return JBossAppMetaDataParser.INSTANCE.parse(xmlReader, propertyReplacer); } catch (Exception e) { throw EeLogger.ROOT_LOGGER.failedToParse(e, applicationXmlFile); } finally { VFSUtils.safeClose(inputStream); } }
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); if(deploymentUnit.hasAttachment(Attachments.DEPLOYMENT_PROPERTIES)) { return; } final ResourceRoot deploymentRoot = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.DEPLOYMENT_ROOT); final VirtualFile deploymentFile = deploymentRoot.getRoot(); final VirtualFile propertiesFile = deploymentFile.getChild(DEPLOYMENT_PROPERTIES); if (!propertiesFile.exists()) { return; } Properties properties = new Properties(); InputStream propertyFileStream = null; try { propertyFileStream = propertiesFile.openStream(); properties.load(propertyFileStream); } catch (IOException e) { throw EeLogger.ROOT_LOGGER.failedToLoadJbossProperties(e); } finally { VFSUtils.safeClose(propertyFileStream); } deploymentUnit.putAttachment(Attachments.DEPLOYMENT_PROPERTIES, properties); }
final VirtualFile deploymentRoot = phaseContext.getDeploymentUnit().getAttachment(Attachments.DEPLOYMENT_ROOT).getRoot(); if(deploymentRoot == null || !deploymentRoot.exists()) return; if(deploymentRoot.isDirectory()) { serviceXmlFile = deploymentRoot.getChild(SERVICE_DESCRIPTOR_PATH); } else if(deploymentRoot.getName().toLowerCase(Locale.ENGLISH).endsWith(SERVICE_DESCRIPTOR_SUFFIX)) { serviceXmlFile = deploymentRoot; final JBossServiceXmlDescriptor xmlDescriptor = result.getResult(); if(xmlDescriptor != null) phaseContext.getDeploymentUnit().putAttachment(JBossServiceXmlDescriptor.ATTACHMENT_KEY, xmlDescriptor); else throw SarLogger.ROOT_LOGGER.failedXmlParsing(serviceXmlFile); throw SarLogger.ROOT_LOGGER.failedXmlParsing(e, serviceXmlFile); } finally { VFSUtils.safeClose(xmlStream);
private void processRoot(final ResourceRoot resourceRoot, final Map<String, List<String>> foundServices) throws DeploymentUnitProcessingException { final VirtualFile virtualFile = resourceRoot.getRoot(); final VirtualFile child = virtualFile.getChild("META-INF/services"); for (VirtualFile serviceType : child.getChildren()) { final String name = serviceType.getName(); try { List<String> list = foundServices.get(name); VFSUtils.safeClose(stream);
DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); if (deploymentUnit.getAttachment( Attachments.DEPLOYMENT_ROOT ) != null || !deploymentUnit.getName().endsWith( this.fileSuffix )) { return; final DeploymentMountProvider deploymentMountProvider = deploymentUnit.getAttachment( Attachments.SERVER_DEPLOYMENT_REPOSITORY ); if(deploymentMountProvider == null) { throw new DeploymentUnitProcessingException( "No deployment repository available." ); } finally { if (failed) { VFSUtils.safeClose( handle ); final ResourceRoot resourceRoot = new ResourceRoot( deploymentRoot, mountHandle ); deploymentUnit.putAttachment( Attachments.DEPLOYMENT_ROOT, resourceRoot ); deploymentUnit.putAttachment( DESCRIPTOR_ROOT, resourceRoot );
/** * Recursively copy a file or directory from one location to another. * * @param original the original virtual file or directory * @param destDir the destination virtual directory * @throws IOException if an I/O error occurs before the copy is complete */ public static void recursiveCopy(VirtualFile original, VirtualFile destDir) throws IOException { final String name = original.getName(); final File destFile = destDir.getChild(name).getPhysicalFile(); if (original.isDirectory()) { destFile.mkdir(); for (VirtualFile file : original.getChildren()) { recursiveCopy(file, destFile); } } else { final OutputStream os = new FileOutputStream(destFile); try { final InputStream is = original.openStream(); copyStreamAndClose(is, os); } finally { // in case the input stream open fails safeClose(os); } } }
/** * Parse -jboss-beans.xml file. * * @param unit the deployment unit * @param beansXmlFile the beans xml file * @throws DeploymentUnitProcessingException * for any error */ protected void parseDescriptor(DeploymentUnit unit, VirtualFile beansXmlFile) throws DeploymentUnitProcessingException { if (beansXmlFile == null || beansXmlFile.exists() == false) return; InputStream xmlStream = null; try { xmlStream = beansXmlFile.openStream(); final XMLStreamReader reader = inputFactory.createXMLStreamReader(xmlStream); final ParseResult<KernelDeploymentXmlDescriptor> result = new ParseResult<KernelDeploymentXmlDescriptor>(); xmlMapper.parseDocument(result, reader); final KernelDeploymentXmlDescriptor xmlDescriptor = result.getResult(); if (xmlDescriptor != null) unit.addToAttachmentList(KernelDeploymentXmlDescriptor.ATTACHMENT_KEY, xmlDescriptor); else throw PojoLogger.ROOT_LOGGER.failedToParse(beansXmlFile); } catch (DeploymentUnitProcessingException e) { throw e; } catch (Exception e) { throw PojoLogger.ROOT_LOGGER.parsingException(beansXmlFile, e); } finally { VFSUtils.safeClose(xmlStream); } }
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); boolean resolveProperties = Util.shouldResolveJBoss(deploymentUnit); final PropertyResolver propertyResolver = deploymentUnit.getAttachment(org.jboss.as.ee.metadata.property.Attachments.FINAL_PROPERTY_RESOLVER); final PropertyReplacer propertyReplacer = deploymentUnit.getAttachment(org.jboss.as.ee.metadata.property.Attachments.FINAL_PROPERTY_REPLACER); InputStream xmlStream = null; try { xmlStream = new FileInputStream(f.getPhysicalFile()); DsXmlParser parser = new DsXmlParser(propertyResolver, propertyReplacer); parser.setSystemPropertiesResolved(resolveProperties); deploymentUnit.addToAttachmentList(DATA_SOURCES_ATTACHMENT_KEY, dataSources); VFSUtils.safeClose(xmlStream);
Manifest manifest = getManifest(file); if (manifest == null) { return; } Attributes mainAttributes = manifest.getMainAttributes(); if (classPath == null) { if (trace) { VFSLogger.ROOT_LOGGER.tracef("Manifest has no Class-Path for %s", file.getPathName()); VirtualFile parent = file.getParent(); if (parent == null) { VFSLogger.ROOT_LOGGER.debugf("%s has no parent.", file); VFSLogger.ROOT_LOGGER.tracef("Parsing Class-Path: %s for %s parent=%s", classPath, file.getName(), parent.getName()); addManifestLocations(vf, paths); } else if (trace) { VFSLogger.ROOT_LOGGER.tracef("%s from manifest is already in the classpath %s", vf.getName(), paths);
child = root.getChild(entry.getPath()); throw DeploymentException.rethrowAsDeploymentException("Unable to find class path entry " + entry + " from " + root.getName(), t); if (child.exists() == false) throw new DeploymentException("Unable to find class path entry " + entry + " from " + root.getName()); VFSUtils.addManifestLocations(file, classPath); if (classPathHadVF == false) classPathHadVF = file.equals(root); if (classPathHadVF == false && SecurityActions.isLeaf(file) == false) VFSUtils.addManifestLocations(file, classPath);
public void undeploy(DeploymentUnit context) { final List<ResourceRoot> children = context.removeAttachment(Attachments.RESOURCE_ROOTS); if (children != null) { for (ResourceRoot childRoot : children) { VFSUtils.safeClose(childRoot.getMountHandle()); } } } }
/** * Recursively copy a file or directory from one location to another. * * @param original the original virtual file or directory * @param destDir the destination directory * @throws IOException if an I/O error occurs before the copy is complete */ public static void recursiveCopy(VirtualFile original, File destDir) throws IOException { final String name = original.getName(); final File destFile = new File(destDir, name); if (original.isDirectory()) { destFile.mkdir(); for (VirtualFile file : original.getChildren()) { recursiveCopy(file, destFile); } } else { final OutputStream os = new FileOutputStream(destFile); try { final InputStream is = original.openStream(); copyStreamAndClose(is, os); } finally { // in case the input stream open fails safeClose(os); } } }
/** * Construct a {@link VirtualJarInputStream} from a {@link VirtualFile} root * * @param root VirtualFile directory to use as the base of the virtual Jar. * @throws IOException */ public VirtualJarInputStream(VirtualFile root) throws IOException { super(VFSUtils.emptyStream()); this.root = root; final VirtualFile manifest = root.getChild(JarFile.MANIFEST_NAME); if (manifest.exists()) { entryItr.add(Collections.singleton(manifest).iterator()); this.manifest = VFSUtils.readManifest(manifest); } else { this.manifest = null; } entryItr.add(root.getChildren().iterator()); }
/** * Get a manifest from a virtual file, assuming the virtual file is the root of an archive * * @param archive the root the archive * @return the manifest or null if not found * @throws IOException if there is an error reading the manifest or the virtual file is closed * @throws IllegalArgumentException for a null archive */ public static Manifest getManifest(VirtualFile archive) throws IOException { if (archive == null) { throw MESSAGES.nullArgument("archive"); } VirtualFile manifest = archive.getChild(JarFile.MANIFEST_NAME); if (manifest == null || !manifest.exists()) { if (VFSLogger.ROOT_LOGGER.isTraceEnabled()) { VFSLogger.ROOT_LOGGER.tracef("Can't find manifest for %s", archive.getPathName()); } return null; } return readManifest(manifest); }
public static Manifest getManifest(ResourceRoot resourceRoot) throws DeploymentUnitProcessingException { Manifest manifest = resourceRoot.getAttachment(Attachments.MANIFEST); if (manifest == null) { final VirtualFile deploymentRoot = resourceRoot.getRoot(); try { manifest = VFSUtils.getManifest(deploymentRoot); } catch (IOException e) { throw ServerMessages.MESSAGES.failedToGetManifest(deploymentRoot, e); } } return manifest; }
final File f = file.getPhysicalFile(); xmlStream = new FileInputStream(f); try { try { mapper.parseDocument(result, streamReader); deploymentUnit.addToAttachmentList(MessagingAttachments.PARSE_RESULT, result); } finally { safeClose(streamReader, f.getAbsolutePath()); throw new DeploymentUnitProcessingException(e.getMessage(), e); } finally { VFSUtils.safeClose(xmlStream);
/** * Recursively copy a file or directory from one location to another. * * @param original the original file or directory * @param destDir the destination directory * @throws IOException if an I/O error occurs before the copy is complete */ public static void recursiveCopy(File original, VirtualFile destDir) throws IOException { final String name = original.getName(); final File destFile = destDir.getChild(name).getPhysicalFile(); if (original.isDirectory()) { destFile.mkdir(); for (File file : original.listFiles()) { recursiveCopy(file, destFile); } } else { final OutputStream os = new FileOutputStream(destFile); try { final InputStream is = new FileInputStream(original); copyStreamAndClose(is, os); } finally { // in case the input stream open fails safeClose(os); } } }
server.deploy(runtimeName, input); } finally { VFSUtils.safeClose(input); XBundleRevision brev = depUnit.getAttachment(OSGiConstants.BUNDLE_REVISION_KEY); return brev;
final boolean checking = WildFlySecurityManager.isChecking(); if (checking) { sm.checkPermission(new VirtualFilePermission(root.getPathName(), "read")); return VFSUtils.getManifest(root); }) : VFSUtils.getManifest(root); } catch (PrivilegedActionException pe) { try { rootUrl = usePhysicalCodeSource ? VFSUtils.getRootURL(root) : root.asFileURL();
if (includeRootManifestCP && entry.isDirectory()) VFSUtils.addManifestLocations(entry, paths); context.addClassPathEntry(cpe); if (trace) log.trace("Added classpath entry " + entryPath + " for " + vf.getName() + " from " + root);