protected InputStream getConfigurationAsStream() { return ResourceLoader.instance().getResourceAsStream(getConfiguration()); }
/** * Get a Facelet for a URL */ protected Facelet faceletForViewId(String viewId) throws IOException { URL url = ResourceLoader.instance().getResource(viewId); if (url == null) { throw new IllegalArgumentException("resource doesn't exist: " + viewId); } return ApplicationAssociate.getCurrentInstance().getFaceletFactory().getFacelet(url); }
private List<ResourceBundle> loadBundlesForCurrentLocale() { List<ResourceBundle> bundles = new ArrayList<ResourceBundle>(); ResourceLoader resourceLoader = ResourceLoader.instance(); for (String bundleName : resourceLoader.getBundleNames()) { ResourceBundle bundle = resourceLoader.loadBundle(bundleName); if (bundle != null) bundles.add(bundle); } ResourceBundle bundle = resourceLoader.loadBundle("ValidatorMessages"); if (bundle != null) { bundles.add(bundle); } bundle = resourceLoader.loadBundle("org/hibernate/validator/ValidationMessages"); if (bundle != null) bundles.add(bundle); bundle = resourceLoader.loadBundle("javax.faces.Messages"); if (bundle != null) bundles.add(bundle); return Collections.unmodifiableList(bundles); }
public java.util.ResourceBundle getResourceBundle() { String resourceBundleName = getResourceBundleName(); if (resourceBundleName==null) { return null; } else { return ResourceLoader.instance().loadBundle(resourceBundleName); } }
@Override public InputStream getResourceAsStream(String resource) { InputStream stream = null; javax.faces.context.FacesContext context = javax.faces.context.FacesContext.getCurrentInstance(); if (context!=null) { stream = FacesResources.getResourceAsStream( resource, context.getExternalContext() ); } if (stream == null) { stream = super.getResourceAsStream(resource); } return stream; }
@Override public URL getResource(String resource) { URL url = null; javax.faces.context.FacesContext context = javax.faces.context.FacesContext.getCurrentInstance(); if (context!=null) { url = FacesResources.getResource( resource, context.getExternalContext() ); } if (url == null) { url = super.getResource(resource); } return url; }
public static ResourceLoader instance() { if (!Contexts.isApplicationContextActive()) { return new ResourceLoader(); } else { return (ResourceLoader) Component.getInstance(ResourceLoader.class, ScopeType.STATELESS); } }
public ProcessDefinition getProcessDefinitionFromResource(String resourceName) { InputStream resource = ResourceLoader.instance().getResourceAsStream(resourceName); if (resource==null) { throw new IllegalArgumentException("process definition resource not found: " + resourceName); } try { return ProcessDefinition.parseXmlInputStream(resource); } finally { Resources.closeStream(resource); } }
public static ProcessDefinition getPageflowDefinitionFromResource(String resourceName) { InputStream resource = ResourceLoader.instance().getResourceAsStream(resourceName); if (resource==null) { throw new IllegalArgumentException("pageflow resource not found: " + resourceName); } try { return Jbpm.parseInputSource( new InputSource(resource) ); } catch (JpdlException e) { throw new JpdlException("Unable to parse process definition " + resourceName, e); } finally { Resources.closeStream(resource); } }
private void readImage() throws IOException { if (input instanceof URL) { readImage(((URL) input).openStream()); } else if (input instanceof File) { readImage(((File) input).toURL().openStream()); } else if (input instanceof String) { readImage(ResourceLoader.instance().getResourceAsStream((String) input)); } else if (input instanceof InputStream) { readImage((InputStream) input); } else if (input != null && input.getClass().isArray()) { if (input.getClass().getComponentType().isAssignableFrom(Byte.TYPE)) { byte[] b = (byte[]) input; readImage(new ByteArrayInputStream(b)); } } }
public void initialize(Set<FileDescriptor> fileNames) { pagesByViewId = Collections.synchronizedMap(new HashMap<String, Page>()); pageStacksByViewId = Collections.synchronizedMap(new HashMap<String, List<Page>>()); conversations = Collections.synchronizedMap(new HashMap<String, ConversationIdParameter>()); for (String resource: resources) { InputStream stream = ResourceLoader.instance().getResourceAsStream(resource); if (stream==null) { log.debug("no pages.xml file found: " + resource); } else { log.debug("reading pages.xml file: " + resource); try { parse(stream); } finally { Resources.closeStream(stream); } } } if (fileNames != null) { parsePages(fileNames); } }
private ExceptionHandler parse(String fileName) throws DocumentException, ClassNotFoundException InputStream stream = ResourceLoader.instance().getResourceAsStream(fileName); if (stream!=null)
@Override public void encodeBegin(FacesContext facesContext) throws IOException { log.info("Loading template #0", getURL()); if (getURL().indexOf("://") < 0) { reader = new PdfReader(ResourceLoader.instance().getResourceAsStream(getURL())); } else { reader = new PdfReader(new URL(getURL())); } buffer = new ByteArrayOutputStream(); try { stamper = new PdfStamper(reader, buffer); Contexts.getEventContext().set(STAMPER_KEY, stamper); } catch (DocumentException e) { throw new FacesException("Could not create PDF stamper", e); } fields = stamper.getAcroFields(); Contexts.getEventContext().set(FIELDS_KEY, fields); }
InputStream stream = ResourceLoader.instance().getResourceAsStream(ruleFile); if (stream==null) Reader dslReader = new InputStreamReader( ResourceLoader.instance().getResourceAsStream(dslFile) ); builder.addPackageFromDrl(drlReader, dslReader);