hivemind-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Howard Lewis Ship <hls...@gmail.com>
Subject Re: Service implementing multiple interfaces
Date Wed, 08 Sep 2004 16:34:49 GMT
Thanks for the bug and the fix (which needs to be applied in a couple
of different places). If you could add a JIRA bug, that would be
great!


On Wed, 08 Sep 2004 17:31:15 +0200, Strutynski, Oliver
<oliver.strutynski@sdm-research.de> wrote:
> For now I have worked around this by adding  some code to
> ProxyBuilder.addServiceMethods that avoids that methods are being added
> twice. Not sure if this is a good patch, as addServiceMethods should
> probably check, if these methods are really defined in different
> interfaces. But works for now. Code below.
> 
> This issue is related to issue 39
> (http://issues.apache.org/jira/browse/HIVEMIND-39). Here combining two
> interfaces into one was suggested as a way to write a service that has
> multiple interfaces, but the fact that two interfaces ARE ALLOWED to
> have similar methods was not taken into account.
> 
> My new ProxyBuilder.addServiceMethods():
> 
>     public void addServiceMethods(String indirection)
>     {
>         // use a local map to remember all method signatures
>         java.util.Map methodMap = new java.util.HashMap();
>         BodyBuilder builder = new BodyBuilder();
>         boolean toString = false;
> 
>         Method[] methods = _serviceInterface.getMethods();
>         for (int i = 0; i < methods.length; i++)
>         {
>             Method m = methods[i];
> 
>             builder.clear();
>             builder.begin();
>             builder.add("return ($r) ");
>             builder.add(indirection);
>             builder.add(".");
>             builder.add(m.getName());
>             builder.addln("($$);");
>             builder.end();
>             // only add new methods, ignore ones with signatures that
> have already been added to proxy.
>             if (!methodMap.containsKey(new MethodSignature(m))) {
>               methodMap.put(new MethodSignature(m), null);
>               _classFab.addMethod(Modifier.PUBLIC, new
> MethodSignature(m), builder.toString());
>             }
>             toString |= ClassFabUtils.isToString(m);
>         }
> 
>         if (!toString)
>             ClassFabUtils.addToStringMethod(
>                 _classFab,
>                 "<"
>                     + _type
>                     + " for "
>                     + _point.getExtensionPointId()
>                     + "("
>                     + _serviceInterface.getName()
>                     + ")>");
> 
> 
>     }
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: hivemind-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: hivemind-user-help@jakarta.apache.org
> 
> 



-- 
Howard M. Lewis Ship
Independent J2EE / Open-Source Java Consultant
Creator, Jakarta Tapestry
Creator, Jakarta HiveMind
http://howardlewisship.com

---------------------------------------------------------------------
To unsubscribe, e-mail: hivemind-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: hivemind-user-help@jakarta.apache.org


Mime
View raw message