• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Per Session model connection and EOCooperatingObjectStore
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Per Session model connection and EOCooperatingObjectStore


  • Subject: Re: Per Session model connection and EOCooperatingObjectStore
  • From: Chuck Hill <email@hidden>
  • Date: Tue, 3 Mar 2009 08:24:53 -0800


On Mar 3, 2009, at 8:02 AM, Laurence Mills-Gahl wrote:

I am going around in circles with a per-session eomodel connection and I am looking for advice.

I have two models. One with data common to all application sessions and one with data that should be used for connecting to a database determined by data in the common model. This is the same as the setup in EOEditingContext docs "Getting Data from Multiple Sources". The difference is that one of the models is a per-session connection model

That is a very, very large difference.


and the other is (or at least can be) consistently connected to a single database.

That is not how EOF works.


The problem that I am running into is in changing the connection of the session specific model and running into adaptorChannel problems. I feel like I'm facing the wrong direction in looking for an answer because the usual answer to my questions about webobjects is that someone has figured this out before and it is much more straight forward than I can see at the moment.

Should I be looking to remove the EOCooperatingObjectStore related to the dynamic model, create a new one, add it to the EOObjectStoreCoordinator for the session editing context? Does anybody have any advice or examples or docs that might help with this?

You will need to create a new EOModelGroup, load the dynamic model into it, modify the dynamic model, and create a new EOF stack using the model group for each session. If you are doing this, the EOF default*() methods are to be avoided. I'd really try and find another way to do this.



Chuck



Here is the problematic connection method on Session:

	public void setDatabaseConnection(String dbname) {
		// Get the model and adaptor
		EOModel model = EOModelGroup.defaultGroup().modelNamed(
				Application.VAEMR_MODELNAME);

		EODatabaseContext dc = EODatabaseContext
				.registeredDatabaseContextForModel(model,
						EOObjectStoreCoordinator.defaultCoordinator());
		EOAdaptor adaptor = dc.adaptorContext().adaptor();
		if (adaptor.hasOpenChannels()) {
			log.debug("has adaptor channels");
			NSArray<EOAdaptorContext> ctxs = adaptor.contexts();
			log.debug(ctxs.count() + " contexts");
			for (int i = 0; i < ctxs.count(); i++) {
				EOAdaptorContext ctx = (EOAdaptorContext) ctxs.get(i);
				NSArray chans = ctx.channels();
				log.debug(chans.count() + " channels in this context");
				for (int j = 0; j < chans.count(); j++) {
					EOAdaptorChannel chan = (EOAdaptorChannel) chans.get(i);
					chan.closeChannel();
				}
			}
		}

NSDictionary<String,Object> prevConnDict = adaptor.connectionDictionary();
emrConnectionDict = new NSMutableDictionary<String, Object>(adaptor
.connectionDictionary());
Object[] args = { dbname };
emrConnectionDict.takeValueForKey(String.format(url, args), "URL");


		try {
			adaptor.setConnectionDictionary(emrConnectionDict);
			adaptor.assertConnectionDictionaryIsValid();

		} catch (Throwable exception) {
			exception.printStackTrace();
			log.error(exception.toString());
			log.error("reverting to previous connectionk dictionary");
			log.error(prevConnDict);
			adaptor.setConnectionDictionary(prevConnDict);
		}

		EOModel common = EOModelGroup.defaultGroup().modelNamed(
				Application.VACOMMON_MODELNAME);
		EODatabaseContext dccommon = EODatabaseContext
				.registeredDatabaseContextForModel(common, this
						.defaultEditingContext());
		EOAdaptor adaptorCommon = dccommon.adaptorContext().adaptor();
		System.out.println("common connection");
		System.out.println(adaptorCommon.connectionDictionary());
		System.out.println("emr connection");
		System.out.println(adaptor.connectionDictionary());
		log.debug(emrConnectionDict);
	}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden

-- Chuck Hill Senior Consultant / VP Development

Practical WebObjects - for developers who want to increase their overall knowledge of WebObjects or who are trying to solve specific problems.
http://www.global-village.net/products/practical_webobjects







_______________________________________________ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: Per Session model connection and EOCooperatingObjectStore
      • From: Larry Mills-Gahl <email@hidden>
References: 
 >Per Session model connection and EOCooperatingObjectStore (From: Laurence Mills-Gahl <email@hidden>)

  • Prev by Date: Per Session model connection and EOCooperatingObjectStore
  • Next by Date: Re: Per Session model connection and EOCooperatingObjectStore
  • Previous by thread: Per Session model connection and EOCooperatingObjectStore
  • Next by thread: Re: Per Session model connection and EOCooperatingObjectStore
  • Index(es):
    • Date
    • Thread