Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## opencard.core.service
Class CardServiceFactory

    java.lang.Object
      |
      +--opencard.core.service.CardServiceFactory

public abstract class CardServiceFactory
extends java.lang.Object

A `CardServiceFactory` can instantiate `CardService`s for a specific smart card. Typically, the `CardServiceRegistry` will instantiate a `CardServiceFactory` once a smart card has been inserted for which a `waitForCard()` method was invoked.

Note: Subclasses should implement the getCardType() and getClasses() methods which can communicate with the card to classify the card. OCF 1.1 style card service factories should instead derive from `opencard.opt.service.OCF11CardServiceFactory` which still offers the deprecated knows() and cardServiceClasses() methods.

See Also:
  `opencard.opt.service.OCF11CardServiceFactory`, `CardService`, `PrimaryCardServiceFactory`, `CardID`

Constructor Summary
`CardServiceFactory()` Instantiate a `CardServiceFactory`.

Method Summary
`protected CardService` | `getCardServiceInstance(java.lang.Class clazz, CardType type, CardServiceScheduler scheduler, SmartCard card, boolean block)` Instantiate a `CardService` implementing the class `clazz`.
`protected abstract CardType` | `getCardType(CardID cid, CardServiceScheduler scheduler)` Indicate whether this `CardServiceFactory` "knows" the smart card OS and/or installed card applications and might be able to instantiate `CardService`s for it.
`protected abstract java.util.Enumeration` | `getClasses(CardType type)` Return an enumeration of known `CardService` classes.
`protected java.lang.Class` | `getClassFor(java.lang.Class clazz, CardType type)` Locate the `CardService` class that implements `clazz`.
`protected CardService` | `newCardServiceInstance(java.lang.Class clazz, CardType type, CardServiceScheduler scheduler, SmartCard card, boolean blocking)` Utility method to instantiate a `CardService`.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### CardServiceFactory

    public CardServiceFactory()

  Instantiate a `CardServiceFactory`.

Method Detail

### getCardServiceInstance

    protected CardService getCardServiceInstance(java.lang.Class clazz,
                                                 CardType type,
                                                 CardServiceScheduler scheduler,
                                                 SmartCard card,
                                                 boolean block)
                                          throws CardServiceException

  Instantiate a `CardService` implementing the class `clazz`.
  Parameters:
    `clazz` - The `Class` object for which an implementing `CardService` is requested.
    `cid` - A `CardID` object representing the smart card for which the `CardService` is requested.
    `scheduler` - The controlling `CardServiceScheduler`
    `card` - The `SmarCard` object requesting the `CardService`
    `block` - Specifies the waiting behavior of the newly created `CardService`; if true it will wait for `CardChannel` (i.e., block).
  Returns:
    An instance of the requested `CardService`, or `null` if the requested `CardService` cannot be instantiated.

### getClassFor

    protected java.lang.Class getClassFor(java.lang.Class clazz,
                                          CardType type)

  Locate the `CardService` class that implements `clazz`.
  Parameters:
    `clazz` - The `Class` object for which an implementing `CardService` is requested.
    `type` - A `CardType` object representing the smart card for which the `CardService` is requested.
  Returns:
    The class object of the `CardService` class that implements `clazz` if there is one; `null` otherwise.

### newCardServiceInstance

    protected CardService newCardServiceInstance(java.lang.Class clazz,
                                                 CardType type,
                                                 CardServiceScheduler scheduler,
                                                 SmartCard card,
                                                 boolean blocking)
                                          throws CardServiceException

  Utility method to instantiate a `CardService`.
  Parameters:
    `clazz` - The class of the `CardService` to instantiate.
    `scheduler` - The controlling scheduler.
    `card` - The owning `SmartCard` object.
    `blocking` - Whether to run the new `CardService` in blocking mode.
  Returns:
    The instantiated `CardService` object or `null` if the requested class could not be instantiated.
  Throws:
    CardServiceException - if the service could be instantiated using the default constructor, but encountered an error when `initialize` was invoked
  See Also:
    `CardService.CardService()`, `CardService.initialize(opencard.core.service.CardServiceScheduler, opencard.core.service.SmartCard, boolean)`

### getCardType

    protected abstract CardType getCardType(CardID cid,
                                            CardServiceScheduler scheduler)
                                     throws CardTerminalException

  Indicate whether this `CardServiceFactory` "knows" the smart card OS and/or installed card applications and might be able to instantiate `CardService`s for it.

  This method replaces the former knows() method. Note: OCF 1.1 style card service factories should instead derive from `opencard.opt.service.OCF11CardServiceFactory` which still offers the knows() and cardServiceClasses() methods.

  Should return a CardType that contains enough information to answer the getClassFor() method.

  The factory can inspect the card (communicate with the card) using the provided CardServiceScheduler if the CardID information is insufficient to classify the card.

  Parameters:
    `cid` - A `CardID` received from a `Slot`.
    `scheduler` - A `CardServiceScheduler` that can be used to communicate with the card to determine its type.
  Returns:
    A valid CardType if the factory can instantiate services for this card. CardType.UNSUPPORTED if the factory does not know the card.
  See Also:
    `getClasses(opencard.core.service.CardType)`

### getClasses

    protected abstract java.util.Enumeration getClasses(CardType type)

  Return an enumeration of known `CardService` classes.

  Replaces the former cardServiceClasses() method. Note: OCF 1.1 style card service factories should instead derive from `opencard.opt.service.OCF11CardServiceFactory` which still offers the knows() and cardServiceClasses() methods.

  Parameters:
    `type` - The `CardType` of the smart card for which the enumeration is requested.
  Returns:
    An `Enumeration` of class objects.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD