You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@servicemix.apache.org by Eduardo Burgos <eb...@gmail.com> on 2007/05/25 19:45:34 UTC

servicemix-bean, BeanInfo, how to set operations

Hi, I've been looking at servicemix-bean and I noticed this in
org.apache.servicemix.bean.support.BeanInfo line 103 in the following method
"protected void introspect(Class clazz, Method method)"

I'm quoting lines 121-130

121-       // now lets add the method to the repository
             String opName = method.getName();
             if (method.getAnnotation(Operation.class) != null) {
                  String name = method.getAnnotation(Operation.class).name();

                  if (name != null && name.length() > 0) {
                      opName = name;
                  }
              }
              Expression parametersExpression =
createMethodParametersExpression(parameterExpressions);
130-        operations.put(opName, new MethodInfo(clazz, method,
parametersExpression));



According to this, every method of my bean is an operation whose name is
defined at least by the method's name. Is this intended? I thought that only
the methods that had the Operation attribute would be listed as operations.
For example, I have a "setSessionTimeout" method that I wouldn't want it to
be an operation :).

Any ideas?


Eduardo Burgos

Re: servicemix-bean, BeanInfo, how to set operations

Posted by Eduardo Burgos <eb...@gmail.com>.
Implementing MessageExchangeListener will lose the beauty of servicemix-bean
:(, but I understand you may be out of time and stuff, so I will just do
that.



On 5/25/07, Guillaume Nodet <gn...@gmail.com> wrote:
>
> Why not implementing MessageExhcangeListener ?
> I know it does not solve the operation problem, but it is the
> easiest work around at the moment.
>
> On 5/25/07, Eduardo Burgos <eb...@gmail.com> wrote:
> >
> > Ok, that's exactly my point. Now look at this, same class, lines 68-76
> >
> > public void introspect() {
> >         introspect(getType());
> >         if (operations.size() == 1) {
> >             Collection<MethodInfo> methodInfos = operations.values();
> >             for (MethodInfo methodInfo : methodInfos) {
> >                 defaultExpression = methodInfo;
> >             }
> >         }
> >     }
> >
> >
> > According to this, only if operations.size() == 1 I will get a
> > defaultExpression, this involves that my bean has one and only one
> method.
> > This restricts a lot when it comes to receiving a message with a null
> > operation, my bean can't have more than one method. Can we fix this
> > somehow?
> > maybe having the first Operation() attribute with no name to be the
> > default
> > one?
> >
> > To be more concrete, I'm trying to receive a message from a Quartz
> > endpoint
> > and I get no oportunity to specify an operation name, not even with a
> > Marshaler.
> >
> > This way, having a defaultOperation is almost impossible.
> >
> > Any Comments?
> >
> >
> > Eduardo Burgos
> >
> > On 5/25/07, Guillaume Nodet <gn...@gmail.com> wrote:
> > >
> > > Yeah.  It sounds like there is no way to hide
> > > methods, so all public methods are exposed as operations :-(
> > >
> > > On 5/25/07, Eduardo Burgos <eb...@gmail.com> wrote:
> > > >
> > > > Hi, I've been looking at servicemix-bean and I noticed this in
> > > > org.apache.servicemix.bean.support.BeanInfo line 103 in the
> following
> > > > method
> > > > "protected void introspect(Class clazz, Method method)"
> > > >
> > > > I'm quoting lines 121-130
> > > >
> > > > 121-       // now lets add the method to the repository
> > > >              String opName = method.getName();
> > > >              if (method.getAnnotation(Operation.class) != null) {
> > > >                   String name = method.getAnnotation(Operation.class
> > > > ).name();
> > > >
> > > >                   if (name != null && name.length() > 0) {
> > > >                       opName = name;
> > > >                   }
> > > >               }
> > > >               Expression parametersExpression =
> > > > createMethodParametersExpression(parameterExpressions);
> > > > 130-        operations.put(opName, new MethodInfo(clazz, method,
> > > > parametersExpression));
> > > >
> > > >
> > > >
> > > > According to this, every method of my bean is an operation whose
> name
> > is
> > > > defined at least by the method's name. Is this intended? I thought
> > that
> > > > only
> > > > the methods that had the Operation attribute would be listed as
> > > > operations.
> > > > For example, I have a "setSessionTimeout" method that I wouldn't
> want
> > it
> > > > to
> > > > be an operation :).
> > > >
> > > > Any ideas?
> > > >
> > > >
> > > > Eduardo Burgos
> > > >
> > >
> > >
> > >
> > > --
> > > Cheers,
> > > Guillaume Nodet
> > > ------------------------
> > > Principal Engineer, IONA
> > > Blog: http://gnodet.blogspot.com/
> > >
> >
>
>
>
> --
> Cheers,
> Guillaume Nodet
> ------------------------
> Principal Engineer, IONA
> Blog: http://gnodet.blogspot.com/
>

Re: servicemix-bean, BeanInfo, how to set operations

Posted by Guillaume Nodet <gn...@gmail.com>.
Why not implementing MessageExhcangeListener ?
I know it does not solve the operation problem, but it is the
easiest work around at the moment.

On 5/25/07, Eduardo Burgos <eb...@gmail.com> wrote:
>
> Ok, that's exactly my point. Now look at this, same class, lines 68-76
>
> public void introspect() {
>         introspect(getType());
>         if (operations.size() == 1) {
>             Collection<MethodInfo> methodInfos = operations.values();
>             for (MethodInfo methodInfo : methodInfos) {
>                 defaultExpression = methodInfo;
>             }
>         }
>     }
>
>
> According to this, only if operations.size() == 1 I will get a
> defaultExpression, this involves that my bean has one and only one method.
> This restricts a lot when it comes to receiving a message with a null
> operation, my bean can't have more than one method. Can we fix this
> somehow?
> maybe having the first Operation() attribute with no name to be the
> default
> one?
>
> To be more concrete, I'm trying to receive a message from a Quartz
> endpoint
> and I get no oportunity to specify an operation name, not even with a
> Marshaler.
>
> This way, having a defaultOperation is almost impossible.
>
> Any Comments?
>
>
> Eduardo Burgos
>
> On 5/25/07, Guillaume Nodet <gn...@gmail.com> wrote:
> >
> > Yeah.  It sounds like there is no way to hide
> > methods, so all public methods are exposed as operations :-(
> >
> > On 5/25/07, Eduardo Burgos <eb...@gmail.com> wrote:
> > >
> > > Hi, I've been looking at servicemix-bean and I noticed this in
> > > org.apache.servicemix.bean.support.BeanInfo line 103 in the following
> > > method
> > > "protected void introspect(Class clazz, Method method)"
> > >
> > > I'm quoting lines 121-130
> > >
> > > 121-       // now lets add the method to the repository
> > >              String opName = method.getName();
> > >              if (method.getAnnotation(Operation.class) != null) {
> > >                   String name = method.getAnnotation(Operation.class
> > > ).name();
> > >
> > >                   if (name != null && name.length() > 0) {
> > >                       opName = name;
> > >                   }
> > >               }
> > >               Expression parametersExpression =
> > > createMethodParametersExpression(parameterExpressions);
> > > 130-        operations.put(opName, new MethodInfo(clazz, method,
> > > parametersExpression));
> > >
> > >
> > >
> > > According to this, every method of my bean is an operation whose name
> is
> > > defined at least by the method's name. Is this intended? I thought
> that
> > > only
> > > the methods that had the Operation attribute would be listed as
> > > operations.
> > > For example, I have a "setSessionTimeout" method that I wouldn't want
> it
> > > to
> > > be an operation :).
> > >
> > > Any ideas?
> > >
> > >
> > > Eduardo Burgos
> > >
> >
> >
> >
> > --
> > Cheers,
> > Guillaume Nodet
> > ------------------------
> > Principal Engineer, IONA
> > Blog: http://gnodet.blogspot.com/
> >
>



-- 
Cheers,
Guillaume Nodet
------------------------
Principal Engineer, IONA
Blog: http://gnodet.blogspot.com/

Re: servicemix-bean, BeanInfo, how to set operations

Posted by Eduardo Burgos <eb...@gmail.com>.
Ok, that's exactly my point. Now look at this, same class, lines 68-76

public void introspect() {
        introspect(getType());
        if (operations.size() == 1) {
            Collection<MethodInfo> methodInfos = operations.values();
            for (MethodInfo methodInfo : methodInfos) {
                defaultExpression = methodInfo;
            }
        }
    }


According to this, only if operations.size() == 1 I will get a
defaultExpression, this involves that my bean has one and only one method.
This restricts a lot when it comes to receiving a message with a null
operation, my bean can't have more than one method. Can we fix this somehow?
maybe having the first Operation() attribute with no name to be the default
one?

To be more concrete, I'm trying to receive a message from a Quartz endpoint
and I get no oportunity to specify an operation name, not even with a
Marshaler.

This way, having a defaultOperation is almost impossible.

Any Comments?


Eduardo Burgos

On 5/25/07, Guillaume Nodet <gn...@gmail.com> wrote:
>
> Yeah.  It sounds like there is no way to hide
> methods, so all public methods are exposed as operations :-(
>
> On 5/25/07, Eduardo Burgos <eb...@gmail.com> wrote:
> >
> > Hi, I've been looking at servicemix-bean and I noticed this in
> > org.apache.servicemix.bean.support.BeanInfo line 103 in the following
> > method
> > "protected void introspect(Class clazz, Method method)"
> >
> > I'm quoting lines 121-130
> >
> > 121-       // now lets add the method to the repository
> >              String opName = method.getName();
> >              if (method.getAnnotation(Operation.class) != null) {
> >                   String name = method.getAnnotation(Operation.class
> > ).name();
> >
> >                   if (name != null && name.length() > 0) {
> >                       opName = name;
> >                   }
> >               }
> >               Expression parametersExpression =
> > createMethodParametersExpression(parameterExpressions);
> > 130-        operations.put(opName, new MethodInfo(clazz, method,
> > parametersExpression));
> >
> >
> >
> > According to this, every method of my bean is an operation whose name is
> > defined at least by the method's name. Is this intended? I thought that
> > only
> > the methods that had the Operation attribute would be listed as
> > operations.
> > For example, I have a "setSessionTimeout" method that I wouldn't want it
> > to
> > be an operation :).
> >
> > Any ideas?
> >
> >
> > Eduardo Burgos
> >
>
>
>
> --
> Cheers,
> Guillaume Nodet
> ------------------------
> Principal Engineer, IONA
> Blog: http://gnodet.blogspot.com/
>

Re: servicemix-bean, BeanInfo, how to set operations

Posted by Guillaume Nodet <gn...@gmail.com>.
Yeah.  It sounds like there is no way to hide
methods, so all public methods are exposed as operations :-(

On 5/25/07, Eduardo Burgos <eb...@gmail.com> wrote:
>
> Hi, I've been looking at servicemix-bean and I noticed this in
> org.apache.servicemix.bean.support.BeanInfo line 103 in the following
> method
> "protected void introspect(Class clazz, Method method)"
>
> I'm quoting lines 121-130
>
> 121-       // now lets add the method to the repository
>              String opName = method.getName();
>              if (method.getAnnotation(Operation.class) != null) {
>                   String name = method.getAnnotation(Operation.class
> ).name();
>
>                   if (name != null && name.length() > 0) {
>                       opName = name;
>                   }
>               }
>               Expression parametersExpression =
> createMethodParametersExpression(parameterExpressions);
> 130-        operations.put(opName, new MethodInfo(clazz, method,
> parametersExpression));
>
>
>
> According to this, every method of my bean is an operation whose name is
> defined at least by the method's name. Is this intended? I thought that
> only
> the methods that had the Operation attribute would be listed as
> operations.
> For example, I have a "setSessionTimeout" method that I wouldn't want it
> to
> be an operation :).
>
> Any ideas?
>
>
> Eduardo Burgos
>



-- 
Cheers,
Guillaume Nodet
------------------------
Principal Engineer, IONA
Blog: http://gnodet.blogspot.com/