org.granite.tide.seam
Class AbstractSeamServiceContext

java.lang.Object
  extended by org.granite.tide.TideServiceContext
      extended by org.granite.tide.seam.AbstractSeamServiceContext
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
SeamServiceContext

public abstract class AbstractSeamServiceContext
extends org.granite.tide.TideServiceContext

Author:
William DRAI
See Also:
Serialized Form

Field Summary
static String COMPONENT_NAME
           
protected  Log log
           
 
Fields inherited from class org.granite.tide.TideServiceContext
COMPONENT_ATTR, COMPONENT_CLASS_ATTR, EMPTY_ARGS
 
Constructor Summary
AbstractSeamServiceContext()
           
 
Method Summary
 void addResultEval(ScopedContextResult result)
           
protected abstract  void clearTideMessages()
           
 void endSession()
          Clear current session from user events registry
 List<org.granite.tide.invocation.ContextUpdate> evaluateResults(Component component, Object target, boolean nothing)
          Evaluate results from context
 Object findComponent(String componentName, Class<?> componentClass)
          Implementation of component lookup for Seam service
 Set<Class<?>> findComponentClasses(String componentName, Class<?> componentClass)
          Implementation of component lookup for Seam service
 AsyncContext getAsyncContext()
          Constructs an asynchronous context object
protected  org.granite.tide.async.AsyncPublisher getAsyncPublisher()
          Factory for Seam async publisher
protected abstract  org.granite.tide.TideStatusMessages getTideMessages()
          Retrieve current messages
protected  org.granite.tide.TidePersistenceManager getTidePersistenceManager(boolean create)
           
 void initCall()
          Determines the current sessionId for web invocations
protected abstract  void initTideMessages()
           
 Object invokeAsynchronous(AsyncContext asyncContext, String targetComponentName, Class<?> targetComponentClass, String methodName, Class<?>[] paramTypes, Object[] params)
          Implementations of intercepted asynchronous calls Send asynchronous event to client
static Object[] lookupInStatefulContexts(String name, ScopeType scope)
          Search for a named attribute in all contexts, in the following order: method, event, page, conversation, session, business process, application.
 void observeBeginConversation()
           
 org.granite.tide.IInvocationResult postCall(org.granite.messaging.service.ServiceInvocationContext context, Object result, String componentName, Class<?> componentClass)
          Builds the result object for the invocation
 void postCallFault(org.granite.messaging.service.ServiceInvocationContext context, Throwable t, String componentName, Class<?> componentClass)
          Intercepts a fault on the invocation
 void prepareCall(org.granite.messaging.service.ServiceInvocationContext context, org.granite.tide.IInvocationCall c, String componentName, Class<?> componentClass)
          Synchronizes server context with data provided by the client
 void raiseEvent(String type, Object... params)
          Add an event in the current context
 void restoreContext(List<org.granite.tide.invocation.ContextUpdate> updates, Component component, Object target)
          Evaluate updates in current server context
 void setAsyncContext(AsyncContext asyncContext)
          Restores an asynchronous context
 void setSessionId(String sessionId)
          Initialize current sessionId and event listeners for this context
 
Methods inherited from class org.granite.tide.TideServiceContext
adjustInvokee, beforeMethodSearch, equals, getSessionId, lazyInitialize, mergeExternal, mergeExternal, sendEvent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COMPONENT_NAME

public static final String COMPONENT_NAME
See Also:
Constant Field Values

log

@Logger
protected Log log
Constructor Detail

AbstractSeamServiceContext

public AbstractSeamServiceContext()
                           throws org.granite.messaging.service.ServiceException
Throws:
org.granite.messaging.service.ServiceException
Method Detail

initCall

public void initCall()
Determines the current sessionId for web invocations

Overrides:
initCall in class org.granite.tide.TideServiceContext

setSessionId

public void setSessionId(String sessionId)
Initialize current sessionId and event listeners for this context

Overrides:
setSessionId in class org.granite.tide.TideServiceContext
Parameters:
sessionId - current sessionId

endSession

@Destroy
public void endSession()
Clear current session from user events registry


getAsyncContext

public AsyncContext getAsyncContext()
Constructs an asynchronous context object

