org.glassfish.cafe.spi
Interface CafeObjectBuilder<O>

Type Parameters:
O - Generic type name of the object being built.

public interface CafeObjectBuilder<O>

CAFE framework uses an instance of this class returned by CafeModule for creating the objects like Communications,UserProcedures or Participants. One instance of the CafeObjectBuilder is used to build exactly one object and it will be discarded as soon as the object is built. During the build process, the CafeObjectBuilder will be stateful as per the java builder pattern semantics.


Method Summary
 O buildCommunication(String name, Communication other, Object... arg)
          Build a Communication object from an already existing Communication.
 O buildCommunication(String name, Participant initiator, Object... arg)
          Build a Communication object using the specified initiator.
 O buildCommunication(String name, ProtocolMessage msg)
          Build a Communication object from an incoming ProtocolMessage.
 O buildParticipant(String name, javax.media.mscontrol.join.Joinable j)
          Build a Participant object with the specified name.
 ProtocolMessageHandler buildProtocolMessageHandler()
          Return a ProtocolMessageHandler object that encapsulate the Communication or UserProcedure.
 O buildUserProcedure(String id, Object... arg)
          Build a UserProcedure object with the specified id.
 Class<?> getType()
          Return the type of the object built.
 void setCommunication(O cached)
          If the CAFE framework might have found an object that matches the name of the object being built in its cache.
 

Method Detail

setCommunication

void setCommunication(O cached)
If the CAFE framework might have found an object that matches the name of the object being built in its cache. In such cases, framework will set this object on the the builder so that, the CafeObjectBuilder can take an appropriate decision.

Parameters:
cached - Object found in the cache.

buildCommunication

O buildCommunication(String name,
                     Communication other,
                     Object... arg)
Build a Communication object from an already existing Communication.

Parameters:
name - Name of the Communication to be built. This will never be null.
other - Input Communication object. This will not be null.
arg - Any other arguments. This is an optional parameter.
Returns:
Built Communication object.

buildCommunication

O buildCommunication(String name,
                     Participant initiator,
                     Object... arg)
Build a Communication object using the specified initiator.

Parameters:
name - Name of the Communication to be built. This will never be null.
initiator - An instance of Participant which is the initiator of this Communication. This can be null.
arg - Any other arguments. This is an optional parameter.
Returns:
Built Communication object.

buildCommunication

O buildCommunication(String name,
                     ProtocolMessage msg)
Build a Communication object from an incoming ProtocolMessage.

Parameters:
name - Name of the Communication to be built. This will never be null.
msg - ProtocolMessage object. This will be never be null.

buildUserProcedure

O buildUserProcedure(String id,
                     Object... arg)
Build a UserProcedure object with the specified id.

Parameters:
id - Name of the UserProcedure to be built. This will never be null.
arg - Any other arguments. This is an optional parameter.

buildParticipant

O buildParticipant(String name,
                   javax.media.mscontrol.join.Joinable j)
Build a Participant object with the specified name.

Parameters:
name - Name of the Participant to be built. This will never be null.
j - JSR 309 Joinable object that the Participantmight be associated with. This is optional.

getType

Class<?> getType()
Return the type of the object built.

Returns:
Class of the object being built.

buildProtocolMessageHandler

ProtocolMessageHandler buildProtocolMessageHandler()
Return a ProtocolMessageHandler object that encapsulate the Communication or UserProcedure. Framework will execute this method only after the execution of either a buildCommunication method or buildUserProcedure method. The returned ProtocolMessageHandler will represent the Communication or UserProcedure object created in that method execution.

Returns:
an instance of ProtocolMessageHandler
See Also:
ProtocolMessageHandler


Copyright © 2010. All Rights Reserved.