Here's what I ended up doing...
Since CacheLoader.setCache(TreeCache treeCache) interface method sends in the controlling treeCache instance, I use it to add any additional nodes that should be added to the cache as a result of the initial cache miss. ( When I call my external service to get data, it returns additional data nodes to add to the cache.) As long as I am careful to not use the treeCache to add the node for the original get's Fqn, it works ok. ( Doing that would stick me in a recursive loop. )
I was not sure if there was another intended approach such as a callback to the cache loader interceptor directly, for example.
That would be the best way to do it. It does sound a bit odd and kludgy though, although it is a pretty unusual request. :-)
There are no such callbacks in the cache loader interceptor.
Do you really think it is kludgy?
The problem arises out of the fact that my cache loader impl is calling an external service that returns more data than I wish to store in a single node.
I can put it in terms of the Student/ Course sample that comes with jboss-cache. ( The node names are overly simplified to make the point easier. ) :)
Assume I have an object node bound to a fqn called /teacher/Jones/ and that 'get' results in a cache miss that triggers a call to my custom cache loader. What should I do if my custom loader call returns 'extra' data. Let's say it returns a set of students in addition to the teacher object.
JBC works fine if I plan on stuffing the 'extra' data into the node's Map, but what if I want to bind that data? That would be reasonable in this case. I could see creating nodes for '/student/Brown' , '/student/Jones', etc...
In my case, I am calling existing legacy services that happen to return this extra data in this fashion. I would think this could happen often in practice.
Still, odd that this is triggered by trying to load /teacher/Jones. I would expect the student data to be loaded lazily when accessed separately.
Sorry for the late reply...
>I would expect the student data to be loaded lazily when accessed >separately.
But what if the remote service that fetches this data was written to return additional data for the single call ( in the example above, I was suggesting that it would return both teach and student data ).
In my application this is the case. My custom cache loader impl fetches calls an existing external service call that returns additional data that I wish to define elsewhere in the cache under a separate node. ( Essentially, I am given flattened data and am normalizing it in the cache under separate nodes )
I would not want to make a service call from the cache loader impl that gives me all this data and then discard the 'extra' data until another cache miss (on a differnet fqn/node) for the 'extra' data leads to another invocation of the same service call.