User: vharcq
Date: 02/04/17 13:32:21
Modified: core/src/xdoclet/ejb/tags EjbRefTagsHandler.java
HomeTagsHandler.java
Log:
1. Merging shuld care of package substitution (Address-env-entries.xml should be
found i ejb/ and not in interfaces/)
2. Inheritance for ejb:env-entry now works
3. beautifier
Revision Changes Path
1.9 +84 -53 xdoclet/core/src/xdoclet/ejb/tags/EjbRefTagsHandler.java
Index: EjbRefTagsHandler.java
===================================================================
RCS file: /cvsroot/xdoclet/xdoclet/core/src/xdoclet/ejb/tags/EjbRefTagsHandler.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -w -r1.8 -r1.9
--- EjbRefTagsHandler.java 4 Apr 2002 01:03:06 -0000 1.8
+++ EjbRefTagsHandler.java 17 Apr 2002 20:32:20 -0000 1.9
@@ -13,8 +13,10 @@
import xdoclet.tags.IdTagsHandler;
import xdoclet.util.Translator;
+import xdoclet.util.TypeConversionUtil;
import java.util.Properties;
+import java.util.HashSet;
/**
* @author Ara Abrahamian
@@ -22,10 +24,11 @@
* @version $Revision 1.1 $
* @todo refactor ejbRefId properly to account for ejb:bean - it may not be
* needed anymore.
- * @todo refactor storeReferringClassId properly to take ejb:bean into account -
- * may not be needed anymore.
+ * @todo refactor storeReferringClassId properly to take ejb:bean into
+ * account - may not be needed anymore.
*/
-public class EjbRefTagsHandler extends EjbTagsHandler {
+public class EjbRefTagsHandler extends EjbTagsHandler
+{
/**
* The id of the EJB referencing another EJB, used for setting up a correct
* unique id for the ejb-ref.
@@ -36,22 +39,21 @@
*/
protected transient String referringClassId;
-
/**
* Returns unique id for the specified ejb-ref. It prefixes it with the
* referring class's id, then a _ and the id of the ejb object.
*
- * @todo refactor this properly to account for ejb:bean - it may not be needed
- * anymore.
* @return Description of the Returned Value
* @exception XDocletException Description of Exception
+ * @todo refactor this properly to account for ejb:bean
+ * - it may not be needed anymore.
* @doc:tag type="content"
*/
- public String ejbRefId() throws XDocletException {
+ public String ejbRefId() throws XDocletException
+ {
return referringClassId + "_" +
EjbTagsHandler.getEjbIdFor(getCurrentClass());
}
-
/**
* Evaluates the body block for each ejb:ejb-ref defined for the EJB. One of
* the useful things is does is to lookup the EJB using the ejb-name parameter
@@ -62,40 +64,63 @@
* @exception XDocletException Description of Exception
* @doc:tag type="block"
*/
- public void forAllEjbRefs(String template, Properties attributes) throws
XDocletException {
- XTag[] tags = getCurrentClass().doc().tags("ejb:ejb-ref");
+ public void forAllEjbRefs( String template, Properties attributes ) throws
XDocletException
+ {
+ boolean superclasses = TypeConversionUtil.stringToBoolean(
attributes.getProperty( "superclasses" ), true );
+
+ XClass oldCurClass = getCurrentClass();
- for (int i = 0; i < tags.length; i++) {
+ XClass cur_class = getCurrentClass();
+ HashSet already = new HashSet();
+
+ do
+ {
+ XTag[] tags = cur_class.doc().tags( "ejb:ejb-ref" );
+
+ for( int i = 0; i < tags.length; i++ )
+ {
setCurrentTag(tags[i]);
storeReferringClassId();
String ejbName = getCurrentTag().attributeValue("ejb-name");
+ if( !already.contains( ejbName ) )
+ {
+ already.add( ejbName );
pushCurrentClass(findEjb(ejbName));
generate(template);
popCurrentClass();
+ }
referringClassId = null;
}
-
- setCurrentTag(null);
+ if( superclasses == true )
+ {
+ cur_class = cur_class.superclass();
+ }
+ else
+ {
+ break;
}
+ }while ( cur_class != null );
+ setCurrentClass( oldCurClass );
+ }
/**
* Stores the id of current EJB for further use by other tags in
* referringClassId attribute.
*
- * @todo refactor this properly to take ejb:bean into account - may not be
- * needed anymore.
* @exception XDocletException Description of Exception
+ * @todo refactor this properly to take ejb:bean into
+ * account - may not be needed anymore.
*/
- protected void storeReferringClassId() throws XDocletException {
+ protected void storeReferringClassId() throws XDocletException
+ {
referringClassId = EjbTagsHandler.getEjbIdFor(getCurrentClass());
}
-
/**
* Finds and returns the class with the specified ejbName. An XDocletException
* is thrown if not found.
@@ -104,16 +129,22 @@
* @return Description of the Returned Value
* @exception XDocletException Description of Exception
*/
- protected XClass findEjb(String ejbName) throws XDocletException {
- try {
+ protected XClass findEjb( String ejbName ) throws XDocletException
+ {
+ try
+ {
XClass[] classes = XJavaDoc.getInstance().sourceClasses();
- for (int i = 0; i < classes.length; i++) {
- if (isEjb(classes[i]) &&
ejbName.equals(getEjbNameFor(classes[i]))) {
+ for( int i = 0; i < classes.length; i++ )
+ {
+ if( isEjb( classes[i] ) && ejbName.equals(
getEjbNameFor( classes[i] ) ) )
+ {
return classes[i];
}
}
- } catch (XJavaDocException e) {
+ }
+ catch( XJavaDocException e )
+ {
throw new XDocletException(e, e.getMessage());
}
1.34 +768 -674 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.33
retrieving revision 1.34
diff -u -w -r1.33 -r1.34
--- HomeTagsHandler.java 16 Apr 2002 22:09:06 -0000 1.33
+++ HomeTagsHandler.java 17 Apr 2002 20:32:20 -0000 1.34
@@ -27,9 +27,10 @@
/**
* @author Ara Abrahamian ([EMAIL PROTECTED])
* @created Oct 15, 2001
- * @version $Revision: 1.33 $
+ * @version $Revision: 1.34 $
*/
-public class HomeTagsHandler extends EjbTagsHandler {
+public class HomeTagsHandler extends EjbTagsHandler
+{
/**
* @todo-javadoc Describe the field
*/
@@ -39,6 +40,397 @@
*/
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" ) )
+ {
+ String ejbReturn = method.returnType().toString();
+
+ if( ejbReturn.equals( "java.util.Collection" ) )
+ {
+ homeMethodName.append( ejbReturn );
+
+ }
+ // end of if ()
+ else
+ {
+ homeMethodName.append(
InterfaceTagsHandler.getComponentInterface( type, clazz ) );
+
+ }
+ // end of else
+
+ }
+ 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 +440,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 +453,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 +486,6 @@
}
}
-
/**
* Evaluates the body block if current create method's ejbPostCreate method
* does not exist.
@@ -101,10 +496,12 @@
* @doc:tag type="block"
*/
public void ifDoesntHavePostCreateMethod(String template, Properties
attributes)
- throws XDocletException {
+ throws XDocletException
+ {
XMethod currentMethod = getCurrentMethod();
- if (!isCreateMethod(currentMethod)) {
+ if( !isCreateMethod( currentMethod ) )
+ {
throw new XDocletException("Cannot call
ifDoesntHavePostCreateMethod if the current method is not a create method: "
+ currentMethod);
}
@@ -115,12 +512,12 @@
XMethod ejbPostCreateMethod =
getCurrentClass().getMethod(currentMethodName.toString());
- if (ejbPostCreateMethod == null) {
+ if( ejbPostCreateMethod == null )
+ {
generate(template);
}
}
-
/**
* Returns the appropriate ejbPostCreate method name for the current ejbCreate
* method.
@@ -129,14 +526,14 @@
* @return Description of the Returned Value
* @doc:tag type="content"
*/
- public String ejbPostCreateSignature(Properties attributes) {
+ public String ejbPostCreateSignature( Properties attributes )
+ {
StringBuffer currentMethodName = new
StringBuffer(getCurrentMethod().name());
currentMethodName.insert(3, "Post");
return currentMethodName.toString();
}
-
/**
* Evaluates the body block if current method is a home method. Home methods
* should have ejb:home-method defined.
@@ -146,16 +543,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;
}
@@ -163,7 +563,6 @@
}
}
-
/**
* Evaluates the body block if current method is ejbRemove method.
*
@@ -172,13 +571,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.
// *
@@ -210,14 +610,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");
@@ -226,37 +627,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) {
+ 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;
}
@@ -268,7 +673,6 @@
return compName;
}
-
/**
* Returns the name of the class home interface extends.
*
@@ -277,7 +681,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";
@@ -288,30 +693,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'");
}
@@ -320,31 +728,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);
@@ -353,12 +769,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);
@@ -371,77 +790,96 @@
XMethod[] methods = getCurrentClass().methods();
boolean fbpkFound = false;
- 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());
@@ -450,7 +888,8 @@
// If custom findByPrimaryKey exists then we should
not add the
// mandatory later
- if (method.name().equals("findByPrimaryKey")) {
+ if( method.name().equals( "findByPrimaryKey" ) )
+ {
fbpkFound = true;
}
@@ -461,20 +900,25 @@
// 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()) {
+ if( cat.isDebugEnabled() )
+ {
cat.debug("Finder Method = " + signature);
}
- if (signature.indexOf("findByPrimaryKey") != -1) {
+ if( signature.indexOf( "findByPrimaryKey" ) != -1 )
+ {
fbpkFound = true;
}
@@ -483,520 +927,170 @@
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 (!fbpkFound && 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 (home_interface != null) {
- return home_interface;
+ 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( !fbpkFound && 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")) {
- String ejbReturn = method.returnType().toString();
-
- if (ejbReturn.equals("java.util.Collection")) {
- homeMethodName.append(ejbReturn);
-
- }
- // end of if ()
- else {
-
homeMethodName.append(InterfaceTagsHandler.getComponentInterface(type, clazz));
-
- }
- // end of else
-
- }
- 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