[jbossseam-issues] [JBoss JIRA] Updated: (JBSEAM-3654) Reduce number of checks to see if Jbpm is installed in BusinessProcessContext

Michael Youngstrom (JIRA) jira-events at lists.jboss.org
Thu Oct 30 17:14:21 EDT 2008


     [ https://jira.jboss.org/jira/browse/JBSEAM-3654?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Michael Youngstrom updated JBSEAM-3654:
---------------------------------------

    Component/s: Core


> Reduce number of checks to see if Jbpm is installed in BusinessProcessContext
> -----------------------------------------------------------------------------
>
>                 Key: JBSEAM-3654
>                 URL: https://jira.jboss.org/jira/browse/JBSEAM-3654
>             Project: Seam
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 2.1.0.GA
>            Reporter: Michael Youngstrom
>            Assignee: Michael Youngstrom
>             Fix For: 2.1.1.CR1
>
>
> In my application profiling the SeamELResolver is an extremely hot spot.  Although checking to see if jbpm is installed would appear a rather efficient process when done thousands of times a request it can become harmful.  BusinessProcessContext.get is called every time an el expression is evaluated in a page.  Here is a simple and I believe safe patch that will help make BusinessProcessContext more efficient.  isJbpmInstalled() is only called once a request.
> Index: src/main/org/jboss/seam/contexts/Lifecycle.java
> ===================================================================
> --- src/main/org/jboss/seam/contexts/Lifecycle.java	(revision 9465)
> +++ src/main/org/jboss/seam/contexts/Lifecycle.java	(working copy)
> @@ -81,11 +81,11 @@
>     public static void beginCall()
>     {
>        log.debug( ">>> Begin call" );
> +      Contexts.applicationContext.set( new ApplicationContext(getApplication()) );
>        Contexts.eventContext.set( new BasicContext(ScopeType.EVENT) );
>        Contexts.sessionContext.set( new BasicContext(ScopeType.SESSION) );
>        Contexts.conversationContext.set( new BasicContext(ScopeType.CONVERSATION) );
>        Contexts.businessProcessContext.set( new BusinessProcessContext() );
> -      Contexts.applicationContext.set( new ApplicationContext(getApplication()) );
>     }
>  
>     public static void endCall()
> Index: src/main/org/jboss/seam/contexts/BusinessProcessContext.java
> ===================================================================
> --- src/main/org/jboss/seam/contexts/BusinessProcessContext.java	(revision 9465)
> +++ src/main/org/jboss/seam/contexts/BusinessProcessContext.java	(working copy)
> @@ -35,21 +35,26 @@
>  
>     private final Map<String, Object> additions = new HashMap<String, Object>();
>     private final Set<String> removals = new HashSet<String>();
> +   private final boolean enabled;
>  
>     public ScopeType getType()
>     {
>        return ScopeType.BUSINESS_PROCESS;
>     }
>  
> -   public BusinessProcessContext() {}
> +   public BusinessProcessContext() {
> +       enabled = Init.instance().isJbpmInstalled();
> +   }
>     
>     public Object get(String name) 
>     {
> -      
>        Object result = additions.get(name);
>        if (result!=null) return result;
>        if ( removals.contains(name) ) return null;
> -      
> +
> +      if(!enabled) {
> +          return null;
> +      }
>        org.jbpm.taskmgmt.exe.TaskInstance taskInstance = getTaskInstance();
>        if (taskInstance==null)
>        {
> Index: src/main/org/jboss/seam/contexts/TestLifecycle.java
> ===================================================================
> --- src/main/org/jboss/seam/contexts/TestLifecycle.java	(revision 9465)
> +++ src/main/org/jboss/seam/contexts/TestLifecycle.java	(working copy)
> @@ -29,11 +29,11 @@
>     public static void beginTest(ServletContext context, Map<String, Object> session)
>     {
>        log.debug( ">>> Begin test" );
> +      Contexts.applicationContext.set( new ApplicationContext( new ServletApplicationMap(context) ) );
>        Contexts.eventContext.set( new BasicContext(ScopeType.EVENT) );
>        Contexts.conversationContext.set( new BasicContext(ScopeType.CONVERSATION) );
>        Contexts.businessProcessContext.set( new BusinessProcessContext() );
>        Contexts.sessionContext.set( new SessionContext(session) );
> -      Contexts.applicationContext.set( new ApplicationContext( new ServletApplicationMap(context) ) );
>     }
>  
>     public static void endTest()

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the seam-issues mailing list