[jboss-svn-commits] JBoss Common SVN: r4182 - invokablecontainer/trunk/api/src/main/java/org/jboss/invokable.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Mar 17 11:17:34 EDT 2010
Author: david.lloyd at jboss.com
Date: 2010-03-17 11:17:33 -0400 (Wed, 17 Mar 2010)
New Revision: 4182
Modified:
invokablecontainer/trunk/api/src/main/java/org/jboss/invokable/Invocation.java
Log:
Add defaults, change field and accessor names
Modified: invokablecontainer/trunk/api/src/main/java/org/jboss/invokable/Invocation.java
===================================================================
--- invokablecontainer/trunk/api/src/main/java/org/jboss/invokable/Invocation.java 2010-03-17 12:43:18 UTC (rev 4181)
+++ invokablecontainer/trunk/api/src/main/java/org/jboss/invokable/Invocation.java 2010-03-17 15:17:33 UTC (rev 4182)
@@ -71,6 +71,8 @@
*/
private final Object[] args;
+ private static final Object[] NONE = new Object[0];
+
@SuppressWarnings({ "InstanceVariableMayNotBeInitializedByReadObject" })
private transient final Method targetMethod;
@@ -80,28 +82,22 @@
*
* @serial
*/
- private volatile InvocationProperties context;
+ private volatile InvocationProperties properties;
/**
* Construct a new instance.
*
- * @param context the invocation context to use
+ * @param properties the invocation context to use
* @param targetMethod the method being invoked
* @param args the arguments
*/
- public Invocation(final InvocationProperties context, final Method targetMethod, final Object... args) {
+ public Invocation(final InvocationProperties properties, final Method targetMethod, final Object... args) {
if (targetMethod == null) {
throw new IllegalArgumentException("targetMethod is null");
}
- if (args == null) {
- throw new IllegalArgumentException("args is null");
- }
- if (context == null) {
- throw new IllegalArgumentException("context is null");
- }
this.targetMethod = targetMethod;
- this.args = args;
- this.context = context;
+ this.args = defaulted(args, NONE);
+ this.properties = defaulted(properties, InvocationProperties.EMPTY);
}
/**
@@ -114,6 +110,15 @@
this(InvocationProperties.EMPTY, targetMethod, args);
}
+ /**
+ * Construct a new instance with no arguments.
+ *
+ * @param targetMethod the method being invoked
+ */
+ public Invocation(final Method targetMethod) {
+ this(InvocationProperties.EMPTY, targetMethod, NONE);
+ }
+
static {
targetMethodField = AccessController.doPrivileged(new PrivilegedAction<Field>() {
public Field run() {
@@ -156,17 +161,17 @@
*
* @return the current invocation context
*/
- public InvocationProperties getContext() {
- return context;
+ public InvocationProperties getProperties() {
+ return properties;
}
/**
* Replace this invocation's {@code InvocationContext}.
*
- * @param context the new invocation context
+ * @param properties the new invocation context
*/
- public void setContext(final InvocationProperties context) {
- this.context = context;
+ public void setProperties(final InvocationProperties properties) {
+ this.properties = properties;
}
//-------------------------------------------------------------------------------------||
@@ -192,14 +197,14 @@
out.writeObject(name);
out.writeObject(paramTypes);
// See if the invocation context is empty
- final InvocationProperties contextToWrite = context;
- if (context.isEmpty()) {
+ final InvocationProperties properties = this.properties;
+ if (properties.isEmpty()) {
// Null out; we don't need to send empty properties. On deserialization
// we'll just re-instantiate.
out.writeObject(null);
} else {
// Write invocation context
- out.writeObject(contextToWrite);
+ out.writeObject(properties);
}
}
@@ -236,14 +241,14 @@
// Set the target method
setTargetMethod(targetMethod);
// Set the InvocationContext
- final InvocationProperties context = (InvocationProperties) in.readObject();
+ final InvocationProperties properties = (InvocationProperties) in.readObject();
// If no context is provided
- if (context == null) {
+ if (properties == null) {
// Replace with a new instance; this signals empty properties were present when the instance
// was serialized
- this.context = InvocationProperties.EMPTY;
+ this.properties = InvocationProperties.EMPTY;
} else {
- this.context = context;
+ this.properties = properties;
}
}
@@ -254,4 +259,8 @@
throw new IllegalStateException(e);
}
}
+
+ private static <T> T defaulted(T value, T defaultValue) {
+ return value == null ? defaultValue : value;
+ }
}
More information about the jboss-svn-commits
mailing list