Skip to content

Instantly share code, notes, and snippets.

@ansell
Created August 24, 2011 03:03
Show Gist options
  • Save ansell/1167214 to your computer and use it in GitHub Desktop.
Save ansell/1167214 to your computer and use it in GitHub Desktop.
Tasks to add dynamic service support in queryall
1. Create class QueryTypeEnum extends QueryAllEnum
2. Create interface QueryTypeParser extends QueryAllParser<QueryType>
3. Create interface QueryTypeFactory extends QueryAllFactory<QueryTypeEnum, QueryTypeParser, QueryType>
4. Create class QueryTypeRegistry extends AbstractServiceLoader<QueryTypeEnum, QueryTypeFactory>
5. Create org.queryall.impl.querytype.QueryTypeImplParser with:
public QueryType createObject(...)
...
return new QueryTypeImpl(rdfStatements, subjectKey, modelVersion);
...
6. Create org.queryall.impl.querytype.QueryTypeImplFactory with:
public class QueryTypeImplFactory implements QueryTypeFactory
{
/**
* Returns the enumeration from the enumeration that matches this factory
*/
@Override
public QueryTypeEnum getEnum()
{
return QueryTypeEnum.valueOf(QueryTypeImpl.class.getName());
}
@Override
public QueryTypeParser getParser()
{
return new QueryTypeImplParser();
}
}
7. Create META-INF/services/org.queryall.api.querytype.QueryTypeFactory with:
org.queryall.impl.querytype.QueryTypeImplFactory
8. In QueryTypeImpl.java:
static
{
...
// register this query type implementation with the central register
QueryTypeEnum.register(QueryTypeImpl.class.getName(), myTypes());
}
9. In RdfUtils.java:
Modify the getQueryTypes() method to find all of the query type objects, and then find all of the RDF.TYPE's for each of these objects and pass this list to QueryTypeEnums to get a full list of supported enums for these types, then pass this list interatively to the parser to get a full list of parsers, and for each parser call createObject() with the relevant statements etc.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment