Foren

ServiceBuilder: Re-entrant code passed to a service impl method

JF Rompre, geändert vor 12 Jahren.

ServiceBuilder: Re-entrant code passed to a service impl method

New Member Beiträge: 3 Beitrittsdatum: 07.01.11 Neueste Beiträge
Hello,

I am trying to do the following inside my LocalServcieImpl class: create a method which accepts amongst its arguments an interface type implemented outside of the service layer. The idea is that external code using a model object (e.g Item below) may need a transaction boundary around tasks which are unrelated to the service.

My question is: would the reentrant code be dead-locked trying to access the same item? I would think not since the external task is
within the same thread and already within the current transaction boundary... is this OK or counter-recommended for any reason?

Thanks for any comment.


//custom interface in top-level service pkg:

public Interface ReEntrantTask { 
	public void perform() throws Exception; 
}

//... inside LocalServiceImplClass

public void setSomeValue( long itemId, String someValue) throws Exception {
   //get Item obj.
   item.setSomeValue( someValue);
   myItemPersistence.update( item);
}

public void someServiceMethod( long someItemId, ReentrantTask task) throws Exception {
	//get Item obj.
	setSomeValue( item, "NonSense");
	task.perform();	//may invoke someMethodFromABunch below
	setSomeValue( item, "MakesSense");
}

public void someMethodFromABunch( long someItemId) {...}

//..