@InterfaceAudience.Public @InterfaceStability.Stable public abstract class BasicChannelSemantics extends AbstractChannel
An implementation of basic Channel
semantics, including the
implied thread-local semantics of the Transaction
class,
which is required to extend BasicTransactionSemantics
.
Constructor and Description |
---|
BasicChannelSemantics() |
Modifier and Type | Method and Description |
---|---|
protected abstract BasicTransactionSemantics |
createTransaction()
Called to create new
Transaction objects, which must
extend BasicTransactionSemantics . |
Transaction |
getTransaction()
Initializes the channel if it is not already, then checks to see
if there is an open transaction for this thread, creating a new
one via
createTransaction if not. |
protected void |
initialize()
Called upon first getTransaction() request, while synchronized on
this
Channel instance. |
void |
put(Event event)
Ensures that a transaction exists for this thread and then
delegates the
put to the thread's BasicTransactionSemantics instance. |
Event |
take()
Ensures that a transaction exists for this thread and then
delegates the
take to the thread's BasicTransactionSemantics instance. |
configure, getLifecycleState, getName, setName, start, stop, toString
protected void initialize()
Called upon first getTransaction() request, while synchronized on
this Channel
instance. Use this method to delay the
initializization resources until just before the first
transaction begins.
protected abstract BasicTransactionSemantics createTransaction()
Called to create new Transaction
objects, which must
extend BasicTransactionSemantics
. Each object is used
for only one transaction, but is stored in a thread-local and
retrieved by getTransaction
for the duration of that
transaction.
public void put(Event event) throws ChannelException
Ensures that a transaction exists for this thread and then
delegates the put
to the thread's BasicTransactionSemantics
instance.
event
- the event to transport.ChannelException
- in case this operation fails.Transaction.begin()
public Event take() throws ChannelException
Ensures that a transaction exists for this thread and then
delegates the take
to the thread's BasicTransactionSemantics
instance.
null
if no events are
available.ChannelException
- in case this operation fails.Transaction.begin()
public Transaction getTransaction()
Initializes the channel if it is not already, then checks to see
if there is an open transaction for this thread, creating a new
one via createTransaction
if not.
Transaction
object for the
calling thread
Copyright © 2009-2017 Apache Software Foundation. All Rights Reserved.