protected JSONRPCBridge createBridgeForComponent( JSONComponent component, String componentName, String componentInstance, Map<String, JSONRPCBridge> componentBridges) throws Exception { JSONRPCBridge jsonBridge = JSONBridge.createBridge(); jsonBridge.registerCallableReference(JSONComponent.class); jsonBridge.registerObject("component", component); String componentNameAndInstance = JSONRequestHandler.componentNameAndInstance(componentName, componentInstance); componentBridges.put(componentNameAndInstance, jsonBridge); return jsonBridge; }
protected void activate(ComponentContext ctxt) { this.ctxt = ctxt; this.bc = ctxt.getBundleContext(); jsonRpcBridge = JSONRPCBridge.getGlobalBridge(); try { registryProxy = new ServiceRegistryProxy(this.bc, jsonRpcBridge); jsonRpcBridge.registerObject("OSGi", registryProxy); } catch (Throwable e) { LOG.error("Exception on activate", e); } }
/** * Registers the given object in the shared JSON bridge. The shared JSON bridge is used for * stateless JSON services. As an example, if you call registerService("myExampleService", new * ExampleService()) you can then call json.myExampleService.someMethodInExampleService from your * Javascript. The same instance is shared across all of your service users, so you should not * store any state in this class. * * @param name the name to register the object as * @param serviceObject the instance to register */ public void registerService(String name, Object serviceObject) { _sharedBridge.registerObject(name, serviceObject); }
@Override public void register(JSONRPCBridge bridge) { bridge.registerObject("registerBackService", getRegisterBackService()); }