/** * {@inheritDoc} */ @Override public String toString() { return getName() + ", " + path; }
/** * Create from a spring resource. * * @param res * the spring resource * @return the paxml resource */ public static PaxmlResource createFromResource(Resource res) { URL url; try { url = res.getURL(); } catch (IOException e) { throw new PaxmlRuntimeException("Cannot create paxmlResource from spring resource: " + res, e); } return createFromPath(url.toString()); }
private List<IParserContext> findCircle(LinkedList<IParserContext> stack, PaxmlResource resource) { List<IParserContext> list = null; for (IParserContext context : stack) { PaxmlResource res = context.getResource(); if (list == null && res.equals(resource)) { list = new ArrayList<IParserContext>(2); } if (list != null) { list.add(context); } } return list; }
/** * {@inheritDoc} */ @Override protected Object doInvoke(Context context) { Object value = getValue(); PaxmlResource res = getEntity().getResource(); String msg = includeResourceName ? ((fullResourceName ? res.getPath() : res.getName()) + ": " + value) : String .valueOf(value); if (level == Level.ERROR) { log.error(msg); } else if (level == Level.WARN) { log.warn(msg); } else if (level == Level.DEBUG) { log.debug(msg); } else { log.info(msg); } return value; }
|| cached.isModified()) { if (resource.getSpringResource().exists()) { InputStream in = null; try { in = resource.openInputStream(); OMElement root = AxiomUtils.getRootElement(in); root.close(false); if (entity != null && entity.isCachable() && StringUtils.isNotBlank(resource.getName())) { resourceLocator.getCachedPaxmlEntities().put(resource, entity);
if (paxmlOrPlanFileName.equals(res.getName())) { r = res; break; log.info("Starting plan file execution: " + entity.getResource().getPath()); model.setResource(r.getSpringResource()); run(model, execId); if (log.isInfoEnabled()) { log.info("Finished executing plan file: " + entity.getResource().getPath());
public long getLastModified() { Resource res = getSpringResource(); if (!res.exists()) { return -1; } final File file; try { file = res.getFile(); } catch (IOException e) { return 0; } return file.lastModified(); }
/** * {@inheritDoc} */ @Override protected Object doInvoke(Context context) throws Exception { final Object value = getValue(); final String path = value == null ? null : value.toString().trim(); if (StringUtils.isBlank(path)) { throw new PaxmlRuntimeException("No spring xml file given!"); } Resource res = PaxmlUtils.getResource(path, getEntity().getResource().getSpringResource()); PaxmlResource _res = PaxmlResource.createFromResource(res); return SpringXmlEntityFactory.getApplicationContext(_res); }
private final static void logExecution(PaxmlResource res, boolean trueStartFalseEnd) { if (log.isInfoEnabled()) { log.info((trueStartFalseEnd ? "Starting" : "Finished") + " Paxml execution: " + res.getPath()); } }
/** * {@inheritDoc} */ @Override public String printTree(int indent) { InputStream in = getResource().openInputStream(); try { ByteArrayOutputStream out = new ByteArrayOutputStream(); IOUtils.copy(in, out); return out.toString("UTF-8"); } catch (Exception e) { throw new PaxmlRuntimeException("Cannot inspect paxml resource: " + getResource(), e); } finally { IOUtils.closeQuietly(in); } }
entity.setTimestamp(resource.getLastModified()); entity.setTagName(root.getLocalName()); entity.setLineNumber(root.getLineNumber());
/** * {@inheritDoc} */ @Override protected Object doInvoke(Context context) { Object value = getValue(); PaxmlResource res = getEntity().getResource(); String msg = includeResourceName ? ((fullResourceName ? res.getPath() : res.getName()) + ": " + value) : String .valueOf(value); if (level == Level.ERROR) { log.error(msg); } else if (level == Level.WARN) { log.warn(msg); } else if (level == Level.DEBUG) { log.debug(msg); } else { log.info(msg); } return value; }
if (forceRefresh || (cached = this.resourceLocator.getCachedPaxmlEntities().get(resource)) == null || cached.isModified()) { if (resource.getSpringResource().exists()) { InputStream in = null; try { in = resource.openInputStream(); OMElement root = AxiomUtils.getRootElement(in); try { root.close(false); if (entity != null && entity.isCachable() && StringUtils.isNotBlank(resource.getName())) { resourceLocator.getCachedPaxmlEntities().put(resource, entity);
public long getLastModified() { Resource res = getSpringResource(); if (!res.exists()) { return -1; } final File file; try { file = res.getFile(); } catch (IOException e) { return 0; } return file.lastModified(); }
/** * {@inheritDoc} */ @Override protected Object doInvoke(Context context) throws Exception { final Object value = getValue(); final String path = value == null ? null : value.toString().trim(); if (StringUtils.isBlank(path)) { throw new PaxmlRuntimeException("No spring xml file given!"); } Resource res = Parser.getResource(path, getEntity().getResource().getSpringResource()); PaxmlResource _res = PaxmlResource.createFromResource(res); return SpringXmlEntityFactory.getApplicationContext(_res); }
/** * Get the cached application context with paxml resource. * * @param targetResource * the paxml resource pointing to a spring bean xml file. * @return the application context. */ public static ApplicationContext getApplicationContext(PaxmlResource targetResource) { if (log.isInfoEnabled()) { log.debug("Requesting spring resource: " + targetResource.getPath()); } ApplicationContext factory = FACTORY_CACHE.get(targetResource); if (factory == null) { if (log.isInfoEnabled()) { log.info("Loading spring xml: " + targetResource.getPath()); } if (targetResource instanceof ClasspathResource) { factory = new ClassPathXmlApplicationContext(targetResource.getPath()); } else { factory = new FileSystemXmlApplicationContext(targetResource.getPath()); } ApplicationContext existing = FACTORY_CACHE.putIfAbsent(targetResource, factory); if (existing != null) { factory = existing; } } return factory; } }
/** * {@inheritDoc} */ @Override public String printTree(int indent) { InputStream in = getResource().openInputStream(); try { ByteArrayOutputStream out = new ByteArrayOutputStream(); IOUtils.copy(in, out); return out.toString("UTF-8"); } catch (Exception e) { throw new PaxmlRuntimeException("Cannot inspect paxml resource: " + getResource(), e); } finally { IOUtils.closeQuietly(in); } }
entity.setTimestamp(resource.getLastModified()); entity.setTagName(root.getLocalName()); entity.setLineNumber(root.getLineNumber());
/** * {@inheritDoc} */ @Override public String toString() { return getName() + ", " + path; }
/** * {@inheritDoc} */ @Override public String toString() { StringBuilder sb = new StringBuilder(); PaxmlResource res = getDisplayResource(); sb.append("<").append(getTagName()).append(":").append(getClass().getSimpleName()).append("> line ") .append(getLineNumber()).append(" of '").append(res.getName()).append("' ["); Map<String, Object> attrs = inspectAttributes(); if (attrs != null) { boolean first = true; for (Map.Entry<String, Object> entry : attrs.entrySet()) { if (entry.getValue() != null) { if (first) { first = false; } else { sb.append(", "); } sb.append(entry.getKey()).append("=").append(entry.getValue()); } } } sb.append("], resource: ").append(res.getPath()); return sb.toString(); }