@Override public void deploy(DeploymentUnit unit) throws DeploymentException { TorqueBoxMetaData externalMetaData = unit.getAttachment(TorqueBoxMetaData.EXTERNAL, TorqueBoxMetaData.class); if (log.isTraceEnabled()) { log.trace("External: " + externalMetaData); } if (externalMetaData == null) { return; } TorqueBoxMetaData metaData = unit.getAttachment(TorqueBoxMetaData.class); if (log.isTraceEnabled()) { log.trace("Internal: " + metaData); } if (metaData == null) { unit.addAttachment(TorqueBoxMetaData.class, externalMetaData); return; } try { TorqueBoxMetaData mergedMetaData = externalMetaData.overlayOnto(metaData); if (log.isTraceEnabled()) { log.trace("Merged: " + mergedMetaData); } unit.addAttachment(TorqueBoxMetaData.class, mergedMetaData); } catch (ClassCastException e) { throw new DeploymentException( "Incompatible structures in external and internal deployment descriptors", e); } }
@SuppressWarnings("unchecked") public void deploy(VFSDeploymentUnit unit) throws DeploymentException { TorqueBoxMetaData globalMetaData = unit.getAttachment(TorqueBoxMetaData.class); log.debug("Global torquebox.yml: " + globalMetaData); Object data = null; if (globalMetaData != null) { data = globalMetaData.getSection(getSectionName()); log.debug("Global data section for " + getSectionName() + ": " + data); } if (data == null && isSupportsStandalone()) { VirtualFile metaDataFile = getMetaDataFile(unit, getFileName()); if ((metaDataFile != null) && metaDataFile.exists()) { log.warn("Usage of " + getFileName() + " is deprecated. Please use torquebox.yml."); InputStream in = null; try { in = metaDataFile.openStream(); Yaml yaml = new Yaml(); data = (Map<String, ?>) yaml.load(in); } catch (YAMLException e) { log.warn("Error parsing: " + metaDataFile + ": " + e.getMessage()); data = null; } catch (IOException e) { throw new DeploymentException(e); } finally { if (in != null) { try { in.close(); } catch (IOException e) { throw new DeploymentException(e); } } } } } if (data == null) { return; } try { parse(unit, data); } catch (DeploymentException e) { throw e; } catch (Exception e) { throw new DeploymentException(e); } }