You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beehive.apache.org by ke...@apache.org on 2005/07/21 20:25:10 UTC
svn commit: r220161 - in /incubator/beehive/trunk/controls:
src/runtime/org/apache/beehive/controls/runtime/generator/
test/src/auxilaries/org/apache/beehive/controls/test/controls/interceptor/
test/src/controls/org/apache/beehive/controls/test/control...
Author: kentam
Date: Thu Jul 21 11:25:06 2005
New Revision: 220161
URL: http://svn.apache.org/viewcvs?rev=220161&view=rev
Log:
Fix BEEHIVE-850 (Interceptor infrastructure broken when used on overloaded control methods):
Interceptor field naming convention now includes method order index to support overloaded operations (this was being done for events but not for operations). Added a code-gen DRT.
Added:
incubator/beehive/trunk/controls/test/src/auxilaries/org/apache/beehive/controls/test/controls/interceptor/
incubator/beehive/trunk/controls/test/src/auxilaries/org/apache/beehive/controls/test/controls/interceptor/SampleInterceptor.java (with props)
incubator/beehive/trunk/controls/test/src/auxilaries/org/apache/beehive/controls/test/controls/interceptor/SampleInterceptorAnnotation.java (with props)
incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/interceptor/
incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/interceptor/HelloIntercepted.java (with props)
incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/interceptor/HelloInterceptedImpl.jcs (with props)
Modified:
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ControlBean.vm
Modified: incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ControlBean.vm
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ControlBean.vm?rev=220161&r1=220160&r2=220161&view=diff
==============================================================================
--- incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ControlBean.vm (original)
+++ incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ControlBean.vm Thu Jul 21 11:25:06 2005
@@ -119,7 +119,7 @@
#if ($operation.interceptorServiceNames.size() == 0)
preInvoke(${operation.methodField}, argArray);
#else
- preInvoke(${operation.methodField}, argArray, _${operation.name}Interceptors);
+ preInvoke(${operation.methodField}, argArray, ${operation.methodField}Interceptors);
#end
##
@@ -176,7 +176,7 @@
#if ($operation.interceptorServiceNames.size() == 0)
postInvoke(${operation.methodField}, argArray, rv, thrown);
#else
- postInvoke(${operation.methodField}, argArray, rv, thrown, _${operation.name}Interceptors, pivotedInterceptor);
+ postInvoke(${operation.methodField}, argArray, rv, thrown, ${operation.methodField}Interceptors, pivotedInterceptor);
#end
}
#if ($returnType != "void")
@@ -514,12 +514,12 @@
org.apache.beehive.controls.runtime.bean.ControlBean.enforceVersionRequired("${intf.className}", versionPresent, versionRequired);
#end
##
-## This macro declares the interceptor arrays for operations
+## This macro declares the interceptor arrays for operations and eventsets
##
#macro (declareMethodInterceptors)
#foreach ($operation in $intf.operations)
#if ($operation.interceptorServiceNames.size() != 0)
- private static String[] _${operation.name}Interceptors = ${operation.interceptorDecl};
+ private static String[] ${operation.methodField}Interceptors = ${operation.interceptorDecl};
#end
#end
@@ -538,7 +538,7 @@
#macro (prioritizeInterceptors)
#foreach ($operation in $intf.operations)
#if ($operation.interceptorServiceNames.size() != 0)
- _${operation.name}Interceptors = org.apache.beehive.controls.runtime.bean.ControlBeanContext.prioritizeInterceptors( _${operation.name}Interceptors );
+ ${operation.methodField}Interceptors = org.apache.beehive.controls.runtime.bean.ControlBeanContext.prioritizeInterceptors( ${operation.methodField}Interceptors );
#end
#end
#foreach ($eventSet in $intf.eventSets)
Added: incubator/beehive/trunk/controls/test/src/auxilaries/org/apache/beehive/controls/test/controls/interceptor/SampleInterceptor.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/controls/test/src/auxilaries/org/apache/beehive/controls/test/controls/interceptor/SampleInterceptor.java?rev=220161&view=auto
==============================================================================
--- incubator/beehive/trunk/controls/test/src/auxilaries/org/apache/beehive/controls/test/controls/interceptor/SampleInterceptor.java (added)
+++ incubator/beehive/trunk/controls/test/src/auxilaries/org/apache/beehive/controls/test/controls/interceptor/SampleInterceptor.java Thu Jul 21 11:25:06 2005
@@ -0,0 +1,48 @@
+package org.apache.beehive.controls.test.controls.interceptor;
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Header:$
+ */
+
+import org.apache.beehive.controls.api.bean.ControlBean;
+import org.apache.beehive.controls.spi.svc.Interceptor;
+import org.apache.beehive.controls.spi.svc.InterceptorPivotException;
+import java.lang.reflect.Method;
+
+public class SampleInterceptor implements Interceptor
+{
+ /** Called before a control operation is invoked */
+ public void preInvoke( ControlBean cb, Method m, Object [] args)
+ throws InterceptorPivotException
+ {
+ }
+
+ /** Called after a control operation is invoked */
+ public void postInvoke( ControlBean cb, Method m, Object [] args, Object retval, Throwable t )
+ {
+ }
+
+ /** Called before a control event is fired (through a client proxy) */
+ public void preEvent( ControlBean cb, Class eventSet, Method m, Object [] args )
+ throws InterceptorPivotException
+ {
+ }
+
+ /** Called after a control event is fired (through a client proxy) */
+ public void postEvent( ControlBean cb, Class eventSet, Method m, Object [] args)
+ {
+ }
+}
Propchange: incubator/beehive/trunk/controls/test/src/auxilaries/org/apache/beehive/controls/test/controls/interceptor/SampleInterceptor.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/beehive/trunk/controls/test/src/auxilaries/org/apache/beehive/controls/test/controls/interceptor/SampleInterceptorAnnotation.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/controls/test/src/auxilaries/org/apache/beehive/controls/test/controls/interceptor/SampleInterceptorAnnotation.java?rev=220161&view=auto
==============================================================================
--- incubator/beehive/trunk/controls/test/src/auxilaries/org/apache/beehive/controls/test/controls/interceptor/SampleInterceptorAnnotation.java (added)
+++ incubator/beehive/trunk/controls/test/src/auxilaries/org/apache/beehive/controls/test/controls/interceptor/SampleInterceptorAnnotation.java Thu Jul 21 11:25:06 2005
@@ -0,0 +1,26 @@
+package org.apache.beehive.controls.test.controls.interceptor;
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Header:$
+ */
+
+import org.apache.beehive.controls.spi.svc.InterceptorAnnotation;
+
+@InterceptorAnnotation( service=SampleInterceptor.class )
+public @interface SampleInterceptorAnnotation
+{
+}
+
Propchange: incubator/beehive/trunk/controls/test/src/auxilaries/org/apache/beehive/controls/test/controls/interceptor/SampleInterceptorAnnotation.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/interceptor/HelloIntercepted.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/interceptor/HelloIntercepted.java?rev=220161&view=auto
==============================================================================
--- incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/interceptor/HelloIntercepted.java (added)
+++ incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/interceptor/HelloIntercepted.java Thu Jul 21 11:25:06 2005
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Header:$
+ */
+
+package org.apache.beehive.controls.test.controls.interceptor;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import org.apache.beehive.controls.api.bean.ControlInterface;
+import org.apache.beehive.controls.api.properties.PropertySet;
+
+/**
+ * Code-gen test for interceptors. Note that there is currently no
+ * runtime test for interceptors; this just tests that the code-gen
+ * path for interceptors results in compilable code.
+ */
+@ControlInterface
+public interface HelloIntercepted
+{
+ //
+ // A simple enumerated type used to customize the greeting by gender
+ //
+ public enum GenderType
+ {
+ NEUTRAL, MALE, FEMALE
+ }
+
+ public @interface Gender
+ {
+ GenderType value();
+ }
+
+ /**
+ * Declare a simple PropertySet, that allows the salutation used by the custom
+ * control to be customized.
+ */
+ @PropertySet
+ @Target( {ElementType.TYPE, ElementType.FIELD, ElementType.METHOD} )
+ @Retention(RetentionPolicy.RUNTIME)
+ public @interface Greeting
+ {
+ String salutation() default "Hello";
+ Gender gender() default @Gender(GenderType.NEUTRAL);
+ }
+
+ java.lang.String hello(java.lang.String name);
+
+ @SampleInterceptorAnnotation
+ java.lang.String lastVisitor();
+
+ @SampleInterceptorAnnotation
+ int visitorCount();
+
+ /**
+ * Test intereptor annotations on overloaded methods
+ */
+ @SampleInterceptorAnnotation
+ int visitorCount(java.lang.String name);
+}
Propchange: incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/interceptor/HelloIntercepted.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/interceptor/HelloInterceptedImpl.jcs
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/interceptor/HelloInterceptedImpl.jcs?rev=220161&view=auto
==============================================================================
--- incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/interceptor/HelloInterceptedImpl.jcs (added)
+++ incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/interceptor/HelloInterceptedImpl.jcs Thu Jul 21 11:25:06 2005
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Header:$
+ */
+
+package org.apache.beehive.controls.test.controls.interceptor;
+
+import java.lang.reflect.Method;
+
+import org.apache.beehive.controls.api.bean.ControlImplementation;
+import org.apache.beehive.controls.api.bean.Extensible;
+
+@ControlImplementation
+public class HelloInterceptedImpl implements HelloIntercepted, Extensible, java.io.Serializable
+{
+ public String _lastVisitor = "<none>";
+ int _visitorCount = 0;
+
+ public String hello(String name)
+ {
+ _lastVisitor = name;
+ _visitorCount++;
+ return "Hello, " + name;
+ }
+
+ public String lastVisitor()
+ {
+ return _lastVisitor;
+ }
+
+ public int visitorCount()
+ {
+ return _visitorCount;
+ }
+
+ public int visitorCount(String name)
+ {
+ return _visitorCount;
+ }
+
+ /**
+ * Implements the Extensible.invoke interface when a JCX-declared method is called
+ */
+ public Object invoke(Method method, Object [] args)
+ {
+ //
+ // To Be Implemented
+ //
+ return null;
+ }
+}
Propchange: incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/interceptor/HelloInterceptedImpl.jcs
------------------------------------------------------------------------------
svn:eol-style = native