Issue 3320: Java language mapping: Tie classes for local interfaces. (java-rtf) Source: ICL (Mr. Chris Wood, ) Nature: Uncategorized Issue Severity: Summary: The new java mapping as specified in 99-10-10 for local classes generates a class which is subclassed much as previous implementations subclassed the POA class. ie: local interface Test { void call(); }; maps to: class Test extends org.omg.CORBA.portable.LocalImpl implements TestOperations {} then implementers subclass Test to get desired functionality. I believe there is a need for a tie class similar to the POATie class: class TestTie extends Test { public TestTie(TestOperations delegate) { _delegate = delegate; } private TestOperations _delegate; public void call() { _delegate.call(); } } Also the implementation for _hash is not correct : public int _hash(int max) { // return hashCode(); // incorrect, return value exceeds max. return hashCode() % (max+1); } Resolution: Incorporate revised text and close issue Revised Text: In section 1.20.2.7, add a new subsection at the end of the section titled: Ties for local interface implementations Ties for local interfaces are defined in a manner very similar to the normal POA-based Ties. The major difference is that no POA is present in the Tie, since local interfaces do not use the POA. Ties are useful for local interfaces for the same reason as they are for normal interfaces: java does not support multiple inheritance. For each local interface <interface_name> the mapping defines a Java local tie class as follows: //Java public class <interface_name>LocalTie extends LocalBase { private <interface_name>Operations _impl; public <interface_name>LocalTie ( <interface_name>Operations delegate ) { this._impl = delegate; } public <interface_name>Operations _delegate() { return this._impl; } public void _delegate (<interface_name>Operations delegate ) { this._impl = delegate; } // For each <method> defined in <interface_name>Operations // (the return statement is present for methods with non-void // <method_return_type>): public <method_return_type> <method>( <params> ) { [return] _impl.<method>( <param_names> ); } } Assume that we have the interface Alocal defined as follows: local interface A { short op1() ; void op2( in long val ) ; } ; Then the LocalTie class for ALocal is as follows: public class ALocalTie extends ALocalBase { public ALocalTie ( AOperations delegate ) { this._impl = delegate; } public AOperations _delegate() { return this._impl; } public void _delegate (AOperations delegate ) { this._impl = delegate; } public short op1 () { return _impl.op1(); } public void op2 (int val) { _impl.op2(val); } private AOperations _impl; } To implement a local interface using the Tie approach, a developer must write an implementation class, which implements the operations class associated with the interface they wish to implement. The developer then instantiates an instance of the implementation class and uses this instance in the constructor of the LocalTie class associated with the interface. The Tie class then provides an implementation of the local interface. Actions taken: February 16, 2000: received issue May 13, 2002: closed issue Discussion: . End of Annotations:===== From: Chris Wood To: "'issues@omg.org'" Subject: Java language mapping: Tie classes for local interfaces. Date: Wed, 16 Feb 2000 10:39:46 -0000 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2448.0) Content-Type: text/plain; charset="iso-8859-1" X-UIDL: dA-!!\@P!!*;Qe9iQ,!! The new java mapping as specified in 99-10-10 for local classes generates a class which is subclassed much as previous implementations subclassed the POA class. ie: local interface Test { void call(); }; maps to: class Test extends org.omg.CORBA.portable.LocalImpl implements TestOperations {} then implementers subclass Test to get desired functionality. I believe there is a need for a tie class similar to the POATie class: class TestTie extends Test { public TestTie(TestOperations delegate) { _delegate = delegate; } private TestOperations _delegate; public void call() { _delegate.call(); } } Also the implementation for _hash is not correct : public int _hash(int max) { // return hashCode(); // incorrect, return value exceeds max. return hashCode() % (max+1); } -- Chris Wood IT Innovation Centre 2 Venture Road Chilworth Science Park Southampton, SO16 7NP, UK tel: +44 23 8076 0834 fax: +44 23 8076 0833 mailto:cww@it-innovation.soton.ac.uk http://www.it-innovation.soton.ac.uk/ Date: Tue, 11 Dec 2001 23:07:14 -0800 (PST) From: Ken Cavanaugh Reply-To: Ken Cavanaugh Subject: Proposal for issue 3320 To: java-rtf@omg.org MIME-Version: 1.0 Content-MD5: QPVGChM2NnI3Ixv9oIL2WA== X-Mailer: dtmail 1.3.0 @(#)CDE Version 1.3.5 SunOS 5.7 sun4u sparc Content-Type: TEXT/plain; charset=us-ascii X-UIDL: \ the mapping defines a Java local tie class as follows: //Java public class LocalTie extends LocalBase { private Operations _impl; public LocalTie ( Operations delegate ) { this._impl = delegate; } public Operations _delegate() { return this._impl; } public void _delegate (Operations delegate ) { this._impl = delegate; } // For each method defined in // Operations // (the return statement is present for methods with return // values): public ( ) { [return] _impl.( ); } } Assume that we have the interface Alocal defined as follows: local interface A { short op1() ; void op2( in long val ) ; } ; Then the LocalTie class for ALocal is as follows: public class ALocalTie extends ALocalBase { public ALocalTie ( AOperations delegate ) { this._impl = delegate; } public AOperations _delegate() { return this._impl; } public void _delegate (AOperations delegate ) { this._impl = delegate; } public short op1 () { return _impl.op1(); } public void op2 (int val) { _impl.op2(val); } private AOperations _impl; } To implement a local interface using the Tie approach, a developer must write an implementation class, which implements the operations class associated with the interface they wish to implement. The developer then instantiates an instance of the implementation class and uses this instance in the constructor of the LocalTie class associated with the interface. The Tie class then provides an implementation of the local interface. Ken.