Published Business Service Boundary for Auto Commit
The startPublishedMethod, finishPublishedMethod, and close methods within the published business service are used to create the auto commit connection and to clean up the connections. All activities that occur within the startPublishedMethod and finishPublishedMethod calls are committed or rolled back immediately because no transaction boundary exists that encompasses more than one operation, including the table updates within the business function. For an auto commit connection, the purpose of finishPublishedMethod is different than for a manual commit because no need exists to commit the transaction. The finishPublishedMethod plays a roll in monitoring and tying the entire business process together. You call the close method to clean up all connections.
For both manual commit and auto commit, you should use a try block to enclose startPublishedMethod and finishPublishedMethod. You call the close method from a finally block to ensure that all transactions are finished and no connections linger.
This code sample shows the structure for defining the transaction processing boundary for the published business service:
public ConfirmAddAddressBook addAddressBook(AddAddressBook vo) throws BusinessServiceException { return (addAddressBook(null, null, vo)); } protected ConfirmAddAddressBook addAddressBook(IContext context, IConnection connection, AddAddressBook vo) throws BusinessServiceException{ //perform all work within try block, finally will clean up any //connections try { // call start published method, passing null, //will return context object so BSFN can be called later //used to indicate transaction boundary as well as used for //logging //Start Implicit Transaction context = startPublishedMethod(context, "addAddressBook"); // create a new internal VO. InternalAddAddressBook internalVO= new InternalAddAddress Book(); messages.addMessages(vo.mapFromPublsihed(context, internal VO));// // start business service addAddressBook passing context and // internal VO published business service Calling business // service E1MessageList messages = AddressBookProcessor.addAddressBook (context, connection, internalVO); // published business service will send either warnings in // the Confirm Value Object or throw a published business // serviceException. if (messages.hasErrors()) { // get the string representation of all the messages //RI: Error Handling String error = messages.getMessagesAsString()); // Throw BusinessServiceException.( throw new BusinessServiceException(error,context); } // exception was not thrown, so create the confirm VO from // internal VO ConfirmAddAddressBook confirmVO = new ConfirmAddAddressBook (internalVO); confirmVO.setE1MessageList(messages); //Call to commit default transaction. finishPublishedMethod(context, "addAddressBook"); // return confirm VO, filled with return values and messages return confirmVO; } finally { //Call close to clean up all remaining connections and //resources. close(context,"addAddressBook"); } }