use of com.bluenimble.platform.PackageClassLoader in project serverless by bluenimble.
the class ScriptingPlugin method init.
@Override
public void init(final ApiServer server) throws Exception {
if (Lang.isNullOrEmpty(vmArgs)) {
masterEngine = Manager.getScriptEngine(ScriptingPlugin.class.getClassLoader());
} else {
masterEngine = Manager.getScriptEngine(Lang.split(vmArgs, Lang.SPACE, true), ScriptingPlugin.class.getClassLoader());
}
Feature aFeature = ScriptingEngine.class.getAnnotation(Feature.class);
if (aFeature == null || Lang.isNullOrEmpty(aFeature.name())) {
return;
}
PackageClassLoader pcl = (PackageClassLoader) ScriptingPlugin.class.getClassLoader();
pcl.registerObject(Registered.ApiSpi, new ScriptableApiSpi());
pcl.registerObject(Registered.ServiceSpi, new ScriptableApiServiceSpi());
File platform = new File(home, "platform");
// load platform
Reader pReader = null;
try {
pReader = new FileReader(new File(platform, "Platform.js"));
Bindings bindings = new SimpleBindings();
bindings.put(Vars.Core, new File(platform, Vars.Core).getAbsolutePath());
bindings.put(Vars.Tools, new File(platform, Vars.Tools).getAbsolutePath());
shared = new DefaultScriptingEngine(this, (ScriptObjectMirror) masterEngine.eval(pReader, bindings), server.getMapProvider());
} finally {
IOUtils.closeQuietly(pReader);
}
// add features
server.addFeature(new ServerFeature() {
private static final long serialVersionUID = 2626039344401539390L;
@Override
public Class<?> type() {
return ScriptingEngine.class;
}
@Override
public Object get(ApiSpace space, String name) {
return shared;
}
@Override
public String provider() {
return ScriptingPlugin.this.getName();
}
@Override
public Plugin implementor() {
return ScriptingPlugin.this;
}
});
}
use of com.bluenimble.platform.PackageClassLoader in project serverless by bluenimble.
the class Log4JTracerPlugin method init.
@Override
public void init(ApiServer server) throws Exception {
PackageClassLoader pcl = (PackageClassLoader) Log4JTracerPlugin.class.getClassLoader();
pcl.addSynonym(Synonyms.Default, DefaultTracer.class.getName());
}
use of com.bluenimble.platform.PackageClassLoader in project serverless by bluenimble.
the class RemotePlugin method init.
@Override
public void init(final ApiServer server) throws Exception {
Feature aFeature = Remote.class.getAnnotation(Feature.class);
if (aFeature == null || Lang.isNullOrEmpty(aFeature.name())) {
return;
}
feature = aFeature.name();
PackageClassLoader pcl = (PackageClassLoader) RemotePlugin.class.getClassLoader();
pcl.registerObject(Protocol.http.name(), new HttpRemote(null));
server.addFeature(new ServerFeature() {
private static final long serialVersionUID = -9012279234275100528L;
@Override
public Class<?> type() {
return Remote.class;
}
@Override
public Object get(ApiSpace space, String name) {
return remotes.get(createRemoteKey(name, space));
}
@Override
public String provider() {
return RemotePlugin.this.getName();
}
@Override
public Plugin implementor() {
return RemotePlugin.this;
}
});
}
use of com.bluenimble.platform.PackageClassLoader 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;
}
});
}
use of com.bluenimble.platform.PackageClassLoader in project serverless by bluenimble.
the class IMPlugin method init.
@Override
public void init(ApiServer server) throws Exception {
PackageClassLoader pcl = (PackageClassLoader) IMPlugin.class.getClassLoader();
pcl.registerObject(Registered.LoginSpi, new LoginServiceSpi());
pcl.registerObject(Registered.SignupSpi, new SignupServiceSpi());
pcl.registerObject(Registered.ActivateSpi, new ActivateServiceSpi());
pcl.registerObject(Registered.OAuthSpi, new OAuthServiceSpi());
pcl.registerObject(Registered.ChangePasswordSpi, new ChangePasswordSpi());
pcl.registerObject(Registered.ResendActivationSpi, new ResendActivationRequestSpi());
}
Aggregations