Returns:
current context

setAsyncContext

public void setAsyncContext(AsyncContext asyncContext)
Restores an asynchronous context

Parameters:
asyncContext - saved context

getTideMessages

protected abstract org.granite.tide.TideStatusMessages getTideMessages()
Retrieve current messages

Returns:
list of messages

initTideMessages

protected abstract void initTideMessages()

clearTideMessages

protected abstract void clearTideMessages()

findComponent

public Object findComponent(String componentName,
                            Class<?> componentClass)
Implementation of component lookup for Seam service

Specified by:
findComponent in class org.granite.tide.TideServiceContext
Parameters:
componentName - component name

findComponentClasses

public Set<Class<?>> findComponentClasses(String componentName,
                                          Class<?> componentClass)
Implementation of component lookup for Seam service

Specified by:
findComponentClasses in class org.granite.tide.TideServiceContext
Parameters:
componentName - component name

observeBeginConversation

@Observer(value="org.jboss.seam.beginConversation")
public void observeBeginConversation()

raiseEvent

public void raiseEvent(String type,
                       Object... params)
Add an event in the current context

Parameters:
type - event type
params - event parameters

getAsyncPublisher

protected org.granite.tide.async.AsyncPublisher getAsyncPublisher()
Factory for Seam async publisher

Specified by:
getAsyncPublisher in class org.granite.tide.TideServiceContext
Returns:
servlet context of the current application

prepareCall

public void prepareCall(org.granite.messaging.service.ServiceInvocationContext context,
                        org.granite.tide.IInvocationCall c,
                        String componentName,
                        Class<?> componentClass)
Synchronizes server context with data provided by the client

Specified by:
prepareCall in class org.granite.tide.TideServiceContext
Parameters:
context - invocation context
c - client call
componentName - name of the component which will be invoked

postCall

public org.granite.tide.IInvocationResult postCall(org.granite.messaging.service.ServiceInvocationContext context,
                                                   Object result,
                                                   String componentName,
                                                   Class<?> componentClass)
Builds the result object for the invocation

Specified by:
postCall in class org.granite.tide.TideServiceContext
Parameters:
context - invocation context
result - result of the method invocation
componentName - name of the invoked component
Returns:
result object

postCallFault

public void postCallFault(org.granite.messaging.service.ServiceInvocationContext context,
                          Throwable t,
                          String componentName,
                          Class<?> componentClass)
Intercepts a fault on the invocation

Overrides:
postCallFault in class org.granite.tide.TideServiceContext
Parameters:
context - invocation context
t - exception thrown
componentName - name of the invoked component

addResultEval

public void addResultEval(ScopedContextResult result)

restoreContext

public void restoreContext(List<org.granite.tide.invocation.ContextUpdate> updates,
                           Component component,
                           Object target)
Evaluate updates in current server context

Parameters:
updates - list of updates
component - the target component
target - the target instance

evaluateResults

public List<org.granite.tide.invocation.ContextUpdate> evaluateResults(Component component,
                                                                       Object target,
                                                                       boolean nothing)
Evaluate results from context

Parameters:
component - the target component
target - the target instance
nothing - used by initializer to avoid interactions with context sync
Returns:
list of updates to send back to the client

invokeAsynchronous

public Object invokeAsynchronous(AsyncContext asyncContext,
                                 String targetComponentName,
                                 Class<?> targetComponentClass,
                                 String methodName,
                                 Class<?>[] paramTypes,
                                 Object[] params)
Implementations of intercepted asynchronous calls Send asynchronous event to client

Parameters:
asyncContext - current context (session id)
targetComponentName - target component name
methodName - method name
paramTypes - method argument types
params - argument values
Returns:
result

getTidePersistenceManager

protected org.granite.tide.TidePersistenceManager getTidePersistenceManager(boolean create)
Specified by:
getTidePersistenceManager in class org.granite.tide.TideServiceContext

lookupInStatefulContexts

public static Object[] lookupInStatefulContexts(String name,
                                                ScopeType scope)
Search for a named attribute in all contexts, in the following order: method, event, page, conversation, session, business process, application.

Returns:
the first component found, or null