Java Application Interface
If you are using the Java SDK to create your analysis agent, use the methods in the IAnalysisService application interface to plug in your analysis software to the Analytics Manager framework.
* 
If you want to use additional helper methods apart from the methods defined in the IAnalysisService application interface, you can use the helper methods in the AnalysisServiceHelper class.
public interface IAnalysisService {

// map of appdelegates to connectedThingClient instances. The values are added internally by AnalysisSdk
// framework...do not modify or
// access this field explicitly, use GetClient to get the client instance
static final Map<Integer, PrivateObservable> appDelToObservable = new Hashtable<Integer, PrivateObservable>();
static final Logger LOG = LoggerFactory.getLogger(IAnalysisService.class);


long GetPid();

// Must return array of JSON objects with name, type and value attributes
default JSONArray GetPerformanceData() {
return null;
}

// [Description("Initialize the Application")]
// It is expected that the application will populate models with already deployed models in this call
public default void Initialize(Map<String, Object> initParams) {};

// [Description("Shutdown the Compute Engine/Application gracefully")]
// It is expected that the delegate will stop the compute engine/application and return only when the instance is
// stopped
public default void Shutdown() {};

// [Description("Return information about the application that is being exposed over REST. ")]
public ServiceInfo GetServiceInfo();

// [Description("Allow upload of models. The file(s) are uploaded as a multi-part message. ")]
public Model DeployModel(Model data) throws Exception;

// [Description("Return only the data structure of the inputs that the model requires")]
public ParamField[] GetInputData(String modelName);

// [Description("Return the data structure of the results that the model generates.")]
public ParamField[] GetResultData(String modelName);

// [Description("Submit a job for processing. The request indicates whether the job should be executed "+"synchronously or asynchronously")]
public Job PostJob(Job jb) throws Exception;

public default boolean AbortJob(String jobId) throws Exception {
// by default do nothing
return true;
}

public Job StartJob(Job jb) throws Exception;

public void UpdateJob(String jobId, JSONObject updatedProps) throws Exception;
public void UpdateJob(String jobId, JSONArray updatedProps) throws Exception;

public boolean StopJob(String jobId) throws Exception;

// [Description("Return requested result file for the given job id")]
public File GetJobResultFile(String id, String resultFileName) throws Exception;

public default PrivateObservable getObservable() {
if (appDelToObservable.containsKey(this.hashCode()))
return appDelToObservable.get(this.hashCode());
else {
PrivateObservable p = new PrivateObservable();
appDelToObservable.put(this.hashCode(), p);
return p;
}
}

public default void addObserver(Observer o) {
getObservable().addObserver(o);
}

public default void ReturnUpdate(Object o) {
getObservable().setChanged();
getObservable().notifyObservers(o);
}

// simply make setChanged public, and therefore usable in delegation
class PrivateObservable extends Observable {
@Override
public void setChanged() {
super.setChanged();
}
}

public default void processMessage(JSONObject payLoad) throws Exception {
};

public default String getClientId() {
return null;
}

public default void DeleteModel(Model model) throws Exception {};

}
The methods used in IAnalysisService are explained below:
Method
Description
GetServiceInfo
This method returns information about the application.
DeployModel
This method allows upload of models. The files are uploaded as a multi-part message.
GetInputData
This method returns only the data structure of the inputs that the model requires.
GetResultData
This method returns the data structure of the results that the model generates.
PostJob
This method submits a job for processing. This also indicates whether the job should be executed synchronously or asynchronously.
StartJob
This method is used to start a job. It initializes data structures and threads to handle continuous jobs.
StopJob
This method is used to stop a job. It also performs cleanup.
UpdateJob
This method is used to send updated inputs in the form of a JSON for a simulation job.
GetJobResultFile
This method returns requested result file for the given job ID.
addObserver
This method is used to maintain a list of observers. To send updates to the server, the service invokes the ReturnUpdate() method and passes in the updated job object.
DeleteModel
This method deletes the specified model.
getClientId
This method is used to access the ThingWorx server by using the same credentials that the agent uses to access the ThingWorx server.
* 
Input and output data is exchanged between the service and the SDK in JSON format strings. The input is always a JSON array serialized as a string and the output should be a JSON array. Sometimes, the JSON array might contain a single object.
* 
Java-based implementations can override the finalize() method to perform cleanup.
Was this helpful?