org.glassfish.cafe.spi
Interface CafeModule


public interface CafeModule

Represents a module in CAFE framework. Each functionality in CAFE is a module. A module might support one or more types of Communications and/or UserProcedures. An implementation of this interface is the basic entry point of any Custom module to CAFE. For example, if some particular SIP dialogs need to be handled in a custom way using new types of Communications, a new CafeModule need to be defined. Custom CAFE modules should follow the Java Service Provider Interface mechanism. Any jar which contains a META-INF/services/org.glassfish.cafe.spi.CafeModule file would be treated as a CAFE module. This file will contain fully qualified name of the a class that implements this interface. For each CAFE Java EE application deployed in the container and instance of CafeModule will be created. During this process, an instance of CafeModuleRuntime will be passed to the cafeModule. After initializing the CafeModule, every new ProtocolMessage and any new Object creation request will be referred to the module, to check whether the module can handle it.


Method Summary
 void cleanup()
          Framework executes this method, so that any internal housekeeping of the cafeModule can be released.
<O> CafeObjectBuilder<O>
createBuilder(Class<O> type, CommunicationSession session)
          Creates an Object builder for a specified type for a particular CommunicationSession.
 Class<?> getSupportedType(ProtocolMessage msg)
          Get the type of Communication or UserProcedure supported for the incoming ProtocolMessage.
 boolean handles(Class<?> type)
          Checks whether the module can create an instance of specified CAFE artifact type.
 void initialize(CafeModuleRuntime cmr)
          Initialize the CafeModule with an instance of the CafeModuleRuntime.
 

Method Detail

initialize

void initialize(CafeModuleRuntime cmr)
Initialize the CafeModule with an instance of the CafeModuleRuntime.

Parameters:
cmr - An instance of CafeModuleRuntime
See Also:
CafeModuleRuntime

getSupportedType

Class<?> getSupportedType(ProtocolMessage msg)
Get the type of Communication or UserProcedure supported for the incoming ProtocolMessage. This is typically invoked when an initial SIP request reaches the CAFE framework.

Parameters:
msg - Incoming ProtocolMessage
Returns:
The type of Communication or UserProcedure. This method returns null, if the module cannot handle the message.
See Also:
Communication, UserProcedure, ProtocolMessage

handles

boolean handles(Class<?> type)
Checks whether the module can create an instance of specified CAFE artifact type. A module can define its own types of Communication, UserProcedure or Participant. And subsequently this method can be used to notify the framework that it can handle the building of these artifacts.

Parameters:
type - This can be any sub-type of Communication, UserProcedure or Participant.
Returns:
True if the module can handle building an object of specified type. False otherwise.
See Also:
Communication, UserProcedure, ProtocolMessage

createBuilder

<O> CafeObjectBuilder<O> createBuilder(Class<O> type,
                                       CommunicationSession session)
Creates an Object builder for a specified type for a particular CommunicationSession. The framework will invoke this, only after it finds out that the module is capable of handling the type, either as a result of invoking the getSupportedType or handlesmethod.

Type Parameters:
O - Generic type name of the object to be built.
Parameters:
type - Type of the object to be built. This can be any sub-type of Communication, UserProcedure or Participant.
session - an instance of CommunicationSession
Returns:
An instance of CafeObjectBuilder
See Also:
Communication, UserProcedure, ProtocolMessage

cleanup

void cleanup()
Framework executes this method, so that any internal housekeeping of the cafeModule can be released. Typically happens when the Java EE application is undeployed.



Copyright © 2010. All Rights Reserved.