[jboss-svn-commits] JBL Code SVN: r22439 - in labs/jbossesb/workspace/skeagh: commons/src/main/java/org/jboss/esb/annotation and 6 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Fri Sep 5 10:02:46 EDT 2008
Author: beve
Date: 2008-09-05 10:02:45 -0400 (Fri, 05 Sep 2008)
New Revision: 22439
Added:
labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/annotation/Properties.java
labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/annotation/Property.java
labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/annotation/package.html
Removed:
labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/annotation/ConfigParam.java
Modified:
labs/jbossesb/workspace/skeagh/api/service/src/main/java/org/jboss/esb/service/ServiceName.java
labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/annotation/AnnotationConstants.java
labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/JmsInboundRouter.java
labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/config/digest/SetProperty.java
labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/schedule/AbstractScheduleListener.java
labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/schedule/CronSchedule.java
labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/schedule/SimpleSchedule.java
labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/deploy/config/AnnotatedResource.java
labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/deploy/config/MyInRouter.java
labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/deploy/config/MyMessageTransformer.java
labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/deploy/config/MyOutRouter.java
labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/deploy/config/MyTestService.java
labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/deploy/config/XProtDeploymentResource.java
labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/deploy/config/digest/SetPropertyTest.java
labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/dispatch/HelloInboundRouter.java
labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/dispatch/RestStringTransformer.java
Log:
Modified the annotations so that they are now mandatory if values are to be injected..
Modified: labs/jbossesb/workspace/skeagh/api/service/src/main/java/org/jboss/esb/service/ServiceName.java
===================================================================
--- labs/jbossesb/workspace/skeagh/api/service/src/main/java/org/jboss/esb/service/ServiceName.java 2008-09-05 13:47:56 UTC (rev 22438)
+++ labs/jbossesb/workspace/skeagh/api/service/src/main/java/org/jboss/esb/service/ServiceName.java 2008-09-05 14:02:45 UTC (rev 22439)
@@ -19,6 +19,7 @@
*/
package org.jboss.esb.service;
+import org.jboss.esb.annotation.Property;
import org.jboss.esb.util.AssertArgument;
/**
@@ -35,10 +36,12 @@
/**
* Service Category.
*/
+ @Property
private String category = null;
/**
* Service Name.
*/
+ @Property
private String name = null;
/**
@@ -91,6 +94,7 @@
*
* @return The Service Category and Name concatenated.
*/
+ @Override
public String toString()
{
return (category + ":" + name);
@@ -102,6 +106,7 @@
* @param obj Object to compare against.
* @return True if the object is a ServiceName with the same category and name values, otherwise false.
*/
+ @Override
public boolean equals(final Object obj)
{
if (obj == null)
@@ -123,6 +128,7 @@
*
* @return Object hash value.
*/
+ @Override
public int hashCode()
{
return toString().hashCode();
Modified: labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/annotation/AnnotationConstants.java
===================================================================
--- labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/annotation/AnnotationConstants.java 2008-09-05 13:47:56 UTC (rev 22438)
+++ labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/annotation/AnnotationConstants.java 2008-09-05 14:02:45 UTC (rev 22439)
@@ -3,9 +3,17 @@
/**
* Annotation constants.
*
-* @author <a href="mailto:tom.fennelly at gmail.com">tom.fennelly at gmail.com</a>
+* @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
*/
-public abstract class AnnotationConstants {
+public final class AnnotationConstants
+{
+ /**
+ * Private constructor to prevent instanitiation.
+ */
+ private AnnotationConstants()
+ {
+ throw new AssertionError("Should not be able to call this private constructor.");
+ }
/**
* "null" default annotation value.
Deleted: labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/annotation/ConfigParam.java
===================================================================
--- labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/annotation/ConfigParam.java 2008-09-05 13:47:56 UTC (rev 22438)
+++ labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/annotation/ConfigParam.java 2008-09-05 14:02:45 UTC (rev 22439)
@@ -1,102 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source Copyright 2008, Red Hat Middleware
- * LLC, and individual contributors by the @authors tag. See the copyright.txt
- * in the distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it under the
- * terms of the GNU Lesser General Public License as published by the Free
- * Software Foundation; either version 2.1 of the License, or (at your option)
- * any later version.
- *
- * This software is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
- * details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this software; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
- * site: http://www.fsf.org.
- */
-package org.jboss.esb.annotation;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-import org.apache.log4j.spi.Configurator;
-
-/**
- * Configuration paramater field annotation.
- * <p/>
- *
- * <h3>Usage</h3>
- * Where the paramater name is the same as the field name:
- * <pre>{@code
- * @ConfigParam(decoder={@link org.milyn.javabean.decoders.IntegerDecoder}.class)
- * private int maxDigits;
- * </pre>}
- * Where the paramater name is NOT the same as the field name:
- * <pre>{@code
- * @ConfigParam(name="max-digits", decoder={@link org.milyn.javabean.decoders.IntegerDecoder}.class)
- * private int maxDigits;
- * </pre>}
- *
- * @author <a href="mailto:tom.fennelly at gmail.com">tom.fennelly at gmail.com</a>
- * @see Configurator
- */
- at Documented
- at Retention(RetentionPolicy.RUNTIME)
- at Target({ElementType.FIELD, ElementType.METHOD})
-public @interface ConfigParam {
-
- /**
- * The paramater name as defined in the resource configuration. If not defined,
- * the name defaults to the name of the field.
- * @return The paramater name.
- */
- public String name() default AnnotationConstants.NULL_STRING;
-
- /**
- * Paramater required or optional.
- * <p/>
- * Defaults to required.
- *
- * @return Paramater usage.
- */
- public Use use() default Use.REQUIRED;
-
- /**
- * The default paramater value.
- * <p/>
- * Only relevant when use=OPTIONAL and the paramater is not defined on the configuration..
- *
- * @return The default paramater value (un-decoded).
- */
- public String defaultVal() default AnnotationConstants.UNASSIGNED;
-
- /**
- * Paramater choice values.
- *
- * @return List of valid choices (un-decoded).
- */
- public String[] choice() default AnnotationConstants.NULL_STRING;
-
- /**
- * Configuration paramater use.
- */
- public static enum Use {
- /**
- * Parameter is required.
- */
- REQUIRED,
-
- /**
- * Parameter is optional.
- */
- OPTIONAL,
- }
-}
-
Added: labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/annotation/Properties.java
===================================================================
--- labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/annotation/Properties.java (rev 0)
+++ labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/annotation/Properties.java 2008-09-05 14:02:45 UTC (rev 22439)
@@ -0,0 +1,91 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2008, Red Hat Middleware
+ * LLC, and individual contributors by the @authors tag. See the copyright.txt
+ * in the distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ *
+ * This software is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this software; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
+ * site: http://www.fsf.org.
+ */
+package org.jboss.esb.annotation;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Configuration paramater field annotation.
+ * <p/>
+ *
+ * <h3>Usage</h3>
+ * Where the paramater name is the same as the field name:
+ * <pre>{@code
+ * @Property(decoder={@link org.milyn.javabean.decoders.IntegerDecoder}.class)
+ * private int maxDigits;
+ * </pre>}
+ * Where the paramater name is NOT the same as the field name:
+ * <pre>{@code
+ * @Property(name="max-digits", decoder={@link org.milyn.javabean.decoders.IntegerDecoder}.class)
+ * private int maxDigits;
+ * </pre>}
+ *
+ * @author <a href="mailto:tom.fennelly at gmail.com">tom.fennelly at gmail.com</a>
+ */
+ at Documented
+ at Retention(RetentionPolicy.RUNTIME)
+ at Target({ ElementType.FIELD, ElementType.METHOD })
+public @interface Properties
+{
+
+ /**
+ * The paramater name as defined in the resource configuration. If not
+ * defined, the name defaults to the name of the field.
+ */
+ String name() default AnnotationConstants.NULL_STRING;
+
+ /**
+ * Paramater required or optional. <p/> Defaults to required.
+ */
+ Use use() default Use.REQUIRED;
+
+ /**
+ * The default paramater value. <p/> Only relevant when use=OPTIONAL and the
+ * paramater is not defined on the configuration..
+ */
+ String defaultVal() default AnnotationConstants.UNASSIGNED;
+
+ /**
+ * Paramater choice values.
+ *
+ */
+ String[] choice() default AnnotationConstants.NULL_STRING;
+
+ /**
+ * Configuration paramater use.
+ */
+ public static enum Use
+ {
+ /**
+ * Parameter is required.
+ */
+ REQUIRED,
+
+ /**
+ * Parameter is optional.
+ */
+ OPTIONAL,
+ }
+}
Added: labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/annotation/Property.java
===================================================================
--- labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/annotation/Property.java (rev 0)
+++ labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/annotation/Property.java 2008-09-05 14:02:45 UTC (rev 22439)
@@ -0,0 +1,90 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2008, Red Hat Middleware
+ * LLC, and individual contributors by the @authors tag. See the copyright.txt
+ * in the distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ *
+ * This software is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this software; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
+ * site: http://www.fsf.org.
+ */
+package org.jboss.esb.annotation;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Configuration paramater field annotation.
+ * <p/>
+ *
+ * <h3>Usage</h3>
+ * Where the paramater name is the same as the field name:
+ * <pre>{@code
+ * @Property(decoder={@link org.milyn.javabean.decoders.IntegerDecoder}.class)
+ * private int maxDigits;
+ * </pre>}
+ * Where the paramater name is NOT the same as the field name:
+ * <pre>{@code
+ * @Property(name="max-digits", decoder={@link org.milyn.javabean.decoders.IntegerDecoder}.class)
+ * private int maxDigits;
+ * </pre>}
+ *
+ * @author <a href="mailto:tom.fennelly at gmail.com">tom.fennelly at gmail.com</a>
+ */
+ at Documented
+ at Retention(RetentionPolicy.RUNTIME)
+ at Target({ ElementType.FIELD, ElementType.METHOD })
+public @interface Property
+{
+
+ /**
+ * The paramater name as defined in the resource configuration. If not
+ * defined, the name defaults to the name of the field.
+ */
+ String name() default AnnotationConstants.NULL_STRING;
+
+ /**
+ * Paramater required or optional. <p/> Defaults to required.
+ */
+ Use use() default Use.REQUIRED;
+
+ /**
+ * The default paramater value. <p/> Only relevant when use=OPTIONAL and the
+ * paramater is not defined on the configuration..
+ */
+ String defaultVal() default AnnotationConstants.UNASSIGNED;
+
+ /**
+ * Paramater choice values.
+ */
+ String[] choice() default AnnotationConstants.NULL_STRING;
+
+ /**
+ * Configuration paramater use.
+ */
+ public static enum Use
+ {
+ /**
+ * Parameter is required.
+ */
+ REQUIRED,
+
+ /**
+ * Parameter is optional.
+ */
+ OPTIONAL,
+ }
+}
Added: labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/annotation/package.html
===================================================================
--- labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/annotation/package.html (rev 0)
+++ labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/annotation/package.html 2008-09-05 14:02:45 UTC (rev 22439)
@@ -0,0 +1,8 @@
+<html>
+<head></head>
+<body>
+Configuration Annotations.
+
+<h2>Package Specification</h2>
+</body>
+</html>
Modified: labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/JmsInboundRouter.java
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/JmsInboundRouter.java 2008-09-05 13:47:56 UTC (rev 22438)
+++ labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/JmsInboundRouter.java 2008-09-05 14:02:45 UTC (rev 22439)
@@ -27,15 +27,14 @@
import javax.naming.Context;
import org.apache.log4j.Logger;
-import org.jboss.esb.annotation.ConfigParam;
-import org.jboss.esb.annotation.ConfigParam.Use;
+import org.jboss.esb.annotation.Property;
+import org.jboss.esb.annotation.Property.Use;
import org.jboss.esb.annotations.Initialize;
import org.jboss.esb.context.InvocationContext;
import org.jboss.esb.message.Message;
import org.jboss.esb.routing.InboundRouter;
import org.jboss.esb.routing.MessageDispatcher;
import org.jboss.esb.routing.RoutingException;
-import org.jboss.esb.service.ServiceName;
import org.jboss.esb.util.AssertArgument;
/**
@@ -59,12 +58,13 @@
/**
* JMS destination name.
*/
- @ConfigParam(use = Use.REQUIRED, name = "jmsDestination")
+ @Property(use = Use.REQUIRED, name = "jmsDestination")
private String destination;
/**
* default jms properties.
*/
+ @org.jboss.esb.annotation.Properties
private final Properties jmsProperties = getDefaultProperties();
/**
@@ -72,8 +72,6 @@
*/
private Properties properties;
- private ServiceName serviceName;
-
/**
* Initializes this instance.
*/
@@ -88,12 +86,17 @@
// add/overwrite properties from the configuration
jmsProperties.putAll(properties);
}
- log.info("Service : + " + serviceName + ", JMSProperties : " + jmsProperties);
+ log.info("JMSProperties : " + jmsProperties);
// add this class as a JMS message listener...
}
- public void onMessage() throws RoutingException
+ /**
+ * Excecuted when a message arrives on the configured destination(Queue or Topic).
+ *
+ * @throws RoutingException if routing is not successful
+ */
+ public final void onMessage() throws RoutingException
{
Message esbMessage = new Message();
esbMessage.setPayload("test");
@@ -119,7 +122,12 @@
this.dispatcher = dispatcher;
}
- public String getDestination()
+ /**
+ * Gets the Destination that this router listens to.
+ *
+ * @return String the name of the destination that this instance listens to.
+ */
+ public final String getDestination()
{
return destination;
}
Modified: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/config/digest/SetProperty.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/config/digest/SetProperty.java 2008-09-05 13:47:56 UTC (rev 22438)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/config/digest/SetProperty.java 2008-09-05 14:02:45 UTC (rev 22439)
@@ -19,6 +19,7 @@
*/
package org.jboss.esb.deploy.config.digest;
+import org.jboss.esb.annotation.Property;
import org.jboss.esb.classpath.ClassUtil;
import org.milyn.SmooksException;
import org.milyn.cdr.annotation.ConfigParam;
@@ -87,42 +88,66 @@
{
try
{
- if ( !attemptAnnotationFieldSet(instance, propertyName, value) )
- {
- Field field = getPropertyField(propertyName, objectClass);
- setPropertyValue(field, instance, value);
- }
- } catch (NoSuchFieldException e)
+ attemptAnnotationFieldSet(objectClass, instance, propertyName, value);
+ } catch (final IllegalAccessException e)
{
+ e.printStackTrace();
+ /*
if (!attemptPropertiesFieldSet(instance, propertyName, value))
{
// Throw the original exception...
throw new SmooksException("Property '" + propertyName + "' unknown on class '" + objectClass + "' (or super class).", e);
}
+ */
}
- catch (IllegalAccessException e)
- {
- throw new SmooksException("Property '" + propertyName + "' cannot be set on class '" + objectClass + "'.", e);
- }
}
}
- boolean attemptAnnotationFieldSet(final Object instance, final String propertyName, final String value) throws IllegalAccessException
+ /**
+ * Will set the value of the instance field annotated with {@link Property}.
+ *
+ * @param clazz Class object on which the field should be set. Needed to be able to find superclasses.
+ * @param instance the instance that contains the field to be set
+ * @param propertyName the name of the configuration property
+ * @param value the value to set the field to
+ * @return true if the field was set, otherwise false.
+ *
+ * @throws IllegalAccessException if the field was not accessible.
+ */
+ final boolean attemptAnnotationFieldSet(final Class<?> clazz, final Object instance, final String propertyName, final String value) throws IllegalAccessException
{
boolean fieldSet = false;
- Field[] fields = instance.getClass().getDeclaredFields();
+ Field[] fields = clazz.getDeclaredFields();
for (Field field : fields)
{
- org.jboss.esb.annotation.ConfigParam configParam = field.getAnnotation(org.jboss.esb.annotation.ConfigParam.class);
- if ( configParam != null )
+ Property propertyAnnotation = field.getAnnotation(Property.class);
+ if (propertyAnnotation != null)
{
- if ( configParam.name().equals(propertyName) || field.getName().equals(propertyName) )
+ if (propertyAnnotation.name().equals(propertyName) || field.getName().equals(propertyName))
{
setPropertyValue(field, instance, value);
fieldSet = true;
}
}
+ else
+ {
+ org.jboss.esb.annotation.Properties properties = field.getAnnotation(org.jboss.esb.annotation.Properties.class);
+ if (properties != null)
+ {
+ fieldSet = attemptPropertiesFieldSet(instance, field, propertyName, value);
+ }
+ }
}
+
+ if (!fieldSet)
+ {
+ Class<?> superclass = instance.getClass().getSuperclass();
+ if (superclass != null && !superclass.getName().equals(Object.class.getName()))
+ {
+ fieldSet = attemptAnnotationFieldSet(superclass, instance, propertyName, value);
+ }
+ }
+
return fieldSet;
}
@@ -148,17 +173,15 @@
* on the object, if such a field exists.
*
* @param instance The object instance.
+ * @param field The field to be set.
* @param propertyName The property name.
* @param value The property value.
* @return True if the property was successfully set, otherwise false.
*/
- private boolean attemptPropertiesFieldSet(final Object instance, final String propertyName, final String value)
+ private boolean attemptPropertiesFieldSet(final Object instance, final Field field, final String propertyName, final String value)
{
try
{
- Class objectClass = instance.getClass();
- Field field = getPropertyField("properties", objectClass);
-
if (Properties.class.isAssignableFrom(field.getType()))
{
Properties properties = (Properties) ClassUtil.getFieldValue(field, instance);
@@ -170,41 +193,14 @@
properties.put(propertyName, value);
return true;
}
- } catch (NoSuchFieldException e1)
+ } catch (IllegalAccessException ignored)
{
// Ignore... fall through...
- } catch (IllegalAccessException e1)
- {
- // Ignore... fall through...
}
return false;
}
/**
- * Get the {@link Field} for the specified property of the specified class.
- *
- * @param propertyName The property name.
- * @param objectClass The class.
- * @return The property field.
- * @throws NoSuchFieldException Unknown property field.
- */
- private Field getPropertyField(final String propertyName, final Class objectClass) throws NoSuchFieldException
- {
- try
- {
- return objectClass.getDeclaredField(propertyName);
- } catch (NoSuchFieldException e)
- {
- Class superClass = objectClass.getSuperclass();
- if (superClass != null)
- {
- return getPropertyField(propertyName, superClass);
- }
- throw e;
- }
- }
-
- /**
* Get the property bean instance from the supplied Smooks ExecutionContext.
*
* @param executionContext The Smooks Execution Context.
Modified: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/schedule/AbstractScheduleListener.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/schedule/AbstractScheduleListener.java 2008-09-05 13:47:56 UTC (rev 22438)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/schedule/AbstractScheduleListener.java 2008-09-05 14:02:45 UTC (rev 22439)
@@ -19,6 +19,7 @@
*/
package org.jboss.esb.schedule;
+import org.jboss.esb.annotation.Property;
import org.jboss.esb.annotations.Initialize;
import org.jboss.esb.context.DeploymentContext;
import org.jboss.esb.deploy.AssertDeployment;
@@ -38,6 +39,7 @@
/**
* The objectName of the listener.
*/
+ @Property
private String objectName;
/**
* Deployment context.
@@ -46,6 +48,7 @@
/**
* The scheduleResourceId of the listener.
*/
+ @Property
private String scheduleResourceId;
/**
Modified: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/schedule/CronSchedule.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/schedule/CronSchedule.java 2008-09-05 13:47:56 UTC (rev 22438)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/schedule/CronSchedule.java 2008-09-05 14:02:45 UTC (rev 22439)
@@ -19,6 +19,7 @@
*/
package org.jboss.esb.schedule;
+import org.jboss.esb.annotation.Property;
import org.quartz.CronTrigger;
import org.quartz.Trigger;
@@ -43,6 +44,7 @@
/**
* Cron scheduling expression (see Quartz docs).
*/
+ @Property
private String cronExpression;
/**
@@ -50,6 +52,7 @@
*
* @return The Cron expression.
*/
+ @Property
public final String getCronExpression()
{
return cronExpression;
@@ -71,6 +74,7 @@
* @return A Trigger instance.
* @throws SchedulingException Unable to create Trigger.
*/
+ @Override
public final Trigger toTrigger() throws SchedulingException
{
CronTrigger trigger = new CronTrigger();
Modified: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/schedule/SimpleSchedule.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/schedule/SimpleSchedule.java 2008-09-05 13:47:56 UTC (rev 22438)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/schedule/SimpleSchedule.java 2008-09-05 14:02:45 UTC (rev 22439)
@@ -19,6 +19,7 @@
*/
package org.jboss.esb.schedule;
+import org.jboss.esb.annotation.Property;
import org.quartz.SimpleTrigger;
import org.quartz.Trigger;
@@ -41,10 +42,12 @@
/**
* Poll frequency in milliseconds.
*/
+ @Property
private long frequency;
/**
* Number of times to execute (default - execute indefinitely).
*/
+ @Property
private int execCount = -1;
/**
@@ -93,6 +96,7 @@
* @return A Trigger instance.
* @throws SchedulingException Unable to create Trigger.
*/
+ @Override
public final Trigger toTrigger() throws SchedulingException
{
SimpleTrigger trigger = new SimpleTrigger();
Modified: labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/deploy/config/AnnotatedResource.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/deploy/config/AnnotatedResource.java 2008-09-05 13:47:56 UTC (rev 22438)
+++ labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/deploy/config/AnnotatedResource.java 2008-09-05 14:02:45 UTC (rev 22439)
@@ -19,9 +19,11 @@
*/
package org.jboss.esb.deploy.config;
-import org.jboss.esb.annotation.ConfigParam;
-import org.jboss.esb.annotation.ConfigParam.Use;
+import java.util.Properties;
+import org.jboss.esb.annotation.Property;
+import org.jboss.esb.annotation.Property.Use;
+
/**
* Simple pojo which uses annotations.
*
@@ -30,23 +32,31 @@
*/
public class AnnotatedResource
{
- @ConfigParam ( use = Use.REQUIRED, name = "userName" )
+ @Property ( use = Use.REQUIRED, name = "userName" )
private String name;
- @ConfigParam ( use = Use.REQUIRED )
+ @Property ( use = Use.REQUIRED )
private String lastName;
private String password;
+ @org.jboss.esb.annotation.Properties
+ private Properties props;
+
+ public Properties getProps()
+ {
+ return props;
+ }
+
public String getPassword()
{
return password;
}
- @ConfigParam ( use = Use.OPTIONAL, defaultVal = "John Doe" )
+ @Property ( use = Use.OPTIONAL, defaultVal = "John Doe" )
private int age;
- @ConfigParam ( use = Use.REQUIRED )
+ @Property ( use = Use.REQUIRED )
private Double weight;
private String org;
@@ -56,7 +66,7 @@
return org;
}
- @ConfigParam ( use = Use.REQUIRED )
+ @Property ( use = Use.REQUIRED )
public void setOrganization(String org)
{
this.org = org;
Modified: labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/deploy/config/MyInRouter.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/deploy/config/MyInRouter.java 2008-09-05 13:47:56 UTC (rev 22438)
+++ labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/deploy/config/MyInRouter.java 2008-09-05 14:02:45 UTC (rev 22439)
@@ -21,6 +21,7 @@
import org.jboss.esb.routing.InboundRouter;
import org.jboss.esb.routing.MessageDispatcher;
+import org.jboss.esb.annotation.Property;
import org.jboss.esb.annotations.Initialize;
import org.jboss.esb.annotations.Uninitialize;
import org.jboss.esb.service.ServiceName;
@@ -33,7 +34,9 @@
{
private ServiceName serviceName;
+ @Property
private String myparam;
+ @Property
private int myOtherParam;
public static Exception exception;
public static boolean initialised = false;
Modified: labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/deploy/config/MyMessageTransformer.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/deploy/config/MyMessageTransformer.java 2008-09-05 13:47:56 UTC (rev 22438)
+++ labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/deploy/config/MyMessageTransformer.java 2008-09-05 14:02:45 UTC (rev 22439)
@@ -22,6 +22,7 @@
import org.jboss.esb.message.MessageTransformer;
import org.jboss.esb.message.Message;
import org.jboss.esb.message.MessageTransformationException;
+import org.jboss.esb.annotation.Property;
import org.jboss.esb.annotations.Initialize;
import org.jboss.esb.annotations.Uninitialize;
import org.jboss.esb.context.AddressingContext;
@@ -34,6 +35,7 @@
public class MyMessageTransformer implements MessageTransformer
{
private ServiceName serviceName;
+ @Property
private int someParam;
public static boolean initialised = false;
Modified: labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/deploy/config/MyOutRouter.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/deploy/config/MyOutRouter.java 2008-09-05 13:47:56 UTC (rev 22438)
+++ labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/deploy/config/MyOutRouter.java 2008-09-05 14:02:45 UTC (rev 22439)
@@ -24,6 +24,7 @@
import org.jboss.esb.routing.OutboundRouter;
import org.jboss.esb.routing.RoutingException;
import org.jboss.esb.message.Message;
+import org.jboss.esb.annotation.Property;
import org.jboss.esb.annotations.Initialize;
import org.jboss.esb.annotations.Uninitialize;
import org.jboss.esb.context.AddressingContext;
@@ -37,7 +38,9 @@
{
private ServiceName serviceName;
+ @Property
private String myparam;
+ @Property
private int myOtherParam;
public static boolean initialised = false;
Modified: labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/deploy/config/MyTestService.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/deploy/config/MyTestService.java 2008-09-05 13:47:56 UTC (rev 22438)
+++ labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/deploy/config/MyTestService.java 2008-09-05 14:02:45 UTC (rev 22439)
@@ -23,6 +23,7 @@
import org.jboss.esb.service.ServiceException;
import org.jboss.esb.service.ServiceName;
import org.jboss.esb.message.Message;
+import org.jboss.esb.annotation.Property;
import org.jboss.esb.annotations.Initialize;
import org.jboss.esb.annotations.Uninitialize;
import org.jboss.esb.context.AddressingContext;
@@ -33,8 +34,9 @@
*/
public class MyTestService implements Service
{
- private ServiceName serviceName;
+ private ServiceName serviceName;
+ @Property
private String prop1;
public static boolean initialised = false;
@@ -47,7 +49,7 @@
public void uninitialise() {
initialised = false;
}
-
+
public Message process(Message message) throws ServiceException
{
TestCase.assertNotNull(serviceName);
Modified: labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/deploy/config/XProtDeploymentResource.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/deploy/config/XProtDeploymentResource.java 2008-09-05 13:47:56 UTC (rev 22438)
+++ labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/deploy/config/XProtDeploymentResource.java 2008-09-05 14:02:45 UTC (rev 22439)
@@ -21,13 +21,18 @@
import java.net.URI;
+import org.jboss.esb.annotation.Property;
+
/**
* @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
*/
public class XProtDeploymentResource
{
+ @Property
private int xprotResPropA;
+ @Property
private Double xprotResPropB;
+ @Property
private URI xprotResPropC;
public int getXprotResPropA()
Modified: labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/deploy/config/digest/SetPropertyTest.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/deploy/config/digest/SetPropertyTest.java 2008-09-05 13:47:56 UTC (rev 22438)
+++ labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/deploy/config/digest/SetPropertyTest.java 2008-09-05 14:02:45 UTC (rev 22439)
@@ -35,14 +35,14 @@
*/
public class SetPropertyTest
{
- private final SetProperty setProperty = new SetProperty();
+ private final SetProperty setProperty = new SetProperty();
private final AnnotatedResource annotatedResource = new AnnotatedResource();
@Test
public void attemptAnnotationFieldSet() throws IllegalAccessException
{
final String expectedName = "Fletcher";
- boolean fieldSet = setProperty.attemptAnnotationFieldSet(annotatedResource , "lastName", expectedName);
+ boolean fieldSet = setProperty.attemptAnnotationFieldSet(annotatedResource.getClass(), annotatedResource , "lastName", expectedName);
assertTrue( fieldSet );
assertEquals( expectedName, annotatedResource.getLastName());
}
@@ -51,7 +51,7 @@
public void attemptAnnotationFieldSetNameSpecified() throws IllegalAccessException
{
final String expectedName = "Dr.Rosen";
- boolean fieldSet = setProperty.attemptAnnotationFieldSet(annotatedResource , "userName", expectedName);
+ boolean fieldSet = setProperty.attemptAnnotationFieldSet(annotatedResource.getClass(), annotatedResource , "userName", expectedName);
assertTrue( fieldSet );
assertEquals( expectedName, annotatedResource.getName() );
}
@@ -59,8 +59,22 @@
@Test
public void attemptAnnotationFieldSetNotAnnotated() throws IllegalAccessException
{
- setProperty.attemptAnnotationFieldSet(annotatedResource , "password", "secret");
+ setProperty.attemptAnnotationFieldSet(annotatedResource.getClass(), annotatedResource , "password", "secret");
assertNull( annotatedResource.getName() );
}
+ @Test
+ public void attemptAnnotationFieldSetProperties() throws IllegalAccessException
+ {
+ final String expectedPropValue1 = "value1";
+ final String expectedPropValue2 = "value2";
+ boolean fieldSet = setProperty.attemptAnnotationFieldSet(annotatedResource.getClass(), annotatedResource , "prop1", expectedPropValue1);
+ assertTrue( fieldSet );
+ assertTrue( annotatedResource.getProps().size() == 1 );
+
+ fieldSet = setProperty.attemptAnnotationFieldSet(annotatedResource.getClass(), annotatedResource , "prop2", expectedPropValue2);
+ assertTrue( annotatedResource.getProps().size() == 2 );
+ System.out.println(annotatedResource.getProps());
+ }
+
}
Modified: labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/dispatch/HelloInboundRouter.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/dispatch/HelloInboundRouter.java 2008-09-05 13:47:56 UTC (rev 22438)
+++ labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/dispatch/HelloInboundRouter.java 2008-09-05 14:02:45 UTC (rev 22439)
@@ -19,13 +19,11 @@
*/
package org.jboss.esb.dispatch;
+import org.jboss.esb.context.InvocationContext;
+import org.jboss.esb.message.Message;
import org.jboss.esb.routing.InboundRouter;
import org.jboss.esb.routing.MessageDispatcher;
import org.jboss.esb.routing.RoutingException;
-import org.jboss.esb.message.Message;
-import org.jboss.esb.context.InvocationContext;
-import org.jboss.esb.context.AddressingContext;
-import org.jboss.esb.context.DeploymentContext;
/**
* @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
Modified: labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/dispatch/RestStringTransformer.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/dispatch/RestStringTransformer.java 2008-09-05 13:47:56 UTC (rev 22438)
+++ labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/dispatch/RestStringTransformer.java 2008-09-05 14:02:45 UTC (rev 22439)
@@ -19,19 +19,20 @@
*/
package org.jboss.esb.dispatch;
-import org.jboss.esb.message.MessageTransformer;
+import org.jboss.esb.annotation.Property;
+import org.jboss.esb.context.AddressingContext;
+import org.jboss.esb.context.DeploymentContext;
+import org.jboss.esb.context.InvocationContext;
import org.jboss.esb.message.Message;
import org.jboss.esb.message.MessageTransformationException;
-import org.jboss.esb.context.InvocationContext;
-import org.jboss.esb.context.AddressingContext;
-import org.jboss.esb.context.DeploymentContext;
-import junit.framework.TestCase;
+import org.jboss.esb.message.MessageTransformer;
/**
* @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
*/
public class RestStringTransformer implements MessageTransformer
{
+ @Property
private String newString;
public static InvocationContext invocationContext;
public static AddressingContext addressingContext;
More information about the jboss-svn-commits
mailing list