[jboss-user] [JBossCache] - Re: PojoCacheListener fqn recovery

mc.coder do-not-reply at jboss.com
Thu Dec 13 18:13:01 EST 2007


Jason,

Thank you for your reply and sorry for the very late response.  I have been (and still am :)) swamped.

I appreciate your adding this as a feature request.  I have voted for it (hope others will too) and am watching it eagerly.

A couple of comments:

I tried the solution you proposed, and it does do what I want to an extent.  Here is the test scenario.

I have one object nested within another, and a method on the enclosing object modifies the enclosed object (field) value.  I modeled this as follows:

@Replicable
  | protected class integer implements Serializable {
  | 	private static final long serialVersionUID = 811409324986665055L;
  | 	private int i;
  | 	public integer(int i) {
  | 		this.i = new Integer(i);
  | 	}
  | 	public integer add(int addend) {
  | 		return new integer(this.i += addend);
  | 	}
  | 	public String toString() {
  | 		return i + ": integer";
  | 	}
  | }
  | 
  | @Replicable
  | protected class IntegerWrapper implements Serializable {
  | 	private static final long serialVersionUID = -6675820439881914329L;
  | 	private integer value;
  | 	public IntegerWrapper(int i) {
  | 		value = new integer(i);
  | 	}
  | 	public void makeChange() {
  | 		value.add(57);
  | 	}
  | 	public String toString() {
  | 		return value + " wrapper";
  | 	}
  | }

I interpreted your suggested solution as the following:

private void showRealFQNFor(Event e) {
  | 	BaseInterceptor interceptor = (BaseInterceptor) AopUtil.findCacheInterceptor(((Advised) e.getSource())._getInstanceAdvisor());
  | 	Fqn internalFqn = interceptor.getFqn();
  | 	PojoInstance pojoInstance = interceptor.getAopInstance();
  | 	List<Fqn> fqns = pojoInstance.getReferences();	
  | 	System.out.println(fqns);
  | }

First, I instantiate and add the enclosing object (IntegerWrapper) to a cache and I get the following attach notifications:

Node attached: org.jboss.cache.pojo.notification.event.AttachedEvent[source=0: integer]
  | [/__JBossInternal__/root/child/0/_ID_/4l4o6a2l-99frc3-fa5q02ws-1-fa5q02ws-2]
  | Node attached: org.jboss.cache.pojo.notification.event.AttachedEvent[source=0: integer wrapper]
  | [/root/child/0]

Note that the fqn returned for the enclosing object is the internal representation (not useful for me) and the fqn of the enclosed object is the external representation of the enclosing object (this is what I need).  I can achieve what I need for this event type even though I would have expected the fqn returned for the enclosing object to be the external representation.

Second, I call the method on the enclosing object (IntegerWrapper.makeChange) to modify the enclosed object and I get the following:

Field modified: org.jboss.cache.pojo.notification.event.FieldModifiedEvent[source=57: integer]
  | [/__JBossInternal__/root/child/0/_ID_/4l4o6a2l-99frc3-fa5q02ws-1-fa5q02ws-2]

When I call the makeChange method on the enclosing object is the event generated has the enclosed object as it's source (which is fine) and the fqn returned is the external fqn of the enclosing object which does not allow me to retrieve the enclosing object (which does not give me what I need).

1) Have I interpreted your instructions incorrectly in my showRealFQNFor() method?  I may well have since I don't think it matches up exactly with you description, but I didn't see a more obvious way using the 2.0.0.GA API.

2) If I did interpret your reply correctly, is there another way for me to solve my issue I have with the FieldModifiedEvent type?

3) To clarify what I think would be useful in relation to the feature request, it would be useful to retrieve the user created (external) fqn representation of the object added to the cache whenever any event type notification comes in for any objects enclosed within the object which was added to the cache.

Thanks, and sorry if this is long.  Just wanted to include all the information.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4112752#4112752

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4112752



More information about the jboss-user mailing list