Eclipse CD5405 Manuel d'utilisateur Page 17

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 23
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 16
! ! ! System.out.println("File " + file.toString() + " found");
! ! ! try {
! ! ! ! // Open the file
! ! ! ! final BufferedReader in =
! ! ! ! ! new BufferedReader(new FileReader(file));
! ! ! ! // Identify the step handler for the steps assigned to this
! ! ! ! // agent.
! ! ! ! setItemHandlerFactory(new ItemHandlerFactory() {
! ! ! ! ! public ItemHandler createItemHandler(
! ! ! ! ! ! ! AgendaItem associatedItem) {
! ! ! ! ! ! return new
! ! ! ! ! ! StreamDischargeHandler(associatedItem, in);
!!!!!}
! ! ! ! });
! ! ! ! // Let us handle both new steps that are posted and ones
! ! ! ! // that existed before the agent was started.
! ! ! ! setProcessingMode(ProcessingMode.EXISTING_AND_NEW);
!!!!
! ! ! } catch (FileNotFoundException e) {
! ! ! ! // This shouldn't happen since we checked if the file
! ! ! ! // existed before trying to open it.
! ! ! ! System.out.println(
! ! ! ! ! "File " + file.toString() + " not found");
!!!}
! ! }
! ! else {
! ! ! // Report an error if we can't open the file.
! ! ! System.out.println("File " + file.toString() + " not found");
!!}
!}
}
A handler is the object that actually performs the work of a step. Here is a handler that
corresponds with the agent above. The only step for which it does actual work is Read S.
For all other steps, it simply completes.
When the handler reaches the end of the file, it signals this to the process by throwing the
EndOfSetException. We should therefore modify our Little-JIL process to expect this
exception and handle it. In this case, the exception is thrown by the Read S step. Add a
declaration of EndOfSetException to the Read S step. Propagate it all the way to the root,
where you should add a complete handler. You should also define an EndOfSetException
Java class similar to our earlier exception.
Now that we have this way of detecting the end of the input, we should change the
cardinality on the connector between Get Q Dataset and Build Q so that it loops indefinitely.
To do this, select the connector. Change the cardinality to have a lower bound of Default
and an upper bound of Unlimited. The “2” on the edge should be replaced with a “+”,
meaning 1 or more executions of the substep are expected.
Here is the code for StreamDischargeHandler:
Vue de la page 16
1 2 ... 12 13 14 15 16 17 18 19 20 21 22 23

Commentaires sur ces manuels

Pas de commentaire