/** * participant recovery modules may need to perform special processing when the a recovery scan * has completed. in particular it is only after the first recovery scan has completed they can * identify whether locally prepared changes are accompanied by a recreated participant and roll * back changes for those with no such participant. */ public void endScan() { if (isFirst) { // let the restaurant and theatre state manager know that the BA log records have all been // scanned RestaurantManager.getSingletonInstance().recoveryScanCompleted(TX_TYPE_BA); isFirst = false; } }
/** * called during recovery processing to allow an application to identify a participant id * belonging to one of its participants and recreate the participant by deserializing it from the * supplied object input stream. n.b. this is only appropriate in case the original was a * ParticipantCompletion participant saved using serialization. * * @param id the id used when the participant was created * @param stream a stream from which the application should deserialise the participant if it * recognises that the id belongs to the module's application * @return the deserialized ParticipantCompletion participant if the id identifies a restaurant * participant otherwise null * @throws Exception if an error occurs deserializing the ParticipantCompletion participant */ public BusinessAgreementWithParticipantCompletionParticipant deserializeParticipantCompletionParticipant(String id, ObjectInputStream stream) throws Exception { if (id.startsWith("org.jboss.jbossts.xts-demo:restaurantBA")) { System.out.println("xts-demo : attempting to deserialize RestaurantParticipantBA " + id); RestaurantParticipantBA participant = (RestaurantParticipantBA) stream.readObject(); // ensure that the participant has completed any changes to local service state. System.out.println("xts-demo : deserialized RestaurantParticipantBA " + id); if (RestaurantManager.getSingletonInstance().recovered(participant.getTxID(), TX_TYPE_BA)) { participant.confirmCompleted(true); } return participant; } else if (id.startsWith("org.jboss.jbossts.xts-demo:theatreBA") || id.startsWith("org.jboss.jbossts.xts-demo:taxiBA")) { // this should not get called -- xts-demo WS-BA theatre and taxi participants employ the // CoordinatorCompletion protocol throw new Exception( "xts-demo : invalid request to deserialize as WS-BA ParticipantCompletion participant " + id); } return null; }