use of com.bluenimble.platform.indexer.impls.ElasticSearchIndexer in project serverless by bluenimble.
the class ElasticSearchPlugin method init.
@Override
public void init(final ApiServer server) throws Exception {
Feature aFeature = Indexer.class.getAnnotation(Feature.class);
if (aFeature == null || Lang.isNullOrEmpty(aFeature.name())) {
return;
}
feature = aFeature.name();
server.addFeature(new ServerFeature() {
private static final long serialVersionUID = -9012279234275100528L;
@Override
public Class<?> type() {
return Indexer.class;
}
@Override
public Object get(ApiSpace space, String name) {
String remotePluginName = Json.getString(remote, Spec.RemotePlugin);
String remoteObjectId = Json.getString(remote, Spec.RemoteObject);
if (Lang.isNullOrEmpty(remotePluginName) || Lang.isNullOrEmpty(remoteObjectId)) {
return null;
}
Plugin pRemote = server.getPluginsRegistry().lockup(Json.getString(remote, Spec.RemotePlugin));
if (pRemote == null) {
return null;
}
PackageClassLoader pcl = (PackageClassLoader) pRemote.getClass().getClassLoader();
Remote iRemote = (Remote) pcl.lookupObject(Json.getString(remote, Spec.RemoteObject));
if (iRemote == null) {
return null;
}
// build basic auth and url
String token = buildAuthToken(space, name);
if (Lang.isNullOrEmpty(token)) {
return null;
}
String url = buildUrl(space, name);
if (Lang.isNullOrEmpty(url)) {
return null;
}
return new ElasticSearchIndexer(iRemote, url, token, tracer());
}
@Override
public String provider() {
return ElasticSearchPlugin.this.getName();
}
@Override
public Plugin implementor() {
return ElasticSearchPlugin.this;
}
});
}
Aggregations