We could simply use Object as the return value and then cast it to the type of the property.

The caller code could perform the test as follows:

if(invoker instanceof Configurable) {
boolean allowsPBR = ((Configurable) invoker).getProperty("AllowsPassByReference");
   if(allowsPBR) {
       // do something here
   }
}

Thanks,
Raymond

----- Original Message ----- From: "Simon Nash" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Monday, February 18, 2008 3:15 PM
Subject: Re: svn commit: r628163 - in /incubator/tuscany/java/sca: itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/ itest/interfaces/src/test/java/org/apache/tuscany/sca/itest/interfaces/ modules/binding-ejb/src/main/java/org/apache/tus


Raymond Feng wrote:
The Configurable interface can be optionally implemented by the Invoker implementation classes. To support multiple properties, the invoker can simply do this:

public class MyInvokerImpl implements Invoker, Configurable {
   ...
   <T> public T getProperty(String name) {
       if("AllowsPassByReference".equals(name) {
           return true;
       } else if("AnotherProperty".equals(name) {
           return "StringValue";
       } else {
           return null;
       }
   }
}

This way, the property set is kept at the invoker instances.

I didn't know that generics could do this, with multiple return
types from a single method.  (Seems like I need to go back to
Java school!)  What does the code invoking the magical getProperty()
method look like?

  Simon


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to