Server Side Services

Writing server side services is not different than the known and accepted way of writing and handling services. Although NeuroKernel offers some easy to use classes for easy integration In its dynamic mode, any service written on any framework is accepted as well. NeuroKernel can make CORS (Cross-Origin Resource Sharing) service calls. The service handler interface has methods to detail the type of service call. There are callService methods to make calls to the originating server, and callRemoteService to make CORS services

import com.neurokernel.client.*;
import com.neurokernel.client.net.*;
 
public class ServiceExample extends NApplication {
      @Override
      public void main(int argc, String[] argv) {
          final NFrame mainFrame = getMainFrame();
 
          IServiceHandler serviceHandler = getSystem().getServiceHandler();
          serviceHandler.callService("GetData", "John Doe", new IServiceListener() {
               @Override
               public void onRead(IConnection connection) {
                   NMessageDialog.showInfo(mainFrame, connection.readString());
               }
 
               @Override
               public void onError(IConnection connection) {
                   NMessageDialog.showError(mainFrame, "Data is not found!");
               }
          });
 
          mainFrame.setTitle("Service Example");
          mainFrame.setBounds(20,20,200,200);
          mainFrame.setVisible(true);
      }
}

1. Direct Access Services

In dynamic mode, servlet based services can be registered as directly accessible by the application. This will mean that when the application is run at the server side, it wont need to go through network layer, but will access the service directly by reference. Directly accessible services should implement IService interface. They can be registered with addDirectService methods of IServiceHandler system interface.