User: pathoss
Date: 02/04/05 01:59:52
Modified: core/src/xdoclet/ejb UtilObjectSubTask.java
Log:
Added a GUID generator in the util object. This is disabled by default. Add
includeGUID to the <utilobject/> subtask.
Revision Changes Path
1.20 +138 -103 xdoclet/core/src/xdoclet/ejb/UtilObjectSubTask.java
Index: UtilObjectSubTask.java
===================================================================
RCS file: /cvsroot/xdoclet/xdoclet/core/src/xdoclet/ejb/UtilObjectSubTask.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -w -r1.19 -r1.20
--- UtilObjectSubTask.java 4 Apr 2002 01:03:04 -0000 1.19
+++ UtilObjectSubTask.java 5 Apr 2002 09:59:51 -0000 1.20
@@ -20,24 +20,12 @@
/**
* @author Konstantin Pribluda
* @created October 3, 2001
- * @version $Revision: 1.19 $
+ * @version $Revision: 1.20 $
*/
-public class UtilObjectSubTask extends AbstractEjbCodeGeneratorSubTask {
+public class UtilObjectSubTask extends AbstractEjbCodeGeneratorSubTask
+{
/**
- * A configuration parameter for specifying the utility class name pattern. By
- * default the value is used for deciding the utility name. {0} in the value
- * mean current class's symbolic name which for an EJBean is the EJB name.
- *
- * @see #getUtilClassPattern()
- */
- private String utilClassPattern;
-
- /**
- * The preferred kind of lookup code, which is either logical or physical.
- */
- private String kind = LookupKind.LOGICAL;
- /**
* @todo-javadoc Describe the field
*/
public final static String SUBTASK_NAME = "utilObject";
@@ -46,63 +34,72 @@
* @todo-javadoc Describe the field
*/
public final static String DEFAULT_UTIL_CLASS_PATTERN = "{0}Util";
+
/**
* @todo-javadoc Describe the field
*/
private static String DEFAULT_TEMPLATE_FILE = "/xdoclet/ejb/util.j";
-
/**
- * Describe what the UtilObjectSubTask constructor does
+ * A configuration parameter for specifying the utility class name pattern. By
+ * default the value is used for deciding the utility name. {0} in the value
+ * mean current class's symbolic name which for an EJBean is the EJB name.
*
- * @todo-javadoc Write javadocs for constructor
+ * @see #getUtilClassPattern()
*/
- public UtilObjectSubTask() {
- setTemplateURL(getClass().getResource(DEFAULT_TEMPLATE_FILE));
- setDestinationFile(getUtilClassPattern() + ".java");
- setOfType("javax.ejb.EntityBean,javax.ejb.SessionBean");
- }
-
+ private String utilClassPattern;
/**
- * Sets the Kind attribute of the UtilObjectSubTask object
- *
- * @param kind The new Kind value
+ * Include a performant GUID generator in the util object.
*/
- public void setKind(LookupKind kind) {
- this.kind = kind.getValue();
- }
+ private boolean includeGUID = false;
+ /**
+ * The preferred kind of lookup code, which is either logical or physical.
+ */
+ private String kind = LookupKind.LOGICAL;
/**
- * Sets the Pattern attribute of the UtilObjectSubTask object
+ * Describe what the UtilObjectSubTask constructor does
*
- * @param new_pattern The new Pattern value
+ * @todo-javadoc Write javadocs for constructor
*/
- public void setPattern(String new_pattern) {
- utilClassPattern = new_pattern;
+ public UtilObjectSubTask()
+ {
+ setTemplateURL( getClass().getResource( DEFAULT_TEMPLATE_FILE ) );
+ setDestinationFile( getUtilClassPattern() + ".java" );
+ setOfType( "javax.ejb.EntityBean,javax.ejb.SessionBean" );
}
-
/**
* Gets the Kind attribute of the UtilObjectSubTask object
*
* @return The Kind value
*/
- public String getKind() {
+ public String getKind()
+ {
return kind;
}
-
/**
* Gets the SubTaskName attribute of the UtilObjectSubTask object
*
* @return The SubTaskName value
*/
- public String getSubTaskName() {
+ public String getSubTaskName()
+ {
return SUBTASK_NAME;
}
+ /**
+ * Include a performant GUID generator in the util object.
+ *
+ * @return
+ */
+ public boolean getIncludeGUID()
+ {
+ return includeGUID;
+ }
/**
* Returns the configuration parameter for specifying the utility class name
@@ -113,34 +110,68 @@
*
* @return The UtilClassPattern value
*/
- public String getUtilClassPattern() {
- if (utilClassPattern != null) {
+ public String getUtilClassPattern()
+ {
+ if( utilClassPattern != null )
+ {
return utilClassPattern;
}
- else {
+ else
+ {
return DEFAULT_UTIL_CLASS_PATTERN;
}
}
+ /**
+ * Sets the Kind attribute of the UtilObjectSubTask object
+ *
+ * @param kind The new Kind value
+ */
+ public void setKind( LookupKind kind )
+ {
+ this.kind = kind.getValue();
+ }
+
+ /**
+ * Sets the Pattern attribute of the UtilObjectSubTask object
+ *
+ * @param new_pattern The new Pattern value
+ */
+ public void setPattern( String new_pattern )
+ {
+ utilClassPattern = new_pattern;
+ }
+
+ /**
+ * Include a performant GUID generator in the util object.
+ *
+ * @param includeGUID include the GUID generator or not
+ */
+ public void setIncludeGUID( boolean includeGUID )
+ {
+ this.includeGUID = includeGUID;
+ }
/**
* Called to validate configuration parameters.
*
* @exception XDocletException Description of Exception
*/
- public void validateOptions() throws XDocletException {
+ public void validateOptions() throws XDocletException
+ {
super.validateOptions();
- if (getUtilClassPattern() == null ||
getUtilClassPattern().trim().equals("")) {
+ if( getUtilClassPattern() == null ||
getUtilClassPattern().trim().equals( "" ) )
+ {
throw new
XDocletException(Translator.getString("parameter_missing_or_empty", new
String[]{"pattern"}));
}
- if (getUtilClassPattern().indexOf("{0}") == -1) {
+ if( getUtilClassPattern().indexOf( "{0}" ) == -1 )
+ {
throw new
XDocletException(Translator.getString("xdoclet.ejb.Messages",
"pattern_has_no_placeholder"));
}
}
-
/**
* Gets the GeneratedFileName attribute of the UtilObjectSubTask object
*
@@ -150,11 +181,11 @@
* @todo-javadoc Write javadocs for method parameter
* @todo-javadoc Write javadocs for exception
*/
- protected String getGeneratedFileName(XClass clazz) throws XDocletException {
+ protected String getGeneratedFileName( XClass clazz ) throws XDocletException
+ {
return
PackageTagsHandler.packageNameAsPathFor(UtilTagsHandler.getUtilClassFor(getCurrentClass()))
+ ".java";
}
-
/**
* Describe what the method does
*
@@ -162,12 +193,12 @@
* @todo-javadoc Write javadocs for method
* @todo-javadoc Write javadocs for exception
*/
- protected void engineStarted() throws XDocletException {
+ protected void engineStarted() throws XDocletException
+ {
System.out.println(Translator.getString("xdoclet.ejb.Messages",
"generating_util_for",
new String[]{getCurrentClass().qualifiedName()}));
}
-
/**
* Describe what the method does
*
@@ -179,22 +210,26 @@
* @todo-javadoc Write javadocs for return value
* @todo-javadoc Write javadocs for exception
*/
- protected boolean matchesGenerationRules(XClass clazz) throws XDocletException
{
+ protected boolean matchesGenerationRules( XClass clazz ) throws
XDocletException
+ {
Category cat = Log.getCategory(UtilObjectSubTask.class,
"matchesGenerationRules");
- if (super.matchesGenerationRules(clazz) == false) {
+ if( super.matchesGenerationRules( clazz ) == false )
+ {
cat.debug("Skip bean " + clazz.qualifiedName() + " because
super.matchesGenerationRules() returned false.");
return false;
}
- if (!EjbTagsHandler.isAConcreteEJBean(getCurrentClass())) {
+ if( !EjbTagsHandler.isAConcreteEJBean( getCurrentClass() ) )
+ {
cat.debug("Skip bean " + clazz.qualifiedName() + " because
it's not a concrete bean.");
return false;
}
String generate =
getCurrentClass().doc().tagAttributeValue("ejb:util", "generate", false);
- if ((generate != null) && (generate.equals("false") ||
generate.equals("no"))) {
+ if( ( generate != null ) && ( generate.equals( "false" ) ||
generate.equals( "no" ) ) )
+ {
cat.debug("Skip util class for " + clazz.qualifiedName() + "
because of generate=" + generate + " flag.");
return false;
}
@@ -202,12 +237,12 @@
return true;
}
-
/**
* @author Ara Abrahamian ([EMAIL PROTECTED])
* @created March 6, 2002
*/
- public static class LookupKind extends
org.apache.tools.ant.types.EnumeratedAttribute {
+ public static class LookupKind extends
org.apache.tools.ant.types.EnumeratedAttribute
+ {
/**
* @todo-javadoc Describe the field
*/
@@ -217,13 +252,13 @@
*/
public final static String LOGICAL = "logical";
-
/**
* Gets the Values attribute of the LookupKind object
*
* @return The Values value
*/
- public java.lang.String[] getValues() {
+ public java.lang.String[] getValues()
+ {
return (new java.lang.String[]{
PHYSICAL, LOGICAL
});
_______________________________________________
Xdoclet-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-devel