EnhancedXmlStreamWriterProxypublic final class EnhancedXmlStreamWriterProxy extends Object implements InvocationHandlerThe class provides an implementation of an {@link InvocationHandler} interface
that handles requests of {@link XMLStreamWriter} proxy instances.
This {@link InvocationHandler} implementation adds additional feature or enhancement
to the underlying {@link XMLStreamWriter} instance. The new enhancement or feature is
defined by an {@link InvocationProcessor} implementation.
The class also contains a static factory method for creating such 'enhanced'
{@link XMLStreamWriter} proxies. |
Fields Summary |
---|
private static final com.sun.xml.ws.policy.privateutil.PolicyLogger | LOGGER | private static final Class[] | PROXIED_INTERFACES | private static final Method | hashCodeMethod | private static final Method | equalsMethod | private static final Method | toStringMethod | private final InvocationProcessor | invocationProcessor |
Methods Summary |
---|
public static javax.xml.stream.XMLStreamWriter | createProxy(javax.xml.stream.XMLStreamWriter writer, InvocationProcessorFactory processorFactory)Creates a wrapper {@link XMLStreamWriter} proxy that adds enhanced feature
to the {@code writer} instance.
LOGGER.entering();
XMLStreamWriter proxy = null;
try {
proxy = (XMLStreamWriter) Proxy.newProxyInstance(
writer.getClass().getClassLoader(),
PROXIED_INTERFACES,
new EnhancedXmlStreamWriterProxy(writer, processorFactory));
return proxy;
} finally {
LOGGER.exiting(proxy);
}
| private java.lang.Object | handleObjectMethodCall(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args)
if (method.equals(hashCodeMethod)) {
return new Integer(System.identityHashCode(proxy));
} else if (method.equals(equalsMethod)) {
return (proxy == args[0] ? Boolean.TRUE : Boolean.FALSE);
} else if (method.equals(toStringMethod)) {
return proxy.getClass().getName() + '@" + Integer.toHexString(proxy.hashCode());
} else {
throw LOGGER.logSevereException(new InternalError(LocalizationMessages.WSP_1007_UNEXPECTED_OBJECT_METHOD(method)));
}
| public java.lang.Object | invoke(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args)
if (LOGGER.isMethodCallLoggable()) {
LOGGER.entering(method, args);
}
Object result = null;
try {
final Class declaringClass = method.getDeclaringClass();
if (declaringClass == Object.class) {
return handleObjectMethodCall(proxy, method, args);
} else {
final Invocation invocation = Invocation.createInvocation(method, args);
result = invocationProcessor.process(invocation);
return result;
}
} finally {
LOGGER.exiting(result);
}
|
|