Author: craigmcc
Date: Mon Jun 26 22:45:25 2006
New Revision: 417348
URL: http://svn.apache.org/viewvc?rev=417348&view=rev
Log:
SHALE-191 -- Rename @Value to @Property (deprecating @Value)
Added:
struts/shale/trunk/shale-tiger/src/main/java/org/apache/shale/tiger/managed/Property.java
(with props)
Modified:
struts/shale/trunk/shale-tiger/src/main/java/org/apache/shale/tiger/faces/LifecycleListener.java
struts/shale/trunk/shale-tiger/src/main/java/org/apache/shale/tiger/managed/Value.java
struts/shale/trunk/shale-tiger/src/test/java/org/apache/shale/tiger/config/TestBean.java
Modified:
struts/shale/trunk/shale-tiger/src/main/java/org/apache/shale/tiger/faces/LifecycleListener.java
URL:
http://svn.apache.org/viewvc/struts/shale/trunk/shale-tiger/src/main/java/org/apache/shale/tiger/faces/LifecycleListener.java?rev=417348&r1=417347&r2=417348&view=diff
==============================================================================
---
struts/shale/trunk/shale-tiger/src/main/java/org/apache/shale/tiger/faces/LifecycleListener.java
(original)
+++
struts/shale/trunk/shale-tiger/src/main/java/org/apache/shale/tiger/faces/LifecycleListener.java
Mon Jun 26 22:45:25 2006
@@ -42,6 +42,7 @@
import org.apache.shale.tiger.config.FacesConfigConfig;
import org.apache.shale.tiger.config.FacesConfigParser;
import org.apache.shale.tiger.managed.Bean;
+import org.apache.shale.tiger.managed.Property;
import org.apache.shale.tiger.managed.Scope;
import org.apache.shale.tiger.managed.Value;
import org.apache.shale.tiger.managed.config.ManagedBeanConfig;
@@ -602,6 +603,16 @@
if (log().isTraceEnabled()) {
log().trace(" Scanning field '" + field.getName() + "'");
}
+ Property property = (Property)
field.getAnnotation(Property.class);
+ if (property != null) {
+ ManagedPropertyConfig mpc = new ManagedPropertyConfig();
+ mpc.setName(field.getName());
+ mpc.setType(field.getType().getName()); // FIXME -
primitives, arrays, etc.
+ mpc.setValue(property.value());
+ mbc.addProperty(mpc);
+ continue;
+ }
+ // Support deprecated @Value annotation as well
Value value = (Value) field.getAnnotation(Value.class);
if (value == null) {
continue;
Added:
struts/shale/trunk/shale-tiger/src/main/java/org/apache/shale/tiger/managed/Property.java
URL:
http://svn.apache.org/viewvc/struts/shale/trunk/shale-tiger/src/main/java/org/apache/shale/tiger/managed/Property.java?rev=417348&view=auto
==============================================================================
---
struts/shale/trunk/shale-tiger/src/main/java/org/apache/shale/tiger/managed/Property.java
(added)
+++
struts/shale/trunk/shale-tiger/src/main/java/org/apache/shale/tiger/managed/Property.java
Mon Jun 26 22:45:25 2006
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2006 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.shale.tiger.managed;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * <p>Field-level annotation indicating that the decorated field should be
+ * initialized to a literal or value binding expression value specified by the
+ * <code>value</code> attribute, when a managed instance of the containing
+ * class is instantiated.</p>
+ *
+ * @since 1.0.3
+ */
[EMAIL PROTECTED](RetentionPolicy.RUNTIME)
[EMAIL PROTECTED](ElementType.FIELD)
+public @interface Property {
+
+ /**
+ * <p>The string representation of the literal value, or value
+ * binding expression, used to intiialize this field.
+ * Appropriate type conversion will be performed.</p>
+ */
+ String value();
+
+
+}
Propchange:
struts/shale/trunk/shale-tiger/src/main/java/org/apache/shale/tiger/managed/Property.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
struts/shale/trunk/shale-tiger/src/main/java/org/apache/shale/tiger/managed/Property.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Modified:
struts/shale/trunk/shale-tiger/src/main/java/org/apache/shale/tiger/managed/Value.java
URL:
http://svn.apache.org/viewvc/struts/shale/trunk/shale-tiger/src/main/java/org/apache/shale/tiger/managed/Value.java?rev=417348&r1=417347&r2=417348&view=diff
==============================================================================
---
struts/shale/trunk/shale-tiger/src/main/java/org/apache/shale/tiger/managed/Value.java
(original)
+++
struts/shale/trunk/shale-tiger/src/main/java/org/apache/shale/tiger/managed/Value.java
Mon Jun 26 22:45:25 2006
@@ -26,6 +26,8 @@
* initialized to a literal or value binding expression value specified by the
* <code>value</code> attribute, when a managed instance of the containing
* class is instantiated.</p>
+ *
+ * @deprecated Use [EMAIL PROTECTED] Property} instead
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
Modified:
struts/shale/trunk/shale-tiger/src/test/java/org/apache/shale/tiger/config/TestBean.java
URL:
http://svn.apache.org/viewvc/struts/shale/trunk/shale-tiger/src/test/java/org/apache/shale/tiger/config/TestBean.java?rev=417348&r1=417347&r2=417348&view=diff
==============================================================================
---
struts/shale/trunk/shale-tiger/src/test/java/org/apache/shale/tiger/config/TestBean.java
(original)
+++
struts/shale/trunk/shale-tiger/src/test/java/org/apache/shale/tiger/config/TestBean.java
Mon Jun 26 22:45:25 2006
@@ -17,6 +17,7 @@
package org.apache.shale.tiger.config;
import org.apache.shale.tiger.managed.Bean;
+import org.apache.shale.tiger.managed.Property;
import org.apache.shale.tiger.managed.Scope;
import org.apache.shale.tiger.managed.Value;
@@ -33,7 +34,7 @@
/**
* Holds value of property byteProperty.
*/
- @Value("-1")
+ @Property("-1")
private byte byteProperty = (byte) 1;
/**
@@ -81,7 +82,7 @@
/**
* Holds value of property doubleProperty.
*/
- @Value("-2.0")
+ @Property("-2.0")
private double doubleProperty = (double) 2.0;
/**
@@ -129,7 +130,7 @@
/**
* Holds value of property intProperty.
*/
- @Value("-4")
+ @Property("-4")
private int intProperty = 4;
/**
@@ -177,7 +178,7 @@
/**
* Holds value of property shortProperty.
*/
- @Value("-6")
+ @Property("-6")
private short shortProperty = (short) 6;
/**