Jakarta XML Web Services (JAX-WS) runtime implementation providing comprehensive SOAP web service capabilities
—
XML-to-Java databinding system with comprehensive JAXB integration and support for custom databinding providers. The system provides flexible serialization/deserialization of Java objects to/from XML with support for various databinding modes and optimization strategies.
Central databinding abstraction providing XML-to-Java serialization services.
/**
* Core interface for XML/Java serialization and WSDL generation
*/
package com.oracle.webservices.api.databinding;
public interface Databinding {
/** Create call bridge for server-side endpoint operations */
EndpointCallBridge createCallBridge(JavaCallInfo callInfo);
/** Create call bridge for client-side service calls */
ClientCallBridge createCallBridge(JavaCallInfo callInfo);
/** Generate WSDL from Java service interface */
void generateWSDL(WSDLGenInfo wsdlGenInfo);
/** Marshal Java object to XML */
XMLBridge createBridge(TypeInfo typeInfo);
/** Get databinding configuration */
DatabindingConfig getConfig();
/** Get bound context */
Object getBoundContext();
}
/**
* Factory for creating databinding instances
*/
public abstract class DatabindingFactory {
/** Get default databinding factory instance */
public static DatabindingFactory newInstance();
/** Create databinding with configuration */
public abstract Databinding createDatabinding(DatabindingConfig config);
/** Create runtime databinding */
public Databinding createRuntime(DatabindingConfig config);
}Configuration system for customizing databinding behavior and selecting providers.
/**
* Configuration for databinding creation and behavior
*/
public final class DatabindingConfig {
/** Set contract class (SEI) */
public DatabindingConfig setContractClass(Class<?> contractClass);
/** Set endpoint class (implementation) */
public DatabindingConfig setEndpointClass(Class<?> endpointClass);
/** Set databinding mode */
public DatabindingConfig setDatabindingMode(DatabindingMode mode);
/** Set properties */
public DatabindingConfig setProperties(Map<String, Object> properties);
/** Set class loader */
public DatabindingConfig setClassLoader(ClassLoader classLoader);
/** Set metadata reader */
public DatabindingConfig setMetadataReader(MetadataReader metadataReader);
/** Set WSDL port */
public DatabindingConfig setWsdlPort(WSDLPort wsdlPort);
/** Set features */
public DatabindingConfig setFeatures(WebServiceFeature... features);
/** Get contract class */
public Class<?> getContractClass();
/** Get endpoint class */
public Class<?> getEndpointClass();
/** Get databinding mode */
public DatabindingMode getDatabindingMode();
/** Get properties */
public Map<String, Object> getProperties();
}
/**
* Databinding mode enumeration
*/
public enum DatabindingMode {
/** Use JAXB for databinding */
glassfish_jaxb,
/** Use Eclipse MOXy for databinding */
eclipselink_moxy,
/** Use custom databinding provider */
custom;
/** Get mode from string */
public static DatabindingMode fromString(String mode);
}Call bridges providing method invocation abstraction for client and server sides.
/**
* Server-side call bridge for endpoint method invocation
*/
public interface EndpointCallBridge {
/** Invoke endpoint method with deserialized parameters */
Object invoke(Object endpoint, Object... args) throws Throwable;
/** Get method information */
Method getMethod();
/** Get parameter bridges */
ParameterBridge[] getParameterBridges();
/** Get return type bridge */
ParameterBridge getReturnBridge();
/** Check if method is one-way */
boolean isOneWay();
/** Get exception bridges */
ExceptionBridge[] getExceptionBridges();
}
/**
* Client-side call bridge for service method invocation
*/
public interface ClientCallBridge {
/** Create request packet from method parameters */
Packet createRequestPacket(JavaCallInfo callInfo);
/** Extract return value from response packet */
JavaCallInfo readResponse(Packet response, JavaCallInfo callInfo) throws Throwable;
/** Get method information */
Method getMethod();
/** Get operation name */
QName getOperationName();
/** Check if operation is one-way */
boolean isOneWay();
}Method call information container for databinding operations.
/**
* Container for Java method call information and parameters
*/
public final class JavaCallInfo {
/** Create call info for method */
public static JavaCallInfo create(Method method, Object[] parameters);
/** Get method being called */
public Method getMethod();
/** Get method parameters */
public Object[] getParameters();
/** Set method parameters */
public void setParameters(Object[] parameters);
/** Get return value */
public Object getReturnValue();
/** Set return value */
public void setReturnValue(Object returnValue);
/** Get exception thrown */
public Throwable getException();
/** Set exception */
public void setException(Throwable exception);
/** Get parameter at index */
public Object getParameter(int index);
/** Set parameter at index */
public void setParameter(int index, Object value);
}Low-level XML serialization bridges for individual type marshalling.
/**
* Bridge for marshalling/unmarshalling individual types
*/
package com.sun.xml.ws.spi.db;
public interface XMLBridge<T> {
/** Marshal object to XMLStreamWriter */
void marshal(T object, XMLStreamWriter output) throws XMLStreamException;
/** Marshal object to Result */
void marshal(T object, Result result) throws JAXBException;
/** Marshal object to ContentHandler */
void marshal(T object, ContentHandler contentHandler) throws JAXBException;
/** Unmarshal from XMLStreamReader */
T unmarshal(XMLStreamReader input) throws JAXBException;
/** Unmarshal from Source */
T unmarshal(Source source) throws JAXBException;
/** Get type information */
TypeInfo getTypeInfo();
/** Check if type supports marshalling to Element */
boolean supportElementProperty();
}
/**
* Bridge for repeated elements (arrays, lists)
*/
public interface RepeatedElementBridge<T> extends XMLBridge<T> {
/** Marshal collection of items */
void marshal(Iterable<T> collection, XMLStreamWriter output) throws XMLStreamException;
/** Unmarshal to collection */
Collection<T> unmarshal(XMLStreamReader input, Collection<T> collection) throws JAXBException;
}Binding context management and provider SPI for pluggable databinding implementations.
/**
* Binding context providing access to databinding services
*/
public interface BindingContext {
/** Create bridge for type */
XMLBridge createBridge(TypeInfo typeInfo);
/** Create fragment bridge for inner types */
XMLBridge createFragmentBridge();
/** Get JAXB context if available */
JAXBContext getJAXBContext();
/** Get known types */
QName[] getKnownTypes();
/** Create marshaller */
Marshaller createMarshaller() throws JAXBException;
/** Create unmarshaller */
Unmarshaller createUnmarshaller() throws JAXBException;
/** Create schema generator */
void generateSchema(SchemaOutputResolver resolver) throws IOException;
/** Get type information for class */
TypeInfo getTypeInfo(Class<?> type);
}
/**
* SPI for custom databinding providers
*/
public interface DatabindingProvider {
/** Check if provider supports the databinding mode */
boolean isFor(String databindingMode);
/** Initialize provider with properties */
void init(Map<String, Object> properties);
/** Create databinding instance */
Databinding create(DatabindingConfig config);
}
/**
* Factory SPI for binding contexts
*/
public interface BindingContextFactory {
/** Create binding context */
BindingContext newContext(JAXBContext jaxbContext);
/** Create binding context with type information */
BindingContext newContext(BindingInfo bindingInfo);
/** Create binding context for known types */
BindingContext newContext(Class<?>... knownTypes) throws JAXBException;
}Property accessor system for efficient field/property access during databinding.
/**
* Efficient property access interface
*/
public interface PropertyAccessor {
/** Get property value from object */
Object get(Object bean) throws AccessorException;
/** Set property value on object */
void set(Object bean, Object value) throws AccessorException;
/** Get property type */
Class<?> getType();
/** Get property name */
String getName();
/** Check if property is readable */
boolean isReadable();
/** Check if property is writable */
boolean isWritable();
}
/**
* Factory for creating property accessors
*/
public abstract class PropertyAccessorFactory {
/** Create accessor for field */
public abstract PropertyAccessor createFieldAccessor(Class<?> beanClass, Field field);
/** Create accessor for property (getter/setter) */
public abstract PropertyAccessor createPropertyAccessor(Class<?> beanClass, Method getter, Method setter);
/** Get default factory instance */
public static PropertyAccessorFactory getDefault();
}Default implementations provided by JAX-WS RI.
/**
* Default JAXB databinding provider implementation
*/
package com.sun.xml.ws.db;
public final class DatabindingProviderImpl implements DatabindingProvider {
/** Check if provider handles mode */
public boolean isFor(String databindingMode);
/** Initialize with properties */
public void init(Map<String, Object> properties);
/** Create databinding instance */
public Databinding create(DatabindingConfig config);
}
/**
* JAXB RI binding context factory
*/
package com.sun.xml.ws.db.glassfish;
public final class JAXBRIContextFactory implements BindingContextFactory {
/** Create new binding context from JAXB context */
public BindingContext newContext(JAXBContext jaxbContext);
/** Create binding context with binding info */
public BindingContext newContext(BindingInfo bindingInfo);
}Usage Examples:
import com.oracle.webservices.api.databinding.*;
import com.sun.xml.ws.spi.db.*;
// Basic databinding configuration
DatabindingConfig config = new DatabindingConfig()
.setContractClass(MyServiceInterface.class)
.setEndpointClass(MyServiceImpl.class)
.setDatabindingMode(DatabindingMode.glassfish_jaxb);
// Create databinding instance
DatabindingFactory factory = DatabindingFactory.newInstance();
Databinding databinding = factory.createDatabinding(config);
// Server-side call bridge usage
Method serviceMethod = MyServiceInterface.class.getMethod("processData", DataRequest.class);
JavaCallInfo callInfo = JavaCallInfo.create(serviceMethod, new Object[0]);
EndpointCallBridge bridge = databinding.createCallBridge(callInfo);
// Invoke service method
Object serviceInstance = new MyServiceImpl();
DataRequest request = new DataRequest();
Object result = bridge.invoke(serviceInstance, request);
// Client-side call bridge usage
ClientCallBridge clientBridge = databinding.createCallBridge(callInfo);
JavaCallInfo clientCallInfo = JavaCallInfo.create(serviceMethod, new Object[]{ request });
// Create request packet
Packet requestPacket = clientBridge.createRequestPacket(clientCallInfo);
// Process response (after receiving response packet)
JavaCallInfo responseInfo = clientBridge.readResponse(responsePacket, clientCallInfo);
Object returnValue = responseInfo.getReturnValue();
// Custom databinding provider
public class MyDatabindingProvider implements DatabindingProvider {
public boolean isFor(String databindingMode) {
return "custom".equals(databindingMode);
}
public void init(Map<String, Object> properties) {
// Initialize provider
}
public Databinding create(DatabindingConfig config) {
return new MyCustomDatabinding(config);
}
}
// XML Bridge usage for individual types
TypeInfo typeInfo = new TypeInfo(DataRequest.class);
XMLBridge<DataRequest> bridge = databinding.createBridge(typeInfo);
// Marshal to XML
StringWriter writer = new StringWriter();
XMLStreamWriter xmlWriter = XMLOutputFactory.newInstance().createXMLStreamWriter(writer);
bridge.marshal(request, xmlWriter);
String xml = writer.toString();
// Unmarshal from XML
StringReader reader = new StringReader(xml);
XMLStreamReader xmlReader = XMLInputFactory.newInstance().createXMLStreamReader(reader);
DataRequest unmarshalled = bridge.unmarshal(xmlReader);
// Advanced databinding configuration with features
DatabindingConfig advancedConfig = new DatabindingConfig()
.setContractClass(MyServiceInterface.class)
.setDatabindingMode(DatabindingMode.glassfish_jaxb)
.setFeatures(new UsesJAXBContextFeature(createCustomJAXBContext()))
.setMetadataReader(new ExternalMetadataReader());
// Property accessor usage
PropertyAccessorFactory accessorFactory = PropertyAccessorFactory.getDefault();
Field nameField = DataRequest.class.getDeclaredField("name");
PropertyAccessor nameAccessor = accessorFactory.createFieldAccessor(DataRequest.class, nameField);
// Use accessor
DataRequest obj = new DataRequest();
nameAccessor.set(obj, "value");
String name = (String) nameAccessor.get(obj);
// Binding context for low-level operations
BindingContextFactory contextFactory = new JAXBRIContextFactory();
BindingContext bindingContext = contextFactory.newContext(DataRequest.class, DataResponse.class);
// Create bridge from binding context
XMLBridge<DataRequest> contextBridge = bindingContext.createBridge(new TypeInfo(DataRequest.class));Install with Tessl CLI
npx tessl i tessl/maven-com-sun-xml-ws--jaxws-rt