[otj-users] Callin methods

Carsten Pfeiffer carsten.pfeiffer at alumni.tu-berlin.de
Mon Feb 4 12:54:36 CET 2008


Am Montag, 4. Februar 2008 schrieben Sie:

> Yes, I'd like to call a role method directly. Shouldn't that be possible
> whenever the context (i.e. the team instance) is given, e.g.
>
> MyTeam t = new MyTeam();
> within(t) {
>   baseObject.roleMethod();
> }
>
> I assume that there is a role type having a method m that is a played by
> the class of baseObject.

Just to add to what Marco already said:

"within(t)" does not really give a context to the method call. It only 
activates the given team instance for the time of the method call. There 
might be other teams which are also active, and may also have a role bound to 
the base object.

For the above to work, all bound roles would have to have a roleMethod(), 
which doesn't really make sense.

But if you already have access to the team instance (i.e. the desired 
context), would it help if you did the following:

MyTeam t = new MyTeam();
t.doTheRoleMethod(baseObject);

And the implementation:

team class MyTeam {
	public void doTheRoleMethod(MyBase as MyRole roleObject) {
		roleObject.roleMethod();
	}
}

Cheers,
Carsten
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 447 bytes
Desc: This is a digitally signed message part.
Url : http://collegium-musicum.tu-berlin.de/pipermail/otj-users/attachments/20080204/80acd0a3/attachment.pgp


More information about the otj-users mailing list