Refine search
@Override protected void configureContext(MutablePicoContainer container) { super.configureContext(container); container.registerComponentImplementation(StyleFactory.class, StyleFactoryImpl.class); container.registerComponentInstance(ResourceLocator.class, new DefaultResourceLocator()); }
List dependencies = allDependencies(); XSDSchemaLocationResolver resolver = dependency.getSchemaLocationResolver(); QName key = new QName(dependency.getNamespaceURI(), "schemaLocationResolver"); container.registerComponentInstance(key, resolver); XSDSchemaLocator locator = dependency.getSchemaLocator(); QName key = new QName(dependency.getNamespaceURI(), "schemaLocator"); container.registerComponentInstance(key, locator); for (Iterator p = dependency.getProperties().iterator(); p.hasNext();) { QName property = (QName) p.next(); container.registerComponentInstance(property, property); } catch (DuplicateComponentKeyRegistrationException e) { container = container.makeChildContainer(); dependency.configureContext(container);
/** * Creates an encoder from a configuration. * <p> * This constructor calls through to {@link #Encoder(Configuration, XSDSchema)} * obtaining the schema instance from {@link Configuration#schema()}. * </p> * @param configuration The encoder configuration. */ public Encoder(Configuration configuration) { this(configuration, configuration.schema()); }
/** * Configures a container which houses all the bindings used during a parse. * * @param container The container housing the binding objects. */ public final MutablePicoContainer setupBindings(MutablePicoContainer container) { //configure bindings of all dependencies for (Iterator d = allDependencies().iterator(); d.hasNext();) { Configuration dependency = (Configuration) d.next(); dependency.registerBindings(container); } //call template method, create a new container to allow subclass to override bindings container = container.makeChildContainer(); configureBindings(container); return container; }
/** * Finds all {@link XSDSchemaLocationResolver}'s used by the configuration. * * @param configuration The parser configuration. * * @return A list of location resolvers, empty if none found. */ public static List findSchemaLocationResolvers( Configuration configuration ) { List all = configuration.allDependencies(); List resolvers = new ArrayList(); for ( Iterator c = all.iterator(); c.hasNext(); ) { configuration = (Configuration) c.next(); XSDSchemaLocationResolver resolver = configuration.getSchemaLocationResolver(); if ( resolver != null ) { resolvers.add( resolver ); } } return resolvers; }
/** * Creates the map of QName to Binding which is used during parsing to attach * bindinds to an element,attribute, or type. * * @return A map of Qname,[Class|Object] */ public final Map setupBindings() { HashMap bindings = new HashMap(); //wrap the binding map up in a pico container for backwards compatability // with old api which registered bindings in a pico container PicoMap container = new PicoMap(bindings); //configure bindings of all dependencies for (Iterator d = allDependencies().iterator(); d.hasNext();) { Configuration dependency = (Configuration) d.next(); dependency.registerBindings(bindings); //call old api dependency.registerBindings((MutablePicoContainer)container); } //call template method, create a new container to allow subclass to override bindings configureBindings(bindings); //call old api configureBindings((MutablePicoContainer)container); return bindings; }
protected void configureContext(MutablePicoContainer container) { super.configureContext(container); container.registerComponentImplementation(FilterFactory.class, FilterFactoryImpl.class); } }
bindingLoader.setContainer(configuration.setupBindings(bindingLoader.getContainer())); context.registerComponentInstance(bindingFactory); context.registerComponentInstance(encoder); context.registerComponentInstance(index); context = configuration.setupContext(context); encoder.setContext(context);
context = configuration.setupContext( context ); container = configuration.setupBindings( container ); bindingLoader.setContainer( container ); context.registerComponentInstance( new BindingFactoryImpl( bindingLoader ) ); context.registerComponentInstance( new BindingWalkerFactoryImpl( bindingLoader , context ) ); context.registerComponentInstance( logger );
public void startDocument() throws SAXException { //perform teh configuration configure(config); //create the document handler + root context DocumentHandler docHandler = handlerFactory.createDocumentHandler(this); context = new DefaultPicoContainer(); context = config.setupContext(context); docHandler.setContext(context); // create the stack and add handler for document element handlers = new Stack(); handlers.push(docHandler); // get a logger from the context logger = (Logger) context.getComponentInstanceOfType(Logger.class); if (logger == null) { //create a default logger = Logger.getLogger("org.geotools.xml"); context.registerComponentInstance(logger); } //setup the namespace support namespaces = new NamespaceSupport(); context.registerComponentInstance(namespaces); context.registerComponentInstance(new NamespaceSupportWrapper(namespaces)); //binding factory support bindingFactory = new BindingFactoryImpl(bindingLoader); context.registerComponentInstance(bindingFactory); //binding walker support context.registerComponentInstance(new BindingWalkerFactoryImpl(bindingLoader, context)); }
@Override protected void configureContext(MutablePicoContainer container) { super.configureContext(container); delegate.configureContext(container); container.unregisterComponent(GML3EncodingUtils.class); container.registerComponentInstance(new GML32EncodingUtils()); } }
protected void encode(FeatureCollectionResponse hits, OutputStream output, WFSInfo wfs) throws IOException { Encoder encoder = new Encoder(configuration, configuration.schema()); encoder.setEncoding(Charset.forName(wfs.getGeoServer().getSettings().getCharset())); encoder.setSchemaLocation( org.geoserver.wfs.xml.v1_1_0.WFS.NAMESPACE, ResponseUtils.appendPath(wfs.getSchemaBaseURL(), "wfs/1.1.0/wfs.xsd")); encoder.encode( hits.getAdaptee(), org.geoserver.wfs.xml.v1_1_0.WFS.FEATURECOLLECTION, output); } }
context = configuration.setupContext(context); Map bindings = configuration.setupBindings(); BindingLoader bindingLoader = new BindingLoader(bindings); context.registerComponentInstance(new BindingFactoryImpl(bindingLoader)); context.registerComponentInstance(new BindingWalkerFactoryImpl(bindingLoader, context)); context.registerComponentInstance(logger); for (Iterator d = configuration.getXSD().getDependencies().iterator(); d.hasNext();) { XSD xsd = (XSD) d.next(); XSDSchema schema = xsd.getSchema(); mappings.putAll(configuration.getXSD().getSchema().getQNamePrefixToNamespaceMap()); } catch (IOException e) { throw new RuntimeException(e);
logger.finer( "No schemaLocation found, using '" + config.getNamespaceURI() + " " + config.getSchemaFileURL() ); locations = new String[] { config.getNamespaceURI(), config.getSchemaFileURL() }; schemas = new XSDSchema[] { config.getXSD().getSchema() }; } catch (IOException e) { throw (SAXException) new SAXException().initCause(e); if ( config.getNamespaceURI().equals( schemas[i].getTargetNamespace()) ) { found = true; break O; XSDImport imprt = (XSDImport) im.next(); if (config.getNamespaceURI().equals(imprt.getNamespace())) { found = true; copy[schemas.length] = config.schema(); schemas = copy; } else { String msg = "parser configuration specified schema: '" + config.getNamespaceURI() + "', but instance document does not reference this schema."; logger.info(msg); namespaces.declarePrefix("", config.getNamespaceURI()); List handlerFactories = context.getComponentInstancesOfType(HandlerFactory.class);
/** * Configures a container which houses all the bindings used during a parse. * * @param container The container housing the binding objects. */ public final MutablePicoContainer setupBindings(MutablePicoContainer container) { //configure bindings of all dependencies for ( Iterator d = allDependencies().iterator(); d.hasNext(); ) { Configuration dependency = (Configuration) d.next(); BindingConfiguration bindings = dependency.getBindingConfiguration(); if ( bindings != null ) bindings.configure( container ); } //call template method, create a new container to allow subclass to override bindings container = container.makeChildContainer(); configureBindings( container ); return container; }
protected Encoder createEncoder( Configuration configuration, Map<String, Set<ResourceInfo>> resources, Object request) { // reuse the WFS configuration feature builder, otherwise build a new one FeatureTypeSchemaBuilder schemaBuilder; if (configuration instanceof WFSConfiguration) { schemaBuilder = ((WFSConfiguration) configuration).getSchemaBuilder(); } else { schemaBuilder = new FeatureTypeSchemaBuilder.GML3(geoServer); } // create this request specific schema ApplicationSchemaXSD1 schema = new ApplicationSchemaXSD1(schemaBuilder); schema.setBaseURL(GetFeatureRequest.adapt(request).getBaseURL()); schema.setResources(resources); if (schema.getFeatureTypes().isEmpty()) { // no feature types so let's use the base WFS schema return new Encoder(configuration, configuration.schema()); } try { // let's just instantiate the encoder return new Encoder(configuration, schema.getSchema()); } catch (IOException exception) { throw new RuntimeException( "Error generating the XSD schema during the encoder instantiation.", exception); } }
locations = new String[] { config.getNamespaceURI(), config.getSchemaFileURL() }; XSDImport imprt = (XSDImport) im.next(); if (config.getNamespaceURI().equals(imprt.getNamespace())) { found = true; copy[schemas.length] = config.schema(); schemas = copy; } else { String msg = "parser configuration specified schema: '" + config.getNamespaceURI() + "', but instance document does not reference this schema."; logger.info(msg); namespaces.declarePrefix("", config.getNamespaceURI()); List handlerFactories = context.getComponentInstancesOfType(HandlerFactory.class);
Set configurations = new HashSet(configuration.allDependencies()); configurations.add(configuration); Configuration conf = (Configuration) it.next(); if(LOGGER.isLoggable(Level.FINE)) LOGGER.fine("looking up schema for " + conf.getNamespaceURI()); XSDSchemaLocator locator = conf.getSchemaLocator(); if(locator == null){ if(LOGGER.isLoggable(Level.FINE)) LOGGER.fine("No schema locator for " + conf.getNamespaceURI()); continue; String namespaceURI = conf.getNamespaceURI(); String schemaLocation = null; try{ URL location = new URL( conf.getSchemaFileURL() ); schemaLocation = location.toExternalForm(); }catch(MalformedURLException e){
/** * Template method for creating the schema instance from the xml configuration. * <p> * Subclasses may with to override or exten this method. The default implementation * uses {@link Configuration#getSchemaFileURL()} and {@link Configuration#getSchemaLocationResolver()} * to parse the schema directly. * </p> * * @return The created schema. * * @throws Exception Any errors that occur while parsing the schema. */ protected XSDSchema createSchema() throws Exception { //add dependent location resolvers List resolvers = new ArrayList(); for ( Iterator d = configuration.allDependencies().iterator(); d.hasNext(); ) { Configuration dependency = (Configuration) d.next(); XSDSchemaLocationResolver resolver = dependency.getSchemaLocationResolver(); if ( resolver != null) { resolvers.add( resolver ); } } String location = configuration.getSchemaFileURL().toString(); if(logger.isLoggable(Level.FINE)) logger.fine("parsing schema " + configuration.getNamespaceURI() ); return Schemas.parse( location, null, resolvers ); } }
for (Iterator d = handler.getConfiguration().allDependencies().iterator(); d.hasNext();) { Configuration dependency = (Configuration) d.next(); if (XS.NAMESPACE.equals(dependency.getNamespaceURI())) { continue; schemaLocation.append(dependency.getNamespaceURI()); schemaLocation.append(" "); schemaLocation.append(dependency.getSchemaFileURL()); handler.getConfiguration().getSchemaFileURL());