List of usage examples for org.xml.sax InputSource setSystemId
public void setSystemId(String systemId)
From source file:org.apache.axis2.jaxbri.CodeGenerationUtility.java
/** * @param additionalSchemas/*from www . j av a 2s . c om*/ * @throws RuntimeException */ public static TypeMapper processSchemas(final List schemas, Element[] additionalSchemas, CodeGenConfiguration cgconfig) throws RuntimeException { try { //check for the imported types. Any imported types are supposed to be here also if (schemas == null || schemas.isEmpty()) { //there are no types to be code generated //However if the type mapper is left empty it will be a problem for the other //processes. Hence the default type mapper is set to the configuration return new DefaultTypeMapper(); } final Map schemaToInputSourceMap = new HashMap(); final Map<String, StringBuffer> publicIDToStringMap = new HashMap<String, StringBuffer>(); //create the type mapper JavaTypeMapper mapper = new JavaTypeMapper(); String baseURI = cgconfig.getBaseURI(); if (!baseURI.endsWith("/")) { baseURI = baseURI + "/"; } for (int i = 0; i < schemas.size(); i++) { XmlSchema schema = (XmlSchema) schemas.get(i); InputSource inputSource = new InputSource(new StringReader(getSchemaAsString(schema))); //here we have to set a proper system ID. otherwise when processing the // included schaemas for this schema we have a problem // it creates the system ID using this target namespace value inputSource.setSystemId(baseURI + "xsd" + i + ".xsd"); inputSource.setPublicId(schema.getTargetNamespace()); schemaToInputSourceMap.put(schema, inputSource); } File outputDir = new File(cgconfig.getOutputLocation(), "src"); outputDir.mkdir(); Map nsMap = cgconfig.getUri2PackageNameMap(); EntityResolver resolver = new EntityResolver() { public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException { InputSource returnInputSource = null; XmlSchema key = null; for (Iterator iter = schemaToInputSourceMap.keySet().iterator(); iter.hasNext();) { key = (XmlSchema) iter.next(); String nsp = key.getTargetNamespace(); if (nsp != null && nsp.equals(publicId)) { // when returning the input stream we have to always return a new // input stream. // sinc jaxbri internally consumes the input stream it gives an // exception. returnInputSource = new InputSource(new StringReader(getSchemaAsString(key))); InputSource existingInputSource = (InputSource) schemaToInputSourceMap.get(key); returnInputSource.setSystemId(existingInputSource.getSystemId()); returnInputSource.setPublicId(existingInputSource.getPublicId()); break; } } if (returnInputSource == null) { // then we have to find this using the file system if (systemId != null) { returnInputSource = new InputSource(systemId); returnInputSource.setSystemId(systemId); } } if (returnInputSource == null) { if (publicId != null) { if (!publicIDToStringMap.containsKey(publicId)) { URL url = new URL(publicId); BufferedReader bufferedReader = new BufferedReader( new InputStreamReader(url.openStream())); StringBuffer stringBuffer = new StringBuffer(); String str = null; while ((str = bufferedReader.readLine()) != null) { stringBuffer.append(str); } publicIDToStringMap.put(publicId, stringBuffer); } String schemaString = publicIDToStringMap.get(publicId).toString(); returnInputSource = new InputSource(new StringReader(schemaString)); returnInputSource.setPublicId(publicId); returnInputSource.setSystemId(publicId); } } return returnInputSource; } }; Map properties = cgconfig.getProperties(); String bindingFileName = (String) properties.get(BINDING_FILE_NAME); XmlSchema key = null; for (Iterator schemaIter = schemaToInputSourceMap.keySet().iterator(); schemaIter.hasNext();) { SchemaCompiler sc = XJC.createSchemaCompiler(); if (bindingFileName != null) { if (bindingFileName.endsWith(".jar")) { scanEpisodeFile(new File(bindingFileName), sc); } else { InputSource inputSoruce = new InputSource(new FileInputStream(bindingFileName)); inputSoruce.setSystemId(new File(bindingFileName).toURI().toString()); sc.getOptions().addBindFile(inputSoruce); } } key = (XmlSchema) schemaIter.next(); if (nsMap != null) { Iterator iterator = nsMap.entrySet().iterator(); while (iterator.hasNext()) { Map.Entry entry = (Map.Entry) iterator.next(); String namespace = (String) entry.getKey(); String pkg = (String) nsMap.get(namespace); registerNamespace(sc, namespace, pkg); } } sc.setEntityResolver(resolver); sc.setErrorListener(new ErrorListener() { public void error(SAXParseException saxParseException) { log.error(saxParseException.getMessage()); log.debug(saxParseException.getMessage(), saxParseException); } public void fatalError(SAXParseException saxParseException) { log.error(saxParseException.getMessage()); log.debug(saxParseException.getMessage(), saxParseException); } public void warning(SAXParseException saxParseException) { log.warn(saxParseException.getMessage()); log.debug(saxParseException.getMessage(), saxParseException); } public void info(SAXParseException saxParseException) { log.info(saxParseException.getMessage()); log.debug(saxParseException.getMessage(), saxParseException); } }); sc.parseSchema((InputSource) schemaToInputSourceMap.get(key)); sc.getOptions().addGrammar((InputSource) schemaToInputSourceMap.get(key)); for (Object property : properties.keySet()) { String propertyName = (String) property; if (propertyName.startsWith("X")) { String[] args = null; String propertyValue = (String) properties.get(property); if (propertyValue != null) { args = new String[] { "-" + propertyName, propertyValue }; } else { args = new String[] { "-" + propertyName }; } sc.getOptions().parseArguments(args); } } // Bind the XML S2JJAXBModel jaxbModel = sc.bind(); if (jaxbModel == null) { throw new RuntimeException("Unable to generate code using jaxbri"); } // Emit the code artifacts JCodeModel codeModel = jaxbModel.generateCode(null, null); FileCodeWriter writer = new FileCodeWriter(outputDir); codeModel.build(writer); Collection mappings = jaxbModel.getMappings(); Iterator iter = mappings.iterator(); while (iter.hasNext()) { Mapping mapping = (Mapping) iter.next(); QName qn = mapping.getElement(); String typeName = mapping.getType().getTypeClass().fullName(); mapper.addTypeMappingName(qn, typeName); } //process the unwrapped parameters if (!cgconfig.isParametersWrapped()) { //figure out the unwrapped operations List axisServices = cgconfig.getAxisServices(); for (Iterator servicesIter = axisServices.iterator(); servicesIter.hasNext();) { AxisService axisService = (AxisService) servicesIter.next(); for (Iterator operations = axisService.getOperations(); operations.hasNext();) { AxisOperation op = (AxisOperation) operations.next(); if (WSDLUtil.isInputPresentForMEP(op.getMessageExchangePattern())) { AxisMessage message = op.getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE); if (message != null && message.getParameter(Constants.UNWRAPPED_KEY) != null) { Mapping mapping = jaxbModel.get(message.getElementQName()); List elementProperties = mapping.getWrapperStyleDrilldown(); for (int j = 0; j < elementProperties.size(); j++) { Property elementProperty = (Property) elementProperties.get(j); QName partQName = WSDLUtil.getPartQName(op.getName().getLocalPart(), WSDLConstants.INPUT_PART_QNAME_SUFFIX, elementProperty.elementName().getLocalPart()); //this type is based on a primitive type- use the //primitive type name in this case String fullJaveName = elementProperty.type().fullName(); if (elementProperty.type().isArray()) { fullJaveName = fullJaveName.concat("[]"); } mapper.addTypeMappingName(partQName, fullJaveName); if (elementProperty.type().isPrimitive()) { mapper.addTypeMappingStatus(partQName, Boolean.TRUE); } if (elementProperty.type().isArray()) { mapper.addTypeMappingStatus(partQName, Constants.ARRAY_TYPE); } } } } if (WSDLUtil.isOutputPresentForMEP(op.getMessageExchangePattern())) { AxisMessage message = op.getMessage(WSDLConstants.MESSAGE_LABEL_OUT_VALUE); if (message != null && message.getParameter(Constants.UNWRAPPED_KEY) != null) { Mapping mapping = jaxbModel.get(message.getElementQName()); List elementProperties = mapping.getWrapperStyleDrilldown(); for (int j = 0; j < elementProperties.size(); j++) { Property elementProperty = (Property) elementProperties.get(j); QName partQName = WSDLUtil.getPartQName(op.getName().getLocalPart(), WSDLConstants.OUTPUT_PART_QNAME_SUFFIX, elementProperty.elementName().getLocalPart()); //this type is based on a primitive type- use the //primitive type name in this case String fullJaveName = elementProperty.type().fullName(); if (elementProperty.type().isArray()) { fullJaveName = fullJaveName.concat("[]"); } mapper.addTypeMappingName(partQName, fullJaveName); if (elementProperty.type().isPrimitive()) { mapper.addTypeMappingStatus(partQName, Boolean.TRUE); } if (elementProperty.type().isArray()) { mapper.addTypeMappingStatus(partQName, Constants.ARRAY_TYPE); } } } } } } } } // Return the type mapper return mapper; } catch (Exception e) { throw new RuntimeException(e); } }
From source file:org.apache.axis2.jaxws.description.impl.URIResolverImpl.java
public InputSource resolveEntity(String namespace, String schemaLocation, String baseUri) { if (log.isDebugEnabled()) { log.debug("resolveEntity: [" + namespace + "][" + schemaLocation + "][ " + baseUri + "]"); }//from w w w . ja v a 2 s . c o m InputStream is = null; URI pathURI = null; String pathURIStr = null; if (log.isDebugEnabled()) { log.debug("Import location: " + schemaLocation + " parent document: " + baseUri); } if (baseUri != null) { try { // if the location is an absolute path, build a URL directly // from it if (log.isDebugEnabled()) { log.debug("Base URI not null"); } if (isAbsolute(schemaLocation)) { if (log.isDebugEnabled()) { log.debug("Retrieving input stream for absolute schema location: " + schemaLocation); } is = getInputStreamForURI(schemaLocation); } else { if (log.isDebugEnabled()) { log.debug("schemaLocation not in absolute path"); } try { pathURI = new URI(baseUri); } catch (URISyntaxException e) { // Got URISyntaxException, Creation of URI requires // that we use special escape characters in path. // The URI constructor below does this for us, so lets use that. if (log.isDebugEnabled()) { log.debug("Got URISyntaxException. Exception Message = " + e.getMessage()); log.debug("Implementing alternate way to create URI"); } pathURI = new URI(null, null, baseUri, null); } pathURIStr = schemaLocation; // If this is absolute we need to resolve the path without the // scheme information if (pathURI.isAbsolute()) { if (log.isDebugEnabled()) { log.debug("Parent document is at absolute location: " + pathURI.toString()); } URL url = new URL(baseUri); if (url != null) { URI tempURI; try { tempURI = new URI(url.getPath()); } catch (URISyntaxException e) { //Got URISyntaxException, Creation of URI requires // that we use special escape characters in path. // The URI constructor below does this for us, so lets use that. if (log.isDebugEnabled()) { log.debug("Got URISyntaxException. Exception Message = " + e.getMessage()); log.debug("Implementing alternate way to create URI"); } tempURI = new URI(null, null, url.getPath(), null); } URI resolvedURI = tempURI.resolve(schemaLocation); // Add back the scheme to the resolved path pathURIStr = constructPath(url, resolvedURI); if (log.isDebugEnabled()) { log.debug("Resolved this path to imported document: " + pathURIStr); } } } else { if (log.isDebugEnabled()) { log.debug("Parent document is at relative location: " + pathURI.toString()); } pathURI = pathURI.resolve(schemaLocation); pathURIStr = pathURI.toString(); if (log.isDebugEnabled()) { log.debug("Resolved this path to imported document: " + pathURIStr); } } // If path is absolute, build URL directly from it if (isAbsolute(pathURIStr)) { is = getInputStreamForURI(pathURIStr); } // if the location is relative, we need to resolve the // location using // the baseURI, then use the loadStrategy to gain an input // stream // because the URI will still be relative to the module if (is == null) { is = classLoader.getResourceAsStream(pathURI.toString()); } } } catch (Exception e) { if (log.isDebugEnabled()) { log.debug("Exception occured in resolveEntity, ignoring exception continuing processing " + e.getMessage()); log.debug(e); } } } if (is == null) { if (log.isDebugEnabled()) { log.debug("XSD input stream is null after resolving import for: " + schemaLocation + " from parent document: " + baseUri); } } else { if (log.isDebugEnabled()) { log.debug("XSD input stream is not null after resolving import for: " + schemaLocation + " from parent document: " + baseUri); } } InputSource returnInputSource = new InputSource(is); // We need to set the systemId. XmlSchema will use this value to maintain a collection of // imported XSDs that have been read. If this value is null, then circular XSDs will // cause infinite recursive reads. returnInputSource.setSystemId(pathURIStr != null ? pathURIStr : schemaLocation); if (log.isDebugEnabled()) { log.debug("returnInputSource :" + returnInputSource.getSystemId()); } return returnInputSource; }
From source file:org.apache.axis2.jaxws.util.CatalogURIResolver.java
/** * Given a redirecteURI from a static XML catalog, attempt to get the InputSource. * @param redirectedURI URI string from static XML catalog * @return InputSource or null if we were not able to load the resource *//* w w w .jav a 2s.com*/ private InputSource getInputSourceFromRedirectedURI(String redirectedURI) { InputStream is = null; String validatedURI = null; InputSource returnInputSource = null; // If we have an absolute path, try to get the InputStream directly if (isAbsolute(redirectedURI)) { is = getInputStreamForURI(redirectedURI); if (is != null) { validatedURI = redirectedURI; } } // If we couldn't get the inputstream try using the classloader if (is == null && classLoader != null) { try { is = classLoader.getResourceAsStream(redirectedURI); if (is != null) { validatedURI = redirectedURI; } } catch (Throwable t) { if (log.isDebugEnabled()) { log.debug( "Exception occured in validateRedirectedURI, ignoring exception continuing processing: " + t.getMessage()); } } // If we failed to get an InputStream using the entire redirectedURI, // try striping off the protocol. This may be necessary for some cases // if a non-standard protocol is used. if (is == null) { redirectedURI = stripProtocol(redirectedURI); if (log.isDebugEnabled()) { log.debug("getInputSourceFromRedirectedURI: new redirected location: " + redirectedURI); } try { is = classLoader.getResourceAsStream(redirectedURI); if (is != null) { validatedURI = redirectedURI; } } catch (Throwable t) { if (log.isDebugEnabled()) { log.debug( "Exception occured in validateRedirectedURI, ignoring exception continuing processing: " + t.getMessage()); } } } } if (is != null) { if (log.isDebugEnabled()) { log.debug( "getInputSourceFromRedirectedURI: XSD input stream is not null after resolving import for: " + redirectedURI); } returnInputSource = new InputSource(is); // We need to set the systemId. XmlSchema will use this value to // maintain a collection of // imported XSDs that have been read. If this value is null, then // circular XSDs will // cause infinite recursive reads. returnInputSource.setSystemId(validatedURI != null ? validatedURI : redirectedURI); if (log.isDebugEnabled()) { log.debug("returnInputSource :" + returnInputSource.getSystemId()); } } return returnInputSource; }
From source file:org.apache.beehive.netui.pageflow.AutoRegisterActionServlet.java
/** * This method is almost exactly the same as the base class initModuleConfig. The only difference * is that it does not throw an UnavailableException if a module configuration file is missing or * invalid./* w ww . j av a 2 s. c om*/ */ protected ModuleConfig initModuleConfig(String prefix, String paths) throws ServletException { if (_log.isDebugEnabled()) { _log.debug("Initializing module path '" + prefix + "' configuration from '" + paths + '\''); } // Parse the configuration for this module ModuleConfig moduleConfig = null; InputStream input = null; String mapping; try { ModuleConfigFactory factoryObject = ModuleConfigFactory.createFactory(); moduleConfig = factoryObject.createModuleConfig(prefix); // Support for module-wide ActionMapping type override mapping = getServletConfig().getInitParameter("mapping"); if (mapping != null) { moduleConfig.setActionMappingClass(mapping); } // Configure the Digester instance we will use Digester digester = initConfigDigester(); // Process each specified resource path while (paths.length() > 0) { digester.push(moduleConfig); String path; int comma = paths.indexOf(','); if (comma >= 0) { path = paths.substring(0, comma).trim(); paths = paths.substring(comma + 1); } else { path = paths.trim(); paths = ""; } if (path.length() < 1) { break; } URL url = getConfigResource(path); // // THIS IS THE MAIN DIFFERENCE: we're doing a null-check here. // if (url != null) { URLConnection conn = url.openConnection(); conn.setUseCaches(false); InputStream in = conn.getInputStream(); try { InputSource is = new InputSource(in); is.setSystemId(url.toString()); input = getConfigResourceAsStream(path); is.setByteStream(input); // also, we're not letting it fail here either. try { digester.parse(is); getServletContext().setAttribute(Globals.MODULE_KEY + prefix, moduleConfig); } catch (Exception e) { _log.error(Bundle.getString("PageFlow_Struts_ModuleParseError", path), e); } input.close(); } finally { in.close(); } } else { // // Special case. If this is the default (root) module and the module path is one that's normally // generated by the page flow compiler, then we don't want to error out if it's missing, since // this probably just means that there's no root-level page flow. Set up a default, empty, // module config. // if (prefix.equals("") && isAutoLoadModulePath(path, prefix)) { if (_log.isInfoEnabled()) { _log.info("There is no root module at " + path + "; initializing a default module."); } // // Set the ControllerConfig to a MissingRootModuleControllerConfig. This is used by // PageFlowRequestProcessor. // moduleConfig.setControllerConfig(new MissingRootModuleControllerConfig()); } else { _log.error(Bundle.getString("PageFlow_Struts_MissingModuleConfig", path)); } } } } catch (Throwable t) { _log.error(internal.getMessage("configParse", paths), t); throw new UnavailableException(internal.getMessage("configParse", paths)); } finally { if (input != null) { try { input.close(); } catch (IOException e) { // ignore } } } // Force creation and registration of DynaActionFormClass instances // for all dynamic form beans we will be using FormBeanConfig fbs[] = moduleConfig.findFormBeanConfigs(); for (int i = 0; i < fbs.length; i++) { if (fbs[i].getDynamic()) { DynaActionFormClass.createDynaActionFormClass(fbs[i]); } } // Special handling for the default module (for // backwards compatibility only, will be removed later) if (prefix.length() < 1) { defaultControllerConfig(moduleConfig); defaultMessageResourcesConfig(moduleConfig); } // Return the completed configuration object //config.freeze(); // Now done after plugins init return moduleConfig; }
From source file:org.apache.cayenne.map.MapLoader.java
/** * Loads DataMap from file specified by <code>uri</code> parameter. * /*w w w .j a v a 2s . com*/ * @throws CayenneRuntimeException if source URI does not resolve to a valid map files * @deprecated since 3.1 {@link #loadDataMap(InputSource)} should be used. */ @Deprecated public DataMap loadDataMap(String uri) throws CayenneRuntimeException { // configure resource locator ResourceFinder locator = createResourceFinder(); URL url = locator.getResource(uri); if (url == null) { throw new CayenneRuntimeException("Can't find data map " + uri); } InputStream in; try { in = url.openStream(); } catch (IOException e) { throw new CayenneRuntimeException(e); } try { InputSource inSrc = new InputSource(in); inSrc.setSystemId(uri); return loadDataMap(inSrc); } finally { try { in.close(); } catch (IOException ioex) { } } }
From source file:org.apache.cayenne.modeler.action.ImportDataMapAction.java
protected void importDataMap() { File dataMapFile = selectDataMap(Application.getFrame()); if (dataMapFile == null) { return;/*w ww.j a va2 s. c o m*/ } DataMap newMap; try { URL url = dataMapFile.toURI().toURL(); try (InputStream in = url.openStream();) { InputSource inSrc = new InputSource(in); inSrc.setSystemId(dataMapFile.getAbsolutePath()); newMap = new MapLoader().loadDataMap(inSrc); } ConfigurationNode root = getProjectController().getProject().getRootNode(); newMap.setName(NameBuilder.builder(newMap, root).baseName(newMap.getName()).name()); Resource baseResource = ((DataChannelDescriptor) root).getConfigurationSource(); if (baseResource != null) { Resource dataMapResource = baseResource .getRelativeResource(nameMapper.configurationLocation(newMap)); newMap.setConfigurationSource(dataMapResource); } getProjectController().addDataMap(this, newMap); } catch (Exception ex) { logObj.info("Error importing DataMap.", ex); JOptionPane.showMessageDialog(Application.getFrame(), "Error reading DataMap: " + ex.getMessage(), "Can't Open DataMap", JOptionPane.OK_OPTION); } }
From source file:org.apache.cayenne.unit.di.server.SchemaBuilder.java
/** * Completely rebuilds test schema./*from w ww . j a v a2 s .c om*/ */ // TODO - this method changes the internal state of the object ... refactor public void rebuildSchema() { if ("true".equalsIgnoreCase(System.getProperty(SKIP_SCHEMA_KEY))) { logger.info("skipping schema generation... "); return; } // generate schema combining all DataMaps that require schema support. // Schema generation is done like that instead of per DataMap on demand // to avoid conflicts when dropping and generating PK objects. DataMap[] maps = new DataMap[MAPS_REQUIRING_SCHEMA_SETUP.length]; for (int i = 0; i < maps.length; i++) { InputStream stream = getClass().getClassLoader().getResourceAsStream(MAPS_REQUIRING_SCHEMA_SETUP[i]); InputSource in = new InputSource(stream); in.setSystemId(MAPS_REQUIRING_SCHEMA_SETUP[i]); maps[i] = new MapLoader().loadDataMap(in); } this.domain = new DataDomain("temp"); domain.setEventManager(new DefaultEventManager(2)); domain.setEntitySorter(new AshwoodEntitySorter()); domain.setQueryCache(new MapQueryCache(50)); try { for (DataMap map : maps) { initNode(map); } dropSchema(); dropPKSupport(); createSchema(); createPKSupport(); } catch (Exception e) { throw new RuntimeException("Error rebuilding schema", e); } }
From source file:org.apache.cocoon.Cocoon.java
/** * Configure this <code>Cocoon</code> instance. * * @param startupManager an <code>ExcaliburComponentManager</code> value * @exception ConfigurationException if an error occurs * @exception ContextException if an error occurs */// w w w .j a v a 2 s. co m public void configure(ExcaliburComponentManager startupManager) throws ConfigurationException, ContextException { SAXParser p = null; Settings settings = SettingsHelper.getSettings(this.context); Configuration roles = null; try { p = (SAXParser) startupManager.lookup(SAXParser.ROLE); SAXConfigurationHandler b = new PropertyAwareSAXConfigurationHandler(settings, getLogger()); URL url = ClassUtils.getResource("org/apache/cocoon/cocoon.roles"); InputSource is = new InputSource(url.openStream()); is.setSystemId(url.toString()); p.parse(is, b); roles = b.getConfiguration(); } catch (Exception e) { throw new ConfigurationException("Error trying to load configurations", e); } finally { if (p != null) startupManager.release((Component) p); } DefaultRoleManager drm = new DefaultRoleManager(); ContainerUtil.enableLogging(drm, this.rootLogger.getChildLogger("roles")); ContainerUtil.configure(drm, roles); roles = null; try { this.configurationFile.refresh(); p = (SAXParser) startupManager.lookup(SAXParser.ROLE); SAXConfigurationHandler b = new PropertyAwareSAXConfigurationHandler(settings, getLogger()); InputSource is = SourceUtil.getInputSource(this.configurationFile); p.parse(is, b); this.configuration = b.getConfiguration(); } catch (Exception e) { throw new ConfigurationException("Error trying to load configurations", e); } finally { if (p != null) startupManager.release((Component) p); } Configuration conf = this.configuration; if (getLogger().isDebugEnabled()) { getLogger().debug("Root configuration: " + conf.getName()); } if (!"cocoon".equals(conf.getName())) { throw new ConfigurationException("Invalid configuration file\n" + conf.toString()); } if (getLogger().isDebugEnabled()) { getLogger().debug("Configuration version: " + conf.getAttribute("version")); } if (!Constants.CONF_VERSION.equals(conf.getAttribute("version"))) { throw new ConfigurationException( "Invalid configuration schema version. Must be '" + Constants.CONF_VERSION + "'."); } String userRoles = conf.getAttribute("user-roles", ""); if (!"".equals(userRoles)) { try { p = (SAXParser) startupManager.lookup(SAXParser.ROLE); SAXConfigurationHandler b = new PropertyAwareSAXConfigurationHandler(settings, getLogger()); org.apache.cocoon.environment.Context context = (org.apache.cocoon.environment.Context) this.context .get(Constants.CONTEXT_ENVIRONMENT_CONTEXT); URL url = context.getResource(userRoles); if (url == null) { throw new ConfigurationException( "User-roles configuration '" + userRoles + "' cannot be found."); } InputSource is = new InputSource(new BufferedInputStream(url.openStream())); is.setSystemId(url.toString()); p.parse(is, b); roles = b.getConfiguration(); } catch (Exception e) { throw new ConfigurationException("Error trying to load user-roles configuration", e); } finally { startupManager.release((Component) p); } DefaultRoleManager urm = new DefaultRoleManager(drm); ContainerUtil.enableLogging(urm, this.rootLogger.getChildLogger("roles").getChildLogger("user")); ContainerUtil.configure(urm, roles); roles = null; drm = urm; } this.componentManager.setRoleManager(drm); this.componentManager.setLoggerManager(this.loggerManager); getLogger().debug("Setting up components..."); ContainerUtil.configure(this.componentManager, conf); }
From source file:org.apache.cocoon.components.xslt.TraxProcessor.java
/** * Return a new <code>InputSource</code> object that uses the * <code>InputStream</code> and the system ID of the <code>Source</code> * object./*from w ww. java2s . c o m*/ * * @throws IOException * if I/O error occured. */ protected InputSource getInputSource(final Source source) throws IOException, SourceException { final InputSource newObject = new InputSource(source.getInputStream()); newObject.setSystemId(source.getURI()); return newObject; }
From source file:org.apache.cocoon.core.container.spring.avalon.ConfigurationReader.java
/** * Construct input source from given Resource, initialize system Id. * * @param rsrc Resource for the input source * @return Input source//from w w w . j a va 2 s. c om * @throws Exception if resource URL is not valid or input stream is not available */ protected InputSource getInputSource(Resource rsrc) throws IOException { final InputSource is = new InputSource(rsrc.getInputStream()); is.setSystemId(getUrl(rsrc)); return is; }