Package javax.xml.rpc.holders |
JAX-RPC 1.0; JWSDP 1.0, J2EE 1.4 |
This package contains a set of classes that are used to simulate method arguments that can be used to receive output values, a feature that is not directly supported by the Java programming language. A holder argument is used wherever the WSDL definition calls for an output or input/output argument. In terms of method call syntax, a service endpoint interface method that uses a holder class looks like this:
public void methodName(IntHolder arg) throws RemoteException;
All holders implement the Holder interface, which is a marker that does not declare any methods . Each holder class can contain a value of a specific type. There are 21 pre-defined holder classes in the javax.xml.rpc.holders package, which correspond to the Java primitive types (such as int ), their object wrapper counterparts (such as Integer ), and a small number of special cases (such as QNameHolder ). A simple naming convention applies to the standard wrapper classes:
For a Java primitive type, the class name is formed by capitalizing the first letter of the type name and appending Holder . Hence, the IntHolder class is the holder class for a primitive int , ByteHolder corresponds to byte , and so on.
For a primitive wrapper type, the class name consists of the wrapper class name followed by WrapperHolder . The holder for the Integer class is therefore IntegerWrapperHolder
JAX-RPC is capable of generating additional holder classes for method arguments of other types that are defined to have either output or input/output semantics. For the reference implementation, this task is performed by the wscompile utility described in Chapter 2 and Chapter 8. Since the Holder interface does not define any methods, there is no standard way to get or set the value in a holder. Instead, the predefined classes all follow a coding convention as follows :
The class provides a constructor that accepts a value of the appropriate type. For example, the constructor of the IntHolder class requires an argument of type int .
The value itself is held in a public variable called value .
Assuming that the argument of the methodName( ) method just shown has input/output semantics, the following code extract shows how it might be used:
IntHolder arg = new IntHolder(10); // Use 10 as the argument value port.methodName(arg); // Invoke the method... int result = arg.value; // ... and get the result
Customized holders can be created by writing a class that declares that it implements the Holder and follows these coding conventions. Refer to Chapter 2 for an example.
public interface Holder ;
public final class BigDecimalHolder implements Holder; public final class BigIntegerHolder implements Holder; public final class BooleanHolder implements Holder; public final class BooleanWrapperHolder implements Holder; public final class ByteArrayHolder implements Holder; public final class ByteHolder implements Holder; public final class ByteWrapperHolder implements Holder; public final class CalendarHolder implements Holder; public final class DoubleHolder implements Holder; public final class DoubleWrapperHolder implements Holder; public final class FloatHolder implements Holder; public final class FloatWrapperHolder implements Holder; public final class IntegerWrapperHolder implements Holder; public final class IntHolder implements Holder; public final class LongHolder implements Holder; public final class LongWrapperHolder implements Holder; public final class ObjectHolder implements Holder; public final class QNameHolder implements Holder; public final class ShortHolder implements Holder; public final class ShortWrapperHolder implements Holder; public final class StringHolder implements Holder;