Breadcrumb
- Sabre Red 360 Software Development Kit Help
- Desktop Red Apps
- Development Languages and Technologies
- Website Integration Using JavaScript
- Using JavaScript to Access OSGi NonCommunications Services
Using JavaScript to Access OSGi NonCommunications Services
If your web app accesses one of the whitelisted OSGi services with JavaScript, use this procedure.
If your web app accesses SRWRuntime communications with JavaScript, see Using Javascript to Access SRWRuntime Communications.
The SrwOSGiApi.callOSGIService() JavaScript method passes two or more parameters:
-
The service to call. Only the whitelisted services can be called.
-
The function to call from this service.
-
(Optional) Any quantity of additional parameters for this function
Service Parameter and Whitelisted Services
The whitelisted OSGi services that you can pass as the service
parameter follow. For more information about these services, see OSGi Whitelisted Services.
Method Parameter
This parameter is the name of the method that you want to call. This must be a public method that is declared in the service interface that you are calling.
If the calling method expects one or more arguments, pass the arguments as subsequent parameters of the SrwOSGiApi.callOSGIService function. These parameters must be the following types:
-
String
-
Double
-
Boolean
-
JSON String
JSON String
is decoded into Java objects.
The SrwOSGiApi.callOSGIService() method returns a JSON String object, even if the method result is String
, Double
, or Boolean
.
The following process shows how to access whitelisted OSGi services from a web app using JavaScript.
-
Create an editor in your main Red App plug-in using the following class:
DefaultWebkitEditor. (For information about a default editor implementation, see Integrating a Web App Using a Default Editor.
-
(Optional) If your web app will be opened in a view, create a view using the following class.
WebkitView (This is located in com.sabre.edge.platform.optional.webkit.views.WebkitView ). For information about a default view implementation, see Integrating a Web App Using a Default View.
-
Call the Javascript SrwOSGiApi.callOSGIService() function. Sample code is shown below.
Sample JavaScript Code for an OSGi Whitelisted Service Call with a Simple Value
The sample code below displays an alert with the Agent ID in AgentId
.
var result = SrwOSGiApi.callOSGIService("com.sabre.edge.platform.core.sso.base.IAgentProfileService","getAgentId");
result = eval( "(" result ")" );
alert(result.string);