String externalBaseURI = TwitLogic.BASE_URI;
final String datasetURI = TwitLogic.TWITLOGIC_DATASET;
int port = TwitLogic.getConfiguration().getInt(TwitLogic.SERVER_PORT, DEFAULT_PORT);
File staticContentDir = TwitLogic.getConfiguration().getFile(TwitLogic.SERVER_STATICCONTENTDIRECTORY);
LinkedDataServer server = new LinkedDataServer(this.getSail(),
internalBaseURI,
externalBaseURI,
datasetURI);
Component component = new Component();
server.setInboundRoot(component);
component.getServers().add(Protocol.HTTP, port);
component.getServers().add(Protocol.FILE, port);
component.getDefaultHost().attach("/", new Directory(server.getContext(), "file://" + staticContentDir + "/"));
for (TwitLogic.ResourceType t : TwitLogic.ResourceType.values()) {
String p = t.getUriPath();
if (!p.equals("graph") && !p.equals("person")) {
component.getDefaultHost().attach("/" + p + "/", WebResource.class);
}
}
component.getDefaultHost().attach("/person/twitter/", PersonResource.class);
component.getDefaultHost().attach("/graph/", GraphResource.class);
component.getDefaultHost().attach("/sparql", new SparqlResource());
component.getDefaultHost().attach("/stream/relatedTweets", new RelatedTweetsResource());
component.getDefaultHost().attach("/stream/relatedTags", new RelatedHashtagsResource());
server.start();
} catch (Throwable e) {
throw new ServerException(e);
}
}