Skip to Content.
Sympa Menu

grouper-dev - progress on web services and transactions

Subject: Grouper Developers Forum

List archive

progress on web services and transactions


Chronological Thread 
  • From: Chris Hyzer <>
  • To: Grouper Dev <>
  • Subject: progress on web services and transactions
  • Date: Wed, 20 Feb 2008 03:51:40 -0500
  • Accept-language: en-US
  • Acceptlanguage: en-US

Hey,

 

Quick update:

 

WEB SERVICES:

All the non-Lite web services (SOAP and XML/HTTP/RPC) have been finished with the first pass.  I will be revisiting them to make sure they are complete.  If you want to:

 

1.       Check them out to see if your use cases will fit what the services/inputs/outputs support

2.       Let me know if you want to me an early adopter… you can start using them sometime soon.  They will change in small ways fyi, the longer you wait the more stable.  Let me know your schedule

 

https://wiki.internet2.edu/confluence/display/GrouperWG/Grouper+-+Web+Services

 

You can see examples there, and also you can see what the beans look like in javadoc here (the beans translate into what the XML will be):

 

http://viewvc.internet2.edu/viewvc.py/grouper-ws/grouper-ws/doc/api/edu/internet2/middleware/grouper/webservices/GrouperService.html?root=I2MI&view=co&pathrev=HEAD

 

TRANSACTIONS:

 

The definition here is being able to do multiple calls to the Grouper API in one unit of work (and will commit or rollback as a whole unit).  Also you can nest autonomous inner transactions if you like (seems rare).

 

This is done and committed and the unit tests work.  There are three important things to note:

 

1.       There was a lot of tedious work which shouldn’t affect anything

2.       There was a little bit of high impact work to how hibernate works with Grouper which could have effects, but hopefully not

3.       I think all hib3 DB work and transactional code should all be inverse of control with no other option (the way the threadLocals work, if someone forgets to close a Session or Transaction, it would be very bad and confusing to figure out).  Anyone who needs help working with inverse of control, let me know anytime.  I can keep adding examples to the wiki also

 

(transaction stuff at bottom)

https://wiki.internet2.edu/confluence/display/GrouperWG/Hibernate+and+data+layer+updates

 

Here is the high impact hibernate change list:

a.       Since the Session (from Hibernate) can only deal with one object by key at a time, each time an object is retrieved from hibernate it must be "evicted" from the session.  The ByObjectStatic and ByHqlStatic helper methods will do this, and if "Query.list()" for example is called outside of the helpers, then the results must be evicted.  The side effect is that no hibernate dirty checking will be available.  This is no problem since that is more pain than it is worth

b.      If a transaction type is a NEW transaction type, then at the end of the HibernateSesssion callback, it will be committed or rolled back (and Session object is discarded, and state is synced with the DB).  However, if it is a "USE_EXISTING" transaction type, then at the end of the HibernateSession, the Session (from Hibernate) will start bulking up.  So HibernateSession will flush() (write all queries to the wire), and clear() (take all objects in the Session out).  This will make the transactions work

 

Here is an example of inverse of control with transactions that shows how to pass data in and out of the anonymous inner class.  If something fails in the second saveGroup(), then the first and second one will completely rollback.  In this case I put the logic in a separate method (since the nesting of exception handling can make it confusing), but typically you might have it all inline).

 

  /**

   * run multiple logic together

   * @param grouperSession

   * @param groupName

   * @param groupName2

   * @param displayExtension

   * @param groupDescription

   */

  public void runLogic(GrouperSession grouperSession, String groupName,

      String groupName2, String displayExtension, String groupDescription) {

    try {

 

      //insert a group

      Group.saveGroup(grouperSession, groupDescription, displayExtension, groupName,

          null, SaveMode.INSERT, false);

 

      //insert another group

      Group.saveGroup(grouperSession, groupDescription, displayExtension, groupName2,

          null, SaveMode.INSERT, false);

    } catch (StemNotFoundException e) {

      throw new RuntimeException("Stem wasnt found", e);

    } catch (Exception e) {

      throw new RuntimeException(e);

    }

 

  }

 

  /**

   * show simple transaction

   * @throws Exception if problem

   */

  public void testTransaction() {

   

    final GrouperSession rootSession = SessionHelper.getRootSession();

    final String displayExtension = "testing123 display";

    final String groupDescription = "description";

    final String groupName = "i2:a:testing123";

    final String groupName2 = "i2:b:testing124";

 

    try {

      R.populateRegistry(2, 2, 0);

 

      GrouperTest.deleteGroupIfExists(rootSession, groupName);

      GrouperTest.deleteGroupIfExists(rootSession, groupName2);

    } catch (Exception e) {

      throw new RuntimeException(e);

    }

    //demonstrate passing back data with final array

    final Integer[] someInt = new Integer[1];

 

    //you can pass back one object from return

    String anythingString = (String) GrouperTransaction

        .callbackGrouperTransaction(new GrouperTransactionHandler() {

 

          public Object callback(GrouperTransaction grouperTransaction)

              throws GrouperDAOException {

           

            //everything in here will run in one transaction, note how to access "this"

            TestGroup0.this.runLogic(rootSession, groupName, groupName2,

                displayExtension, groupDescription);

           

            //pass data back from final array (if need more than just return value)

            someInt[0] = 5;

 

            //if return with no exception, then it will auto-commit.

            //if exception was thrown it will rollback

            //this can be controlled manually with grouperTransaction.commit()

            //but it would be rare to have to do that

           

            //pass data back from return value

            return "anything";

          }

 

        });

 

    System.out.println(anythingString + ", " + someInt[0]);

  }

 

Kind regards,

Chris




Archive powered by MHonArc 2.6.16.

Top of Page