Author: rich
Date: Wed Oct 6 13:36:07 2004
New Revision: 53904
Modified:
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/CompilerUtils.java
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/JpfLanguageConstants.java
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/PageFlowChecker.java
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/SharedFlowChecker.java
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/ForwardGrammar.java
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/MessageResourcesGrammar.java
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/RaiseActionGrammar.java
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/SimpleActionGrammar.java
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/UniqueValueType.java
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/WebappPathOrActionType.java
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/WebappPathType.java
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowActionServlet.java
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowContextListener.java
Log:
- Fixed to avoid deployment errors when both PageFlowActionServlet and
PageFlowContextListener are registered in web.xml.
- Added an error to ensure that Global.app lives in WEB-INF/src.
- Added a workarond for an APT bug where an AnnotationMirror doesn't equal
itself when another copy is retrieved while iterating over a list of peer
annotations.
DRT: netui (WinXP)
BB: self (linux)
Modified:
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/CompilerUtils.java
==============================================================================
---
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/CompilerUtils.java
(original)
+++
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/CompilerUtils.java
Wed Oct 6 13:36:07 2004
@@ -43,6 +43,7 @@
implements JpfLanguageConstants
{
private static final ErrorTypeDeclaration ERROR_TYPE_DECLARATION = new
ErrorTypeDeclaration();
+ public static final String USE_EQUALS_TO_COMPARE_ANNOTATIONS_ATTR =
"useEqualsToCompareAnnotations";
public static boolean isJpfAnnotation( AnnotationMirror annotation, String
unqualifiedName )
@@ -669,7 +670,7 @@
if ( decl.getQualifiedName().equals( GLOBALAPP_FULL_CLASSNAME
) )
{
StringBuilder sb = new StringBuilder( webappRootPath );
- sb.append( WEBINF_SRC_DIR ).append( '/' );
+ sb.append( WEBINF_SRC_PATH ).append( '/' );
sb.append( GLOBALAPP_PACKAGE ).append( '/' );
sb.append( GLOBALAPP_CLASSNAME );
String basePath = sb.toString();
@@ -740,12 +741,22 @@
return null;
}
-
- public static boolean annotationsAreEqual( AnnotationMirror a1,
AnnotationMirror a2 )
+ public static boolean annotationsAreEqual( AnnotationMirror a1,
AnnotationMirror a2,
+ AnnotationProcessorEnvironment
env )
{
assert a1 != null;
if ( a2 == null ) return false;
+ //
+ // TODO: This entire method is a workaround for a bug in APT where an
annotation does not equal itelf.
+ // If this behavior changes, we want to rely on equals(), not this
deep comparison, which is more expensive
+ // and wrong if the two annotations 'look' exactly the same.
+ //
+ if ( Boolean.parseBoolean( env.getOptions().get(
USE_EQUALS_TO_COMPARE_ANNOTATIONS_ATTR ) ) )
+ {
+ return a1.equals( a2 );
+ }
+
Map< AnnotationTypeElementDeclaration, AnnotationValue > vals1 =
a1.getElementValues();
Map< AnnotationTypeElementDeclaration, AnnotationValue > vals2 =
a2.getElementValues();
@@ -780,7 +791,7 @@
if ( o1 instanceof AnnotationMirror )
{
if ( ! ( o2 instanceof AnnotationMirror ) ) return
false;
- if ( ! annotationsAreEqual( ( AnnotationMirror ) o1, (
AnnotationMirror ) o2 ) ) return false;
+ if ( ! annotationsAreEqual( ( AnnotationMirror ) o1, (
AnnotationMirror ) o2, env ) ) return false;
}
else
{
@@ -791,7 +802,7 @@
else if ( val1 instanceof AnnotationMirror )
{
if ( ! ( val2 instanceof AnnotationMirror ) ) return false;
- if ( ! annotationsAreEqual( ( AnnotationMirror ) val1, (
AnnotationMirror ) val2 ) ) return false;
+ if ( ! annotationsAreEqual( ( AnnotationMirror ) val1, (
AnnotationMirror ) val2, env ) ) return false;
}
else if ( ! val1.equals( val2 ) )
{
Modified:
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/JpfLanguageConstants.java
==============================================================================
---
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/JpfLanguageConstants.java
(original)
+++
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/JpfLanguageConstants.java
Wed Oct 6 13:36:07 2004
@@ -61,14 +61,14 @@
public static final String JSP_FILE_EXTENSION = "jsp";
public static final String XJSP_FILE_EXTENSION = "jspx";
public static final String ACTION_EXTENSION = "do";
- public static final String JPF_FILE_EXTENSION_DOT = "." +
JPF_FILE_EXTENSION;
- public static final String ACTION_EXTENSION_DOT = "." + ACTION_EXTENSION;
- public static final String JAVA_FILE_EXTENSION_DOT = "." +
JAVA_FILE_EXTENSION;
- public static final String FACES_BACKING_FILE_EXTENSION_DOT = "." +
FACES_BACKING_FILE_EXTENSION;
+ public static final String JPF_FILE_EXTENSION_DOT = '.' +
JPF_FILE_EXTENSION;
+ public static final String ACTION_EXTENSION_DOT = '.' + ACTION_EXTENSION;
+ public static final String JAVA_FILE_EXTENSION_DOT = '.' +
JAVA_FILE_EXTENSION;
+ public static final String FACES_BACKING_FILE_EXTENSION_DOT = '.' +
FACES_BACKING_FILE_EXTENSION;
public static final String SHARED_FLOW_FILE_EXTENSION = "jpfs";
public static final String GLOBALAPP_FILE_EXTENSION = "app";
- public static final String GLOBALAPP_FILE_EXTENSION_DOT = "." +
GLOBALAPP_FILE_EXTENSION;
- public static final String SHARED_FLOW_FILE_EXTENSION_DOT = "." +
SHARED_FLOW_FILE_EXTENSION;
+ public static final String GLOBALAPP_FILE_EXTENSION_DOT = '.' +
GLOBALAPP_FILE_EXTENSION;
+ public static final String SHARED_FLOW_FILE_EXTENSION_DOT = '.' +
SHARED_FLOW_FILE_EXTENSION;
public static final String SHARED_FLOW_CLASSNAME = "SharedFlowController";
public static final String FLOWCONTROLLER_BASE_CLASS = PAGEFLOW_PACKAGE +
".FlowController";
public static final String JPF_BASE_CLASS = PAGEFLOW_PACKAGE +
".PageFlowController";
@@ -79,11 +79,13 @@
public static final String GLOBALAPP_BASE_CLASS = PAGEFLOW_PACKAGE +
".GlobalApp";
public static final String GLOBALAPP_PACKAGE = "global";
public static final String GLOBALAPP_CLASSNAME = "Global";
- public static final String GLOBALAPP_FULL_CLASSNAME = GLOBALAPP_PACKAGE +
"." + GLOBALAPP_CLASSNAME;
+ public static final String GLOBALAPP_FULL_CLASSNAME = GLOBALAPP_PACKAGE +
'.' + GLOBALAPP_CLASSNAME;
public static final String WEBINF_DIR_NAME = "WEB-INF";
- public static final String WEBINF_SRC_DIR = "/" + WEBINF_DIR_NAME + "/src";
- public static final String GLOBALAPP_URI =
- WEBINF_SRC_DIR + '/' + GLOBALAPP_FULL_CLASSNAME.replace( '.', '/'
) + GLOBALAPP_FILE_EXTENSION_DOT;
+ public static final String WEBINF_SRC_PATH = '/' + WEBINF_DIR_NAME +
"/src";
+ public static final String WEBINF_SRC_DIR = WEBINF_DIR_NAME +
File.separatorChar + "src";
+ public static final String GLOBALAPP_PARENT_PATH = WEBINF_SRC_PATH + '/' +
GLOBALAPP_PACKAGE;
+ public static final String GLOBALAPP_SOURCE_NAME = GLOBALAPP_CLASSNAME +
GLOBALAPP_FILE_EXTENSION_DOT;
+ public static final String GLOBALAPP_URI = GLOBALAPP_PARENT_PATH + '/' +
GLOBALAPP_SOURCE_NAME;
public static final String TMP_SRC_DIR = "WEB-INF" + File.separatorChar +
".tmpbeansrc" + File.separatorChar;
public static final String ANNOTATION_QUALIFIER = PAGEFLOW_PACKAGE +
".annotations.Jpf.";
public static final String ANNOTATION_INTERFACE_PREFIX = "Jpf.";
@@ -200,7 +202,7 @@
public static final String ARRAY_TYPE_SUFFIX = "[]";
public static final String GETTER_PREFIX = "get";
- public static final String PAGEFLOW_RUNTIME_JAR = "/" + WEBINF_DIR_NAME +
"/lib/beehive-netui-pageflow.jar";
+ public static final String PAGEFLOW_RUNTIME_JAR = '/' + WEBINF_DIR_NAME +
"/lib/beehive-netui-pageflow.jar";
public static final String RUNTIME_VERSION_ATTRIBUTE =
"PageFlow-Runtime-Version";
public static final String VERSION_8_SP2_STRING = "2";
Modified:
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/PageFlowChecker.java
==============================================================================
---
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/PageFlowChecker.java
(original)
+++
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/PageFlowChecker.java
Wed Oct 6 13:36:07 2004
@@ -223,9 +223,9 @@
//
// We support .jpf in WEB-INF/src.
//
- if ( expectedPackage.startsWith( WEBINF_SRC_DIR ) )
+ if ( expectedPackage.startsWith( WEBINF_SRC_PATH ) )
{
- expectedPackage = expectedPackage.substring(
WEBINF_SRC_DIR.length() );
+ expectedPackage = expectedPackage.substring(
WEBINF_SRC_PATH.length() );
}
assert expectedPackage.length() != 1 : expectedPackage;
@@ -248,7 +248,7 @@
//
// Make sure every .jpf has a begin action.
//
- if ( ! WebappPathOrActionType.actionExists( BEGIN_ACTION_NAME,
jpfClass, null ) )
+ if ( ! WebappPathOrActionType.actionExists( BEGIN_ACTION_NAME,
jpfClass, null, getEnv() ) )
{
getDiagnostics().addError( jpfClass, "error.no-begin-action" );
}
Modified:
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/SharedFlowChecker.java
==============================================================================
---
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/SharedFlowChecker.java
(original)
+++
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/SharedFlowChecker.java
Wed Oct 6 13:36:07 2004
@@ -62,6 +62,12 @@
{
getDiagnostics().addError( jclass, "error.wrong-package",
GLOBALAPP_PACKAGE );
}
+
+ if ( ! jclass.getPosition().file().getPath().contains(
WEBINF_SRC_DIR ) )
+ {
+ getDiagnostics().addError( jclass,
"error.global-app-wrong-dir",
+ GLOBALAPP_SOURCE_NAME,
GLOBALAPP_PARENT_PATH );
+ }
}
}
Modified:
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/ForwardGrammar.java
==============================================================================
---
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/ForwardGrammar.java
(original)
+++
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/ForwardGrammar.java
Wed Oct 6 13:36:07 2004
@@ -125,7 +125,7 @@
{
if ( ! CompilerUtils.isInNestedPageFlow( classMember ) )
{
- addError( classMember, "error.only-valid-in-nested", new
Object[]{ valueName } );
+ addError( value, "error.only-valid-in-nested", new Object[]{
valueName } );
}
}
Modified:
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/MessageResourcesGrammar.java
==============================================================================
---
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/MessageResourcesGrammar.java
(original)
+++
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/MessageResourcesGrammar.java
Wed Oct 6 13:36:07 2004
@@ -78,7 +78,7 @@
for ( AnnotationMirror peerAnnotation : peerAnnotations )
{
- if ( ! CompilerUtils.annotationsAreEqual( annotation,
peerAnnotation )
+ if ( ! CompilerUtils.annotationsAreEqual( annotation,
peerAnnotation, getEnv() )
&& CompilerUtils.getString( peerAnnotation,
BUNDLE_KEY_ATTR, false ).length() == 0 )
{
addError( annotation,
"error.multiple-default-message-resources", BUNDLE_KEY_ATTR );
Modified:
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/RaiseActionGrammar.java
==============================================================================
---
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/RaiseActionGrammar.java
(original)
+++
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/RaiseActionGrammar.java
Wed Oct 6 13:36:07 2004
@@ -60,7 +60,7 @@
{
String action = ( String ) member.getValue();
- if ( _jpfClass != null && ! WebappPathOrActionType.actionExists(
action, _jpfClass, null ) )
+ if ( _jpfClass != null && ! WebappPathOrActionType.actionExists(
action, _jpfClass, null, getEnv() ) )
{
getDiagnostics().addWarning( member, "warning.no-such-action",
action,
CompilerUtils.getOriginalFile(
_jpfClass ) );
Modified:
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/SimpleActionGrammar.java
==============================================================================
---
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/SimpleActionGrammar.java
(original)
+++
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/SimpleActionGrammar.java
Wed Oct 6 13:36:07 2004
@@ -71,7 +71,7 @@
{
String name = CompilerUtils.getString( annotation, NAME_ATTR, false );
- if ( WebappPathOrActionType.actionExists( name,
CompilerUtils.getOuterClass( classMember ), annotation ) )
+ if ( WebappPathOrActionType.actionExists( name,
CompilerUtils.getOuterClass( classMember ), annotation, getEnv() ) )
{
addError( annotation, "error.duplicate-action", new Object[]{ name
} );
}
Modified:
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/UniqueValueType.java
==============================================================================
---
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/UniqueValueType.java
(original)
+++
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/UniqueValueType.java
Wed Oct 6 13:36:07 2004
@@ -116,7 +116,7 @@
for ( AnnotationMirror annotation : annotationsToCheck )
{
- if ( ! CompilerUtils.annotationsAreEqual( annotation,
parentAnnotation ) )
+ if ( ! CompilerUtils.annotationsAreEqual( annotation,
parentAnnotation, getEnv() ) )
{
AnnotationValue valueToCheck =
CompilerUtils.getAnnotationValue( annotation,
memberName, _checkDefaultValues );
Modified:
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/WebappPathOrActionType.java
==============================================================================
---
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/WebappPathOrActionType.java
(original)
+++
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/WebappPathOrActionType.java
Wed Oct 6 13:36:07 2004
@@ -26,6 +26,7 @@
import com.sun.mirror.declaration.TypeDeclaration;
import com.sun.mirror.declaration.AnnotationTypeElementDeclaration;
import com.sun.mirror.declaration.MethodDeclaration;
+import com.sun.mirror.apt.AnnotationProcessorEnvironment;
import java.util.Collection;
import java.util.List;
@@ -51,7 +52,7 @@
{
int extensionPos = stringValue.lastIndexOf(
ACTION_EXTENSION_DOT );
String actionMethodName = stringValue.substring( 0,
extensionPos );
- boolean foundIt = actionExists( actionMethodName, outerType,
null );
+ boolean foundIt = actionExists( actionMethodName, outerType,
null, getEnv() );
if ( ! foundIt )
{
@@ -60,7 +61,7 @@
if ( sharedFlowTypeHierarchy != null &&
sharedFlowTypeHierarchy.size() > 0 )
{
- foundIt = actionExists( actionMethodName,
sharedFlowTypeHierarchy.get( 0 ), null );
+ foundIt = actionExists( actionMethodName,
sharedFlowTypeHierarchy.get( 0 ), null, getEnv() );
}
}
@@ -74,7 +75,8 @@
return super.onCheck( valueDecl, value, parentAnnotations, classMember
);
}
- public static boolean actionExists( String actionName, TypeDeclaration
type, AnnotationMirror annotationToIgnore )
+ public static boolean actionExists( String actionName, TypeDeclaration
type, AnnotationMirror annotationToIgnore,
+ AnnotationProcessorEnvironment env )
{
//
// First look through the action methods.
@@ -106,7 +108,8 @@
{
String name = CompilerUtils.getString( ann, NAME_ATTR,
false );
- if ( actionName.equals( name ) && !
CompilerUtils.annotationsAreEqual( ann, annotationToIgnore ) )
+ if ( actionName.equals( name )
+ && ! CompilerUtils.annotationsAreEqual( ann,
annotationToIgnore, env ) )
{
return true;
}
Modified:
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/WebappPathType.java
==============================================================================
---
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/WebappPathType.java
(original)
+++
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/WebappPathType.java
Wed Oct 6 13:36:07 2004
@@ -171,9 +171,9 @@
{
jpfParentRelativePath = jpfParentRelativePath.replace(
'\\', '/' );
- if ( jpfParentRelativePath.startsWith( WEBINF_SRC_DIR ) )
+ if ( jpfParentRelativePath.startsWith( WEBINF_SRC_PATH ) )
{
- jpfParentRelativePath =
jpfParentRelativePath.substring( WEBINF_SRC_DIR.length() );
+ jpfParentRelativePath =
jpfParentRelativePath.substring( WEBINF_SRC_PATH.length() );
}
}
Modified:
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowActionServlet.java
==============================================================================
---
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowActionServlet.java
(original)
+++
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowActionServlet.java
Wed Oct 6 13:36:07 2004
@@ -21,6 +21,7 @@
import javax.servlet.ServletException;
import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
import java.io.Serializable;
@@ -103,10 +104,13 @@
super.init( config );
//
- // Ensure that PageFlowContextListener gets to do its initializations,
even if it's not registered
- // in web.xml.
+ // Ensure that PageFlowContextListener gets to do its initializations,
even if it's not registered in web.xml.
//
- PageFlowContextListener.performInitializations(
config.getServletContext() );
+ ServletContext servletContext = config.getServletContext();
+ if ( ! PageFlowContextListener.isInit( servletContext ) )
+ {
+ PageFlowContextListener.performInitializations( servletContext );
+ }
}
/**
Modified:
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowContextListener.java
==============================================================================
---
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowContextListener.java
(original)
+++
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowContextListener.java
Wed Oct 6 13:36:07 2004
@@ -23,6 +23,7 @@
import org.apache.beehive.netui.pageflow.util.UrlTemplateDescriptor;
import org.apache.beehive.netui.pageflow.internal.ContextCache;
import org.apache.beehive.netui.pageflow.internal.InternalUtils;
+import org.apache.beehive.netui.pageflow.internal.InternalConstants;
import org.apache.beehive.netui.util.config.ConfigUtil;
import org.apache.beehive.netui.util.config.ConfigInitializationException;
import org.apache.beehive.netui.util.logging.Logger;
@@ -42,6 +43,8 @@
public class PageFlowContextListener implements ServletContextListener
{
private static final String CONFIG_FILE = "/WEB-INF/netui-config.xml";
+ private static final String ALREADY_INIT_ATTR =
InternalConstants.ATTR_PREFIX + "contextInit";
+
private static final Logger _log = Logger.getInstance(
PageFlowContextListener.class );
@@ -54,8 +57,15 @@
{
}
+ static boolean isInit( ServletContext servletContext )
+ {
+ return servletContext.getAttribute( ALREADY_INIT_ATTR ) != null;
+ }
+
static void performInitializations( ServletContext servletContext )
{
+ servletContext.setAttribute( ALREADY_INIT_ATTR, Boolean.TRUE );
+
//
// Callback to the server adapter.
//