You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@beehive.apache.org by "Anand Sridharan (JIRA)" <ji...@apache.org> on 2008/01/17 20:32:34 UTC
[jira] Created: (BEEHIVE-1215)
ControlBean.lookupControlBeanContextFactory can be optimized
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
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.
[jira] Updated: (BEEHIVE-1215)
ControlBean.lookupControlBeanContextFactory can be optimized
Posted by "Anand Sridharan (JIRA)" <ji...@apache.org>.
[ 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.
[jira] Updated: (BEEHIVE-1215)
ControlBean.lookupControlBeanContextFactory can be optimized
Posted by "Tomasz Wysocki (JIRA)" <ji...@apache.org>.
[ 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.
[jira] Commented: (BEEHIVE-1215)
ControlBean.lookupControlBeanContextFactory can be optimized
Posted by "Eddie O'Neil (JIRA)" <ji...@apache.org>.
[ 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.
[jira] Commented: (BEEHIVE-1215)
ControlBean.lookupControlBeanContextFactory can be optimized
Posted by "Sandeep Deshpande (JIRA)" <ji...@apache.org>.
[ 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.