Oracle Application Server Wireless J2ME SDK API Reference
B14045-01


oracle.wireless.me.core
Class ServiceManager

java.lang.Object
  extended byoracle.wireless.me.core.ServiceManager

All Implemented Interfaces:
java.lang.Runnable

public final class ServiceManager
extends java.lang.Object
implements java.lang.Runnable

ServiceManager provides the Offline Management capability for Call invocation. When wireless networking connection is temporarily broken, application developers can use the ServiceManger to queue the call. ServiceManager will automatically resend it later after the wireless networking connection is restored.

ServiceManager also provides methods and internal functionality needed for caching of responses in the device's persistent storage.

MIDlet's should always call the ServiceManager's close() method when they exit (just before calling notifyDestroyed()) in order to close the RMS RecordStore used for queueing and caching.

Application developers should only queue a Call when the failure of the service invocation is due to the temporary failure of the wireless network connection. Queuing a successfully invoked Call means that it will be invoked again by ServiceManager.

Version:
1.0

Method Summary
int callKey(Call call)
Returns the cache key for the given call.
void cancelAllQueue()
Removes all queued Calls from the queue.
boolean cancelQueue(Call call)
Removes a queued Call from the queue.
void clearCache()
Clears the cache of all cached responses.
void clearExpiredCache()
Delete expired responses from cache.
void close()
This closes the RMS record store used for caching and queueing; this method should always be called when a MIDlet exits.
int deleteResponse(int key)
Deletes a response from the cache.
static ServiceManager getInstance()
The singleton thread-safe getter
Call getQueuedCall(int recId)
Get a queued Call by RMS record id.
int[] getQueuedCalls(boolean hasBeenInvoked)
Get an array of record ids of queued calls, based on the status of the invocation in the Call Queue managed by ServiceManager
int queueCall(Call call)
Put a Call into the call queue.
void run()

Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Method Detail

getInstance

public static ServiceManager getInstance()
                                  throws ServiceException
The singleton thread-safe getter
Returns:
the ServiceManager singleton instance
Throws:
ServiceException

getQueuedCalls

public int[] getQueuedCalls(boolean hasBeenInvoked)
                     throws ServiceException
Get an array of record ids of queued calls, based on the status of the invocation in the Call Queue managed by ServiceManager
Parameters:
hasBeenInvoked - boolean, true for invoked QueuedCalls, false for the QueuedCalls which have not been invoked by ServiceManager
Returns:
an array of RMS record ids of queued calls
Throws:
ServiceException

getQueuedCall

public Call getQueuedCall(int recId)
                   throws ServiceException
Get a queued Call by RMS record id. If the queued call has not been invoked, the Call's getResponse method will return null. The Call remains in persistent storage, regardless of whether it has been invoked, until the cancelQueue method is called.
Returns:
Call object
Throws:
ServiceException

queueCall

public int queueCall(Call call)
              throws ServiceException
Put a Call into the call queue. The service manager will invoke the call and store the response. This method should only be called after a Call has been invoked and has failed due to a network error. In other words, only this method only if you previously called Call.invoke() and it failed due to a ServiceException for which: (serviceException.getErrorCode() == ServiceException.CONNECTION_FAILED)
Returns:
int RMS record id of queued call
Throws:
ServiceException

callKey

public int callKey(Call call)
            throws ServiceException
Returns the cache key for the given call.
Throws:
ServiceException

cancelQueue

public boolean cancelQueue(Call call)
                    throws ServiceException
Removes a queued Call from the queue.
Parameters:
call - Call to remove from queue.
Returns:
true if call removed from queue, false if call not removed from queue
Throws:
ServiceException

cancelAllQueue

public void cancelAllQueue()
                    throws ServiceException
Removes all queued Calls from the queue. Deletes Calls that have been invoked as well as calls that have not been invoked.
Throws:
ServiceException

clearCache

public void clearCache()
                throws ServiceException
Clears the cache of all cached responses.
Throws:
ServiceException

deleteResponse

public int deleteResponse(int key)
Deletes a response from the cache. Returns 1 if deleteion succeeded, 0 if it didn't. (0 may mean that the response was not found.)

close

public void close()
           throws ServiceException
This closes the RMS record store used for caching and queueing; this method should always be called when a MIDlet exits. It also frees resources used for caching and queueing.
Throws:
ServiceException

clearExpiredCache

public void clearExpiredCache()
                       throws ServiceException
Delete expired responses from cache.
Throws:
ServiceException

run

public void run()
Specified by:
run in interface java.lang.Runnable

Oracle Application Server Wireless J2ME SDK API Reference
B14045-01


Copyright © 2003 Oracle Corporation. All Rights Reserved.