You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@servicemix.apache.org by "Torsten Mielke (JIRA)" <ji...@apache.org> on 2009/02/03 16:46:00 UTC

[jira] Created: (SM-1786) Refactor JmsProviderEndpoint to not use reflection to call protected method on Spring JmsTemplate class

Refactor JmsProviderEndpoint to not use reflection to call protected method on Spring JmsTemplate class
-------------------------------------------------------------------------------------------------------

                 Key: SM-1786
                 URL: https://issues.apache.org/activemq/browse/SM-1786
             Project: ServiceMix
          Issue Type: Improvement
          Components: servicemix-jms
    Affects Versions: servicemix-jms-2008.01
            Reporter: Torsten Mielke
            Priority: Minor


A recent fix changed JmsProviderEndpoint.java and calls the Spring JmsTemplate protected method doSend() directly via reflection. 
{code:java}
Method method = JmsTemplate.class.getDeclaredMethod("doSend", Session.class, Destination.class, MessageCreator.class);
method.setAccessible(true);
method.invoke(template, session, dest, new MessageCreator() {
  public Message createMessage(Session session) throws JMSException {
     return message;
  }
});
{code}

This new approach is based on java.lang.reflect and uses private methods of the JmsTemplate. Do the latest problem related to JmsProviderEndpoint really justify using private methods?
Please consider refactoring the code above.


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (SM-1786) Refactor JmsProviderEndpoint to not use reflection to call protected method on Spring JmsTemplate class

Posted by "Torsten Mielke (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/activemq/browse/SM-1786?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Torsten Mielke updated SM-1786:
-------------------------------

    Attachment: SM-1786.patch

Suggested patch that subclasses Springs JmsTemplate class. 

> Refactor JmsProviderEndpoint to not use reflection to call protected method on Spring JmsTemplate class
> -------------------------------------------------------------------------------------------------------
>
>                 Key: SM-1786
>                 URL: https://issues.apache.org/activemq/browse/SM-1786
>             Project: ServiceMix
>          Issue Type: Improvement
>          Components: servicemix-jms
>    Affects Versions: servicemix-jms-2008.01
>            Reporter: Torsten Mielke
>            Priority: Minor
>         Attachments: SM-1786.patch
>
>
> A recent fix changed JmsProviderEndpoint.java and calls the Spring JmsTemplate protected method doSend() directly via reflection. 
> {code:java}
> Method method = JmsTemplate.class.getDeclaredMethod("doSend", Session.class, Destination.class, MessageCreator.class);
> method.setAccessible(true);
> method.invoke(template, session, dest, new MessageCreator() {
>   public Message createMessage(Session session) throws JMSException {
>      return message;
>   }
> });
> {code}
> This new approach is based on java.lang.reflect and uses private methods of the JmsTemplate. Do the latest problem related to JmsProviderEndpoint really justify using private methods?
> Please consider refactoring the code above.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (SM-1786) Refactor JmsProviderEndpoint to not use reflection to call protected method on Spring JmsTemplate class

Posted by "Guillaume Nodet (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/activemq/browse/SM-1786?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Guillaume Nodet resolved SM-1786.
---------------------------------

       Resolution: Fixed
    Fix Version/s: 3.2.4
                   servicemix-jms-2008.02
         Assignee: Guillaume Nodet

Sending        src/main/java/org/apache/servicemix/jms/endpoints/JmsProviderEndpoint.java
Transmitting file data .
Committed revision 740741.

Sending        servicemix-jms/src/main/java/org/apache/servicemix/jms/endpoints/JmsProviderEndpoint.java
Transmitting file data .
Committed revision 740743.

