Project Wonder 5.0

er.ajax.json
Class JSONRequestHandler

java.lang.Object
  extended by com.webobjects.appserver.WORequestHandler
      extended by er.ajax.json.JSONRequestHandler

public class JSONRequestHandler
extends com.webobjects.appserver.WORequestHandler

JSONRequestHandler provides support for JSON RPC services that can be both stateless or stateful (using JSON Components).

Author:
mschrag
Properties
er.ajax.json.globalBacktrackCacheSize the maximum number of global components that can be in the session (defaults to backtrack cache size)
           
er.ajax.json.backtrackCacheSize the maximum number of non-global components that can be in the session (defaults to backtrack cache size)
           

Nested Class Summary
protected static class JSONRequestHandler.JSONComponentCallback
           
protected static class JSONRequestHandler.LRUMap<U,V>
           
 
Field Summary
static java.lang.String RequestHandlerKey
           
 
Fields inherited from class com.webobjects.appserver.WORequestHandler
DidHandleRequestNotification
 
Constructor Summary
JSONRequestHandler()
          Creates a new JSONRequestHandler.
 
Method Summary
static java.lang.String _jsonUrl(com.webobjects.appserver.WOContext context, java.lang.String requestHandlerKey, java.lang.String componentNameAndInstance, java.lang.String queryString)
          Returns a URL pointing to the JSON request handler.
protected static java.lang.String componentNameAndInstance(java.lang.String componentName, java.lang.String componentInstance)
           
protected  org.jabsorb.JSONRPCBridge createBridgeForComponent(JSONComponent component, java.lang.String componentName, java.lang.String componentInstance, java.util.Map<java.lang.String,org.jabsorb.JSONRPCBridge> componentBridges)
           
 org.jabsorb.JSONRPCBridge getJSONBridge()
          Returns the shared JSON Bridge for this request handler.
 com.webobjects.appserver.WOResponse handleRequest(com.webobjects.appserver.WORequest request)
           
static java.lang.String jsonUrl(com.webobjects.appserver.WOContext context, java.lang.String queryString)
          Returns a URL pointing to the JSON request handler.
static java.lang.String jsonUrl(com.webobjects.appserver.WOContext context, java.lang.String requestHandlerKey, java.lang.String queryString)
          Returns a URL pointing to the JSON request handler.
static java.lang.String jsonUrl(com.webobjects.appserver.WOContext context, java.lang.String componentName, java.lang.String instance, java.lang.String queryString)
          Returns a URL pointing to the JSON request handler for a JSON component.
static java.lang.String jsonUrl(com.webobjects.appserver.WOContext context, java.lang.String requestHandlerKey, java.lang.String componentName, java.lang.String componentInstance, java.lang.String queryString)
          Returns a URL pointing to the JSON request handler.
static JSONRequestHandler register()
          Registers the JSONRequestHandler with your application using the default key.
static void registerClass(java.lang.Class clazz)
          Registers all of the methods of the given class to be available for services to call (see JSONRPCBridge).
static void registerClass(java.lang.String name, java.lang.Class clazz)
          Registers all of the methods of the given class to be available for services to call (see JSONRPCBridge).
static void registerSerializer(org.jabsorb.serializer.Serializer serializer)
          Registers a custom serializer into the global JSON serializers (see JSONRPCBridge).
 void registerService(java.lang.String name, java.lang.Object serviceObject)
          Registers the given object in the shared JSON bridge.
 
Methods inherited from class com.webobjects.appserver.WORequestHandler
toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

RequestHandlerKey

public static final java.lang.String RequestHandlerKey
See Also:
Constant Field Values
Constructor Detail

JSONRequestHandler

public JSONRequestHandler()
Creates a new JSONRequestHandler.

Method Detail

register

public static JSONRequestHandler register()
Registers the JSONRequestHandler with your application using the default key.

Returns:
the request handler instance

getJSONBridge

public org.jabsorb.JSONRPCBridge getJSONBridge()
Returns the shared JSON Bridge for this request handler.

Returns:
the shared JSON Bridge for this request handler

registerSerializer

public static void registerSerializer(org.jabsorb.serializer.Serializer serializer)
                               throws java.lang.Exception
Registers a custom serializer into the global JSON serializers (see JSONRPCBridge).

Parameters:
serializer - the serializer to register
Throws:
java.lang.Exception - if the registration fails

