Author: rich
Date: Thu Apr 14 17:26:25 2005
New Revision: 161371
URL: http://svn.apache.org/viewcvs?view=rev&rev=161371
Log:
Fixes for:
- http://issues.apache.org/jira/browse/BEEHIVE-128 : Switch from
java.net.URLEncoder/Decoder to org.apache.commons.codec.net.URLCodec for
- http://issues.apache.org/jira/browse/BEEHIVE-501 : Duplicate compiler
messages are created when compiling certain pageflows
tests: bvt in netui (WinXP)
BB: self (linux)
Modified:
incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/AnnotationGrammar.java
incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/AnnotationMemberType.java
incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/CompilerUtils.java
incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/grammar/CatchGrammar.java
incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/grammar/SimpleActionGrammar.java
incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/grammar/UniqueValueType.java
incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/typesystem/env/AnnotationProcessorEnvironment.java
incubator/beehive/trunk/netui/src/compiler-xdoclet/org/apache/beehive/netui/compiler/xdoclet/typesystem/impl/env/AnnotationProcessorEnvironmentImpl.java
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/typesystem/impl/env/AnnotationProcessorEnvironmentImpl.java
incubator/beehive/trunk/netui/src/scoping/build.xml
incubator/beehive/trunk/netui/src/scoping/org/apache/beehive/netui/pageflow/scoping/internal/ScopedRequestImpl.java
Modified:
incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/AnnotationGrammar.java
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/AnnotationGrammar.java?view=diff&r1=161370&r2=161371
==============================================================================
---
incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/AnnotationGrammar.java
(original)
+++
incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/AnnotationGrammar.java
Thu Apr 14 17:26:25 2005
@@ -65,7 +65,7 @@
_requiredRuntimeVersion = requiredRuntimeVersion;
}
- public AnnotationProcessorEnvironment getEnv()
+ public final AnnotationProcessorEnvironment getEnv()
{
return _env;
}
Modified:
incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/AnnotationMemberType.java
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/AnnotationMemberType.java?view=diff&r1=161370&r2=161371
==============================================================================
---
incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/AnnotationMemberType.java
(original)
+++
incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/AnnotationMemberType.java
Thu Apr 14 17:26:25 2005
@@ -31,6 +31,7 @@
/** set if this entire attribute type requires a particular runtime
version. */
private String _requiredRuntimeVersion = null;
private AnnotationGrammar _parentGrammar;
+ private AnnotationMemberType _nextInChain;
public AnnotationMemberType( String requiredRuntimeVersion,
AnnotationGrammar parentGrammar )
@@ -39,6 +40,13 @@
_parentGrammar = parentGrammar;
}
+ public AnnotationMemberType( String requiredRuntimeVersion,
AnnotationGrammar parentGrammar,
+ AnnotationMemberType nextInChain )
+ {
+ this( requiredRuntimeVersion, parentGrammar );
+ _nextInChain = nextInChain;
+ }
+
/**
* @return a result (any Object) that will be passed back to the parent
checker. May be null</code>.
*/
@@ -55,7 +63,13 @@
_requiredRuntimeVersion, value, diags,
"error.required-runtime-version-attribute",
new Object[]{ valueName, PAGEFLOW_RUNTIME_JAR } );
- return onCheck( valueDecl, value, parentAnnotations, classMember,
annotationArrayIndex ); // for derived classes
+ // for derived classes
+ Object retVal = onCheck( valueDecl, value, parentAnnotations,
classMember, annotationArrayIndex );
+ if ( _nextInChain != null )
+ {
+ return _nextInChain.check( valueDecl, value, parentAnnotations,
classMember, annotationArrayIndex );
+ }
+ return retVal;
}
/**
@@ -223,7 +237,7 @@
return _parentGrammar;
}
- protected AnnotationProcessorEnvironment getEnv()
+ protected final AnnotationProcessorEnvironment getEnv()
{
return _parentGrammar.getEnv();
}
Modified:
incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/CompilerUtils.java
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/CompilerUtils.java?view=diff&r1=161370&r2=161371
==============================================================================
---
incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/CompilerUtils.java
(original)
+++
incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/CompilerUtils.java
Thu Apr 14 17:26:25 2005
@@ -42,6 +42,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.HashMap;
public class CompilerUtils
@@ -762,6 +763,7 @@
{
private AnnotationProcessorEnvironment _env;
private boolean _useEqualsToCompareAnnotations;
+ private HashMap _attributes;
public ExtendedAnnotationProcessorEnvironment(
AnnotationProcessorEnvironment env,
boolean
useEqualsToCompareAnnotations )
@@ -804,28 +806,17 @@
{
return _env.getDeclarationsAnnotatedWith(
annotationTypeDeclaration );
}
-
- /*
- public Declarations getDeclarationUtils()
- {
- return _env.getDeclarationUtils();
- }
-
- public Types getTypeUtils()
- {
- return _env.getTypeUtils();
- }
-
- public void addListener( AnnotationProcessorListener
annotationProcessorListener )
+
+ public void setAttribute( String propertyName, Object value )
{
- _env.addListener( annotationProcessorListener );
+ if ( _attributes == null ) _attributes = new HashMap();
+ _attributes.put( propertyName, value );
}
-
- public void removeListener( AnnotationProcessorListener
annotationProcessorListener )
+
+ public Object getAttribute( String propertyName )
{
- _env.removeListener( annotationProcessorListener );
+ return _attributes != null ? _attributes.get( propertyName ) :
null;
}
- */
}
public static boolean annotationsAreEqual( AnnotationInstance a1,
AnnotationInstance a2, boolean allowExactDuplicates,
Modified:
incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/grammar/CatchGrammar.java
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/grammar/CatchGrammar.java?view=diff&r1=161370&r2=161371
==============================================================================
---
incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/grammar/CatchGrammar.java
(original)
+++
incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/grammar/CatchGrammar.java
Thu Apr 14 17:26:25 2005
@@ -56,7 +56,10 @@
_annotationRootName = annotationRootName; // the parent of the list
of @Jpf.Catch annotations.
addMemberType( METHOD_ATTR, new CatchTagMethodType() );
- addMemberType( TYPE_ATTR, new TypeNameType( THROWABLE_CLASS_NAME,
false, null, this ) );
+ AnnotationMemberType typeAttrType =
+ new UniqueValueType( CATCHES_ATTR, false, false, null, this,
+ new TypeNameType( THROWABLE_CLASS_NAME,
false, null, this ) );
+ addMemberType( TYPE_ATTR, typeAttrType );
addMemberType( PATH_ATTR, new ForwardToExternalPathType( new
WebappPathOrActionType( false, null, this, fcInfo ), null, this ) );
addMemberType( MESSAGE_ATTR, new AnnotationMemberType( null, this ) );
addMemberType( MESSAGE_KEY_ATTR, new AnnotationMemberType( null, this
) );
Modified:
incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/grammar/SimpleActionGrammar.java
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/grammar/SimpleActionGrammar.java?view=diff&r1=161370&r2=161371
==============================================================================
---
incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/grammar/SimpleActionGrammar.java
(original)
+++
incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/grammar/SimpleActionGrammar.java
Thu Apr 14 17:26:25 2005
@@ -80,7 +80,10 @@
TypeDeclaration outerClass = CompilerUtils.getOuterClass( classMember
);
if ( WebappPathOrActionType.actionExists( name, outerClass,
annotation, getEnv(), getFlowControllerInfo(), false ) )
{
- addError( annotation, "error.duplicate-action", new Object[]{ name
} );
+ if ( ! UniqueValueType.alreadyAddedErrorForValue( classMember,
annotation, name, getEnv() ) )
+ {
+ addError( annotation, "error.duplicate-action", new Object[]{
name } );
+ }
}
//
Modified:
incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/grammar/UniqueValueType.java
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/grammar/UniqueValueType.java?view=diff&r1=161370&r2=161371
==============================================================================
---
incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/grammar/UniqueValueType.java
(original)
+++
incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/grammar/UniqueValueType.java
Thu Apr 14 17:26:25 2005
@@ -24,8 +24,11 @@
import
org.apache.beehive.netui.compiler.typesystem.declaration.AnnotationTypeElementDeclaration;
import
org.apache.beehive.netui.compiler.typesystem.declaration.AnnotationValue;
import
org.apache.beehive.netui.compiler.typesystem.declaration.MemberDeclaration;
+import
org.apache.beehive.netui.compiler.typesystem.env.AnnotationProcessorEnvironment;
import java.util.List;
+import java.util.HashSet;
+import java.util.HashMap;
public class UniqueValueType
@@ -41,7 +44,14 @@
public UniqueValueType( String memberGroupName, boolean allowEmptyString,
boolean checkDefaultValues,
String requiredRuntimeVersion, AnnotationGrammar
parentGrammar )
{
- super( requiredRuntimeVersion, parentGrammar );
+ this( memberGroupName, allowEmptyString, checkDefaultValues,
requiredRuntimeVersion, parentGrammar, null );
+ }
+
+ public UniqueValueType( String memberGroupName, boolean allowEmptyString,
boolean checkDefaultValues,
+ String requiredRuntimeVersion, AnnotationGrammar
parentGrammar,
+ AnnotationMemberType nextInChain )
+ {
+ super( requiredRuntimeVersion, parentGrammar, nextInChain );
_allowEmptyString = allowEmptyString;
_memberGroupName = memberGroupName;
@@ -75,7 +85,8 @@
{
String valueName = valueDecl.getSimpleName();
AnnotationInstance parentAnnotation = parentAnnotations[
parentAnnotations.length - 1 ];
- checkForDuplicates( value, valueName, parentAnnotation,
classMember, memberGroup, false, annotationArrayIndex );
+ checkForDuplicates( value, valueName, parentAnnotation,
classMember, memberGroup, false,
+ annotationArrayIndex );
//
// Get a list of additional annotations (presumably not from the
this one's parent) to check.
@@ -133,6 +144,8 @@
if ( valueToCheck != null && ! valueToCheck.equals( member )
&& valueToCheck.getValue().equals( memberValue ) )
{
+ if ( alreadyAddedErrorForValue( classMember,
parentAnnotation, memberValue, getEnv() ) ) return;
+
String annotationName =
CompilerUtils.getDeclaration(
parentAnnotation.getAnnotationType() ).getSimpleName();
@@ -154,9 +167,45 @@
addError( member, "error.duplicate-attr",
new Object[]{ annotationName, memberName,
memberValue } );
}
+
+ return;
}
}
}
+ }
+
+ static boolean alreadyAddedErrorForValue( MemberDeclaration classMember,
AnnotationInstance parentAnn,
+ Object memberValue,
AnnotationProcessorEnvironment env )
+ {
+ // Map of String class-member-name ->
+ // [ Map of String annotation name -> Set of values for which
errors were added ]
+ HashMap errorsAddedRootMap = ( HashMap ) env.getAttribute(
"uniqueValueErrors" );
+ if ( errorsAddedRootMap == null )
+ {
+ errorsAddedRootMap = new HashMap();
+ env.setAttribute( "uniqueValueErrors", errorsAddedRootMap );
+ }
+
+ String classMemberName = classMember.getSimpleName();
+ HashMap errorsAddedByAnnotation = ( HashMap ) errorsAddedRootMap.get(
classMemberName );
+ if ( errorsAddedByAnnotation == null )
+ {
+ errorsAddedByAnnotation = new HashMap();
+ errorsAddedRootMap.put( classMemberName, errorsAddedByAnnotation );
+ }
+
+ String parentAnnName =
parentAnn.getAnnotationType().getAnnotationTypeDeclaration().getQualifiedName();
+ HashSet errorsAdded = ( HashSet ) errorsAddedByAnnotation.get(
parentAnnName );
+ if ( errorsAdded == null )
+ {
+ errorsAdded = new HashSet();
+ errorsAddedByAnnotation.put( parentAnnName, errorsAdded );
+ }
+
+ if ( errorsAdded.contains( memberValue ) ) return true;
+
+ errorsAdded.add( memberValue );
+ return false;
}
protected boolean allowExactDuplicates()
Modified:
incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/typesystem/env/AnnotationProcessorEnvironment.java
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/typesystem/env/AnnotationProcessorEnvironment.java?view=diff&r1=161370&r2=161371
==============================================================================
---
incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/typesystem/env/AnnotationProcessorEnvironment.java
(original)
+++
incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/typesystem/env/AnnotationProcessorEnvironment.java
Thu Apr 14 17:26:25 2005
@@ -38,15 +38,9 @@
TypeDeclaration getTypeDeclaration( String s );
- //TypeDeclaration[] getTypeDeclarations();
-
Declaration[] getDeclarationsAnnotatedWith( AnnotationTypeDeclaration
annotationTypeDeclaration );
-
- //Declarations getDeclarationUtils();
-
- //Types getTypeUtils();
-
- //void addListener( AnnotationProcessorListener
annotationProcessorListener );
-
- //void removeListener( AnnotationProcessorListener
annotationProcessorListener );
+
+ void setAttribute( String propertyName, Object value );
+
+ Object getAttribute( String propertyName );
}
Modified:
incubator/beehive/trunk/netui/src/compiler-xdoclet/org/apache/beehive/netui/compiler/xdoclet/typesystem/impl/env/AnnotationProcessorEnvironmentImpl.java
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/compiler-xdoclet/org/apache/beehive/netui/compiler/xdoclet/typesystem/impl/env/AnnotationProcessorEnvironmentImpl.java?view=diff&r1=161370&r2=161371
==============================================================================
---
incubator/beehive/trunk/netui/src/compiler-xdoclet/org/apache/beehive/netui/compiler/xdoclet/typesystem/impl/env/AnnotationProcessorEnvironmentImpl.java
(original)
+++
incubator/beehive/trunk/netui/src/compiler-xdoclet/org/apache/beehive/netui/compiler/xdoclet/typesystem/impl/env/AnnotationProcessorEnvironmentImpl.java
Thu Apr 14 17:26:25 2005
@@ -34,6 +34,7 @@
import xjavadoc.XJavaDoc;
import java.util.Map;
+import java.util.HashMap;
public class AnnotationProcessorEnvironmentImpl
extends DelegatingImpl
@@ -43,6 +44,7 @@
private NetuiSubTask _subtask;
private SourceClass _sourceClass;
+ private HashMap _attributes;
protected AnnotationProcessorEnvironmentImpl( DocletContext delegate,
NetuiSubTask subtask, SourceClass sourceClass )
{
@@ -125,5 +127,16 @@
protected final XJavaDoc getXJavaDoc()
{
return _subtask.getXJavaDoc();
+ }
+
+ public void setAttribute( String propertyName, Object value )
+ {
+ if ( _attributes == null ) _attributes = new HashMap();
+ _attributes.put( propertyName, value );
+ }
+
+ public Object getAttribute( String propertyName )
+ {
+ return _attributes != null ? _attributes.get( propertyName ) : null;
}
}
Modified:
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/typesystem/impl/env/AnnotationProcessorEnvironmentImpl.java
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/typesystem/impl/env/AnnotationProcessorEnvironmentImpl.java?view=diff&r1=161370&r2=161371
==============================================================================
---
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/typesystem/impl/env/AnnotationProcessorEnvironmentImpl.java
(original)
+++
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/typesystem/impl/env/AnnotationProcessorEnvironmentImpl.java
Thu Apr 14 17:26:25 2005
@@ -19,7 +19,6 @@
import
org.apache.beehive.netui.compiler.typesystem.declaration.AnnotationTypeDeclaration;
import org.apache.beehive.netui.compiler.typesystem.declaration.Declaration;
-import
org.apache.beehive.netui.compiler.typesystem.declaration.PackageDeclaration;
import
org.apache.beehive.netui.compiler.typesystem.declaration.TypeDeclaration;
import
org.apache.beehive.netui.compiler.typesystem.env.AnnotationProcessorEnvironment;
import org.apache.beehive.netui.compiler.typesystem.env.Filer;
@@ -30,12 +29,14 @@
import java.util.Collection;
import java.util.Map;
+import java.util.HashMap;
public class AnnotationProcessorEnvironmentImpl
extends DelegatingImpl
implements AnnotationProcessorEnvironment
{
private TypeDeclaration[] _specifiedTypeDeclarations;
+ private Map _attributes;
protected AnnotationProcessorEnvironmentImpl(
com.sun.mirror.apt.AnnotationProcessorEnvironment delegate )
{
@@ -80,13 +81,6 @@
return _specifiedTypeDeclarations;
}
- /*
- public PackageDeclaration getPackage( String s )
- {
- return WrapperFactory.get().getPackageDeclaration(
getDelegate().getPackage( s ) );
- }
- */
-
public TypeDeclaration getTypeDeclaration( String s )
{
return WrapperFactory.get().getTypeDeclaration(
getDelegate().getTypeDeclaration( s ) );
@@ -109,5 +103,16 @@
protected com.sun.mirror.apt.AnnotationProcessorEnvironment getDelegate()
{
return ( com.sun.mirror.apt.AnnotationProcessorEnvironment )
super.getDelegate();
+ }
+
+ public void setAttribute( String propertyName, Object value )
+ {
+ if ( _attributes == null ) _attributes = new HashMap();
+ _attributes.put( propertyName, value );
+ }
+
+ public Object getAttribute( String propertyName )
+ {
+ return _attributes != null ? _attributes.get( propertyName ) : null;
}
}
Modified: incubator/beehive/trunk/netui/src/scoping/build.xml
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/scoping/build.xml?view=diff&r1=161370&r2=161371
==============================================================================
--- incubator/beehive/trunk/netui/src/scoping/build.xml (original)
+++ incubator/beehive/trunk/netui/src/scoping/build.xml Thu Apr 14 17:26:25 2005
@@ -11,6 +11,7 @@
<path refid="servlet.dependency.path"/>
<path refid="log4j.dependency.path"/>
<path refid="struts11.dependency.path"/>
+ <path refid="commons-codec.dependency.path"/>
</path>
<target name="build">
Modified:
incubator/beehive/trunk/netui/src/scoping/org/apache/beehive/netui/pageflow/scoping/internal/ScopedRequestImpl.java
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/scoping/org/apache/beehive/netui/pageflow/scoping/internal/ScopedRequestImpl.java?view=diff&r1=161370&r2=161371
==============================================================================
---
incubator/beehive/trunk/netui/src/scoping/org/apache/beehive/netui/pageflow/scoping/internal/ScopedRequestImpl.java
(original)
+++
incubator/beehive/trunk/netui/src/scoping/org/apache/beehive/netui/pageflow/scoping/internal/ScopedRequestImpl.java
Thu Apr 14 17:26:25 2005
@@ -36,9 +36,10 @@
import java.util.Set;
import java.util.HashSet;
import java.io.UnsupportedEncodingException;
-import java.net.URLDecoder;
import org.apache.log4j.Logger;
+import org.apache.commons.codec.net.URLCodec;
+import org.apache.commons.codec.DecoderException;
/**
@@ -68,7 +69,8 @@
private static final String OUR_SESSION_ATTR = ATTR_PREFIX +
"scopedSession";
private static final String STORED_ATTRS_ATTR = ATTR_PREFIX +
"storedAttrs";
- private static final Logger logger = Logger.getLogger(
ScopedRequestImpl.class );
+ private static final Logger _log = Logger.getLogger(
ScopedRequestImpl.class );
+ private static final URLCodec URL_CODEC = new URLCodec();
public ScopedRequestImpl( HttpServletRequest req, String
overrideRequestURI, Object scopeKey,
@@ -132,11 +134,15 @@
try
{
if ( encoding == null ) encoding = "utf-8"; // TODO: is this a
safe assumption?
- servletPath = URLDecoder.decode( servletPath, encoding );
+ servletPath = URL_CODEC.decode( servletPath, encoding );
+ }
+ catch ( DecoderException e )
+ {
+ _log.error( "error decoding path " + servletPath, e );
}
catch ( UnsupportedEncodingException e )
{
- logger.error( "unsupported encoding " + encoding + " in request "
+ _requestURI, e );
+ _log.error( "unsupported encoding " + encoding + " while decoding
path " + servletPath, e );
}
_servletPath = ScopedServletUtils.normalizeURI( servletPath );