private static Properties loadPropertiesFromResource(String resource) { Properties properties = new Properties(); InputStream inputStream = ClassLoaderUtil.getStream(resource); if (inputStream != null) { try { properties.load(inputStream); } catch (IOException e) { log.warn("could not load hibernate properties from resource: " + resource, e); } } else { log.warn("hibernate properties resource not found: " + resource); } return properties; }
private static Properties loadPropertiesFromResource(String resource) { Properties properties = new Properties(); InputStream inputStream = ClassLoaderUtil.getStream(resource); if (inputStream != null) { try { properties.load(inputStream); } catch (IOException e) { log.warn("could not load hibernate properties from resource: " + resource, e); } } else { log.warn("hibernate properties resource not found: " + resource); } return properties; }
/** * parse a process definition from a process archive resource. * * @throws org.jbpm.jpdl.JpdlException if parsing reported an error. */ public static ProcessDefinition parseParResource(String parResource) throws IOException { return parseParZipInputStream(new ZipInputStream(ClassLoaderUtil.getStream(parResource))); }
/** * parse a process definition from a process archive resource. * * @throws org.jbpm.jpdl.JpdlException if parsing reported an error. */ public static ProcessDefinition parseParResource(String parResource) throws IOException { return parseParZipInputStream(new ZipInputStream(ClassLoaderUtil.getStream(parResource))); }
/** * @param useConfiguredLoader if <code>true</code>, this method searches for the resource in * the context class loader, if not found it falls back on the class loader of this class * @see <a href="https://jira.jboss.org/jira/browse/JBPM-1148">JBPM-1148</a> */ public static Document parseXmlResource(String resource, boolean useConfiguredLoader) { InputStream inputStream = ClassLoaderUtil.getStream(resource, useConfiguredLoader); if (inputStream == null) { throw new IllegalArgumentException("resource not found: " + resource); } InputSource inputSource = new InputSource(inputStream); return parseXmlInputSource(inputSource); }
/** * @param useConfiguredLoader if <code>true</code>, this method searches for the resource in * the context class loader, if not found it falls back on the class loader of this class * @see <a href="https://jira.jboss.org/jira/browse/JBPM-1148">JBPM-1148</a> */ public static Document parseXmlResource(String resource, boolean useConfiguredLoader) { InputStream inputStream = ClassLoaderUtil.getStream(resource, useConfiguredLoader); if (inputStream == null) { throw new IllegalArgumentException("resource not found: " + resource); } InputSource inputSource = new InputSource(inputStream); return parseXmlInputSource(inputSource); }
/** * Returns a stream for reading the specified resource. This method helps bootstrap jBPM * because the class loader used for locating the configuration resource cannot be configured * in the configuration itself. * * @param useConfiguredLoader if <code>true</code>, this method searches for the resource in * the context class loader, if not found it falls back on the loader of this class * @return a stream for reading the resource, or <code>null</code> if the resource was not * found */ public static InputStream getStream(String resource, boolean useConfiguredLoader) { if (useConfiguredLoader) return getStream(resource); // try context class loader first, allowing applications to override built-in resources InputStream stream = Thread.currentThread() .getContextClassLoader() .getResourceAsStream(resource); if (stream == null) { // fall back on the loader of this class stream = ClassLoaderUtil.class.getClassLoader().getResourceAsStream(resource); } return stream; }
/** * Returns a stream for reading the specified resource. This method helps bootstrap jBPM * because the class loader used for locating the configuration resource cannot be configured * in the configuration itself. * * @param useConfiguredLoader if <code>true</code>, this method searches for the resource in * the context class loader, if not found it falls back on the loader of this class * @return a stream for reading the resource, or <code>null</code> if the resource was not * found */ public static InputStream getStream(String resource, boolean useConfiguredLoader) { if (useConfiguredLoader) return getStream(resource); // try context class loader first, allowing applications to override built-in resources InputStream stream = Thread.currentThread() .getContextClassLoader() .getResourceAsStream(resource); if (stream == null) { // fall back on the loader of this class stream = ClassLoaderUtil.class.getClassLoader().getResourceAsStream(resource); } return stream; }
private static Map initialiseNodeTypes(String resource) { Map types = new HashMap(); InputStream nodeTypesStream = ClassLoaderUtil.getStream(resource); Element nodeTypesElement = XmlUtil.parseXmlInputStream(nodeTypesStream) .getDocumentElement(); for (Iterator iter = XmlUtil.elementIterator(nodeTypesElement, "node-type"); iter.hasNext();) { Element nodeTypeElement = (Element) iter.next(); String elementTag = nodeTypeElement.getAttribute("element"); String className = nodeTypeElement.getAttribute("class"); try { Class nodeClass = ClassLoaderUtil.classForName(className); types.put(elementTag, nodeClass); } catch (ClassNotFoundException e) { if (log.isDebugEnabled()) { log.debug("node '" + elementTag + "' will not be available, class not found: " + className); } } } return types; }
private static Map initialiseActionTypes(String resource) { Map types = new HashMap(); InputStream actionTypesStream = ClassLoaderUtil.getStream(resource); Element actionTypesElement = XmlUtil.parseXmlInputStream(actionTypesStream) .getDocumentElement(); for (Iterator iter = XmlUtil.elementIterator(actionTypesElement, "action-type"); iter.hasNext();) { Element actionTypeElement = (Element) iter.next(); String elementTag = actionTypeElement.getAttribute("element"); String className = actionTypeElement.getAttribute("class"); try { Class actionClass = ClassLoaderUtil.classForName(className); types.put(elementTag, actionClass); } catch (ClassNotFoundException e) { if (log.isDebugEnabled()) { log.debug("action '" + elementTag + "' will not be available, class not found: " + className); } } } return types; } }
public static Properties getProperties(String resource) { InputStream inStream = getStream(resource); if (inStream == null) throw new JbpmException("resource not found: " + resource); try { Properties properties = new Properties(); properties.load(inStream); return properties; } catch (IOException e) { throw new JbpmException("could not load properties from resource: " + resource, e); } finally { try { inStream.close(); } catch (IOException e) { Log log = LogFactory.getLog(ClassLoaderUtil.class); log.warn("failed to close resource: " + resource, e); } } } }
public static Properties getProperties(String resource) { InputStream inStream = getStream(resource); if (inStream == null) throw new JbpmException("resource not found: " + resource); try { Properties properties = new Properties(); properties.load(inStream); return properties; } catch (IOException e) { throw new JbpmException("could not load properties from resource: " + resource, e); } finally { try { inStream.close(); } catch (IOException e) { Log log = LogFactory.getLog(ClassLoaderUtil.class); log.warn("failed to close resource: " + resource, e); } } } }
private static Map initialiseNodeTypes(String resource) { Map types = new HashMap(); InputStream nodeTypesStream = ClassLoaderUtil.getStream(resource); Element nodeTypesElement = XmlUtil.parseXmlInputStream(nodeTypesStream) .getDocumentElement(); for (Iterator iter = XmlUtil.elementIterator(nodeTypesElement, "node-type"); iter.hasNext();) { Element nodeTypeElement = (Element) iter.next(); String elementTag = nodeTypeElement.getAttribute("element"); String className = nodeTypeElement.getAttribute("class"); try { Class nodeClass = ClassLoaderUtil.classForName(className); types.put(elementTag, nodeClass); } catch (ClassNotFoundException e) { if (log.isDebugEnabled()) { log.debug("node '" + elementTag + "' will not be available, class not found: " + className); } } } return types; }
private static Map initialiseActionTypes(String resource) { Map types = new HashMap(); InputStream actionTypesStream = ClassLoaderUtil.getStream(resource); Element actionTypesElement = XmlUtil.parseXmlInputStream(actionTypesStream) .getDocumentElement(); for (Iterator iter = XmlUtil.elementIterator(actionTypesElement, "action-type"); iter.hasNext();) { Element actionTypeElement = (Element) iter.next(); String elementTag = actionTypeElement.getAttribute("element"); String className = actionTypeElement.getAttribute("class"); try { Class actionClass = ClassLoaderUtil.classForName(className); types.put(elementTag, actionClass); } catch (ClassNotFoundException e) { if (log.isDebugEnabled()) { log.debug("action '" + elementTag + "' will not be available, class not found: " + className); } } } return types; } }
public static JbpmConfiguration parseResource(String resource) { ObjectFactory objectFactory; if (resource != null) { log.info("configuring from resource: " + resource); InputStream inputStream = ClassLoaderUtil.getStream(resource, false); if (inputStream == null) { throw new IllegalArgumentException("resource not found: " + resource); } objectFactory = parseObjectFactory(inputStream); try { inputStream.close(); } catch (IOException e) { log.warn("failed to close resource: " + resource, e); } } else { objectFactory = loadDefaultObjectFactory(); } return createJbpmConfiguration(objectFactory, resource); }
public static JbpmConfiguration parseResource(String resource) { ObjectFactory objectFactory; if (resource != null) { log.info("configuring from resource: " + resource); InputStream inputStream = ClassLoaderUtil.getStream(resource, false); if (inputStream == null) { throw new IllegalArgumentException("resource not found: " + resource); } objectFactory = parseObjectFactory(inputStream); try { inputStream.close(); } catch (IOException e) { log.warn("failed to close resource: " + resource, e); } } else { objectFactory = loadDefaultObjectFactory(); } return createJbpmConfiguration(objectFactory, resource); }
protected synchronized Repository getRepository() { if (repository==null) { try { InputStream stream = ClassLoaderUtil.getStream(configuration); RepositoryConfig config = RepositoryConfig.create(stream, directory); repository = RepositoryImpl.create(config); } catch (Exception e) { // NOTE that Error's are not caught because that might halt the JVM and mask the original Error. throw new JbpmException("couldn't create new jackrabbit repository with configResource '"+configuration+"' and directory '"+directory+"'", e); } } return repository; } }
protected synchronized Repository getRepository() { if (repository==null) { try { InputStream stream = ClassLoaderUtil.getStream(configuration); RepositoryConfig config = RepositoryConfig.create(stream, directory); repository = RepositoryImpl.create(config); } catch (Exception e) { // NOTE that Error's are not caught because that might halt the JVM and mask the original Error. throw new JbpmException("couldn't create new jackrabbit repository with configResource '"+configuration+"' and directory '"+directory+"'", e); } } return repository; } }
public static List getJbpmTypes() { if (Configs.hasObject("jbpm.types")) { return (List) Configs.getObject("jbpm.types"); } String resource = Configs.getString("resource.varmapping"); synchronized (typesByResource) { List types = (List) typesByResource.get(resource); if (types == null) { InputStream resourceStream = ClassLoaderUtil.getStream(resource); ObjectFactory objectFactory = ObjectFactoryParser.parseInputStream(resourceStream); types = (List) objectFactory.createObject("jbpm.types"); typesByResource.put(resource, types); } return types; } } }
public static List getJbpmTypes() { if (Configs.hasObject("jbpm.types")) { return (List) Configs.getObject("jbpm.types"); } String resource = Configs.getString("resource.varmapping"); synchronized (typesByResource) { List types = (List) typesByResource.get(resource); if (types == null) { InputStream resourceStream = ClassLoaderUtil.getStream(resource); ObjectFactory objectFactory = ObjectFactoryParser.parseInputStream(resourceStream); types = (List) objectFactory.createObject("jbpm.types"); typesByResource.put(resource, types); } return types; } } }