You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by hl...@apache.org on 2005/06/22 15:36:47 UTC
cvs commit: jakarta-tapestry/annotations/src/java/org/apache/tapestry/annotations InjectMeta.java InjectScriptAnnotationWorker.java InjectMetaAnnotationWorker.java InjectScript.java
hlship 2005/06/22 06:36:47
Modified: annotations/src/test/org/apache/tapestry/annotations
AnnotatedPage.java
Added: annotations/src/test/org/apache/tapestry/annotations
TestSimpleAnnotationWorkers.java
annotations/src/java/org/apache/tapestry/annotations
InjectMeta.java InjectScriptAnnotationWorker.java
InjectMetaAnnotationWorker.java InjectScript.java
Removed: annotations/src/test/org/apache/tapestry/annotations
TestInjectPageAnnotationWorker.java
Log:
Add InjectMeta and InjectScript annotations.
Revision Changes Path
1.8 +10 -3 jakarta-tapestry/annotations/src/test/org/apache/tapestry/annotations/AnnotatedPage.java
Index: AnnotatedPage.java
===================================================================
RCS file: /home/cvs/jakarta-tapestry/annotations/src/test/org/apache/tapestry/annotations/AnnotatedPage.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- AnnotatedPage.java 22 Jun 2005 12:57:44 -0000 1.7
+++ AnnotatedPage.java 22 Jun 2005 13:36:45 -0000 1.8
@@ -21,6 +21,7 @@
import org.apache.tapestry.IAsset;
import org.apache.tapestry.IComponent;
import org.apache.tapestry.IPage;
+import org.apache.tapestry.IScript;
import org.apache.tapestry.form.Checkbox;
import org.apache.tapestry.form.TextField;
import org.apache.tapestry.html.BasePage;
@@ -104,11 +105,11 @@
@Component(type = "Conditional", bindings =
{ "condition=message", "element=div" })
public abstract IComponent getComponentWithBindings();
-
+
@Component(type = "TextField", bindings =
{ "value = email", "displayName = message:email-label" })
- public abstract IComponent getWhitespace();
-
+ public abstract IComponent getWhitespace();
+
@Message
public abstract String noArgsMessage();
@@ -126,4 +127,10 @@
@Message
public abstract String getLikeGetter();
+
+ @InjectMeta("fred")
+ public abstract String getMetaFred();
+
+ @InjectScript("foo.script")
+ public abstract IScript getScript();
}
1.1 jakarta-tapestry/annotations/src/test/org/apache/tapestry/annotations/TestSimpleAnnotationWorkers.java
Index: TestSimpleAnnotationWorkers.java
===================================================================
// 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.
package org.apache.tapestry.annotations;
import java.lang.reflect.Method;
import org.apache.tapestry.enhance.EnhancementOperation;
import org.apache.tapestry.spec.ComponentSpecification;
import org.apache.tapestry.spec.IComponentSpecification;
import org.apache.tapestry.spec.InjectSpecification;
/**
* Test for the "simple" annotation workers, that collect basic information and update the component
* specification. {@link org.apache.tapestry.annotations.InjectPageAnnotationWorker}.
*
* @author Howard Lewis Ship
* @since 4.0
*/
public class TestSimpleAnnotationWorkers extends BaseAnnotationTestCase
{
public void testInjectPage()
{
IComponentSpecification spec = execute(new InjectPageAnnotationWorker(), "getMyPage");
InjectSpecification is = (InjectSpecification) spec.getInjectSpecifications().get(0);
assertEquals("myPage", is.getProperty());
assertEquals("page", is.getType());
assertEquals("SomePageName", is.getObject());
assertNull(is.getLocation());
}
public void testInjectMeta()
{
IComponentSpecification spec = execute(new InjectMetaAnnotationWorker(), "getMetaFred");
InjectSpecification is = (InjectSpecification) spec.getInjectSpecifications().get(0);
assertEquals("metaFred", is.getProperty());
assertEquals("meta", is.getType());
assertEquals("fred", is.getObject());
assertNull(is.getLocation());
}
public void testInjectScript()
{
IComponentSpecification spec = execute(new InjectScriptAnnotationWorker(), "getScript");
InjectSpecification is = (InjectSpecification) spec.getInjectSpecifications().get(0);
assertEquals("script", is.getProperty());
assertEquals("script", is.getType());
assertEquals("foo.script", is.getObject());
assertNull(is.getLocation());
}
private IComponentSpecification execute(MethodAnnotationEnhancementWorker worker,
String methodName)
{
EnhancementOperation op = newOp();
IComponentSpecification spec = new ComponentSpecification();
Method method = findMethod(AnnotatedPage.class, methodName);
replayControls();
worker.performEnhancement(op, spec, method);
verifyControls();
return spec;
}
}
1.1 jakarta-tapestry/annotations/src/java/org/apache/tapestry/annotations/InjectMeta.java
Index: InjectMeta.java
===================================================================
// 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.
package org.apache.tapestry.annotations;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Creates an {@link org.apache.tapestry.spec.InjectSpecification} for a <meta> data value,
* and adds it to the {@link org.apache.tapestry.spec.IComponentSpecification}.
*
* @author Howard Lewis Ship
* @since 4.0
*/
@Target(
{ ElementType.METHOD })
@Retention(RetentionPolicy.RUNTIME)
public @interface InjectMeta {
/**
* The meta key to inject.
*/
String value();
}
1.1 jakarta-tapestry/annotations/src/java/org/apache/tapestry/annotations/InjectScriptAnnotationWorker.java
Index: InjectScriptAnnotationWorker.java
===================================================================
// 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.
package org.apache.tapestry.annotations;
import java.lang.reflect.Method;
import org.apache.tapestry.enhance.EnhancementOperation;
import org.apache.tapestry.spec.IComponentSpecification;
import org.apache.tapestry.spec.InjectSpecification;
import org.apache.tapestry.spec.InjectSpecificationImpl;
/**
* @author Howard Lewis Ship
* @since 4.0
*/
public class InjectScriptAnnotationWorker implements MethodAnnotationEnhancementWorker
{
public void performEnhancement(EnhancementOperation op, IComponentSpecification spec,
Method method)
{
InjectScript annotation = method.getAnnotation(InjectScript.class);
String propertyName = AnnotationUtils.getPropertyName(method);
InjectSpecification is = new InjectSpecificationImpl();
is.setProperty(propertyName);
is.setType("script");
is.setObject(annotation.value());
spec.addInjectSpecification(is);
}
}
1.1 jakarta-tapestry/annotations/src/java/org/apache/tapestry/annotations/InjectMetaAnnotationWorker.java
Index: InjectMetaAnnotationWorker.java
===================================================================
// 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.
package org.apache.tapestry.annotations;
import java.lang.reflect.Method;
import org.apache.tapestry.enhance.EnhanceUtils;
import org.apache.tapestry.enhance.EnhancementOperation;
import org.apache.tapestry.spec.IComponentSpecification;
import org.apache.tapestry.spec.InjectSpecification;
import org.apache.tapestry.spec.InjectSpecificationImpl;
/**
* @author Howard Lewis Ship
* @since 4.0
*/
public class InjectMetaAnnotationWorker implements MethodAnnotationEnhancementWorker
{
public void performEnhancement(EnhancementOperation op, IComponentSpecification spec,
Method method)
{
String propertyName = AnnotationUtils.getPropertyName(method);
InjectMeta annotation = method.getAnnotation(InjectMeta.class);
InjectSpecification is = new InjectSpecificationImpl();
is.setProperty(propertyName);
is.setType("meta");
is.setObject(annotation.value());
spec.addInjectSpecification(is);
}
}
1.1 jakarta-tapestry/annotations/src/java/org/apache/tapestry/annotations/InjectScript.java
Index: InjectScript.java
===================================================================
// 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.
package org.apache.tapestry.annotations;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Injects a compiled {@link org.apache.tapestry.IScript}.
*
* @author Howard Lewis Ship
* @since 4.0
*/
@Target(
{ ElementType.METHOD })
@Retention(RetentionPolicy.RUNTIME)
public @interface InjectScript {
/**
* The path, relative to the specification (if it exists), or the template (if it does not),j of
* the script file.
*/
String value();
}
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org