| java.lang.Object com.sun.j2me.payment.PaymentModule
All known Subclasses: com.sun.j2me.payment.CldcPaymentModule,
PaymentModule | abstract public class PaymentModule implements TransactionProcessor(Code) | | This class represents a payment module. An instance of this class accepts
payment requests from transaction modules. For each payment request it
creates an instance of the Transaction class, set itself as
an initial transaction processor of this transaction and adds it to the
internal queue.
The internal queue is processed by a background thread created by the
instance of the payment module. This thread iterates through the queued
transactions and calls their process methods. This changes the
internal states of the transactions until they are fully processed and are
removed from the queue.
The process method of a transaction delegates the call to the
associated transaction processor. This is initially the payment module. That
allows him to show a provider selection form. After the user selects the
provider for the transaction, the payment module changes the transaction
processor of the transaction to the provider's payment adapter. This adapter
gets the control over the transaction till it finishes the transaction and
returns the control over it back to the payment module. The payment module
finally removes the transaction from the transaction queue and notifies the
application about the result of the payment.
The notification is done by creating a new transaction record for the
finished transaction and adding it to the transaction notification
queue which is processed by an extra thread which handles the notifications.
Each transaction record is automatically added to the transaction store, so
it can be obtained after crashing of the emulator.
version: |
Constructor Summary | |
protected | PaymentModule() Creates a new instance of PaymentModule. |
Method Summary | |
final public synchronized int | addTransaction(TransactionModuleImpl transactionModule, int featureID, String featureTitle, String featureDescription, byte[] payload) Creates a new transaction from the given payment requests. | final void | addTransactionForNotification(TransactionRecord record, TransactionModuleImpl module) Adds the given transaction record to the transaction notification queue
and associates it with the given payment module. | final void | addTransactionsForNotification(TransactionRecord[] records, TransactionModuleImpl module) Adds the given transaction records to the transaction notification
queue and associates them with the given payment module. | protected void | assignTransaction(Transaction transaction, int providerID) Assigns the given transaction to the provider identified by its
identification number. | final void | continueProcessing() Signals the transaction processing thread to continue processing of the
queued transactions. | protected PaymentAdapter | createAdapter(String adapter, String configuration) Creates the payment adapter for the given registered adapter name and
the adapter configuration string. | abstract public TransactionModuleImpl | createTransactionModule(Object object) It's a factory method for TransactionModuleImpl . | PaymentAdapter | getAdapter(String name, String configuration) Returns the payment adapter for the given registered adapter name and
the adapter configuration string. | public static PaymentModule | getInstance() Returns an instance of the PaymentModule class. | final public int | getNextApplicationID() Returns a new application ID, which can be used to store transaction
records to the transaction store. | protected static PaymentInfo | getPaymentInfo(Transaction transaction) Returns the associated payment information for the given transaction. | abstract protected TransactionStore | getTransactionStore() Returns an instrance of the TransactionStore wich is used
for storing of all transaction records produced in the payment module.
There is only one such instance, which is returned each time the method
is called. | abstract protected Utils | getUtilities() Returns an instance of Utils subclass. | final protected int[] | getValidProviders(PaymentInfo paymentInfo) Returns an array of provider identifiers, which could be used to pay
for features. | protected boolean | handleAutoRequestMode(Transaction transaction) Handles the auto request debug mode for the given transaction. | protected boolean | handleTransactionDebugMode(Transaction transaction) Handles the success/failure/random debug mode for the given transaction. | public boolean | isSupportedAdapter(String name) Indicates if the given adapter is supported by the device. | abstract protected void | preemptDisplay(SecurityToken token, Displayable nextDisplayable) Replaces the current Displayable with the new one if the
nextDisplayable is not null or it recovers
the previous Displayable if the nextDisplayable
is null . | public Transaction | process(Transaction transaction) A method which is responsible for processing of transactions which are
not yet assigned to the provider specific adapters or they are finished
and need to be removed from the transaction processing queue. | protected static void | savePaymentInfo(Transaction transaction) Saves the payment information for the given transaction into storage. |
PaymentModule | protected PaymentModule()(Code) | | Creates a new instance of PaymentModule.
|
addTransaction | final public synchronized int addTransaction(TransactionModuleImpl transactionModule, int featureID, String featureTitle, String featureDescription, byte[] payload) throws TransactionModuleException(Code) | | Creates a new transaction from the given payment requests. It sets the
payment module as a transaction processor and adds the new transaction
to the transaction queue. Returns a generated identification number,
which identifies the new transaction.
Parameters: transactionModule - the transaction module, which called the method Parameters: featureID - the identifier of the feature to be paid for Parameters: featureTitle - the title of the feature Parameters: featureDescription - the description of the feature Parameters: payload - the payload to be transfered as a part of the payment ornull if no such payload required the identification number of the transaction throws: TransactionModuleException - if there is no more space to storethe new transaction |
addTransactionForNotification | final void addTransactionForNotification(TransactionRecord record, TransactionModuleImpl module)(Code) | | Adds the given transaction record to the transaction notification queue
and associates it with the given payment module. The payment module holds
a reference to the listener, which should be notified.
Parameters: record - the transaction record Parameters: module - the transaction module |
addTransactionsForNotification | final void addTransactionsForNotification(TransactionRecord[] records, TransactionModuleImpl module)(Code) | | Adds the given transaction records to the transaction notification
queue and associates them with the given payment module. The payment
module holds a reference to the listener, which should be notified.
Parameters: records - an array of the transaction records Parameters: module - the transaction module |
assignTransaction | protected void assignTransaction(Transaction transaction, int providerID)(Code) | | Assigns the given transaction to the provider identified by its
identification number. It sets the transaction processor of the
transaction to the provider's payment adapter.
Parameters: transaction - the transaction Parameters: providerID - the provider id |
continueProcessing | final void continueProcessing()(Code) | | Signals the transaction processing thread to continue processing of the
queued transactions. It means that there is at least one transaction in
the queue, which is not waiting for some event (an user action,
finishing of some payment adapter's thread, etc.).
|
createAdapter | protected PaymentAdapter createAdapter(String adapter, String configuration) throws PaymentException(Code) | | Creates the payment adapter for the given registered adapter name and
the adapter configuration string. It returns null if no
such adapter can be created.
Parameters: adapter - the registered adapter name Parameters: configuration - the adapter configuration string the instance of the payment adapter or null throws: PaymentException - if the adapter configuration stringhas an invalid format |
getAdapter | PaymentAdapter getAdapter(String name, String configuration) throws PaymentException(Code) | | Returns the payment adapter for the given registered adapter name and
the adapter configuration string. It either returns an adapter created
before for the given combination of name and
providerString or creates a new instance if the old one
doesn't exist. It returns null if no adapter of the given
parameters can be created.
Parameters: name - the registered adapter name Parameters: configuration - the adapter configuration string the instance of the payment adapter or null throws: PaymentException - if the adapter configuration stringhas an invalid format |
getInstance | public static PaymentModule getInstance()(Code) | | Returns an instance of the PaymentModule class. It creates
only one instance and reuses it each time the method is called.
the instance |
getNextApplicationID | final public int getNextApplicationID() throws IOException(Code) | | Returns a new application ID, which can be used to store transaction
records to the transaction store.
the new application ID throws: IOException - if there is a I/O failure while working with thestore |
getPaymentInfo | protected static PaymentInfo getPaymentInfo(Transaction transaction)(Code) | | Returns the associated payment information for the given transaction.
Parameters: transaction - the transaction the payment information |
getTransactionStore | abstract protected TransactionStore getTransactionStore()(Code) | | Returns an instrance of the TransactionStore wich is used
for storing of all transaction records produced in the payment module.
There is only one such instance, which is returned each time the method
is called. This instance is used from both internal threads of the
payment module (TransactionProcessingThread and
TransactionNotificationThread ) and it is left to an
implementation of the TransactionStore to be thread safe.
the transaction store |
getUtilities | abstract protected Utils getUtilities()(Code) | | Returns an instance of Utils subclass.
the instance |
getValidProviders | final protected int[] getValidProviders(PaymentInfo paymentInfo)(Code) | | Returns an array of provider identifiers, which could be used to pay
for features.
Parameters: paymentInfo - the payment information for the MIDlet whichinitiated the payment the array of provider identifiers |
handleAutoRequestMode | protected boolean handleAutoRequestMode(Transaction transaction)(Code) | | Handles the auto request debug mode for the given transaction. It's
called from the parts of the PaymentModule code where this
mode can be applied. If the auto request mode is in effect the
transaction state is set accordingly and the method returns
true .
Parameters: transaction - the transaction true if the transaction is handled in the method(= the auto request mode is in effect) |
handleTransactionDebugMode | protected boolean handleTransactionDebugMode(Transaction transaction)(Code) | | Handles the success/failure/random debug mode for the given transaction.
It's called from the parts of the PaymentModule code where
this mode can be applied. If the debug mode is in effect the transaction
state is set accordingly and the method returns true .
Parameters: transaction - the transaction true if the transaction is handled in the method |
isSupportedAdapter | public boolean isSupportedAdapter(String name)(Code) | | Indicates if the given adapter is supported by the device.
Parameters: name - the name of the adapter true if the given adapter is supported |
preemptDisplay | abstract protected void preemptDisplay(SecurityToken token, Displayable nextDisplayable)(Code) | | Replaces the current Displayable with the new one if the
nextDisplayable is not null or it recovers
the previous Displayable if the nextDisplayable
is null .
Parameters: token - a security token, which allows preempting Parameters: nextDisplayable - the Displayable to show ornull if the recovery of the oldDisplayable is requested |
process | public Transaction process(Transaction transaction)(Code) | | A method which is responsible for processing of transactions which are
not yet assigned to the provider specific adapters or they are finished
and need to be removed from the transaction processing queue.
Parameters: transaction - the transaction to be processed the processed transaction or null if the transactionshould be removed from the transaction queue |
savePaymentInfo | protected static void savePaymentInfo(Transaction transaction)(Code) | | Saves the payment information for the given transaction into storage.
Parameters: transaction - the transaction |
|
|