Writing Applets for Concurrent Logical Channels
This section describes how to write a multiselectable applet that will perform various tasks based on whether it is selected. The code samples in this section show how to extend the applet to implement the MultiSelectable interface and how to implement the MultiSelectable.select(boolean)
and deselect(boolean)
methods. The code samples also show how to use the Applet.select()
and deselect()
methods to work with multiselectable applets.
To take advantage of multiple channel operation, an applet must implement the javacard.framework.MultiSelectable interface. For example:
public class SampleApplet extends Applet
implements MultiSelectable {
...
}
The new applet needs to provide implementation for the MultiSelectable.select(boolean)
and MultiSelectable.deselect(boolean)
methods. These methods are responsible for encoding the behavior that the applet needs during a selection event if either of the following situations occurs:
-
The applet is already selected on a different channel.
-
One or more applets from the same package are also selected on different channels.
The behavior to be encoded might include initializing applet state, accepting or rejecting the selection request, or clearing data structures in case of deselection:
public boolean select(boolean appInstAlreadySelected) {
// Implement the logic to control applet selection
// during a multiselection situation
...
}
public void deselect(boolean appInstStillSelected) {
// Implement the logic to control applet deselection
// during a multiselection situation
...
}
Note:
The applet is still required to implement the Applet.select()
and the Applet.deselect()
methods in addition to the MultiSelectable interface. These methods handle applet selection and deselection behavior when a multiselection situation does not happen.