User: dimc    
  Date: 02/04/04 05:48:13

  Modified:    core/src/xdoclet/ejb/tags HomeTagsHandler.java
  Log:
  Fix for bug 523372 - ant property variables were not being dereferenced.
  
  Also changes that I believe are due to <pretty />
  
  Revision  Changes    Path
  1.28      +723 -635  xdoclet/core/src/xdoclet/ejb/tags/HomeTagsHandler.java
  
  Index: HomeTagsHandler.java
  ===================================================================
  RCS file: /cvsroot/xdoclet/xdoclet/core/src/xdoclet/ejb/tags/HomeTagsHandler.java,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -w -r1.27 -r1.28
  --- HomeTagsHandler.java      4 Apr 2002 12:56:07 -0000       1.27
  +++ HomeTagsHandler.java      4 Apr 2002 13:48:12 -0000       1.28
  @@ -27,9 +27,10 @@
   /**
    * @author Ara Abrahamian ([EMAIL PROTECTED])
    * @created Oct 15, 2001
  - * @version $Revision: 1.27 $
  + * @version   $Revision: 1.28 $
    */
  -public class HomeTagsHandler extends EjbTagsHandler {
  +public class HomeTagsHandler extends EjbTagsHandler
  +{
        /**
         * @todo-javadoc Describe the field
         */
  @@ -39,6 +40,383 @@
         */
        private String currentExceptions;
   
  +     /**
  +      * Similar to {@link InterfaceTagsHandler#getComponentInterface}. Relies on the
  +      * ejb:home tag, which has the following relevant properties:
  +      * <ul>
  +      *   <li> remote-class: The fully qualified name of the remote class -
  +      *   overrides all set patterns
  +      *   <li> local-class: The fully qualified name of the local class - overrides
  +      *   all set patterns
  +      *   <li> remote-pattern: The pattern to be used to determine the unqualified
  +      *   name of the remote class
  +      *   <li> local-pattern: The pattern to be used to determine the unqualified
  +      *   name of the local class
  +      *   <li> pattern: The pattern to be used in determining the unqualified remote
  +      *   and/or local home interface name - used where remote- or local- pattern
  +      *   are not specified.
  +      *   <li> remote-package: The package the remote home interface is to be placed
  +      *   in
  +      *   <li> local-package: The package the local home interface is to be placed
  +      *   in
  +      *   <li> package: The package the remote and/or local home interface is to be
  +      *   placed in - used where remote- or local- package are not specified.
  +      * </ul>
  +      *
  +      *
  +      * @param type                  The type of home interface - can be remote or
  +      *      local.
  +      * @param clazz                 Description of Parameter
  +      * @return                      The HomeInterface value
  +      * @exception XDocletException  Description of Exception
  +      */
  +     public static String getHomeInterface( String type, XClass clazz ) throws 
XDocletException
  +     {
  +             Category cat = Log.getCategory( HomeTagsHandler.class, 
"getHomeInterface" );
  +
  +             // validate type
  +             if( !"remote".equals( type ) && !"local".equals( type ) )
  +             {
  +                     throw new XDocletException( Translator.getString( 
"xdoclet.ejb.Messages",
  +                             "method_only_takes_remote_or_local", new 
String[]{"getHomeInterface", type} ) );
  +             }
  +
  +             String fileName = clazz.containingPackage().name();
  +             String name_pattern = null;
  +             String package_pattern = null;
  +             String home_interface = null;
  +
  +             home_interface = clazz.doc().tagAttributeValue( "ejb:home", type + 
"-class" );
  +             if( cat.isDebugEnabled() )
  +             {
  +                     cat.debug( type + " home Interface for " + 
clazz.qualifiedName() + " = " + home_interface );
  +             }
  +
  +             if( home_interface != null )
  +             {
  +                     return home_interface;
  +             }
  +
  +             name_pattern = clazz.doc().tagAttributeValue( "ejb:home", type + 
"-pattern" );
  +             if( name_pattern == null )
  +             {
  +                     name_pattern = clazz.doc().tagAttributeValue( "ejb:home", 
"pattern" );
  +                     if( name_pattern == null )
  +                     {
  +                             name_pattern = "remote".equals( type ) ? 
getHomeClassPattern() : getLocalHomeClassPattern();
  +                     }
  +             }
  +
  +             package_pattern = clazz.doc().tagAttributeValue( "ejb:home", type + 
"-package" );
  +             if( package_pattern == null )
  +             {
  +                     package_pattern = clazz.doc().tagAttributeValue( "ejb:home", 
"package" );
  +             }
  +
  +             String ejb_name = null;
  +
  +             if( name_pattern.indexOf( "{0}" ) != -1 )
  +             {
  +                     ejb_name = MessageFormat.format( name_pattern, new 
Object[]{getShortEjbNameFor( clazz )} );
  +             }
  +             else
  +             {
  +                     ejb_name = name_pattern;
  +             }
  +
  +             String subtask_name = null;
  +
  +             if( type.equals( "remote" ) )
  +             {
  +                     subtask_name = HomeInterfaceSubTask.SUBTASK_NAME;
  +             }
  +             else
  +             {
  +                     subtask_name = LocalHomeInterfaceSubTask.SUBTASK_NAME;
  +             }
  +
  +             // Fix package name
  +             fileName = choosePackage( fileName, package_pattern, subtask_name );
  +             fileName += "." + ejb_name;
  +
  +             return fileName;
  +     }
  +
  +     /**
  +      * Returns true if method is an ejbRemove method, false otherwise.
  +      *
  +      * @param method                Description of Parameter
  +      * @return                      The RemoveMethod value
  +      * @exception XDocletException  Description of Exception
  +      */
  +     public static boolean isRemoveMethod( XMethod method ) throws XDocletException
  +     {
  +             return method.name().equals( "ejbRemove" );
  +     }
  +
  +     /**
  +      * Returns true if method is a create method marked with a ejb:create-method
  +      * tag, false otherwise.
  +      *
  +      * @param method                Description of Parameter
  +      * @return                      The CreateMethod value
  +      * @exception XDocletException  Description of Exception
  +      */
  +     public static boolean isCreateMethod( XMethod method ) throws XDocletException
  +     {
  +             return method.doc().hasTag( "ejb:create-method" );
  +     }
  +
  +     /**
  +      * Returns true if method is a home method marked with a ejb:home-method tag,
  +      * false otherwise.
  +      *
  +      * @param method                Description of Parameter
  +      * @return                      The HomeMethod value
  +      * @exception XDocletException  Description of Exception
  +      */
  +     public static boolean isHomeMethod( XMethod method ) throws XDocletException
  +     {
  +             return method.doc().hasTag( "ejb:home-method" );
  +     }
  +
  +     /**
  +      * Gets the CompNameFor attribute of the HomeTagsHandler class
  +      *
  +      * @param clazz                 Describe what the parameter does
  +      * @param type                  Describe what the parameter does
  +      * @return                      The CompNameFor value
  +      * @exception XDocletException  Describe the exception
  +      * @todo-javadoc                Write javadocs for method parameter
  +      * @todo-javadoc                Write javadocs for method parameter
  +      * @todo-javadoc                Write javadocs for exception
  +      */
  +     public static String getCompNameFor( XClass clazz, String type ) throws 
XDocletException
  +     {
  +             String compName = getEjbNameFor( clazz ).replace( '.', '/' );
  +
  +             if( type.equals( "local" ) && isLocalEjb( clazz ) && isRemoteEjb( 
clazz ) )
  +             {
  +                     compName = compName + LOCAL_SUFFIX;
  +             }
  +
  +             return compName;
  +     }
  +
  +     /**
  +      * Returns true if method is an ejbFind method, false otherwise.
  +      *
  +      * @param method                Description of Parameter
  +      * @return                      The FinderMethod value
  +      * @exception XDocletException  Description of Exception
  +      */
  +     public static boolean isFinderMethod( XMethod method ) throws XDocletException
  +     {
  +             return method.name().startsWith( "ejbFind" );
  +     }
  +
  +     /**
  +      * Gets the HomeDefinition attribute of the HomeTagsHandler class
  +      *
  +      * @param clazz                 Describe what the parameter does
  +      * @param method                Describe what the parameter does
  +      * @param tagType               Describe what the parameter does
  +      * @param type                  Describe what the parameter does
  +      * @return                      The HomeDefinition value
  +      * @exception XDocletException  Describe the exception
  +      * @todo-javadoc                Write javadocs for method parameter
  +      * @todo-javadoc                Write javadocs for method parameter
  +      * @todo-javadoc                Write javadocs for method parameter
  +      * @todo-javadoc                Write javadocs for method parameter
  +      * @todo-javadoc                Write javadocs for exception
  +      */
  +     public static String getHomeDefinition( XClass clazz, XMethod method, String 
tagType, String type )
  +              throws XDocletException
  +     {
  +             String methodName = method.name().substring( 3 );
  +             StringBuffer homeMethodName = new StringBuffer();
  +
  +             if( tagType.equals( "ejb:finder" ) )
  +             {
  +                     homeMethodName.append( method.returnType() );
  +             }
  +             else if( tagType.equals( "ejb:create-method" ) )
  +             {
  +                     homeMethodName.append( 
InterfaceTagsHandler.getComponentInterface( type, clazz ) );
  +             }
  +             homeMethodName.append( " " );
  +             homeMethodName.append( methodName.substring( 0, 1 ).toLowerCase() );
  +             homeMethodName.append( methodName.substring( 1 ) );
  +             homeMethodName.append( "(" );
  +
  +             StringTokenizer st = new StringTokenizer( 
method.signature().substring( 1, method.signature().length() - 1 ), "," );
  +             int k = 1;
  +
  +             while( st.hasMoreTokens() )
  +             {
  +                     homeMethodName.append( st.nextToken() ).append( " " ).append( 
"param" ).append( k++ );
  +                     if( st.hasMoreTokens() )
  +                     {
  +                             homeMethodName.append( " , " );
  +                     }
  +             }
  +             homeMethodName.append( ")" );
  +             return fullPackageChange( homeMethodName.toString() );
  +     }
  +
  +     /**
  +      * Converts ejbHome<em>blabla</em> to home<em>blabla</em> , the one that should
  +      * appear in home interface.
  +      *
  +      * @param methodName            Description of Parameter
  +      * @return                      Description of the Returned Value
  +      * @exception XDocletException  Description of Exception
  +      */
  +     public static String toHomeMethod( String methodName ) throws XDocletException
  +     {
  +             // Remove "ejbHome" prefix and lower case first char in rest: 
"ejbHomeFoo"->"foo"
  +             return Character.toLowerCase( methodName.charAt( 7 ) ) + 
methodName.substring( 8 );
  +     }
  +
  +     /**
  +      * Converts ejbCreate<em>blabla</em> to create<em>blabla</em> , the one that
  +      * should appear in home interface.
  +      *
  +      * @param methodName            Description of Parameter
  +      * @return                      Description of the Returned Value
  +      * @exception XDocletException  Description of Exception
  +      */
  +     public static String toCreateMethod( String methodName ) throws 
XDocletException
  +     {
  +             if( methodName.length() > 9 )
  +             {
  +                     // Remove "ejbCreate" prefix and lower case first char in 
rest: "ejbCreateFoo"->"createFoo", EJB 2 only
  +                     return "create" + Character.toUpperCase( methodName.charAt( 9 
) ) + methodName.substring( 10 );
  +             }
  +             else
  +             {
  +                     return "create";
  +             }
  +     }
  +
  +     /**
  +      * Describe what the method does
  +      *
  +      * @param clazz                 Describe what the parameter does
  +      * @return                      Describe the return value
  +      * @exception XDocletException  Describe the exception
  +      * @todo-javadoc                Write javadocs for method
  +      * @todo-javadoc                Write javadocs for method parameter
  +      * @todo-javadoc                Write javadocs for return value
  +      * @todo-javadoc                Write javadocs for exception
  +      */
  +     public static XMethod findFirstCreateMethodFor( XClass clazz ) throws 
XDocletException
  +     {
  +             XMethod[] methods = clazz.methods();
  +
  +             do
  +             {
  +                     for( int i = 0; i < methods.length; i++ )
  +                     {
  +                             XMethod method = methods[i];
  +
  +                             if( HomeTagsHandler.isCreateMethod( method ) )
  +                             {
  +                                     return method;
  +                             }
  +                     }
  +
  +                     clazz = clazz.superclass();
  +             }while ( clazz != null );
  +
  +             return null;
  +     }
  +
  +     /**
  +      * Converts ejbFind<em>blabla</em> to find<em>blabla</em> , the one that should
  +      * appear in home interface.
  +      *
  +      * @param methodName            Description of Parameter
  +      * @return                      Description of the Returned Value
  +      * @exception XDocletException  Description of Exception
  +      */
  +     public static String toFinderMethod( String methodName ) throws 
XDocletException
  +     {
  +             // Remove "ejb" prefix and lower case first char in rest: 
"ejbFindByPrimaryKey"->"findByPrimaryKey"
  +             return Character.toLowerCase( methodName.charAt( 3 ) ) + 
methodName.substring( 4 );
  +     }
  +
  +     /**
  +      * Describe what the method does
  +      *
  +      * @param s        Describe what the parameter does
  +      * @return         Describe the return value
  +      * @todo-javadoc   Write javadocs for method
  +      * @todo-javadoc   Write javadocs for method parameter
  +      * @todo-javadoc   Write javadocs for return value
  +      */
  +     public static String fullPackageChange( String s )
  +     {
  +             StringTokenizer st = new StringTokenizer( s, " " );
  +             String sign = st.nextToken();
  +             StringBuffer ret = new StringBuffer();
  +
  +             if( sign.equals( "Collection" ) )
  +             {
  +                     ret.append( "java.util.Collection" );
  +             }
  +             else if( sign.equals( "Enumeration" ) )
  +             {
  +                     ret.append( "java.util.Enumeration" );
  +             }
  +             else
  +             {
  +                     ret.append( sign );
  +             }
  +             while( st.hasMoreTokens() )
  +             {
  +                     ret.append( " " ).append( st.nextToken() );
  +             }
  +             return ret.toString();
  +     }
  +
  +     /**
  +      * Gets the LocalHomeClassPattern attribute of the HomeTagsHandler class
  +      *
  +      * @return   The LocalHomeClassPattern value
  +      */
  +     protected static String getLocalHomeClassPattern()
  +     {
  +             LocalHomeInterfaceSubTask localhomeintf_subtask = ( ( 
LocalHomeInterfaceSubTask ) DocletContext.getInstance().getSubTaskBy( 
LocalHomeInterfaceSubTask.SUBTASK_NAME ) );
  +
  +             if( localhomeintf_subtask != null )
  +             {
  +                     return localhomeintf_subtask.getLocalHomeClassPattern();
  +             }
  +             else
  +             {
  +                     return 
LocalHomeInterfaceSubTask.DEFAULT_LOCALHOMEINTERFACE_CLASS_PATTERN;
  +             }
  +     }
  +
  +     /**
  +      * Gets the HomeClassPattern attribute of the HomeTagsHandler class
  +      *
  +      * @return   The HomeClassPattern value
  +      */
  +     protected static String getHomeClassPattern()
  +     {
  +             HomeInterfaceSubTask homeintf_subtask = ( ( HomeInterfaceSubTask ) 
DocletContext.getInstance().getSubTaskBy( HomeInterfaceSubTask.SUBTASK_NAME ) );
  +
  +             if( homeintf_subtask != null )
  +             {
  +                     return homeintf_subtask.getHomeClassPattern();
  +             }
  +             else
  +             {
  +                     return 
HomeInterfaceSubTask.DEFAULT_HOMEINTERFACE_CLASS_PATTERN;
  +             }
  +     }
   
        /**
         * Returns the full qualified local or remote home interface name for the bean,
  @@ -48,10 +426,12 @@
         * @return Description of the Returned Value
         * @exception XDocletException Description of Exception
         * @doc:tag type="content"
  -      * @doc:param name="type" optional="false" values="remote,local"
  -      *      description="Specifies the type of component home interface."
  +      * @doc:param                   name="type" optional="false"
  +      *      values="remote,local" description="Specifies the type of component home
  +      *      interface."
         */
  -     public String homeInterface(Properties attributes) throws XDocletException {
  +     public String homeInterface( Properties attributes ) throws XDocletException
  +     {
                String type = attributes.getProperty("type");
   
                type = type != null ? type : "remote";
  @@ -59,30 +439,32 @@
                return getHomeInterface(type, getCurrentClass());
        }
   
  -
        /**
         * Evaluates the body block if current method is a create method. Create
         * methods should have ejb:create-method defined.
         *
  -      * @todo I commented somehting strange but surely needed
         * @param template The body of the block tag
         * @param attributes The attributes of the template tag
         * @exception XDocletException Description of Exception
  +      * @todo                        I commented somehting strange but surely needed
         * @see #isCreateMethod(xjavadoc.XMethod)
         * @doc:tag type="block"
  -      * @doc:param name="superclasses" optional="true" description="Traverse
  -      *      superclasses too. With false value used in remote/local home interface
  -      *      templates. Default is False."
  +      * @doc:param                   name="superclasses" optional="true"
  +      *      description="Traverse superclasses too. With false value used in
  +      *      remote/local home interface templates. Default is False."
         */
  -     public void ifIsCreateMethod(String template, Properties attributes) throws 
XDocletException {
  +     public void ifIsCreateMethod( String template, Properties attributes ) throws 
XDocletException
  +     {
                String superclasses_str = attributes.getProperty("superclasses");
                boolean superclasses = 
TypeConversionUtil.stringToBoolean(superclasses_str, true);
   
  -             if (isCreateMethod(getCurrentMethod())) {
  +             if( isCreateMethod( getCurrentMethod() ) )
  +             {
                        boolean currentMethodDoesntBelongToCurrentClass = 
!getCurrentMethod().containingClass().equals(getCurrentClass());
                        boolean shouldTraverse = 
shouldTraverseSuperclassForDependentClass(getCurrentMethod().containingClass(), 
"ejb:home");
   
  -                     if (superclasses == false && 
currentMethodDoesntBelongToCurrentClass == true && shouldTraverse == false) {
  +                     if( superclasses == false && 
currentMethodDoesntBelongToCurrentClass == true && shouldTraverse == false )
  +                     {
                                return;
                        }
   
  @@ -90,7 +472,6 @@
                }
        }
   
  -
        /**
         * Evaluates the body block if current method is a home method. Home methods
         * should have ejb:home-method defined.
  @@ -100,16 +481,19 @@
         * @exception XDocletException Description of Exception
         * @see #isHomeMethod(xjavadoc.XMethod)
         * @doc:tag type="block"
  -      * @doc:param name="superclasses" optional="true" description="Traverse
  -      *      superclasses too. With false value used in remote/local home interface
  -      *      templates. Default is False."
  +      * @doc:param                   name="superclasses" optional="true"
  +      *      description="Traverse superclasses too. With false value used in
  +      *      remote/local home interface templates. Default is False."
         */
  -     public void ifIsHomeMethod(String template, Properties attributes) throws 
XDocletException {
  +     public void ifIsHomeMethod( String template, Properties attributes ) throws 
XDocletException
  +     {
                String superclasses_str = attributes.getProperty("superclasses");
                boolean superclasses = 
TypeConversionUtil.stringToBoolean(superclasses_str, true);
   
  -             if (isHomeMethod(getCurrentMethod())) {
  -                     if (superclasses == false && 
getCurrentMethod().containingClass() != getCurrentClass() && 
shouldTraverseSuperclassForDependentClass(getCurrentMethod().containingClass(), 
"ejb:home") == false) {
  +             if( isHomeMethod( getCurrentMethod() ) )
  +             {
  +                     if( superclasses == false && 
getCurrentMethod().containingClass() != getCurrentClass() && 
shouldTraverseSuperclassForDependentClass( getCurrentMethod().containingClass(), 
"ejb:home" ) == false )
  +                     {
                                return;
                        }
   
  @@ -117,7 +501,6 @@
                }
        }
   
  -
        /**
         * Evaluates the body block if current method is ejbRemove method.
         *
  @@ -126,13 +509,14 @@
         * @see #isRemoveMethod(xjavadoc.XMethod)
         * @doc:tag type="block"
         */
  -     public void ifNotRemoveMethod(String template) throws XDocletException {
  -             if (!isRemoveMethod(getCurrentMethod())) {
  +     public void ifNotRemoveMethod( String template ) throws XDocletException
  +     {
  +             if( !isRemoveMethod( getCurrentMethod() ) )
  +             {
                        generate(template);
                }
        }
   
  -
   //   /**
   //    * Evaluates the body block if current method is a ejbFind method.
   //    *
  @@ -164,14 +548,15 @@
         * @return Description of the Returned Value
         * @exception XDocletException Description of Exception
         * @doc:tag type="content"
  -      * @doc:param name="prefixWithEjbSlash" optional="true" values="true,false"
  -      *      description="Specifies whether to prefix it with ejb/ or not. False by
  -      *      default."
  -      * @doc:param name="type" optional="false" values="remote,local"
  -      *      description="Specifies if we want the jndi name value for local or
  -      *      remote lookup."
  +      * @doc:param                   name="prefixWithEjbSlash" optional="true"
  +      *      values="true,false" description="Specifies whether to prefix it with
  +      *      ejb/ or not. False by default."
  +      * @doc:param                   name="type" optional="false"
  +      *      values="remote,local" description="Specifies if we want the jndi name
  +      *      value for local or remote lookup."
         */
  -     public String compName(Properties attributes) throws XDocletException {
  +     public String compName( Properties attributes ) throws XDocletException
  +     {
                String prefix_with_ejbslash_str = 
attributes.getProperty("prefixWithEjbSlash");
                boolean prefix_with_ejbslash = 
TypeConversionUtil.stringToBoolean(prefix_with_ejbslash_str, false);
                String type = attributes.getProperty("type");
  @@ -180,37 +565,41 @@
   
                String compName;
   
  -             if (prefix_with_ejbslash == true) {
  +             if( prefix_with_ejbslash == true )
  +             {
                        compName = prefixWithEjbSlash(ejb_name);
                }
  -             else {
  +             else
  +             {
                        compName = ejb_name;
                }
   
                return compName;
        }
   
  -
        /**
         * @param attributes
         * @return Description of the Returned Value
         * @exception XDocletException Description of Exception
         * @doc:tag type="content"
  -      * @doc:param name="type" optional="false" values="remote,local"
  -      *      description="Specifies if we want the jndi name value for local or
  -      *      remote lookup."
  +      * @doc:param                   name="type" optional="false"
  +      *      values="remote,local" description="Specifies if we want the jndi name
  +      *      value for local or remote lookup."
         */
  -     public String jndiName(Properties attributes) throws XDocletException {
  +     public String jndiName( Properties attributes ) throws XDocletException
  +     {
                String type = attributes.getProperty("type");
                XTag bean_tag = getCurrentClass().doc().tag("ejb:bean");
                String compName = getCompNameFor(getCurrentClass(), type);
   
  -             if (bean_tag != null) {
  -                     String jndiName = bean_tag.attributeValue("jndi-name");
  -                     String localJndiName = 
bean_tag.attributeValue("local-jndi-name");
  +             if( bean_tag != null )
  +             {
  +                     String jndiName = dereferenceProperties( 
bean_tag.attributeValue( "jndi-name" ) );
  +                     String localJndiName = dereferenceProperties( 
bean_tag.attributeValue( "local-jndi-name" ) );
   
                        //Return "local" jndi name
  -                     if ("local".equals(type)) {
  +                     if( "local".equals( type ) )
  +                     {
                                return localJndiName != null ? localJndiName : 
compName;
                        }
   
  @@ -222,7 +611,6 @@
                return compName;
        }
   
  -
        /**
         * Returns the name of the class home interface extends.
         *
  @@ -231,7 +619,8 @@
         * @exception XDocletException Description of Exception
         * @doc:tag type="content"
         */
  -     public String extendsFrom(Properties attributes) throws XDocletException {
  +     public String extendsFrom( Properties attributes ) throws XDocletException
  +     {
                String type = attributes.getProperty("type");
   
                type = type != null ? type : "remote";
  @@ -242,30 +631,33 @@
                return extendsFromFor(getCurrentClass(), "ejb:home", type, 
extends_param_name, def_base_class_name);
        }
   
  -
        /**
         * Iterates over all finder methods defined in a class and super classes
         *
  -      * @todo skip EJBException as we do in home.j for home-methods
         * @param template The body of the block tag
         * @param attributes The attributes of the template tag
         * @exception XDocletException Description of Exception
  +      * @todo                        skip EJBException as we do in home.j for
  +      *      home-methods
         * @doc:tag type="block"
  -      * @doc:param name="tagName" optional="false" description="The tag name."
  -      * @doc:param name="superclasses" values="true,false" description="If true then
  -      *      traverse superclasses also, otherwise look up the tag in current
  -      *      concrete class only."
  -      * @doc:param name="tagKey" description="A tag property that will be used as a
  -      *      unique key. This is used to avoid duplicate code due to similar tags in
  -      *      superclasses."
  +      * @doc:param                   name="tagName" optional="false"
  +      *      description="The tag name."
  +      * @doc:param                   name="superclasses" values="true,false"
  +      *      description="If true then traverse superclasses also, otherwise look up
  +      *      the tag in current concrete class only."
  +      * @doc:param                   name="tagKey" description="A tag property that
  +      *      will be used as a unique key. This is used to avoid duplicate code due
  +      *      to similar tags in superclasses."
         */
  -     public void forAllHomeMethods(String template, Properties attributes) throws 
XDocletException {
  +     public void forAllHomeMethods( String template, Properties attributes ) throws 
XDocletException
  +     {
                Category cat = Log.getCategory(HomeTagsHandler.class, "forAllFinders");
                boolean superclasses = 
TypeConversionUtil.stringToBoolean(attributes.getProperty("superclasses"), false);
                String type = attributes.getProperty("type");
                String tagType = attributes.getProperty("tagName");
   
  -             if (type == null) {
  +             if( type == null )
  +             {
                        throw new XDocletException("Attribute 'type' is mandatory for 
'forAllFinders'");
                }
   
  @@ -274,31 +666,39 @@
                // Exclude definition coming from super classes
                XClass currentClass = getCurrentClass().superclass();
   
  -             while (currentClass != null) {
  -                     if (cat.isDebugEnabled()) {
  +             while( currentClass != null )
  +             {
  +                     if( cat.isDebugEnabled() )
  +                     {
                                cat.debug("Looking for super definition in " + 
currentClass.name());
                        }
   
                        // 1. METHOD tags
                        XMethod[] methods = currentClass.methods();
   
  -                     for (int i = 0; i < methods.length; i++) {
  +                     for( int i = 0; i < methods.length; i++ )
  +                     {
                                XMethod method = methods[i];
   
  -                             if (tagType.equals("ejb:finder")) {
  -                                     if (!isFinderMethod(method)) {
  +                             if( tagType.equals( "ejb:finder" ) )
  +                             {
  +                                     if( !isFinderMethod( method ) )
  +                                     {
                                                continue;
                                        }
                                }
  -                             else if (tagType.equals("ejb:create-method")) {
  -                                     if (!isCreateMethod(method)) {
  +                             else if( tagType.equals( "ejb:create-method" ) )
  +                             {
  +                                     if( !isCreateMethod( method ) )
  +                                     {
                                                continue;
                                        }
                                }
   
                                String signature = getHomeDefinition(currentClass, 
method, tagType, type);
   
  -                             if (cat.isDebugEnabled()) {
  +                             if( cat.isDebugEnabled() )
  +                             {
                                        cat.debug("Found " + signature);
                                }
                                already.add(signature);
  @@ -307,12 +707,15 @@
                        // 2. CLASS tags
                        XTag[] superTags = currentClass.doc().tags(tagType, true);
   
  -                     for (int i = 0; i < superTags.length; i++) {
  +                     for( int i = 0; i < superTags.length; i++ )
  +                     {
                                String signature = 
fullPackageChange(superTags[i].attributeValue("signature"));
                                String typeMapping = 
superTags[i].attributeValue("result-type-mapping");
   
  -                             if (typeMapping == null || 
typeMapping.equalsIgnoreCase(type)) {
  -                                     if (cat.isDebugEnabled()) {
  +                             if( typeMapping == null || 
typeMapping.equalsIgnoreCase( type ) )
  +                             {
  +                                     if( cat.isDebugEnabled() )
  +                                     {
                                                cat.debug("Found " + signature);
                                        }
                                        already.add(signature);
  @@ -324,77 +727,96 @@
                // 1. Handle METHOD Tag level ejb:finder
                XMethod[] methods = getCurrentClass().methods();
   
  -             for (int i = 0; i < methods.length; i++) {
  +             for( int i = 0; i < methods.length; i++ )
  +             {
                        XMethod method = methods[i];
                        String signature = null;
   
  -                     if (tagType.equals("ejb:finder")) {
  -                             if (!isFinderMethod(method)) {
  +                     if( tagType.equals( "ejb:finder" ) )
  +                     {
  +                             if( !isFinderMethod( method ) )
  +                             {
                                        continue;
                                }
                                signature = getHomeDefinition(getCurrentClass(), 
method, tagType, type);
   
  -                             if (!already.add(signature)) {
  +                             if( !already.add( signature ) )
  +                             {
                                        continue;
                                }
   
  -                             if (cat.isDebugEnabled()) {
  +                             if( cat.isDebugEnabled() )
  +                             {
                                        cat.debug("Finder Method = " + signature);
                                }
                        }
  -                     else if (tagType.equals("ejb:create-method")) {
  -                             if (!isCreateMethod(method)) {
  +                     else if( tagType.equals( "ejb:create-method" ) )
  +                     {
  +                             if( !isCreateMethod( method ) )
  +                             {
                                        continue;
                                }
   
                                String viewType = null;
                                XTag[] tags = method.doc().tags(tagType, superclasses);
   
  -                             for (int k = 0; k < tags.length; k++) {
  +                             for( int k = 0; k < tags.length; k++ )
  +                             {
                                        String attr = 
tags[k].attributeValue("view-type");
   
  -                                     if (attr != null) {
  +                                     if( attr != null )
  +                                     {
                                                viewType = attr;
                                        }
                                }
   
  -                             if (viewType != null && !viewType.equals("both") && 
!viewType.equals(type)) {
  +                             if( viewType != null && !viewType.equals( "both" ) && 
!viewType.equals( type ) )
  +                             {
                                        continue;
                                }
   
                                signature = getHomeDefinition(getCurrentClass(), 
method, tagType, type);
   
  -                             if (!already.add(signature)) {
  +                             if( !already.add( signature ) )
  +                             {
                                        continue;
                                }
   
  -                             if (cat.isDebugEnabled()) {
  +                             if( cat.isDebugEnabled() )
  +                             {
                                        cat.debug("Create Method = " + signature);
                                }
                        }
  -                     if (signature != null) {
  +                     if( signature != null )
  +                     {
                                setCurrentSignature(signature);
   
                                XClass[] exceptions = method.thrownExceptions();
                                StringBuffer exc = new StringBuffer();
   
  -                             for (int j = 0; j < exceptions.length; j++) {
  +                             for( int j = 0; j < exceptions.length; j++ )
  +                             {
                                        XClass exception = exceptions[j];
   
                                        exc.append(exception.qualifiedName());
  -                                     if (j != exceptions.length - 1) {
  +                                     if( j != exceptions.length - 1 )
  +                                     {
                                                exc.append(',');
                                        }
                                }
  -                             if (exc.length() == 0) {
  -                                     if (tagType.equals("ejb:finder")) {
  +                             if( exc.length() == 0 )
  +                             {
  +                                     if( tagType.equals( "ejb:finder" ) )
  +                                     {
                                                
exc.append("javax.ejb.FinderException");
                                        }
  -                                     else if (tagType.equals("ejb:create-method")) {
  +                                     else if( tagType.equals( "ejb:create-method" ) 
)
  +                                     {
                                                
exc.append("javax.ejb.CreateException");
                                        }
                                }
  -                             if (type.equalsIgnoreCase("remote")) {
  +                             if( type.equalsIgnoreCase( "remote" ) )
  +                             {
                                        exc.append(",java.rmi.RemoteException");
                                }
                                setCurrentExceptions(exc.toString());
  @@ -408,526 +830,192 @@
                // 2. Handle CLASS Tag level ejb:finder
                XTag[] tags = getCurrentClass().doc().tags(tagType, superclasses);
   
  -             for (int i = 0; i < tags.length; i++) {
  +             for( int i = 0; i < tags.length; i++ )
  +             {
                        String signature = 
fullPackageChange(tags[i].attributeValue("signature"));
                        String typeMapping = 
tags[i].attributeValue("result-type-mapping");
   
  -                     if (typeMapping == null || typeMapping.equalsIgnoreCase(type)) 
{
  -                             if (!already.add(signature)) {
  +                     if( typeMapping == null || typeMapping.equalsIgnoreCase( type 
) )
  +                     {
  +                             if( !already.add( signature ) )
  +                             {
                                        continue;
  -                             }
  -
  -                             if (cat.isDebugEnabled()) {
  -                                     cat.debug("Finder Method = " + signature);
  -                             }
  -
  -                             setCurrentTag(tags[i]);
  -                             setCurrentSignature(signature);
  -
  -                             StringBuffer exc = new StringBuffer();
  -
  -                             exc.append("javax.ejb.FinderException");
  -                             if (type.equalsIgnoreCase("remote")) {
  -                                     exc.append(",java.rmi.RemoteException");
  -                             }
  -                             setCurrentExceptions(exc.toString());
  -
  -                             generate(template);
  -                     }
  -             }
  -
  -             // Add mandatory findByPrimaryKey if not already there
  -             if (CmpTagsHandler.isEntityCmp(getCurrentClass()) && 
tagType.equals("ejb:finder")) {
  -                     StringBuffer fbpkSign = new 
StringBuffer(InterfaceTagsHandler.getComponentInterface(type, getCurrentClass()));
  -
  -                     fbpkSign.append(" findByPrimaryKey(");
  -                     
fbpkSign.append(PkTagsHandler.getPkClassFor(getCurrentClass())).append(" 
pk").append(")");
  -                     if (already.add(fbpkSign)) {
  -                             setCurrentSignature(fbpkSign.toString());
  -
  -                             StringBuffer exc = new StringBuffer();
  -
  -                             exc.append("javax.ejb.FinderException");
  -                             if (type.equalsIgnoreCase("remote")) {
  -                                     exc.append(",java.rmi.RemoteException");
  -                             }
  -
  -                             setCurrentExceptions(exc.toString());
  -                             setCurrentMethod(null);
  -                             generate(template);
  -                     }
  -             }
  -
  -             // Add mandatory create() method for stateless beans
  -             if (SessionTagsHandler.isSession(getCurrentClass()) && 
tagType.equals("ejb:create-method")) {
  -                     if (already.size() == 0) {
  -                             StringBuffer createSign = new 
StringBuffer(InterfaceTagsHandler.getComponentInterface(type, getCurrentClass()));
  -
  -                             createSign.append(" create()");
  -                             setCurrentSignature(createSign.toString());
  -
  -                             StringBuffer exc = new StringBuffer();
  -
  -                             exc.append("javax.ejb.CreateException");
  -                             if (type.equalsIgnoreCase("remote")) {
  -                                     exc.append(",java.rmi.RemoteException");
  -                             }
  -                             setCurrentExceptions(exc.toString());
  -                             setCurrentMethod(null);
  -                             generate(template);
  -                     }
  -             }
  -
  -             setCurrentTag(null);
  -             setCurrentSignature(null);
  -             setCurrentExceptions(null);
  -             setCurrentMethod(null);
  -
  -     }
  -
  -
  -     /**
  -      * Describe what the method does
  -      *
  -      * @return Describe the return value
  -      * @exception XDocletException Describe the exception
  -      * @todo-javadoc Write javadocs for method
  -      * @todo-javadoc Write javadocs for return value
  -      * @todo-javadoc Write javadocs for exception
  -      */
  -     public String currentSignature() throws XDocletException {
  -             return currentSignature;
  -     }
  -
  -
  -     /**
  -      * Describe what the method does
  -      *
  -      * @return Describe the return value
  -      * @exception XDocletException Describe the exception
  -      * @todo-javadoc Write javadocs for method
  -      * @todo-javadoc Write javadocs for return value
  -      * @todo-javadoc Write javadocs for exception
  -      */
  -     public String currentExceptions() throws XDocletException {
  -             return currentExceptions;
  -     }
  -
  -
  -     /**
  -      * Sets the CurrentSignature attribute of the HomeTagsHandler object
  -      *
  -      * @param cs The new CurrentSignature value
  -      */
  -     protected void setCurrentSignature(String cs) {
  -             this.currentSignature = cs;
  -     }
  -
  -
  -     /**
  -      * Sets the CurrentExceptions attribute of the HomeTagsHandler object
  -      *
  -      * @param es The new CurrentExceptions value
  -      */
  -     protected void setCurrentExceptions(String es) {
  -             this.currentExceptions = es;
  -     }
  -
  -
  -     /**
  -      * Gets the DependentClassFor attribute of the HomeTagsHandler object
  -      *
  -      * @param clazz Describe what the parameter does
  -      * @param type Describe what the parameter does
  -      * @return The DependentClassFor value
  -      * @exception XDocletException Describe the exception
  -      * @todo-javadoc Write javadocs for method parameter
  -      * @todo-javadoc Write javadocs for method parameter
  -      * @todo-javadoc Write javadocs for exception
  -      */
  -     protected String getDependentClassFor(XClass clazz, String type) throws 
XDocletException {
  -             if ((type.equals("local") && InterfaceTagsHandler.isLocalEjb(clazz)) 
|| (type.equals("remote") && InterfaceTagsHandler.isRemoteEjb(clazz))) {
  -                     return getHomeInterface(type, clazz);
  -             }
  -             else {
  -                     return null;
  -             }
  -     }
  -
  -
  -     /**
  -      * Describe what the method does
  -      *
  -      * @param clazz Describe what the parameter does
  -      * @param tag_name Describe what the parameter does
  -      * @return Describe the return value
  -      * @exception XDocletException Describe the exception
  -      * @todo-javadoc Write javadocs for method
  -      * @todo-javadoc Write javadocs for method parameter
  -      * @todo-javadoc Write javadocs for method parameter
  -      * @todo-javadoc Write javadocs for return value
  -      * @todo-javadoc Write javadocs for exception
  -      */
  -     protected boolean shouldTraverseSuperclassForDependentClass(XClass clazz, 
String tag_name) throws XDocletException {
  -             if (super.shouldTraverseSuperclassForDependentClass(clazz, tag_name) 
== false) {
  -                     return false;
  -             }
  -
  -             //shouldn't include create methods of parent if parent is itself a 
concrete ejb
  -             if (isAConcreteEJBean(clazz)) {
  -                     return false;
  -             }
  -
  -             return true;
  -     }
  -
  -
  -     /**
  -      * Similar to {@link InterfaceTagsHandler#getComponentInterface}. Relies on the
  -      * ejb:home tag, which has the following relevant properties:
  -      * <ul>
  -      *   <li> remote-class: The fully qualified name of the remote class -
  -      *   overrides all set patterns
  -      *   <li> local-class: The fully qualified name of the local class - overrides
  -      *   all set patterns
  -      *   <li> remote-pattern: The pattern to be used to determine the unqualified
  -      *   name of the remote class
  -      *   <li> local-pattern: The pattern to be used to determine the unqualified
  -      *   name of the local class
  -      *   <li> pattern: The pattern to be used in determining the unqualified remote
  -      *   and/or local home interface name - used where remote- or local- pattern
  -      *   are not specified.
  -      *   <li> remote-package: The package the remote home interface is to be placed
  -      *   in
  -      *   <li> local-package: The package the local home interface is to be placed
  -      *   in
  -      *   <li> package: The package the remote and/or local home interface is to be
  -      *   placed in - used where remote- or local- package are not specified.
  -      * </ul>
  -      *
  -      *
  -      * @param type The type of home interface - can be remote or local.
  -      * @param clazz Description of Parameter
  -      * @return The HomeInterface value
  -      * @exception XDocletException Description of Exception
  -      */
  -     public static String getHomeInterface(String type, XClass clazz) throws 
XDocletException {
  -             Category cat = Log.getCategory(HomeTagsHandler.class, 
"getHomeInterface");
  -
  -             // validate type
  -             if (!"remote".equals(type) && !"local".equals(type)) {
  -                     throw new 
XDocletException(Translator.getString("xdoclet.ejb.Messages",
  -                                     "method_only_takes_remote_or_local", new 
String[]{"getHomeInterface", type}));
  -             }
  -
  -             String fileName = clazz.containingPackage().name();
  -             String name_pattern = null;
  -             String package_pattern = null;
  -             String home_interface = null;
  +                             }
   
  -             home_interface = clazz.doc().tagAttributeValue("ejb:home", type + 
"-class");
  -             if (cat.isDebugEnabled()) {
  -                     cat.debug(type + " home Interface for " + 
clazz.qualifiedName() + " = " + home_interface);
  +                             if( cat.isDebugEnabled() )
  +                             {
  +                                     cat.debug( "Finder Method = " + signature );
                }
   
  -             if (home_interface != null) {
  -                     return home_interface;
  +                             setCurrentTag( tags[i] );
  +                             setCurrentSignature( signature );
  +
  +                             StringBuffer exc = new StringBuffer();
  +
  +                             exc.append( "javax.ejb.FinderException" );
  +                             if( type.equalsIgnoreCase( "remote" ) )
  +                             {
  +                                     exc.append( ",java.rmi.RemoteException" );
                }
  +                             setCurrentExceptions( exc.toString() );
   
  -             name_pattern = clazz.doc().tagAttributeValue("ejb:home", type + 
"-pattern");
  -             if (name_pattern == null) {
  -                     name_pattern = clazz.doc().tagAttributeValue("ejb:home", 
"pattern");
  -                     if (name_pattern == null) {
  -                             name_pattern = "remote".equals(type) ? 
getHomeClassPattern() : getLocalHomeClassPattern();
  +                             generate( template );
                        }
                }
   
  -             package_pattern = clazz.doc().tagAttributeValue("ejb:home", type + 
"-package");
  -             if (package_pattern == null) {
  -                     package_pattern = clazz.doc().tagAttributeValue("ejb:home", 
"package");
  -             }
  +             // Add mandatory findByPrimaryKey if not already there
  +             if( CmpTagsHandler.isEntityCmp( getCurrentClass() ) && tagType.equals( 
"ejb:finder" ) )
  +             {
  +                     StringBuffer fbpkSign = new StringBuffer( 
InterfaceTagsHandler.getComponentInterface( type, getCurrentClass() ) );
   
  -             String ejb_name = null;
  +                     fbpkSign.append( " findByPrimaryKey(" );
  +                     fbpkSign.append( PkTagsHandler.getPkClassFor( 
getCurrentClass() ) ).append( " pk" ).append( ")" );
  +                     if( already.add( fbpkSign ) )
  +                     {
  +                             setCurrentSignature( fbpkSign.toString() );
   
  -             if (name_pattern.indexOf("{0}") != -1) {
  -                     ejb_name = MessageFormat.format(name_pattern, new 
Object[]{getShortEjbNameFor(clazz)});
  -             }
  -             else {
  -                     ejb_name = name_pattern;
  -             }
  +                             StringBuffer exc = new StringBuffer();
   
  -             String subtask_name = null;
  +                             exc.append( "javax.ejb.FinderException" );
  +                             if( type.equalsIgnoreCase( "remote" ) )
  +                             {
  +                                     exc.append( ",java.rmi.RemoteException" );
  +                             }
   
  -             if (type.equals("remote")) {
  -                     subtask_name = HomeInterfaceSubTask.SUBTASK_NAME;
  +                             setCurrentExceptions( exc.toString() );
  +                             setCurrentMethod( null );
  +                             generate( template );
                }
  -             else {
  -                     subtask_name = LocalHomeInterfaceSubTask.SUBTASK_NAME;
                }
   
  -             // Fix package name
  -             fileName = choosePackage(fileName, package_pattern, subtask_name);
  -             fileName += "." + ejb_name;
  +             // Add mandatory create() method for stateless beans
  +             if( SessionTagsHandler.isSession( getCurrentClass() ) && 
tagType.equals( "ejb:create-method" ) )
  +             {
  +                     if( already.size() == 0 )
  +                     {
  +                             StringBuffer createSign = new StringBuffer( 
InterfaceTagsHandler.getComponentInterface( type, getCurrentClass() ) );
   
  -             return fileName;
  -     }
  +                             createSign.append( " create()" );
  +                             setCurrentSignature( createSign.toString() );
   
  +                             StringBuffer exc = new StringBuffer();
   
  -     /**
  -      * Returns true if method is an ejbRemove method, false otherwise.
  -      *
  -      * @param method Description of Parameter
  -      * @return The RemoveMethod value
  -      * @exception XDocletException Description of Exception
  -      */
  -     public static boolean isRemoveMethod(XMethod method) throws XDocletException {
  -             return method.name().equals("ejbRemove");
  +                             exc.append( "javax.ejb.CreateException" );
  +                             if( type.equalsIgnoreCase( "remote" ) )
  +                             {
  +                                     exc.append( ",java.rmi.RemoteException" );
  +                             }
  +                             setCurrentExceptions( exc.toString() );
  +                             setCurrentMethod( null );
  +                             generate( template );
        }
  -
  -
  -     /**
  -      * Returns true if method is a create method marked with a ejb:create-method
  -      * tag, false otherwise.
  -      *
  -      * @param method Description of Parameter
  -      * @return The CreateMethod value
  -      * @exception XDocletException Description of Exception
  -      */
  -     public static boolean isCreateMethod(XMethod method) throws XDocletException {
  -             return method.doc().hasTag("ejb:create-method");
        }
   
  +             setCurrentTag( null );
  +             setCurrentSignature( null );
  +             setCurrentExceptions( null );
  +             setCurrentMethod( null );
   
  -     /**
  -      * Returns true if method is a home method marked with a ejb:home-method tag,
  -      * false otherwise.
  -      *
  -      * @param method Description of Parameter
  -      * @return The HomeMethod value
  -      * @exception XDocletException Description of Exception
  -      */
  -     public static boolean isHomeMethod(XMethod method) throws XDocletException {
  -             return method.doc().hasTag("ejb:home-method");
        }
   
  -
        /**
  -      * Gets the CompNameFor attribute of the HomeTagsHandler class
  +      * Describe what the method does
         *
  -      * @param clazz Describe what the parameter does
  -      * @param type Describe what the parameter does
  -      * @return The CompNameFor value
  +      * @return                      Describe the return value
         * @exception XDocletException Describe the exception
  -      * @todo-javadoc Write javadocs for method parameter
  -      * @todo-javadoc Write javadocs for method parameter
  +      * @todo-javadoc                Write javadocs for method
  +      * @todo-javadoc                Write javadocs for return value
         * @todo-javadoc Write javadocs for exception
         */
  -     public static String getCompNameFor(XClass clazz, String type) throws 
XDocletException {
  -             String compName = getEjbNameFor(clazz).replace('.', '/');
  -
  -             if (type.equals("local") && isLocalEjb(clazz) && isRemoteEjb(clazz)) {
  -                     compName = compName + LOCAL_SUFFIX;
  -             }
  -
  -             return compName;
  +     public String currentSignature() throws XDocletException
  +     {
  +             return currentSignature;
        }
   
  -
        /**
  -      * Returns true if method is an ejbFind method, false otherwise.
  +      * Describe what the method does
         *
  -      * @param method Description of Parameter
  -      * @return The FinderMethod value
  -      * @exception XDocletException Description of Exception
  +      * @return                      Describe the return value
  +      * @exception XDocletException  Describe the exception
  +      * @todo-javadoc                Write javadocs for method
  +      * @todo-javadoc                Write javadocs for return value
  +      * @todo-javadoc                Write javadocs for exception
         */
  -     public static boolean isFinderMethod(XMethod method) throws XDocletException {
  -             return method.name().startsWith("ejbFind");
  +     public String currentExceptions() throws XDocletException
  +     {
  +             return currentExceptions;
        }
   
  -
        /**
  -      * Gets the HomeDefinition attribute of the HomeTagsHandler class
  +      * Gets the DependentClassFor attribute of the HomeTagsHandler object
         *
         * @param clazz Describe what the parameter does
  -      * @param method Describe what the parameter does
  -      * @param tagType Describe what the parameter does
         * @param type Describe what the parameter does
  -      * @return The HomeDefinition value
  +      * @return                      The DependentClassFor value
         * @exception XDocletException Describe the exception
         * @todo-javadoc Write javadocs for method parameter
         * @todo-javadoc Write javadocs for method parameter
  -      * @todo-javadoc Write javadocs for method parameter
  -      * @todo-javadoc Write javadocs for method parameter
         * @todo-javadoc Write javadocs for exception
         */
  -     public static String getHomeDefinition(XClass clazz, XMethod method, String 
tagType, String type)
  -                      throws XDocletException {
  -             String methodName = method.name().substring(3);
  -             StringBuffer homeMethodName = new StringBuffer();
  -
  -             if (tagType.equals("ejb:finder")) {
  -                     homeMethodName.append(method.returnType());
  -             }
  -             else if (tagType.equals("ejb:create-method")) {
  -                     
homeMethodName.append(InterfaceTagsHandler.getComponentInterface(type, clazz));
  -             }
  -             homeMethodName.append(" ");
  -             homeMethodName.append(methodName.substring(0, 1).toLowerCase());
  -             homeMethodName.append(methodName.substring(1));
  -             homeMethodName.append("(");
  -
  -             StringTokenizer st = new 
StringTokenizer(method.signature().substring(1, method.signature().length() - 1), ",");
  -             int k = 1;
  -
  -             while (st.hasMoreTokens()) {
  -                     homeMethodName.append(st.nextToken()).append(" 
").append("param").append(k++);
  -                     if (st.hasMoreTokens()) {
  -                             homeMethodName.append(" , ");
  +     protected String getDependentClassFor( XClass clazz, String type ) throws 
XDocletException
  +     {
  +             if( ( type.equals( "local" ) && InterfaceTagsHandler.isLocalEjb( clazz 
) ) || ( type.equals( "remote" ) && InterfaceTagsHandler.isRemoteEjb( clazz ) ) )
  +             {
  +                     return getHomeInterface( type, clazz );
                        }
  +             else
  +             {
  +                     return null;
                }
  -             homeMethodName.append(")");
  -             return fullPackageChange(homeMethodName.toString());
        }
   
  -
        /**
  -      * Converts ejbHome<em>blabla</em> to home<em>blabla</em> , the one that should
  -      * appear in home interface.
  +      * Sets the CurrentSignature attribute of the HomeTagsHandler object
         *
  -      * @param methodName Description of Parameter
  -      * @return Description of the Returned Value
  -      * @exception XDocletException Description of Exception
  +      * @param cs  The new CurrentSignature value
         */
  -     public static String toHomeMethod(String methodName) throws XDocletException {
  -             // Remove "ejbHome" prefix and lower case first char in rest: 
"ejbHomeFoo"->"foo"
  -             return Character.toLowerCase(methodName.charAt(7)) + 
methodName.substring(8);
  +     protected void setCurrentSignature( String cs )
  +     {
  +             this.currentSignature = cs;
        }
   
  -
        /**
  -      * Converts ejbCreate<em>blabla</em> to create<em>blabla</em> , the one that
  -      * should appear in home interface.
  +      * Sets the CurrentExceptions attribute of the HomeTagsHandler object
         *
  -      * @param methodName Description of Parameter
  -      * @return Description of the Returned Value
  -      * @exception XDocletException Description of Exception
  +      * @param es  The new CurrentExceptions value
         */
  -     public static String toCreateMethod(String methodName) throws XDocletException 
{
  -             if (methodName.length() > 9) {
  -                     // Remove "ejbCreate" prefix and lower case first char in 
rest: "ejbCreateFoo"->"createFoo", EJB 2 only
  -                     return "create" + Character.toUpperCase(methodName.charAt(9)) 
+ methodName.substring(10);
  -             }
  -             else {
  -                     return "create";
  -             }
  +     protected void setCurrentExceptions( String es )
  +     {
  +             this.currentExceptions = es;
        }
   
  -
        /**
         * Describe what the method does
         *
         * @param clazz Describe what the parameter does
  +      * @param tag_name              Describe what the parameter does
         * @return Describe the return value
         * @exception XDocletException Describe the exception
         * @todo-javadoc Write javadocs for method
         * @todo-javadoc Write javadocs for method parameter
  -      * @todo-javadoc Write javadocs for return value
  -      * @todo-javadoc Write javadocs for exception
  -      */
  -     public static XMethod findFirstCreateMethodFor(XClass clazz) throws 
XDocletException {
  -             XMethod[] methods = clazz.methods();
  -
  -             do {
  -                     for (int i = 0; i < methods.length; i++) {
  -                             XMethod method = methods[i];
  -
  -                             if (HomeTagsHandler.isCreateMethod(method)) {
  -                                     return method;
  -                             }
  -                     }
  -
  -                     clazz = clazz.superclass();
  -             } while (clazz != null);
  -
  -             return null;
  -     }
  -
  -
  -     /**
  -      * Converts ejbFind<em>blabla</em> to find<em>blabla</em> , the one that should
  -      * appear in home interface.
  -      *
  -      * @param methodName Description of Parameter
  -      * @return Description of the Returned Value
  -      * @exception XDocletException Description of Exception
  -      */
  -     public static String toFinderMethod(String methodName) throws XDocletException 
{
  -             // Remove "ejb" prefix and lower case first char in rest: 
"ejbFindByPrimaryKey"->"findByPrimaryKey"
  -             return Character.toLowerCase(methodName.charAt(3)) + 
methodName.substring(4);
  -     }
  -
  -
  -     /**
  -      * Describe what the method does
  -      *
  -      * @param s Describe what the parameter does
  -      * @return Describe the return value
  -      * @todo-javadoc Write javadocs for method
         * @todo-javadoc Write javadocs for method parameter
         * @todo-javadoc Write javadocs for return value
  +      * @todo-javadoc                Write javadocs for exception
         */
  -     public static String fullPackageChange(String s) {
  -             StringTokenizer st = new StringTokenizer(s, " ");
  -             String sign = st.nextToken();
  -             StringBuffer ret = new StringBuffer();
  -
  -             if (sign.equals("Collection")) {
  -                     ret.append("java.util.Collection");
  -             }
  -             else if (sign.equals("Enumeration")) {
  -                     ret.append("java.util.Enumeration");
  -             }
  -             else {
  -                     ret.append(sign);
  -             }
  -             while (st.hasMoreTokens()) {
  -                     ret.append(" ").append(st.nextToken());
  -             }
  -             return ret.toString();
  +     protected boolean shouldTraverseSuperclassForDependentClass( XClass clazz, 
String tag_name ) throws XDocletException
  +     {
  +             if( super.shouldTraverseSuperclassForDependentClass( clazz, tag_name ) 
== false )
  +             {
  +                     return false;
        }
   
  -
  -     /**
  -      * Gets the LocalHomeClassPattern attribute of the HomeTagsHandler class
  -      *
  -      * @return The LocalHomeClassPattern value
  -      */
  -     protected static String getLocalHomeClassPattern() {
  -             LocalHomeInterfaceSubTask localhomeintf_subtask = 
((LocalHomeInterfaceSubTask)DocletContext.getInstance().getSubTaskBy(LocalHomeInterfaceSubTask.SUBTASK_NAME));
  -
  -             if (localhomeintf_subtask != null) {
  -                     return localhomeintf_subtask.getLocalHomeClassPattern();
  -             }
  -             else {
  -                     return 
LocalHomeInterfaceSubTask.DEFAULT_LOCALHOMEINTERFACE_CLASS_PATTERN;
  -             }
  +             //shouldn't include create methods of parent if parent is itself a 
concrete ejb
  +             if( isAConcreteEJBean( clazz ) )
  +             {
  +                     return false;
        }
   
  -
  -     /**
  -      * Gets the HomeClassPattern attribute of the HomeTagsHandler class
  -      *
  -      * @return The HomeClassPattern value
  -      */
  -     protected static String getHomeClassPattern() {
  -             HomeInterfaceSubTask homeintf_subtask = 
((HomeInterfaceSubTask)DocletContext.getInstance().getSubTaskBy(HomeInterfaceSubTask.SUBTASK_NAME));
  -
  -             if (homeintf_subtask != null) {
  -                     return homeintf_subtask.getHomeClassPattern();
  -             }
  -             else {
  -                     return 
HomeInterfaceSubTask.DEFAULT_HOMEINTERFACE_CLASS_PATTERN;
  -             }
  +             return true;
        }
   
   }
  
  
  

_______________________________________________
Xdoclet-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-devel

Reply via email to