[ 
https://issues.apache.org/jira/browse/BEEHIVE-1215?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12560108#action_12560108
 ] 

Eddie O'Neil commented on BEEHIVE-1215:
---------------------------------------

Hi, Anand.  Interesting thing to be looking at -- something like this probably 
needs to be discussed on the dev@ list as the interactions between Controls and 
their context objects are quite complex and subtle, but it seems like this 
might be something to consider.  

For the attached ControlBean.java file, however, please re-attach this as an 
SVN diff file using the instructions for Beehive patch contribution here:

  
http://wiki.apache.org/beehive/For_Beehive_Developers#head-7d726c911217fd59a9f9266349336d96c67cf635

Thanks!

> ControlBean.lookupControlBeanContextFactory can be optimized
> ------------------------------------------------------------
>
>                 Key: BEEHIVE-1215
>                 URL: https://issues.apache.org/jira/browse/BEEHIVE-1215
>             Project: Beehive
>          Issue Type: Improvement
>          Components: Controls
>    Affects Versions: 1.0.2
>            Reporter: Anand Sridharan
>         Attachments: ControlBean.java
>
>
> In ControlBean.lookupControlBeanContextFactory, everytime ControlBeanContext 
> == null or context.getService(ControlBeanContextFactory.class, null) returns 
> null, discoverer.find(ControlBeanContextFactory.class, 
> DefaultControlBeanContextFactory.class.getName()) is called.
> discoverer.find is pretty costly & takes toll on performance when multiple 
> control instantiation happens at the same time under the given scenario.
> Moving discoverer.find to static block will make it run only once & hence 
> improve performance significantly.
> --------------------------->8-------------------------
>   abstract public class ControlBean
>     implements org.apache.beehive.controls.api.bean.ControlBean
> {
> static Class factoryClass;
> static DiscoverClass discoverer; 
>       static {
>                discoverer = new DiscoverClass();
>              factoryClass = discoverer.find(ControlBeanContextFactory.class, 
> DefaultControlBeanContextFactory.class.getName());
>       }
> .................
> .................
>   private ControlBeanContextFactory lookupControlBeanContextFactory
>         (org.apache.beehive.controls.api.context.ControlBeanContext context) {
>         // first, try to find the CBCFactory from the container
>         if(context != null) {
>             ControlBeanContextFactory cbcFactory = 
> context.getService(ControlBeanContextFactory.class, null);
>             if(cbcFactory != null) {
>                 return cbcFactory;
>             }
>         }
>         // Create the context that acts as the BeanContextProxy for this bean 
> (the context that this bean _defines_).
>         try
>         {
>             return (ControlBeanContextFactory)factoryClass.newInstance();
>         }
>         catch (Exception e) {
>             throw new ControlException("Exception creating 
> ControlBeanContext", e);
>         }
>     }
> ..................
> ....................
> ...................
> }
> ---------------------------8<----------------------------

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

Reply via email to