You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@beehive.apache.org by "Tomasz Wysocki (JIRA)" <ji...@apache.org> on 2008/06/10 13:10:45 UTC
[jira] Updated: (BEEHIVE-1215)
ControlBean.lookupControlBeanContextFactory can be optimized
[ https://issues.apache.org/jira/browse/BEEHIVE-1215?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Tomasz Wysocki updated BEEHIVE-1215:
------------------------------------
Attachment: Controls.java
I have prepared a version which should deal with different classloaders that ControlFactory can be loaded from. Eliminates the problem of heavy classpath scanning.
> 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, Controls.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.