Here's how I implemented it (it's actually quite simple):

In Session.java:



 public ERXObjectStoreCoordinator defaultObjectStoreCoordinator() {

return defaultObjectStoreCoordinator;

}

 public void setDefaultObjectStoreCoordinator(ERXObjectStoreCoordinator
defaultObjectStoreCoordinator) {

if (this.defaultObjectStoreCoordinator != null &&
this.defaultObjectStoreCoordinator != defaultObjectStoreCoordinator) {

this.defaultObjectStoreCoordinator.dispose();

this.defaultObjectStoreCoordinator = null;

 System.gc();

}

 this.defaultObjectStoreCoordinator = defaultObjectStoreCoordinator;

}

     public static class OneConnectionPerSessionFactory extends
ERXEC.DefaultFactory {

        public OneConnectionPerSessionFactory() {

            super();

        }



        @Override

public EOEditingContext _newEditingContext() {

            return _newEditingContext(true);

        }



        @Override

public EOEditingContext _newEditingContext(boolean validationEnabled) {

            EOObjectStore os =
((Session)ERXSession.session()).defaultObjectStoreCoordinator();

            EOEditingContext ec = _newEditingContext(os, validationEnabled);


            return ec;

        }

    }


    @Override

public void terminate() {

    setDefaultObjectStoreCoordinator(null); //this will cause a logout from
the database



    super.terminate();

    }

In Application.java:


 public Application() {

ERXApplication.log.info("Welcome to " + name() + " !");


          ERXEC.setFactory(new Session.OneConnectionPerSessionFactory());

}

Basically, every where ERXEC.newEditingContext() is used it should use your
new factory. I can't remember where I got this from…probably Mike…because I
am not smart enough to figure this out (although I do get lucky every now
and then :D).  You should be able to use defaultEditingContext without
worry too…although I rarely use it.


-Lon
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to