RegistryBuilderpublic class RegistryBuilder extends Object Reads the configuration file and creates the
{@link org.apache.lucene.gdata.server.registry.GDataServerRegistry} singleton
instance. All services and components will be instantiated and registered in
the registry. |
Methods Summary |
---|
private static void | addIndexRule(org.apache.commons.digester.Digester digester)
digester.addObjectCreate("gdata/service/index-schema", IndexSchema.class);
digester.addSetNext("gdata/service/index-schema", "setIndexSchema");
digester.addSetProperties("gdata/service/index-schema");
digester.addSetProperties("gdata/service/index-schema/index");
digester.addBeanPropertySetter("gdata/service/index-schema/index/maxMergeDocs");
digester.addBeanPropertySetter("gdata/service/index-schema/index/maxBufferedDocs");
digester.addBeanPropertySetter("gdata/service/index-schema/index/maxFieldLength");
digester.addBeanPropertySetter("gdata/service/index-schema/index/mergeFactor");
digester.addBeanPropertySetter("gdata/service/index-schema/index/indexLocation");
digester.addBeanPropertySetter("gdata/service/index-schema/index/useCompoundFile");
digester.addCallMethod("gdata/service/index-schema/index/defaultAnalyzer", "serviceAnalyzer",1,new Class[]{Class.class});
//call method on top of the stack addSchemaField
digester.addCallMethod("gdata/service/index-schema/field","addSchemaField",1,new Class[]{IndexSchemaField.class});
digester.addObjectCreate("gdata/service/index-schema/field",IndexSchemaField.class);
//set parameter for method call -- parameter is IndexSchemaField
digester.addCallParam("gdata/service/index-schema/field",0,0);
digester.addSetProperties("gdata/service/index-schema/field");
digester.addBeanPropertySetter("gdata/service/index-schema/field/path");
digester.addBeanPropertySetter("gdata/service/index-schema/field/store","storeByName");
digester.addBeanPropertySetter("gdata/service/index-schema/field/index","indexByName");
digester.addBeanPropertySetter("gdata/service/index-schema/field/analyzer","analyzerClass");
// call method on top of the stack addSchemaField
digester.addCallMethod("gdata/service/index-schema/custom","addSchemaField",1,new Class[]{IndexSchemaField.class});
digester.addObjectCreate("gdata/service/index-schema/custom",IndexSchemaField.class);
//set parameter for method call -- parameter is IndexSchemaField
digester.addCallParam("gdata/service/index-schema/custom",0,0);
digester.addSetProperties("gdata/service/index-schema/custom");
digester.addBeanPropertySetter("gdata/service/index-schema/custom/path");
digester.addBeanPropertySetter("gdata/service/index-schema/custom/store","storeByName");
digester.addBeanPropertySetter("gdata/service/index-schema/custom/index","indexByName");
digester.addBeanPropertySetter("gdata/service/index-schema/custom/analyzer","analyzerClass");
digester.addBeanPropertySetter("gdata/service/index-schema/custom/field-class","fieldClass");
// digester.addCallMethod("gdata/service/index-schema/custom/field-class","fieldClass",1,new Class[]{Class.class});
// call method on top of the stack addSchemaField
digester.addCallMethod("gdata/service/index-schema/mixed","addSchemaField",1,new Class[]{IndexSchemaField.class});
digester.addObjectCreate("gdata/service/index-schema/mixed",IndexSchemaField.class);
//set parameter for method call -- parameter is IndexSchemaField
digester.addCallParam("gdata/service/index-schema/mixed",0,0);
digester.addSetProperties("gdata/service/index-schema/mixed");
digester.addBeanPropertySetter("gdata/service/index-schema/mixed","type");
digester.addBeanPropertySetter("gdata/service/index-schema/mixed/path");
digester.addBeanPropertySetter("gdata/service/index-schema/mixed/store","storeByName");
digester.addBeanPropertySetter("gdata/service/index-schema/mixed/index","indexByName");
digester.addBeanPropertySetter("gdata/service/index-schema/mixed/contenttype","typePath");
digester.addBeanPropertySetter("gdata/service/index-schema/mixed/analyzer","analyzerClass");
| private static void | buildFromConfiguration(org.apache.commons.digester.Digester digester, GDataServerRegistry registry, java.lang.String schemaURL)
digester.setValidating(true);
digester.setSchema(schemaURL);
digester.setErrorHandler(new SimpleSaxErrorHandler());
digester.push(registry);
/*
* register services
*/
digester.addObjectCreate("gdata/service", ProvidedServiceConfig.class);
digester.addSetProperties("gdata/service");
digester.addSetNext("gdata/service", "registerService");
digester.addBeanPropertySetter("gdata/service/feed-class", "feedType");
digester.addBeanPropertySetter("gdata/service/entry-class", "entryType");
digester.addBeanPropertySetter("gdata/service/extension-profile",
"extensionProfileClass");
digester.addBeanPropertySetter("gdata/service/previewStyleSheet","xsltStylesheet");
addIndexRule(digester);
/*
* load components and configurations
*/
digester.addCallMethod("gdata/server-components/component",
"registerComponent", 2, new Class[] { Class.class , ComponentConfiguration.class});
digester.addCallParam("gdata/server-components/component/class",0);
digester.addObjectCreate("gdata/server-components/component/configuration",ComponentConfiguration.class);
digester.addCallMethod("gdata/server-components/component/configuration/property","set",2,new Class[]{String.class,String.class});
digester.addCallParam("gdata/server-components/component/configuration/property",0,"name");
digester.addCallParam("gdata/server-components/component/configuration/property",1);
//second parameter on registerComponent -- top of the stack (Component configuration)
digester.addCallParam("gdata/server-components/component/configuration",1,0);
digester.parse(RegistryBuilder.class
.getResourceAsStream("/gdata-config.xml"));
| static void | buildRegistry()builds the {@link GDataServerRegistry} accessible via the
{@link GDataServerRegistry#getRegistry()} method
String schemaFile = RegistryBuilder.class.getResource("/gdata-config.xsd").getFile();
/*
* Force using apache xerces parser for digester
*/
SAXParser parser = new SAXParser();
parser.setFeature("http://apache.org/xml/features/validation/schema-full-checking",true);
parser.setFeature("http://apache.org/xml/features/validation/schema",true);
parser.setFeature("http://xml.org/sax/features/validation",true);
parser.setProperty("http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation",schemaFile);
Digester digester = new Digester(parser);
buildFromConfiguration(digester, GDataServerRegistry
.getRegistry(),schemaFile);
|
|