| java.lang.Object com.sun.midp.content.RegistryImpl
RegistryImpl | final public class RegistryImpl (Code) | | Implementation of Content Handler registry. It maintains
the set of currently registered handlers and updates to
the file that holds the permanent set.
The RegistryImpl class maintains an array of the current
registrations that is initialized on first use.
|
Method Summary | |
public void | cancelGetResponse() Cancels a pending getResponse . | static ContentHandlerImpl | checkConflicts(ContentHandlerImpl handler) Check for conflicts between a proposed new handler and the existing
handlers. | static void | cleanup(int suiteId, String classname) Cleanup as necessary for this classname, both for ContentHandlerServer
and the registry. | public ContentHandler[] | findHandler(InvocationImpl invoc) Gets the registered content handlers that could be used for
this Invocation. | public ContentHandler[] | forAction(String action) Gets the registered content handlers that support the action. | public ContentHandler | forID(String ID, boolean exact) Gets the registered content handler for the ID. | public ContentHandler[] | forSuffix(String suffix) Gets all of the content handlers for the suffix. | public ContentHandler[] | forType(String type) Gets the registered content handlers for the content type. | public String[] | getActions() Gets all of the actions of the registered content handlers. | public String | getID() Gets the content handler ID for the current application. | public String[] | getIDs() Gets all of the IDs of the registered content handlers. | public Registry | getRegistry() Gets the Registry that is delegating to this RegistryImpl. | public static RegistryImpl | getRegistryImpl(String classname, Object token) Gets the RegistryImpl for the application class.
The SecurityToken is needed to call from the public API package.
The application is identified by the classname that implements
the lifecycle of the Java runtime environment.
The classname must be the name of a registered application class
or a registered content handler.
For a MIDP implementation,
application classes must be registered with the
MIDlet-<n> attribute; content handlers are
registered with the MicroEdition-Handler-<n>
attribute or the
RegistryImpl.register register method.
When the RegistryImpl is created (the first time) all of the
existing Invocations are marked. | static RegistryImpl | getRegistryImpl(String classname) Gets the RegistryImpl for the application class.
The application is identified by the classname that implements
the lifecycle of the Java runtime environment.
The classname must be the name of a registered application class
or a registered content handler.
For a MIDP implementation,
application classes must be registered with the
MIDlet-<n> attribute; content handlers are
registered with the MicroEdition-Handler-<n>
attribute or the
RegistryImpl.register register method.
When the RegistryImpl is created (the first time) all of the
existing Invocations are marked. | public Invocation | getResponse(boolean wait, InvocationImpl resp) Gets the next Invocation response pending for this application.
The method blocks until an Invocation response is available, but
not for longer than the timeout period.
The method can be unblocked with a call to
RegistryImpl.cancelGetResponse .
The application can process the Invocation based on
its status. | public ContentHandlerImpl | getServer() Gets the registered content handler for the
application class of this RegistryImpl. | ContentHandlerImpl | getServer(AppProxy appl) Gets the content handler for the specified application class. | public String[] | getSuffixes() Gets all of the suffixes of the registered content handlers. | public String[] | getTypes() Gets all of the content types for which there are registered
handlers. | public boolean | invoke(InvocationImpl invocation, InvocationImpl previous) Checks the Invocation and uses the ID, type, URL, and action,
if present, to find a matching ContentHandler and queues this
request to it.
If the previous Invocation is null , then
a new transaction is created; otherwise, this
Invocation will use the same transaction as the
previous Invocation.
The status of this Invocation MUST be INIT .
If there is a previous Invocation, that Invocation MUST
have a status of ACTIVE .
Candidate content handlers are found as described in
RegistryImpl.findHandler findHandler . | static ContentHandlerImpl | newHandler(String classname, String[] types, String[] suffixes, String[] actions, ActionNameMap[] actionnames, String id, String[] accessRestricted, AppProxy appl) Create and initialize a new ContentHandler server with
type(s), suffix(es), and action(s), action name(s),
access restrictions and content handler ID.
Compute the application name, ID, and version
Parameters: classname - the application class name that implementsthis content handler. | public ContentHandlerImpl | register(String classname, String[] types, String[] suffixes, String[] actions, ActionNameMap[] actionnames, String id, String[] accessRestricted) Registers the application class using content
type(s), suffix(es), and action(s), action name(s),
access restrictions and content handler ID.
An application can use this method to replace or update
its own registrations
that have the same classname with new information.
The update occurs atomically; the update to the registry
either occurs or it does not.
The content handler may request to the following
items:
- zero or more content types
- zero or more suffixes
- zero or more actions
- zero or more mappings from actions to action names
- zero or more access restrictions
- a optional application ID
If no exceptions are thrown, then the type(s), suffix(s), action(s),
action names, and access restrictions, and ID
will be registered for the application class.
If an exception is thrown, then the previous registration, if
any, will not be removed or modified.
Parameters: classname - the application class name that implementsthis content handler. | public boolean | reinvoke(InvocationImpl invocation) Reinvokes the Invocation and uses the ID, type, URL, and action
to find a matching ContentHandler and re-queues this request to
it. | public void | setListener(ResponseListener listener) Sets the listener to be notified when a new response is
available for the application context. | public void | setRegistry(Registry newRegistry) Sets the Registry that is delegating to this instance. | public void | setServer(ContentHandlerImpl server) Sets the ContentHandlerImpl; update any active RegistryImpl. | public boolean | unregister(String classname) Removes the content handler registration for the application
class and any bindings to the content handler name, content
type(s), suffix(es), action(s), and access restrictions. |
application | final AppProxy application(Code) | | The AppProxy for this registry.
|
responseCalls | int responseCalls(Code) | | Count of responses received.
|
cancelGetResponse | public void cancelGetResponse()(Code) | | Cancels a pending getResponse .
This method will force a Thread blocked in a call to the
getResponse method for the same application
context to return early.
If no Thread is blocked; this call has no effect.
|
checkConflicts | static ContentHandlerImpl checkConflicts(ContentHandlerImpl handler) throws ContentHandlerException(Code) | | Check for conflicts between a proposed new handler and the existing
handlers. If the handler is being replaced it will be returned.
Locate and return any existing handler for the same classname.
Parameters: handler - the new content handler a ContentHandlerImpl within the suite thatneed to be removed to register the new ContentHandler |
cleanup | static void cleanup(int suiteId, String classname)(Code) | | Cleanup as necessary for this classname, both for ContentHandlerServer
and the registry.
Cleanup is required by the fault handling descriptions in
javax.microedition.content.ContentHandlerServer .
-
If an Invocation with a status of
ACTIVE is dequeued by
the content handler, but the handler does not call
javax.microedition.content.ContentHandlerServer.finish finish or make a request to chain a new Invocation to the ACTIVE
invocation before the content handler exits, then the AMS MUST
complete the request with an ERROR status.
-
If the content handler is not running, or exits before processing
all queued requests or responses, then it MUST be started.
The content handler is expected to dequeue at least one
invocation that was queued before it was started.
If it does not dequeue any pending Invocations, then Invocations
that were in the queue for the content handler
before it was started MUST be handled as follows:
- Invocation requests with a status of
ACTIVE
are completed with the ERROR status.
- Invocation responses are discarded.
- Invocations queued after the content handler was started are
retained and will require it to be restarted.
Parameters: suiteId - the MIDletSuite to cleanup after Parameters: classname - the application class to cleanup |
findHandler | public ContentHandler[] findHandler(InvocationImpl invoc) throws IOException, ContentHandlerException(Code) | | Gets the registered content handlers that could be used for
this Invocation. Only handlers accessible to the application
are considered. The values for ID, type, URL, and
action are used in the following order:
- If the ID is non-null, then the set of candidate
handlers is determined from the
RegistryImpl.forID forID method with the parameter exact set to false.
If there is an exact match it MUST be returned as
the first handler.
The type and URL are ignored. If there are no handlers that match
the requested ID then a ContentHandlerException
is thrown.
- If the ID and type are
null and
the URL is non-null and
If the protocol supports typing of content, then
the type is determined
as described in
Invocation.findType .
If the type cannot be determined from the content,
the type is set to null .
- If the ID is null and type is non-null,
then the set of candidate handlers is determined from the
RegistryImpl.forType forType method.
If there are no handlers that match the requested type
then a ContentHandlerException is thrown.
- If both the ID and type are
null and
the URL is non-null and
if the protocol does not support typing of content
or the type was not available from the content,
then the set of candidate handlers
includes any handler with a suffix that matches the
end of the path component of the URL.
If there are no handlers that match a registered
suffix then a ContentHandlerException is thrown.
- If the ID, type, and URL are all null, the set of candidate
handlers includes all of the accessible handlers.
- If the action is non-null, the set of candidate handlers
is reduced to contain only handlers that support the
action.
- If the set of candidate handlers is empty
then a ContentHandlerException is thrown.
The calling thread blocks while the ID and type are being determined.
If a network access is needed there may be an associated delay.
Parameters: invoc - the ID, type, action, and URL thatare needed to identify one or more content handlers;must not be null an array of the ContentHandler (s)that could be used for this Invocation; MUST NOT be null ; exception: IOException - is thrown if access to the content fails exception: ContentHandlerException - is thrown with a reason ofNO_REGISTERED_HANDLER ifthere is no registered content handler thatmatches the requested ID, type, URL, and action exception: IllegalArgumentException - is thrown if ID, type, URL,and action are all null orif the content is accessed via the URL and the URL is invalid exception: NullPointerException - is thrown if theinvocation is null exception: SecurityException - is thrown if access to the contentis not permitted |
forAction | public ContentHandler[] forAction(String action)(Code) | | Gets the registered content handlers that support the action.
Only content handlers that are visible and accessible to this
application are returned.
Parameters: action - content handlers for which the action is supported an array of the ContentHandler s registeredfor the action; MUST NOT be null ;an empty array is returned if no ContentHandler sare accessible to this application exception: NullPointerException - if action isnull |
forID | public ContentHandler forID(String ID, boolean exact)(Code) | | Gets the registered content handler for the ID.
The query can be for an exact match or for the handler
matching the prefix of the requested ID.
Only a content handler which is visible to and accessible to this
application will be returned.
Parameters: ID - the content handler application ID of the contenthandler requested Parameters: exact - true to require an exact match;false to allow a registered content handler IDto match a prefix of the requested ID the content handler that matches the ID,otherwise null exception: NullPointerException - if ID isnull |
forSuffix | public ContentHandler[] forSuffix(String suffix)(Code) | | Gets all of the content handlers for the suffix.
Only content handlers that are visible and accessible to this
application are returned.
Parameters: suffix - the suffix to be used to get the associatedcontent handlers an array of the ContentHandler s registeredfor the suffix; MUST NOT be null .An empty array is returned if there are none accessible tothis application exception: NullPointerException - if suffix isnull |
forType | public ContentHandler[] forType(String type)(Code) | | Gets the registered content handlers for the content type.
Only content handlers that are visible and accessible to this
application are returned.
Parameters: type - the type of the requested content handlers an array of the ContentHandler s registeredfor the type; MUST NOT be null .An empty array is returned if there are noContentHandler s accessible tothis application. exception: NullPointerException - if type isnull |
getActions | public String[] getActions()(Code) | | Gets all of the actions of the registered content handlers.
After a successful registration the content handler's action(s),
if any, will appear in this list.
Only content handlers that this application is
allowed to access will be included.
an array of content handler actions;MUST NOT be null |
getID | public String getID()(Code) | | Gets the content handler ID for the current application.
The ID uniquely identifies the application which contains the
content handler.
The application ID is assigned when the application is installed.
If the application is a content handler then the ID must be
the content handler ID.
the ID; MUST NOT be null |
getIDs | public String[] getIDs()(Code) | | Gets all of the IDs of the registered content handlers.
Only content handlers that this application is
allowed to access will be included.
an array of content handler IDs;MUST NOT be null |
getRegistryImpl | public static RegistryImpl getRegistryImpl(String classname, Object token) throws ContentHandlerException(Code) | | Gets the RegistryImpl for the application class.
The SecurityToken is needed to call from the public API package.
The application is identified by the classname that implements
the lifecycle of the Java runtime environment.
The classname must be the name of a registered application class
or a registered content handler.
For a MIDP implementation,
application classes must be registered with the
MIDlet-<n> attribute; content handlers are
registered with the MicroEdition-Handler-<n>
attribute or the
RegistryImpl.register register method.
When the RegistryImpl is created (the first time) all of the
existing Invocations are marked. They will be subject to
RegistryImpl.cleanup when the MIDlet exits.
Parameters: classname - the application class Parameters: token - the security token needed to control access to the impl a RegistryImpl instance providing access to content handlerregistrations and invocations; MUST NOT be null exception: ContentHandlerException - is thrown with a reason ofNO_REGISTERED_HANDLER if there is nocontent handler registered for the classname in the currentapplication exception: NullPointerException - if classname isnull |
getRegistryImpl | static RegistryImpl getRegistryImpl(String classname) throws ContentHandlerException(Code) | | Gets the RegistryImpl for the application class.
The application is identified by the classname that implements
the lifecycle of the Java runtime environment.
The classname must be the name of a registered application class
or a registered content handler.
For a MIDP implementation,
application classes must be registered with the
MIDlet-<n> attribute; content handlers are
registered with the MicroEdition-Handler-<n>
attribute or the
RegistryImpl.register register method.
When the RegistryImpl is created (the first time) all of the
existing Invocations are marked. They will be subject to
RegistryImpl.cleanup when the MIDlet exits.
Parameters: classname - the application class a RegistryImpl instance providing access to content handlerregistrations and invocations; MUST NOT be null exception: ContentHandlerException - is thrown with a reason ofNO_REGISTERED_HANDLER if there is nocontent handler registered for the classname in the currentapplication exception: NullPointerException - if classname isnull |
getResponse | public Invocation getResponse(boolean wait, InvocationImpl resp)(Code) | | Gets the next Invocation response pending for this application.
The method blocks until an Invocation response is available, but
not for longer than the timeout period.
The method can be unblocked with a call to
RegistryImpl.cancelGetResponse .
The application can process the Invocation based on
its status. The status is one of
OK , CANCELLED , or ERROR .
If the Invocation was invoked with
RegistryImpl.invoke(InvocationImpl invocation,InvocationImpl previous) ,
the getPrevious method MUST return the
previous Invocation.
If the status of the previous Invocation is HOLD
then its status is restored to ACTIVE .
If the original Invocation instance is reachable, then it
MUST be updated with the values from the response
and be returned to the application. If it is not
reachable, then a new instance is returned from getResponse
with the response values.
Parameters: wait - true if the methodMUST wait for an Invocation if one is not currently available;otherwise false Parameters: resp - an InvocationImpl to fill in with the response exception: IllegalArgumentException - if the context is not valid the next pending response Invocation or null if the timeout expires and no Invocation is available orif cancelled with RegistryImpl.cancelGetResponse See Also: RegistryImpl.invoke See Also: RegistryImpl.cancelGetResponse |
getServer | public ContentHandlerImpl getServer()(Code) | | Gets the registered content handler for the
application class of this RegistryImpl.
the content handler for the registeredclassname if it was registered by this application.Otherwise, it returns null . exception: NullPointerException - if classname isnull |
getServer | ContentHandlerImpl getServer(AppProxy appl)(Code) | | Gets the content handler for the specified application class.
The classname must be a class in the current application.
Parameters: appl - the application to look up a server fro the content handler information for the registeredclassname if the classname was registered by this application,otherwise return null exception: NullPointerException - if classname isnull |
getSuffixes | public String[] getSuffixes()(Code) | | Gets all of the suffixes of the registered content handlers.
After a successful registration the content handler's suffix(es),
if any, will appear in this list.
Only content handlers that this application is
allowed to access will be included.
an array of content handler suffixes;MUST NOT be null |
getTypes | public String[] getTypes()(Code) | | Gets all of the content types for which there are registered
handlers.
After a successful registration, the content handler's type(s),
if any, will appear in this list.
Only content handlers that this application is
allowed to access will be included.
an array of types; MUST NOT be null |
invoke | public boolean invoke(InvocationImpl invocation, InvocationImpl previous) throws IllegalArgumentException, IOException, ContentHandlerException(Code) | | Checks the Invocation and uses the ID, type, URL, and action,
if present, to find a matching ContentHandler and queues this
request to it.
If the previous Invocation is null , then
a new transaction is created; otherwise, this
Invocation will use the same transaction as the
previous Invocation.
The status of this Invocation MUST be INIT .
If there is a previous Invocation, that Invocation MUST
have a status of ACTIVE .
Candidate content handlers are found as described in
RegistryImpl.findHandler findHandler . If any handlers are
found, one is selected for this Invocation.
The choice of content handler is implemention dependent.
If there is a non-null previous Invocation,
its status is set to HOLD .
A copy of the Invocation is made, the status is set to
ACTIVE and then queued to the
target content handler.
If the invoked content handler is not running, it MUST be started
as described in Invocation Processing.
The calling thread blocks while the content handler is being determined.
If a network access is needed, there may be an associated delay.
Parameters: invocation - the Invocation containing the target ID, type,actions, arguments, and responseRequired parameters;MUST NOT be null Parameters: previous - a previous Invocation for this Invocation;may be null true if the application MUST firstvoluntarily exit before the content handler can be started;false otherwise exception: IllegalArgumentException - is thrown if: - the ID, type, URL, and action are all
null , or - the argument array contains any
null references
exception: IOException - is thrown if access to the content fails exception: ContentHandlerException - is thrown with a reason of:TYPE_UNKNOWN if the typeis not set and cannot be determined from the URL, orNO_REGISTERED_HANDLER ifthere is no registered content handler thatmatches the requested ID, type, url or actions.
exception: IllegalStateException - is thrown if the status of thisInvocation is not INIT or if the status of theprevious Invocation, if any, is not ACTIVE exception: NullPointerException - is thrown if theinvocation is null exception: SecurityException - if an invoke operation is not permitted |
newHandler | static ContentHandlerImpl newHandler(String classname, String[] types, String[] suffixes, String[] actions, ActionNameMap[] actionnames, String id, String[] accessRestricted, AppProxy appl) throws IllegalArgumentException(Code) | | Create and initialize a new ContentHandler server with
type(s), suffix(es), and action(s), action name(s),
access restrictions and content handler ID.
Compute the application name, ID, and version
Parameters: classname - the application class name that implementsthis content handler. The value MUST NOT be null and MUST implement the lifecycle of the Java runtime Parameters: types - an array of types to register;if null it is treated the same as an empty array Parameters: suffixes - an array of suffixes to register;if null it is treated the same as an empty array Parameters: actions - an array of actions to register;if null it is treated the same as an empty array Parameters: actionnames - an array of ActionNameMaps to register;if null it is treated the same as an empty array Parameters: id - the content handler ID; if null a non-null value MUST be provided by the implementation Parameters: accessRestricted - the IDs of applications and contenthandlers that areallowed visibility and access to this content handler;if null then all applications and contenthandlers are allowed access; if non-null , thenONLY applications and content handlers with matching IDs areallowed access. Parameters: appl - the AppProxy registering the handler the registered ContentHandler; MUST NOT be null exception: NullPointerException - if any of the following items isnull :- classname
- any types, suffixes, actions, actionnames, oraccessRestricted array element
,- msuite
exception: IllegalArgumentException - can be thrown:- if any of the
types , suffix ,actions , or accessRestricted strings have a length of zero, or - if the
classname does not implement the validlifecycle for the Java Runtime, - if the sequence of actions in each ActionNameMapis not the same as the sequence of
actions ,or - if the locales of the ActionNameMaps are not unique, or.
- if the length of the
accessRestricted array is zero. .
|
register | public ContentHandlerImpl register(String classname, String[] types, String[] suffixes, String[] actions, ActionNameMap[] actionnames, String id, String[] accessRestricted) throws SecurityException, IllegalArgumentException, ClassNotFoundException, ContentHandlerException(Code) | | Registers the application class using content
type(s), suffix(es), and action(s), action name(s),
access restrictions and content handler ID.
An application can use this method to replace or update
its own registrations
that have the same classname with new information.
The update occurs atomically; the update to the registry
either occurs or it does not.
The content handler may request to the following
items:
- zero or more content types
- zero or more suffixes
- zero or more actions
- zero or more mappings from actions to action names
- zero or more access restrictions
- a optional application ID
If no exceptions are thrown, then the type(s), suffix(s), action(s),
action names, and access restrictions, and ID
will be registered for the application class.
If an exception is thrown, then the previous registration, if
any, will not be removed or modified.
Parameters: classname - the application class name that implementsthis content handler. The value MUST NOT be null and MUST implement the lifecycle of the Java runtime Parameters: types - an array of types to register;if null it is treated the same as an empty array Parameters: suffixes - an array of suffixes to register;if null it is treated the same as an empty array Parameters: actions - an array of actions to register;if null it is treated the same as an empty array Parameters: actionnames - an array of ActionNameMaps to register;if null it is treated the same as an empty array Parameters: id - the content handler ID; if null a non-null value MUST be provided by the implementation Parameters: accessRestricted - the IDs of applications and contenthandlers that areallowed visibility and access to this content handler;if null then all applications and contenthandlers are allowed access; if non-null , thenONLY applications and content handlers with matching IDs areallowed access. the registered ContentHandler; MUST NOT be null exception: NullPointerException - if any of the following items isnull : - classname
- any types, suffixes, actions, actionnames, oraccessRestricted array element
exception: IllegalArgumentException - can be thrown:- if any of the
types , suffix ,actions , or accessRestricted strings have a length of zero, or - if the
classname does not implement the validlifecycle for the Java Runtime, - if the sequence of actions in each ActionNameMapis not the same as the sequence of
actions ,or - if the locales of the ActionNameMaps are not unique, or.
- if the length of the
accessRestricted array is zero. .
exception: ClassNotFoundException - if the classname is not present exception: ContentHandlerException - with a error code ofContentHandlerException.AMBIGUOUS if id is a prefix of any registered handler or if any registeredhandler ID is a prefix of this ID exception: SecurityException - if registrationis not permitted |
reinvoke | public boolean reinvoke(InvocationImpl invocation) throws IllegalArgumentException, IOException, ContentHandlerException, SecurityException(Code) | | Reinvokes the Invocation and uses the ID, type, URL, and action
to find a matching ContentHandler and re-queues this request to
it. Reinvocation is used to delegate the handling of an active
Invocation to another content handler.
The processing of the Invocation instance is complete and the
status is set to OK . Responses to the
reinvocation will be queued to the original invoking
application, if a response is required.
Candidate content handlers are found as described in
RegistryImpl.findHandler findHandler . If any handlers are
found, one is selected for this Invocation.
The choice of content handler is implementation dependent.
The status of this Invocation is set to OK .
A copy of the Invocation is made, the status is set to
ACTIVE , and then queued to the
target content handler.
If the invoked content handler application is not running,
it MUST be started
as described in Invocation Processing.
The calling thread blocks while the content handler is being determined.
If a network access is needed there may be an associated delay.
Parameters: invocation - an Invocation containing the target ID, type,action, arguments, and responseRequired parameters;MUST NOT be null true if the application MUST firstvoluntarily exit before the content handler can be started;false otherwise exception: IllegalArgumentException - is thrown if: - the ID, type, and URL are all
null , or - the argument array contains any
null references
exception: IOException - is thrown if access to the content fails exception: ContentHandlerException - is thrown with a reason of:NO_REGISTERED_HANDLER ifthere is no registered content handler thatmatches the requested ID, type, URL, and action exception: NullPointerException - is thrown if theinvocation is null exception: SecurityException - if an invoke operation is notpermitted or if access to the content is not permitted |
setListener | public void setListener(ResponseListener listener)(Code) | | Sets the listener to be notified when a new response is
available for the application context. The request must
be retrieved using
RegistryImpl.getResponse getResponse .
Parameters: listener - the listener to register;null to remove the listener. |
unregister | public boolean unregister(String classname)(Code) | | Removes the content handler registration for the application
class and any bindings to the content handler name, content
type(s), suffix(es), action(s), and access restrictions.
Parameters: classname - the name of the content handler class if the content handler wassuccessfully removed true is returned,false otherwise exception: NullPointerException - if classname isnull |
|
|