[
https://issues.apache.org/jira/browse/BEEHIVE-1215?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12560268#action_12560268
]
Sandeep Deshpande commented on BEEHIVE-1215:
--------------------------------------------
I am also facing the same issue and I also had suggested same fix. But the fix
will not work in the case of controls which is packaged in a separate jar
having a separate controlfactory class. In that case find method returns a
diffrent factoryClass, even though the parameter to 'find' method of discoverer
remains the same. You can check this out with beehive sample spring control
which has its own controlfactory class. The issue actually is in
URLClassLoader as it locks the jar. Once the jar is locked all the other
threads have to wait till the first thread releases the lock.
> 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.