> Refactor JmsProviderEndpoint to not use reflection to call protected method on Spring JmsTemplate class
> -------------------------------------------------------------------------------------------------------
>
>                 Key: SM-1786
>                 URL: https://issues.apache.org/activemq/browse/SM-1786
>             Project: ServiceMix
>          Issue Type: Improvement
>          Components: servicemix-jms
>    Affects Versions: servicemix-jms-2008.01
>            Reporter: Torsten Mielke
>            Assignee: Guillaume Nodet
>            Priority: Minor
>             Fix For: servicemix-jms-2008.02, 3.2.4
>
>         Attachments: SM-1786.patch
>
>
> A recent fix changed JmsProviderEndpoint.java and calls the Spring JmsTemplate protected method doSend() directly via reflection. 
> {code:java}
> Method method = JmsTemplate.class.getDeclaredMethod("doSend", Session.class, Destination.class, MessageCreator.class);
> method.setAccessible(true);
> method.invoke(template, session, dest, new MessageCreator() {
>   public Message createMessage(Session session) throws JMSException {
>      return message;
>   }
> });
> {code}
> This new approach is based on java.lang.reflect and uses private methods of the JmsTemplate. Do the latest problem related to JmsProviderEndpoint really justify using private methods?
> Please consider refactoring the code above.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (SM-1786) Refactor JmsProviderEndpoint to not use reflection to call protected method on Spring JmsTemplate class

Posted by "Freeman Fang (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/SM-1786?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=49112#action_49112 ] 

Freeman Fang commented on SM-1786:
----------------------------------

Hi Torsten,
It's intended to use the the reflection to avoid creating connection each time when invoke the public method from JmsTemplate.
Related discussion are in SM-1764 

Freeman

> Refactor JmsProviderEndpoint to not use reflection to call protected method on Spring JmsTemplate class
> -------------------------------------------------------------------------------------------------------
>
>                 Key: SM-1786
>                 URL: https://issues.apache.org/activemq/browse/SM-1786
>             Project: ServiceMix
>          Issue Type: Improvement
>          Components: servicemix-jms
>    Affects Versions: servicemix-jms-2008.01
>            Reporter: Torsten Mielke
>            Priority: Minor
>         Attachments: SM-1786.patch
>
>
> A recent fix changed JmsProviderEndpoint.java and calls the Spring JmsTemplate protected method doSend() directly via reflection. 
> {code:java}
> Method method = JmsTemplate.class.getDeclaredMethod("doSend", Session.class, Destination.class, MessageCreator.class);
> method.setAccessible(true);
> method.invoke(template, session, dest, new MessageCreator() {
>   public Message createMessage(Session session) throws JMSException {
>      return message;
>   }
> });
> {code}
> This new approach is based on java.lang.reflect and uses private methods of the JmsTemplate. Do the latest problem related to JmsProviderEndpoint really justify using private methods?
> Please consider refactoring the code above.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (SM-1786) Refactor JmsProviderEndpoint to not use reflection to call protected method on Spring JmsTemplate class

Posted by "Torsten Mielke (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/SM-1786?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=49117#action_49117 ] 

Torsten Mielke commented on SM-1786:
------------------------------------

Thanks Freeman,

I know reflection is currently used here in order to invoke the protected doSend() method on the Spring JmsTemplate class. This avoids recreating a new jms session. However I believe this code rather looks like a hack than a proper solution. It also supresses Java language access checking. Therefore I suggested another solution based on subclassing the Spring JmsTemplate class and invoke the doSend() method directly, not requiring reflection. This solution will still avoid creating a new jms session but use the existing session. No benefits are lost. A patch is attached. 
Btw, the idea of subclassing jms session was brought up by Guillaume Nodet when I discussed this issue with him. He did already agree to this solution.




> Refactor JmsProviderEndpoint to not use reflection to call protected method on Spring JmsTemplate class
> -------------------------------------------------------------------------------------------------------
>
>                 Key: SM-1786
>                 URL: https://issues.apache.org/activemq/browse/SM-1786
>             Project: ServiceMix
>          Issue Type: Improvement
>          Components: servicemix-jms
>    Affects Versions: servicemix-jms-2008.01
>            Reporter: Torsten Mielke
>            Priority: Minor
>         Attachments: SM-1786.patch
>
>
> A recent fix changed JmsProviderEndpoint.java and calls the Spring JmsTemplate protected method doSend() directly via reflection. 
> {code:java}
> Method method = JmsTemplate.class.getDeclaredMethod("doSend", Session.class, Destination.class, MessageCreator.class);
> method.setAccessible(true);
> method.invoke(template, session, dest, new MessageCreator() {
>   public Message createMessage(Session session) throws JMSException {
>      return message;
>   }
> });
> {code}
> This new approach is based on java.lang.reflect and uses private methods of the JmsTemplate. Do the latest problem related to JmsProviderEndpoint really justify using private methods?
> Please consider refactoring the code above.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.