[jboss-user] [Installation, Configuration & DEPLOYMENT] - Re: 5.0.0.Beta4 startup performance problem

gcoleman do-not-reply at jboss.com
Thu Mar 27 09:50:11 EDT 2008


I can cut the startup time to about 5mins by changing org.jboss.ejb3.dependency.EjbLinkDemandMetaData with the following patch.

I stole some code from the ObjectName constructor. It's quick, dirty and not production quality but proves the point that relying on Exceptions for flow control is a bad idea.


  | Index: EjbLinkDemandMetaData.java
  | 
  | ===================================================================
  | 
  | --- EjbLinkDemandMetaData.java	(revision 71344)
  | 
  | +++ EjbLinkDemandMetaData.java	(working copy)
  | 
  | @@ -45,7 +45,7 @@
  | 
  |   * specified.
  |   *
  |   * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
  | - * @version $Revision: $
  | + * @version $Revision$
  |   */
  |  public class EjbLinkDemandMetaData extends JBossObject
  |     implements DemandMetaData, Serializable
  | @@ -129,9 +129,13 @@
  | 
  |        {
  |           for(ControllerContext context : controller.getContextsByState(ControllerState.INSTALLED))
  |           {
  | -            try
  | -            {
  | -               ObjectName otherName = new ObjectName(context.getName().toString());
  | +            
  | +			String otherNameStr = context.getName().toString();
  | + 			if (isValidName(otherNameStr))
  | +			{
  | +			   try
  | +               {
  | +               ObjectName otherName = new ObjectName(otherNameStr);
  |                 
  |                 if(demand.apply(otherName))
  |                 {
  | @@ -144,12 +148,63 @@
  | 
  |              catch (MalformedObjectNameException e)
  |              {
  |                 // ignore this context
  | +			   System.out.println("MalformedObjectNameException constructing ObjectName for " + context.getName().toString());
  |              }
  | +			}
  |           }
  |           setResolved(false);
  |           return isResolved();
  |        }
  | -      
  | +     
  | +      private boolean isValidName(String name) {
  | +
  | +		// The name cannot be null
  | +		if (name == null)
  | +		    return false;
  | +
  | +		if (name.startsWith("vfsfile:/"))
  | +			return false;
  | +
  | +		if (name.startsWith("java:comp/"))
  | +			return false;
  | +	
  | +		// Test if the name is empty
  | +		if (name.length() == 0) {
  | +            return true;
  | +        }
  | +
  | +        // initialize parsing of the string
  | +        char[] name_chars = name.toCharArray();
  | +        int len = name_chars.length;
  | +		// length at most
  | +		int index = 0;
  | +
  | +		domain_parsing:
  | +        while (index < len) {
  | +            switch (name_chars[index]) {
  | +                case ':' :
  | +                    break domain_parsing;
  | +                case '=' :
  | +                    int i = ++index;
  | +                    while ((i < len) && (name_chars[i++] != ':'))
  | +                    if (i == len)
  | +			return false;
  | +		    break;
  | +                case '\n' :
  | +                    return false;
  | +                case '*' :
  | +                case '?' :
  | +
  | +                default :
  | +                    index++;
  | +            }
  | +        }
  | +
  | +        // check for non-empty properties
  | +        return (index != len);
  | +      }
  | +
  | +
  |        @Override
  |        public void toString(JBossStringBuilder buffer)
  |        {
  | 

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4139281#4139281

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4139281



More information about the jboss-user mailing list