registerClass

public static void registerClass(java.lang.Class clazz)
                          throws java.lang.Exception
Registers all of the methods of the given class to be available for services to call (see JSONRPCBridge).

Parameters:
clazz - the class to register
Throws:
java.lang.Exception - if the registration fails

registerClass

public static void registerClass(java.lang.String name,
                                 java.lang.Class clazz)
                          throws java.lang.Exception
Registers all of the methods of the given class to be available for services to call (see JSONRPCBridge).

Parameters:
name - the namespace to register the methods under
clazz - the class to register
Throws:
java.lang.Exception - if the registration fails

registerService

public void registerService(java.lang.String name,
                            java.lang.Object serviceObject)
Registers the given object in the shared JSON bridge. The shared JSON bridge is used for stateless JSON services. As an example, if you call registerService("myExampleService", new ExampleService()) you can then call json.myExampleService.someMethodInExampleService from your Javascript. The same instance is shared across all of your service users, so you should not store any state in this class.

Parameters:
name - the name to register the object as
serviceObject - the instance to register

jsonUrl

public static java.lang.String jsonUrl(com.webobjects.appserver.WOContext context,
                                       java.lang.String queryString)
Returns a URL pointing to the JSON request handler. This variant should be used for the shared web service endpoint.

Parameters:
context - the current WOContext
queryString - the query string to append
Returns:
a JSON request handler URL

jsonUrl

public static java.lang.String jsonUrl(com.webobjects.appserver.WOContext context,
                                       java.lang.String requestHandlerKey,
                                       java.lang.String queryString)
Returns a URL pointing to the JSON request handler. This variant should be used for the shared web service endpoint.

Parameters:
context - the current WOContext
requestHandlerKey - if you registered a custom JSON request handler key
queryString - the query string to append
Returns:
a JSON request handler URL

jsonUrl

public static java.lang.String jsonUrl(com.webobjects.appserver.WOContext context,
                                       java.lang.String componentName,
                                       java.lang.String instance,
                                       java.lang.String queryString)
Returns a URL pointing to the JSON request handler for a JSON component.

Parameters:
context - the current WOContext
componentName - the name of the component to lookup
instance - the instance identifier (any value) to create a unique instance (or null for a session-global)
queryString - the query string to append
Returns:
a JSON request handler URL

jsonUrl

public static java.lang.String jsonUrl(com.webobjects.appserver.WOContext context,
                                       java.lang.String requestHandlerKey,
                                       java.lang.String componentName,
                                       java.lang.String componentInstance,
                                       java.lang.String queryString)
Returns a URL pointing to the JSON request handler.

Parameters:
context - the current WOContext
requestHandlerKey - if you registered a custom JSON request handler key
componentName - the name of the component to lookup (or null for the shared bridge)
componentInstance - the instance identifier (any value) to create a unique instance (or null for a session-global)
queryString - the query string to append
Returns:
a JSON request handler URL

_jsonUrl

public static java.lang.String _jsonUrl(com.webobjects.appserver.WOContext context,
                                        java.lang.String requestHandlerKey,
                                        java.lang.String componentNameAndInstance,
                                        java.lang.String queryString)
Returns a URL pointing to the JSON request handler.

Parameters:
context - the current WOContext
requestHandlerKey - if you registered a custom JSON request handler key
componentNameAndInstance - the name/instance identifier of the component to lookup (or null for the shared bridge)
queryString - the query string to append
Returns:
a JSON request handler URL

handleRequest

public com.webobjects.appserver.WOResponse handleRequest(com.webobjects.appserver.WORequest request)
Specified by:
handleRequest in class com.webobjects.appserver.WORequestHandler

componentNameAndInstance

protected static java.lang.String componentNameAndInstance(java.lang.String componentName,
                                                           java.lang.String componentInstance)

createBridgeForComponent

protected org.jabsorb.JSONRPCBridge createBridgeForComponent(JSONComponent component,
                                                             java.lang.String componentName,
                                                             java.lang.String componentInstance,
                                                             java.util.Map<java.lang.String,org.jabsorb.JSONRPCBridge> componentBridges)
                                                      throws java.lang.Exception
Throws:
java.lang.Exception

Last updated: Tue, Feb 21, 2017 • 05:45 PM CET

Copyright © 2002 – 2007 Project Wonder.