Search in sources :

Example 1 with HttpRemote

use of com.bluenimble.platform.remote.impls.http.HttpRemote 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;
        }
    });
}
Also used : ServerFeature(com.bluenimble.platform.server.ServerFeature) HttpRemote(com.bluenimble.platform.remote.impls.http.HttpRemote) ApiSpace(com.bluenimble.platform.api.ApiSpace) JsonObject(com.bluenimble.platform.json.JsonObject) Feature(com.bluenimble.platform.Feature) ServerFeature(com.bluenimble.platform.server.ServerFeature) PackageClassLoader(com.bluenimble.platform.PackageClassLoader) Plugin(com.bluenimble.platform.plugins.Plugin) AbstractPlugin(com.bluenimble.platform.plugins.impls.AbstractPlugin)

Aggregations

Feature (com.bluenimble.platform.Feature)1 PackageClassLoader (com.bluenimble.platform.PackageClassLoader)1 ApiSpace (com.bluenimble.platform.api.ApiSpace)1 JsonObject (com.bluenimble.platform.json.JsonObject)1 Plugin (com.bluenimble.platform.plugins.Plugin)1 AbstractPlugin (com.bluenimble.platform.plugins.impls.AbstractPlugin)1 HttpRemote (com.bluenimble.platform.remote.impls.http.HttpRemote)1 ServerFeature (com.bluenimble.platform.server.ServerFeature)1