Rupert Westenthaler created STANBOL-884:
-------------------------------------------
Summary: Add ServiceLoader support for the ContentItemFactory
Key: STANBOL-884
URL: https://issues.apache.org/jira/browse/STANBOL-884
Project: Stanbol
Issue Type: Improvement
Components: Enhancer
Reporter: Rupert Westenthaler
Assignee: Rupert Westenthaler
Priority: Trivial
By adding the required property file to the META-INF/services directory this
will allow to instantiate a ContentItemFactory instance by using the Java
ServiceLoader utility
Example code snippet:
private ContentITemFactory contentItemFactory;
public ContentItemFactory getContentItemFactory(){
if(contentItemFactory == null){
ServiceLoader<ContentItemFactory> loader =
ServiceLoader.load(ContentItemFactory.class);
Iterator<ContentItemFactory> cifIt = loader.iterator();
if(cifIt.hasNext()){
contentItemFactory = cifIt.next();
} else {
throw new IllegalStateException("No ContentItemFactory
Implementation available!");
}
}
return contentItemFactory;
}
Intended to be used when instantiating a ContentItemFactory in the absence of
an OSGI environment.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira