The Network layer handles all network layer related tasks, hides the complexity of network communication, and provides easy to use APIs to the applications.
ISDMRequestManager void makeRequest(final ISDMRequest aRequest); void makeRequest(final ISDMBundleRequest aBundleRequest) ISDMConnectivitiyParameters getConnectivityParameters() Vector getAllRequests() int getQueueSize() byte[] getRootContextID() void terminate() void pause() void resume()
ISDMConnectivityParameters void setUserName(String aUserName) String getUserName() void setUserPassword(String aPassword) String getUserPassword() void setBaseUrl(String baseUrl) String getBaseUrl() String getLanguage() void setLanguage(String language)
Example //create and fill parameters for Connectivity library SDMConnectivityParameters params = new SDMConnectivityParameters(); params.setUserName("test"); params.setUserPassword("testpwd"); params.setLogger(Logger.getInstance()); //get the default Logger //create the RequestManager SDMRequestManager reqManager = new SDMRequestManager(); //initialize it reqManager.initialize(params, 2);//set the parameters and the thread number to be used //create the request object ISDMRequest testRequest = new SDMBaseRequest(); testRequest.setRequestUrl("http://test.de:8080/testpath"); testRequest.setRequestMethod(ISDMRequest.REQUEST_METHOD_GET); testRequest.setPriority(ISDMRequest.PRIORITY_NORMAL); //add the request to the connectivity layer reManager.makeRequest(testRequest);
The tasks of the connectivity library have been divided into three main categories: managing the request queues, managing reading and writing to the input/output streams, and managing the platform specific connection creation.
The Connectivity component always performs the requests in asynchronous mode. The application’s role is to handle the request in sync mode. The component is able to perform HTTP and HTTPS requests, which you can use for developing and testing purposes, but the default is SUP Request. The threads in the connectivity library are responsible for taking the requests from the queue (FIFO - First in first out - algorithm) and performing the requests.
An application can have more than one SDMRequestManager, for example, when connecting to two different servers at the same time.
int TIMEOUT = 3500; ISDMPreferences preferences = new SDMPreferences(); preferences.setPreference(ISDMPreferences.CONNECTION_TIMEOUT_MS, String.valueOf(TIMEOUT)); requestManager = new SDMRequestManager(logger, preferences, parameters, NUM_OF_HTTP_EXECUTION_THREADS);
An SDMRequest object wraps all the information which is needed by the connectivity library to be able to perform the requests. The connectivity library interacts with the request object to query the necessary information about the headers, the post data, and so on.
ISDMRequest void setRequestUrl(final String aUrl) String getRequestUrl() void setRequestMethod(final int aRequestMethod) int getRequestMethod() byte[] getData() void setPriority(final int aPriority) int getPriority() boolean useCookies() void setListener(final ISDMNetListener aListener) ISDMNetListener getListener() boolean hasPostData() void postData(OutputStream os) void setHeaders(final Hashtable aHashtable) Hashtable getHeaders() void appendHeaders(final Hashtable aHashtable) void appendHeader(final String aHeaderName, final String aHeaderValue)
ISDMNetListener void onSuccess(ISDMRequest aRequest, IHttpResponse aResponse) void onError(ISDMRequest aRequest, IHttpResponse aResponse, ISDMRequestStateElement aRequestStateElement)
ISDMRequestStateElement int getErrorCode() void setErrorCode(final int code) int getHttpStatusCode() void setHttpStatusCode(final int httpStatus) Exception getException() void setException(final Exception aException) String getRedirectLocation() IHttpResponse getResponse()
Example public void onSuccess(ISDMRequest aRequest, SDMHttpResponse aResponse) { System.out.println("Http response status code:" + aResponse.getStatusCode()); System.out.println("Cookie string:" + aResponse.getCookieString()); byte[] content = aResponse.getContent(); String response = new String(content); System.out.println("Received content:" + response); //get the headers Hashtable headers = aResponse.getHeaders(); }