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()); } } } }
public void undeploy(DeploymentUnit context) { final List<ResourceRoot> childRoots = context.removeAttachment(Attachments.RESOURCE_ROOTS); if(childRoots != null) { for(ResourceRoot childRoot : childRoots) { VFSUtils.safeClose(childRoot.getMountHandle()); } } } }
@Override public void undeploy(DeploymentUnit context) { final List<ResourceRoot> childRoots = context.removeAttachment(Attachments.RESOURCE_ROOTS); if (childRoots != null) { for (ResourceRoot childRoot : childRoots) { VFSUtils.safeClose(childRoot.getMountHandle()); } } }
VFSUtils.safeClose(stream);
private EarMetaData handleSpecMetadata(VirtualFile deploymentFile, final PropertyReplacer propertyReplacer) throws DeploymentUnitProcessingException { final VirtualFile applicationXmlFile = deploymentFile.getChild(APPLICATION_XML); if (!applicationXmlFile.exists()) { return null; } InputStream inputStream = null; try { inputStream = applicationXmlFile.openStream(); final XMLInputFactory inputFactory = XMLInputFactory.newInstance(); inputFactory.setXMLResolver(NoopXMLResolver.create()); XMLStreamReader xmlReader = inputFactory.createXMLStreamReader(inputStream); return EarMetaDataParser.INSTANCE.parse(xmlReader, propertyReplacer); } catch (Exception e) { throw EeLogger.ROOT_LOGGER.failedToParse(e, applicationXmlFile); } finally { VFSUtils.safeClose(inputStream); } }
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); }
public static ConnectorXmlDescriptor process(boolean resolveProperties, VirtualFile file, VirtualFile alternateDescriptor, String deploymentName) throws DeploymentUnitProcessingException { // Locate the descriptor final VirtualFile serviceXmlFile; if (alternateDescriptor != null) { serviceXmlFile = alternateDescriptor; } else { serviceXmlFile = file.getChild("/META-INF/ra.xml"); } InputStream xmlStream = null; Connector result = null; try { if (serviceXmlFile != null && serviceXmlFile.exists()) { xmlStream = serviceXmlFile.openStream(); RaParser raParser = new RaParser(); raParser.setSystemPropertiesResolved(resolveProperties); result = raParser.parse(xmlStream); if (result == null) throw ConnectorLogger.ROOT_LOGGER.failedToParseServiceXml(serviceXmlFile); } File root = file.getPhysicalFile(); URL url = root.toURI().toURL(); return new ConnectorXmlDescriptor(result, root, url, deploymentName); } catch (Exception e) { throw ConnectorLogger.ROOT_LOGGER.failedToParseServiceXml(e, serviceXmlFile); } finally { VFSUtils.safeClose(xmlStream); } }
/** * 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); } }
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; }
throw SarLogger.ROOT_LOGGER.failedXmlParsing(e, serviceXmlFile); } finally { VFSUtils.safeClose(xmlStream);
throw new DeploymentUnitProcessingException(e.getMessage(), e); } finally { VFSUtils.safeClose(xmlStream);
/** * {@inheritDoc} */ public void stop(StopContext context) { VFSUtils.safeClose(PROVIDER); }
/** * Safely close some resources without throwing an exception. Any exception will be logged at TRACE level. * * @param ci the resources */ public static void safeClose(final Iterable<? extends Closeable> ci) { if (ci != null) { for (Closeable closeable : ci) { safeClose(closeable); } } }
/** * Forcefully close this handle. Use with caution. */ public void close() { if (handle != null) { VFSUtils.safeClose(handle); } }
/** * {@inheritDoc} */ public void stop(StopContext context) { VFSUtils.safeClose(PROVIDER); }
/** * {@inheritDoc} */ @Override public void close() throws IOException { VFSUtils.safeClose(virtualJarInputStream); super.close(); }
void cleanup() { if (mounted.compareAndSet(true, false)) { VFSUtils.safeClose(handles); handles.clear(); final Collection<RegistryEntry> entries = getEntriesRecursive(); for (RegistryEntry entry : entries) { entry.cleanup(); } } }
public void undeploy(DeploymentUnit context) { final ResourceRoot resourceRoot = context.removeAttachment(Attachments.DEPLOYMENT_ROOT); if (resourceRoot != null) { final Closeable mountHandle = resourceRoot.getMountHandle(); VFSUtils.safeClose(mountHandle); } } }