[
https://issues.apache.org/jira/browse/BEEHIVE-1215?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Anand Sridharan updated BEEHIVE-1215:
-------------------------------------
Attachment: ControlBean.java
Fix with discoveryclass.find in static block
> 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.