feat(jdk8): move files to new folder to avoid resources compiled.
This commit is contained in:
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code 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 General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.oracle.webservices.internal.api;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
import javax.xml.ws.http.HTTPBinding;
|
||||
import javax.xml.ws.soap.SOAPBinding;
|
||||
import javax.xml.ws.spi.WebServiceFeatureAnnotation;
|
||||
|
||||
/**
|
||||
* The EnvelopeStyle annotation is used to specify the message envelope style(s)
|
||||
* for a web service endpoint implementation class. To smooth the migration from
|
||||
* the BindingType annotation to this EnvelopeStyle annotation, each of the
|
||||
* styles is mapped to a binding identifier defined in JAX-WS specification.
|
||||
* Though a binding identifier includes both the envelope style and transport,
|
||||
* an envelope style defined herein does NOT imply or mandate any transport protocol
|
||||
* to be use together; HTTP is the default transport. An implementation may
|
||||
* chose to support other transport with any of the envelope styles.
|
||||
*
|
||||
* This annotation may be overriden programmatically or via deployment
|
||||
* descriptors, depending on the platform in use.
|
||||
*
|
||||
* @author shih-chang.chen@oracle.com
|
||||
*/
|
||||
@WebServiceFeatureAnnotation(id="", bean=com.oracle.webservices.internal.api.EnvelopeStyleFeature.class)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface EnvelopeStyle {
|
||||
|
||||
/**
|
||||
* The envelope styles. If not specified, the default is the SOAP 1.1.
|
||||
*
|
||||
* @return The enveloping styles
|
||||
*/
|
||||
Style[] style() default { Style.SOAP11 };
|
||||
|
||||
public enum Style {
|
||||
|
||||
/**
|
||||
* SOAP1.1. For JAX-WS, this is mapped from:
|
||||
* javax.xml.ws.soap.SOAPBinding.SOAP11HTTP_BINDING
|
||||
*/
|
||||
SOAP11(SOAPBinding.SOAP11HTTP_BINDING),
|
||||
|
||||
/**
|
||||
* SOAP1.2. For JAX-WS, this is mapped from:
|
||||
* javax.xml.ws.soap.SOAPBinding.SOAP12HTTP_BINDING
|
||||
*/
|
||||
SOAP12(SOAPBinding.SOAP12HTTP_BINDING),
|
||||
|
||||
/**
|
||||
* The raw XML. For JAX-WS, this is mapped from:
|
||||
* javax.xml.ws.http.HTTPBinding.HTTP_BINDING
|
||||
*/
|
||||
XML(HTTPBinding.HTTP_BINDING);
|
||||
|
||||
/**
|
||||
* The BindingID used by the BindingType annotation.
|
||||
*/
|
||||
public final String bindingId;
|
||||
|
||||
private Style(String id) {
|
||||
bindingId = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the style is SOAP 1.1.
|
||||
*
|
||||
* @return true if the style is SOAP 1.1.
|
||||
*/
|
||||
public boolean isSOAP11() { return this.equals(SOAP11); }
|
||||
|
||||
/**
|
||||
* Checks if the style is SOAP 1.2.
|
||||
*
|
||||
* @return true if the style is SOAP 1.2.
|
||||
*/
|
||||
public boolean isSOAP12() { return this.equals(SOAP12); }
|
||||
|
||||
/**
|
||||
* Checks if the style is XML.
|
||||
*
|
||||
* @return true if the style is XML.
|
||||
*/
|
||||
public boolean isXML() { return this.equals(XML); }
|
||||
}
|
||||
}
|
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code 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 General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.oracle.webservices.internal.api;
|
||||
|
||||
import javax.xml.ws.WebServiceFeature;
|
||||
|
||||
public class EnvelopeStyleFeature extends WebServiceFeature {
|
||||
|
||||
private EnvelopeStyle.Style[] styles;
|
||||
|
||||
public EnvelopeStyleFeature(EnvelopeStyle.Style... s) {
|
||||
styles = s;
|
||||
}
|
||||
|
||||
public EnvelopeStyle.Style[] getStyles() {
|
||||
return styles;
|
||||
}
|
||||
|
||||
public String getID() {
|
||||
return EnvelopeStyleFeature.class.getName();
|
||||
}
|
||||
}
|
@@ -0,0 +1,247 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code 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 General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.oracle.webservices.internal.api.databinding;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URL;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.transform.Source;
|
||||
import javax.xml.ws.WebServiceFeature;
|
||||
|
||||
import org.xml.sax.EntityResolver;
|
||||
|
||||
import com.oracle.webservices.internal.api.message.MessageContext;
|
||||
|
||||
/**
|
||||
* {@code Databinding} is the entry point for all the WebService Databinding
|
||||
* functionality. Primarily, a Databinding is to serialize/deserialize an
|
||||
* XML(SOAP) message to/from a JAVA method invocation and return which are
|
||||
* represented as <code>JavaCallInfo</code> instances. A WSDLGenerator can
|
||||
* be created from a Databinding object to genreate WSDL representation of
|
||||
* a JAVA service endpoint interface.
|
||||
* <p>
|
||||
* </p>
|
||||
* The supported databinding modes(flavors) are:
|
||||
* <ul>
|
||||
* <li>"toplink.jaxb"</li>
|
||||
* <li>"glassfish.jaxb"</li>
|
||||
* </ul>
|
||||
* <blockquote> Following is an example that creates a {@code Databinding} which
|
||||
* provides the operations to serialize/deserialize a JavaCallInfo to/from a
|
||||
* SOAP message:<br/>
|
||||
*
|
||||
* <pre>
|
||||
* DatabindingFactory factory = DatabindingFactory.newInstance();
|
||||
* Databinding.Builder builder = factory.createBuilder(seiClass, endpointClass);
|
||||
* Databinding databinding = builder.build();
|
||||
* </pre>
|
||||
*
|
||||
* </blockquote>
|
||||
*
|
||||
* @see com.oracle.webservices.internal.api.databinding.DatabindingFactory
|
||||
*
|
||||
* @author shih-chang.chen@oracle.com
|
||||
*/
|
||||
public interface Databinding {
|
||||
|
||||
/**
|
||||
* Creates a new instance of a <code>JavaCallInfo</code>.
|
||||
*
|
||||
* @param method The JAVA method
|
||||
* @param args The parameter objects
|
||||
*
|
||||
* @return New instance of a <code>JavaCallInfo</code>
|
||||
*/
|
||||
JavaCallInfo createJavaCallInfo(Method method, Object[] args);
|
||||
|
||||
/**
|
||||
* Serializes a JavaCallInfo instance representing a JAVA method call to a
|
||||
* request XML(SOAP) message.
|
||||
*
|
||||
* @param call The JavaCallInfo representing a method call
|
||||
*
|
||||
* @return The request XML(SOAP) message
|
||||
*/
|
||||
MessageContext serializeRequest(JavaCallInfo call);
|
||||
|
||||
/**
|
||||
* Deserializes a response XML(SOAP) message to a JavaCallInfo instance
|
||||
* representing the return value or exception of a JAVA method call.
|
||||
*
|
||||
* @param message The response message
|
||||
* @param call The JavaCallInfo instance to be updated
|
||||
*
|
||||
* @return The JavaCallInfo updated with the return value or exception of a
|
||||
* JAVA method call
|
||||
*/
|
||||
JavaCallInfo deserializeResponse(MessageContext message, JavaCallInfo call);
|
||||
|
||||
/**
|
||||
* Deserializes a request XML(SOAP) message to a JavaCallInfo instance
|
||||
* representing a JAVA method call.
|
||||
*
|
||||
* @param message The request message
|
||||
*
|
||||
* @return The JavaCallInfo representing a method call
|
||||
*/
|
||||
JavaCallInfo deserializeRequest(MessageContext message);
|
||||
|
||||
/**
|
||||
* Serializes a JavaCallInfo instance representing the return value or
|
||||
* exception of a JAVA method call to a response XML(SOAP) message.
|
||||
*
|
||||
* @param call The JavaCallInfo representing the return value or exception
|
||||
* of a JAVA method call
|
||||
*
|
||||
* @return The response XML(SOAP) message
|
||||
*/
|
||||
MessageContext serializeResponse(JavaCallInfo call);
|
||||
|
||||
/**
|
||||
* Gets the MessageContextFactory
|
||||
*
|
||||
* @return The MessageContextFactory
|
||||
*/
|
||||
//Wait for WLS/src1212 - wls.jaxrpc wrapper
|
||||
// MessageContextFactory getMessageContextFactory();
|
||||
|
||||
/**
|
||||
* {@code Databinding.Builder}, created from the DatabindingFactory, is used to
|
||||
* configure how a Databinding instance is to be built from this builder.
|
||||
*
|
||||
* @see com.oracle.webservices.internal.api.databinding.DatabindingFactory
|
||||
* @author shih-chang.chen@oracle.com
|
||||
*/
|
||||
public interface Builder {
|
||||
|
||||
/**
|
||||
* Sets the targetNamespace of the WSDL
|
||||
*
|
||||
* @param targetNamespace The targetNamespace to set
|
||||
*
|
||||
* @return this Builder instance
|
||||
*/
|
||||
Builder targetNamespace(String targetNamespace);
|
||||
|
||||
/**
|
||||
* Sets the service name of the WSDL
|
||||
*
|
||||
* @param serviceName The serviceName to set
|
||||
*
|
||||
* @return this Builder instance
|
||||
*/
|
||||
Builder serviceName(QName serviceName);
|
||||
|
||||
/**
|
||||
* Sets the port name of the WSDL
|
||||
*
|
||||
* @param portName The portName to set
|
||||
*
|
||||
* @return this Builder instance
|
||||
*/
|
||||
Builder portName(QName portName);
|
||||
|
||||
/**
|
||||
* @deprecated - no replacement - this was never implemented
|
||||
*
|
||||
* Sets the WSDL URL where the WSDL can be read from
|
||||
*
|
||||
* @param wsdlURL The wsdlURL to set
|
||||
*
|
||||
* @return this Builder instance
|
||||
*/
|
||||
Builder wsdlURL(URL wsdlURL);
|
||||
|
||||
/**
|
||||
* @deprecated - no replacement - this was never implemented
|
||||
*
|
||||
* Sets the WSDL Source where the WSDL can be read from
|
||||
*
|
||||
* @param wsdlSource The wsdlSource to set
|
||||
*
|
||||
* @return this Builder instance
|
||||
*/
|
||||
Builder wsdlSource(Source wsdlSource);
|
||||
|
||||
/**
|
||||
* @deprecated - no replacement - this was never implemented
|
||||
*
|
||||
* Sets the {@link EntityResolver} for reading the WSDL
|
||||
*
|
||||
* @param entityResolver The {@link EntityResolver} to set
|
||||
*
|
||||
* @return this Builder instance
|
||||
*/
|
||||
Builder entityResolver(EntityResolver entityResolver);
|
||||
|
||||
/**
|
||||
* Sets the ClassLoader which is used to load the service endpoint
|
||||
* interface, implementation bean, and all the value types. If this
|
||||
* value is not set, the default it uses contractClass.getClassLoader().
|
||||
*
|
||||
* @param classLoader The classLoader to set
|
||||
*
|
||||
* @return this Builder instance
|
||||
*/
|
||||
Builder classLoader(ClassLoader classLoader);
|
||||
|
||||
/**
|
||||
* Sets A list of WebServiceFeatures
|
||||
*
|
||||
* @param features The list of WebServiceFeatures
|
||||
*
|
||||
* @return this Builder instance
|
||||
*/
|
||||
Builder feature(WebServiceFeature... features);
|
||||
|
||||
/**
|
||||
* Sets A property of the Databinding object to be created
|
||||
*
|
||||
* @param name The name of the property
|
||||
* @param value The value of the property
|
||||
*
|
||||
* @return this Builder instance
|
||||
*/
|
||||
Builder property(String name, Object value);
|
||||
|
||||
/**
|
||||
* Builds a new Databinding instance
|
||||
*
|
||||
* @return The Builder instance
|
||||
*/
|
||||
Databinding build();
|
||||
|
||||
/**
|
||||
* Creates the WSDLGenerator which can be used to generate the WSDL
|
||||
* representation of the service endpoint interface of this Databinding
|
||||
* object.
|
||||
*
|
||||
* @return WSDLGenerator The WSDLGenerator
|
||||
*/
|
||||
com.oracle.webservices.internal.api.databinding.WSDLGenerator createWSDLGenerator();
|
||||
}
|
||||
}
|
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code 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 General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.oracle.webservices.internal.api.databinding;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* {@code DatabindingFactory} is the entry point of all the WebService
|
||||
* Databinding APIs. A DatabindingFactory instance can be used to create
|
||||
* <code>Databinding.Builder</code> instances, and <code>Databinding.Builder</code>
|
||||
* instances are used to configure and build <code>Databinding</code> instances.
|
||||
* <p>
|
||||
* </P>
|
||||
* <blockquote>
|
||||
* Following is an example that creates a {@code Databinding} which provides the
|
||||
* operations to serialize/deserialize a JavaCallInfo to/from a SOAP message:<br/>
|
||||
* <pre>
|
||||
* DatabindingFactory factory = DatabindingFactory.newInstance();
|
||||
* Databinding.Builder builder = factory.createBuilder(seiClass, endpointClass);
|
||||
* Databinding databinding = builder.build();
|
||||
* </pre>
|
||||
* </blockquote>
|
||||
*
|
||||
* @see com.oracle.webservices.internal.api.databinding.Databinding
|
||||
*
|
||||
* @author shih-chang.chen@oracle.com
|
||||
*/
|
||||
public abstract class DatabindingFactory {
|
||||
|
||||
/**
|
||||
* Creates a new instance of a <code>Databinding.Builder</code> which is
|
||||
* initialized with the specified contractClass and endpointClass. The most
|
||||
* importance initial states of a Builder object is the contract class which
|
||||
* is also called "service endpoint interface" or "SEI" in JAX-WS and JAX-RPC,
|
||||
* and the implementation bean class (endpointClass). The the implementation
|
||||
* bean class (endpointClass) should be null if the Builder is to create
|
||||
* the client side proxy databinding.
|
||||
*
|
||||
* @param contractClass The service endpoint interface class
|
||||
* @param endpointClass The service implementation bean class
|
||||
*
|
||||
* @return New instance of a <code>Databinding.Builder</code>
|
||||
*/
|
||||
abstract public Databinding.Builder createBuilder(Class<?> contractClass, Class<?> endpointClass);
|
||||
|
||||
/**
|
||||
* Access properties on the <code>DatabindingFactory</code> instance.
|
||||
*
|
||||
* @return properties of this WsFactory
|
||||
*/
|
||||
abstract public Map<String, Object> properties();
|
||||
|
||||
/**
|
||||
* The default implementation class name.
|
||||
*/
|
||||
static final String ImplClass = "com.sun.xml.internal.ws.db.DatabindingFactoryImpl";
|
||||
|
||||
/**
|
||||
* Create a new instance of a <code>DatabindingFactory</code>. This static method
|
||||
* creates a new factory instance.
|
||||
*
|
||||
* Once an application has obtained a reference to a <code>DatabindingFactory</code>
|
||||
* it can use the factory to obtain and configure a <code>Databinding.Builder</code>
|
||||
* to build a <code>Databinding</code> instances.
|
||||
*
|
||||
* @return New instance of a <code>DatabindingFactory</code>
|
||||
*/
|
||||
static public DatabindingFactory newInstance() {
|
||||
try {
|
||||
Class<?> cls = Class.forName(ImplClass);
|
||||
return convertIfNecessary(cls);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private static DatabindingFactory convertIfNecessary(Class<?> cls) throws InstantiationException, IllegalAccessException {
|
||||
return (DatabindingFactory) cls.newInstance();
|
||||
}
|
||||
}
|
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code 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 General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.oracle.webservices.internal.api.databinding;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
import javax.xml.ws.spi.WebServiceFeatureAnnotation;
|
||||
|
||||
@WebServiceFeatureAnnotation(id="", bean=com.oracle.webservices.internal.api.databinding.DatabindingModeFeature.class)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface DatabindingMode {
|
||||
String value();
|
||||
}
|
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code 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 General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.oracle.webservices.internal.api.databinding;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.xml.ws.WebServiceFeature;
|
||||
|
||||
public class DatabindingModeFeature extends WebServiceFeature implements com.sun.xml.internal.ws.api.ServiceSharedFeatureMarker {
|
||||
/**
|
||||
* Constant value identifying the DatabindingFeature
|
||||
*/
|
||||
static public final String ID = "http://jax-ws.java.net/features/databinding";
|
||||
|
||||
static public final String GLASSFISH_JAXB = "glassfish.jaxb";
|
||||
|
||||
//These constants should be defined in the corresponding plugin package
|
||||
// static public final String ECLIPSELINK_JAXB = "eclipselink.jaxb";
|
||||
// static public final String ECLIPSELINK_SDO = "eclipselink.sdo";
|
||||
// static public final String TOPLINK_JAXB = "toplink.jaxb";
|
||||
// static public final String TOPLINK_SDO = "toplink.sdo";
|
||||
|
||||
private String mode;
|
||||
private Map<String, Object> properties;
|
||||
|
||||
public DatabindingModeFeature(String mode) {
|
||||
super();
|
||||
this.mode = mode;
|
||||
properties = new HashMap<String, Object>();
|
||||
}
|
||||
|
||||
public String getMode() {
|
||||
return mode;
|
||||
}
|
||||
|
||||
public String getID() {
|
||||
return ID;
|
||||
}
|
||||
|
||||
public Map<String, Object> getProperties() {
|
||||
return properties;
|
||||
}
|
||||
|
||||
public static Builder builder() { return new Builder(new DatabindingModeFeature(null)); }
|
||||
|
||||
public final static class Builder {
|
||||
final private DatabindingModeFeature o;
|
||||
Builder(final DatabindingModeFeature x) { o = x; }
|
||||
public DatabindingModeFeature build() { return o; }
|
||||
// public DatabindingModeFeature build() { return (DatabindingModeFeature) FeatureValidator.validate(o); }
|
||||
public Builder value(final String x) { o.mode = x; return this; }
|
||||
}
|
||||
}
|
@@ -0,0 +1,163 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code 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 General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.oracle.webservices.internal.api.databinding;
|
||||
|
||||
import com.sun.xml.internal.ws.api.databinding.MetadataReader;
|
||||
import com.sun.xml.internal.ws.model.ExternalMetadataReader;
|
||||
|
||||
import javax.xml.ws.WebServiceFeature;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* WebServiceFeature allowing to define either on server or client side external xml descriptors replacing/supplementing
|
||||
* WS metadata provided by class annotations. This can be useful if those annotations are missing (existing non-WS
|
||||
* components) or if it is necessary to override those.
|
||||
*
|
||||
* @author Miroslav Kos (miroslav.kos at oracle.com)
|
||||
*/
|
||||
public class ExternalMetadataFeature extends WebServiceFeature {
|
||||
|
||||
private static final String ID = "com.oracle.webservices.internal.api.databinding.ExternalMetadataFeature";
|
||||
|
||||
/**
|
||||
* Enable this feature. Defaults to true.
|
||||
*/
|
||||
private boolean enabled = true;
|
||||
|
||||
private List<String> resourceNames;
|
||||
private List<File> files;
|
||||
private MetadataReader reader;
|
||||
|
||||
private ExternalMetadataFeature() {
|
||||
}
|
||||
|
||||
public void addResources(String... resourceNames) {
|
||||
if (this.resourceNames == null) {
|
||||
this.resourceNames = new ArrayList<String>();
|
||||
}
|
||||
Collections.addAll(this.resourceNames, resourceNames);
|
||||
}
|
||||
|
||||
public List<String> getResourceNames() { return resourceNames; }
|
||||
|
||||
public void addFiles(File... files) {
|
||||
if (this.files == null) {
|
||||
this.files = new ArrayList<File>();
|
||||
}
|
||||
Collections.addAll(this.files, files);
|
||||
}
|
||||
|
||||
public List<File> getFiles() { return files; }
|
||||
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
private void setEnabled(final boolean x) {
|
||||
enabled = x;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getID() {
|
||||
return ID;
|
||||
}
|
||||
|
||||
public MetadataReader getMetadataReader(ClassLoader classLoader, boolean disableXmlSecurity) {
|
||||
if (reader != null && enabled) return reader;
|
||||
return enabled ? new ExternalMetadataReader(files, resourceNames, classLoader, true, disableXmlSecurity) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
ExternalMetadataFeature that = (ExternalMetadataFeature) o;
|
||||
|
||||
if (enabled != that.enabled) return false;
|
||||
if (files != null ? !files.equals(that.files) : that.files != null) return false;
|
||||
if (resourceNames != null ? !resourceNames.equals(that.resourceNames) : that.resourceNames != null)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = (enabled ? 1 : 0);
|
||||
result = 31 * result + (resourceNames != null ? resourceNames.hashCode() : 0);
|
||||
result = 31 * result + (files != null ? files.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[" + getID() +
|
||||
", enabled=" + enabled +
|
||||
", resourceNames=" + resourceNames +
|
||||
", files=" + files +
|
||||
']';
|
||||
}
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder(new ExternalMetadataFeature());
|
||||
}
|
||||
|
||||
public final static class Builder {
|
||||
final private ExternalMetadataFeature o;
|
||||
|
||||
Builder(final ExternalMetadataFeature x) {
|
||||
o = x;
|
||||
}
|
||||
|
||||
public ExternalMetadataFeature build() {
|
||||
return o;
|
||||
}
|
||||
|
||||
public Builder addResources(String... res) {
|
||||
o.addResources(res);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder addFiles(File... files) {
|
||||
o.addFiles(files);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setEnabled(boolean enabled) {
|
||||
o.setEnabled(enabled);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setReader( MetadataReader r ) {
|
||||
o.reader = r;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code 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 General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.oracle.webservices.internal.api.databinding;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/**
|
||||
* On the client or service-requestor side, a JavaCallInfo object represents a
|
||||
* method call on the service proxy to be serialized as a SOAP request message
|
||||
* to be sent to the service. A SOAP response message returned to the service
|
||||
* client is deserialized as an update to the JavaCallInfo object which is used
|
||||
* to generated the request.
|
||||
* <p>
|
||||
* </p>
|
||||
* On the server or service provider side, a SOAP request message is
|
||||
* deserialized to a JavaCallInfo object which can be used to determine which
|
||||
* method to call, and get the parameter values to call the back-end service
|
||||
* implementation object. The return value or exception returned from the
|
||||
* service implementation should be set to the JavaCallInfo object which then
|
||||
* can be used to serialize to a A SOAP response or fault message to be sent
|
||||
* back to the service client.
|
||||
*
|
||||
* @author shih-chang.chen@oracle.com
|
||||
*/
|
||||
public interface JavaCallInfo {
|
||||
|
||||
/**
|
||||
* Gets the method of this JavaCallInfo
|
||||
*
|
||||
* @return the method
|
||||
*/
|
||||
public Method getMethod();
|
||||
|
||||
// /**
|
||||
// * Sets the method of this JavaCallInfo
|
||||
// *
|
||||
// * @param method The method to set
|
||||
// */
|
||||
// public void setMethod(Method method);
|
||||
|
||||
/**
|
||||
* Gets the parameters of this JavaCallInfo
|
||||
*
|
||||
* @return The parameters
|
||||
*/
|
||||
public Object[] getParameters();
|
||||
|
||||
// /**
|
||||
// * Sets the parameters of this JavaCallInfo
|
||||
// *
|
||||
// * @param parameters
|
||||
// * the parameters to set
|
||||
// */
|
||||
// public void setParameters(Object[] parameters);
|
||||
|
||||
/**
|
||||
* Gets the returnValue of this JavaCallInfo
|
||||
*
|
||||
* @return the returnValue
|
||||
*/
|
||||
public Object getReturnValue();
|
||||
|
||||
/**
|
||||
* Sets the returnValue of this JavaCallInfo
|
||||
*
|
||||
* @param returnValue
|
||||
* the returnValue to set
|
||||
*/
|
||||
public void setReturnValue(Object returnValue);
|
||||
|
||||
/**
|
||||
* Gets the exception of this JavaCallInfo
|
||||
*
|
||||
* @return the exception
|
||||
*/
|
||||
public Throwable getException();
|
||||
|
||||
/**
|
||||
* Sets the exception of this JavaCallInfo
|
||||
*
|
||||
* @param exception
|
||||
* the exception to set
|
||||
*/
|
||||
public void setException(Throwable exception);
|
||||
}
|
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code 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 General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.oracle.webservices.internal.api.databinding;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* WSDLGenerator is used to generate the WSDL representation of the service
|
||||
* endpoint interface of the parent Databinding object.
|
||||
*/
|
||||
public interface WSDLGenerator {
|
||||
|
||||
/**
|
||||
* Sets the inlineSchema boolean. When the inlineSchema is true, the
|
||||
* generated schema documents are embedded within the type element of
|
||||
* the generated WSDL. When the inlineSchema is false, the generated
|
||||
* schema documents are generated as standalone schema documents and
|
||||
* imported into the generated WSDL.
|
||||
*
|
||||
* @param inline the inlineSchema boolean.
|
||||
* @return
|
||||
*/
|
||||
WSDLGenerator inlineSchema(boolean inline);
|
||||
|
||||
/**
|
||||
* Sets A property of the WSDLGenerator
|
||||
*
|
||||
* @param name The name of the property
|
||||
* @param value The value of the property
|
||||
*
|
||||
* @return this WSDLGenerator instance
|
||||
*/
|
||||
WSDLGenerator property(String name, Object value);
|
||||
|
||||
/**
|
||||
* Generates the WSDL using the wsdlResolver to output the generated
|
||||
* documents.
|
||||
*
|
||||
* @param wsdlResolver The WSDLResolver
|
||||
*/
|
||||
void generate(com.oracle.webservices.internal.api.databinding.WSDLResolver wsdlResolver);
|
||||
|
||||
/**
|
||||
* Generates the WSDL into the file directory
|
||||
*
|
||||
* @param outputDir The output file directory
|
||||
* @param name The file name of the main WSDL document
|
||||
*/
|
||||
void generate(File outputDir, String name);
|
||||
}
|
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code 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 General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.oracle.webservices.internal.api.databinding;
|
||||
|
||||
import javax.xml.transform.Result;
|
||||
import javax.xml.ws.Holder;
|
||||
|
||||
/**
|
||||
* WSDLResolver is used by WSDLGenerator while generating WSDL and its associated
|
||||
* documents. It is used to control what documents need to be generated and what
|
||||
* documents need to be picked from metadata. If endpont's document metadata
|
||||
* already contains some documents, their systemids may be used for wsdl:import,
|
||||
* and schema:import. The suggested filenames are relative urls(for e.g: EchoSchema1.xsd)
|
||||
* The Result object systemids are also relative urls(for e.g: AbsWsdl.wsdl).
|
||||
*
|
||||
* @author Jitendra Kotamraju
|
||||
*/
|
||||
public interface WSDLResolver {
|
||||
/**
|
||||
* Create a Result object into which concrete WSDL is to be generated.
|
||||
*
|
||||
* @return Result for the concrete WSDL
|
||||
*/
|
||||
public Result getWSDL(String suggestedFilename);
|
||||
|
||||
/**
|
||||
* Create a Result object into which abstract WSDL is to be generated. If the the
|
||||
* abstract WSDL is already in metadata, it is not generated.
|
||||
*
|
||||
* Update filename if the suggested filename need to be changed in wsdl:import.
|
||||
* This needs to be done if the metadata contains abstract WSDL, and that systemid
|
||||
* needs to be reflected in concrete WSDL's wsdl:import
|
||||
*
|
||||
* @return null if abstract WSDL need not be generated
|
||||
*/
|
||||
public Result getAbstractWSDL(Holder<String> filename);
|
||||
|
||||
/**
|
||||
* Create a Result object into which schema doc is to be generated. Typically if
|
||||
* there is a schema doc for namespace in metadata, then it is not generated.
|
||||
*
|
||||
* Update filename if the suggested filename need to be changed in xsd:import. This
|
||||
* needs to be done if the metadata contains the document, and that systemid
|
||||
* needs to be reflected in some other document's xsd:import
|
||||
*
|
||||
* @return null if schema need not be generated
|
||||
*/
|
||||
public Result getSchemaOutput(String namespace, Holder<String> filename);
|
||||
|
||||
}
|
@@ -0,0 +1,308 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code 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 General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.oracle.webservices.internal.api.message;
|
||||
|
||||
import com.sun.istack.internal.NotNull;
|
||||
import com.sun.istack.internal.Nullable;
|
||||
import com.sun.xml.internal.ws.api.message.Packet;
|
||||
import com.sun.xml.internal.ws.client.RequestContext;
|
||||
import com.sun.xml.internal.ws.client.ResponseContext;
|
||||
|
||||
import javax.xml.ws.WebServiceContext;
|
||||
|
||||
import java.util.AbstractMap;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.HashSet;
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* {@link PropertySet} that combines properties exposed from multiple
|
||||
* {@link PropertySet}s into one.
|
||||
*
|
||||
* <p>
|
||||
* This implementation allows one {@link PropertySet} to assemble
|
||||
* all properties exposed from other "satellite" {@link PropertySet}s.
|
||||
* (A satellite may itself be a {@link DistributedPropertySet}, so
|
||||
* in general this can form a tree.)
|
||||
*
|
||||
* <p>
|
||||
* This is useful for JAX-WS because the properties we expose to the application
|
||||
* are contributed by different pieces, and therefore we'd like each of them
|
||||
* to have a separate {@link PropertySet} implementation that backs up
|
||||
* the properties. For example, this allows FastInfoset to expose its
|
||||
* set of properties to {@link RequestContext} by using a strongly-typed fields.
|
||||
*
|
||||
* <p>
|
||||
* This is also useful for a client-side transport to expose a bunch of properties
|
||||
* into {@link ResponseContext}. It simply needs to create a {@link PropertySet}
|
||||
* object with methods for each property it wants to expose, and then add that
|
||||
* {@link PropertySet} to {@link Packet}. This allows property values to be
|
||||
* lazily computed (when actually asked by users), thus improving the performance
|
||||
* of the typical case where property values are not asked.
|
||||
*
|
||||
* <p>
|
||||
* A similar benefit applies on the server-side, for a transport to expose
|
||||
* a bunch of properties to {@link WebServiceContext}.
|
||||
*
|
||||
* <p>
|
||||
* To achieve these benefits, access to {@link DistributedPropertySet} is slower
|
||||
* compared to {@link PropertySet} (such as get/set), while adding a satellite
|
||||
* object is relatively fast.
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
public abstract class BaseDistributedPropertySet extends BasePropertySet implements DistributedPropertySet {
|
||||
|
||||
/**
|
||||
* All {@link PropertySet}s that are bundled into this {@link PropertySet}.
|
||||
*/
|
||||
private final Map<Class<? extends com.oracle.webservices.internal.api.message.PropertySet>, PropertySet> satellites
|
||||
= new IdentityHashMap<Class<? extends com.oracle.webservices.internal.api.message.PropertySet>, PropertySet>();
|
||||
|
||||
private final Map<String, Object> viewthis;
|
||||
|
||||
public BaseDistributedPropertySet() {
|
||||
this.viewthis = super.createView();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addSatellite(@NotNull PropertySet satellite) {
|
||||
addSatellite(satellite.getClass(), satellite);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addSatellite(@NotNull Class<? extends com.oracle.webservices.internal.api.message.PropertySet> keyClass, @NotNull PropertySet satellite) {
|
||||
satellites.put(keyClass, satellite);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeSatellite(PropertySet satellite) {
|
||||
satellites.remove(satellite.getClass());
|
||||
}
|
||||
|
||||
public void copySatelliteInto(@NotNull DistributedPropertySet r) {
|
||||
for (Map.Entry<Class<? extends com.oracle.webservices.internal.api.message.PropertySet>, PropertySet> entry : satellites.entrySet()) {
|
||||
r.addSatellite(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copySatelliteInto(MessageContext r) {
|
||||
copySatelliteInto((DistributedPropertySet)r);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable <T extends com.oracle.webservices.internal.api.message.PropertySet> T getSatellite(Class<T> satelliteClass) {
|
||||
T satellite = (T) satellites.get(satelliteClass);
|
||||
if (satellite != null) {
|
||||
return satellite;
|
||||
}
|
||||
|
||||
for (PropertySet child : satellites.values()) {
|
||||
if (satelliteClass.isInstance(child)) {
|
||||
return satelliteClass.cast(child);
|
||||
}
|
||||
|
||||
if (DistributedPropertySet.class.isInstance(child)) {
|
||||
satellite = DistributedPropertySet.class.cast(child).getSatellite(satelliteClass);
|
||||
if (satellite != null) {
|
||||
return satellite;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Class<? extends com.oracle.webservices.internal.api.message.PropertySet>, com.oracle.webservices.internal.api.message.PropertySet> getSatellites() {
|
||||
return satellites;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object get(Object key) {
|
||||
// check satellites
|
||||
for (PropertySet child : satellites.values()) {
|
||||
if (child.supports(key)) {
|
||||
return child.get(key);
|
||||
}
|
||||
}
|
||||
|
||||
// otherwise it must be the master
|
||||
return super.get(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object put(String key, Object value) {
|
||||
// check satellites
|
||||
for (PropertySet child : satellites.values()) {
|
||||
if(child.supports(key)) {
|
||||
return child.put(key,value);
|
||||
}
|
||||
}
|
||||
|
||||
// otherwise it must be the master
|
||||
return super.put(key,value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsKey(Object key) {
|
||||
if (viewthis.containsKey(key))
|
||||
return true;
|
||||
for (PropertySet child : satellites.values()) {
|
||||
if (child.containsKey(key)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supports(Object key) {
|
||||
// check satellites
|
||||
for (PropertySet child : satellites.values()) {
|
||||
if (child.supports(key)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return super.supports(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object remove(Object key) {
|
||||
// check satellites
|
||||
for (PropertySet child : satellites.values()) {
|
||||
if (child.supports(key)) {
|
||||
return child.remove(key);
|
||||
}
|
||||
}
|
||||
|
||||
return super.remove(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createEntrySet(Set<Entry<String, Object>> core) {
|
||||
super.createEntrySet(core);
|
||||
for (PropertySet child : satellites.values()) {
|
||||
((BasePropertySet) child).createEntrySet(core);
|
||||
}
|
||||
}
|
||||
|
||||
protected Map<String, Object> asMapLocal() {
|
||||
return viewthis;
|
||||
}
|
||||
|
||||
protected boolean supportsLocal(Object key) {
|
||||
return super.supports(key);
|
||||
}
|
||||
|
||||
class DistributedMapView extends AbstractMap<String, Object> {
|
||||
@Override
|
||||
public Object get(Object key) {
|
||||
for (PropertySet child : satellites.values()) {
|
||||
if (child.supports(key)) {
|
||||
return child.get(key);
|
||||
}
|
||||
}
|
||||
|
||||
return viewthis.get(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
int size = viewthis.size();
|
||||
for (PropertySet child : satellites.values()) {
|
||||
size += child.asMap().size();
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsKey(Object key) {
|
||||
if (viewthis.containsKey(key))
|
||||
return true;
|
||||
for (PropertySet child : satellites.values()) {
|
||||
if (child.containsKey(key))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Entry<String, Object>> entrySet() {
|
||||
Set<Entry<String, Object>> entries = new HashSet<Entry<String, Object>>();
|
||||
for (PropertySet child : satellites.values()) {
|
||||
for (Entry<String,Object> entry : child.asMap().entrySet()) {
|
||||
// the code below is here to avoid entries.addAll(child.asMap().entrySet()); which works differently on JDK6/7
|
||||
// see DMI_ENTRY_SETS_MAY_REUSE_ENTRY_OBJECTS
|
||||
entries.add(new SimpleImmutableEntry<String, Object>(entry.getKey(), entry.getValue()));
|
||||
}
|
||||
}
|
||||
for (Entry<String,Object> entry : viewthis.entrySet()) {
|
||||
// the code below is here to avoid entries.addAll(child.asMap().entrySet()); which works differently on JDK6/7
|
||||
// see DMI_ENTRY_SETS_MAY_REUSE_ENTRY_OBJECTS
|
||||
entries.add(new SimpleImmutableEntry<String, Object>(entry.getKey(), entry.getValue()));
|
||||
}
|
||||
|
||||
return entries;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object put(String key, Object value) {
|
||||
for (PropertySet child : satellites.values()) {
|
||||
if (child.supports(key)) {
|
||||
return child.put(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
return viewthis.put(key, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
satellites.clear();
|
||||
viewthis.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object remove(Object key) {
|
||||
for (PropertySet child : satellites.values()) {
|
||||
if (child.supports(key)) {
|
||||
return child.remove(key);
|
||||
}
|
||||
}
|
||||
|
||||
return viewthis.remove(key);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Map<String, Object> createView() {
|
||||
return new DistributedMapView();
|
||||
}
|
||||
}
|
@@ -0,0 +1,548 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code 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 General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.oracle.webservices.internal.api.message;
|
||||
|
||||
import com.sun.istack.internal.NotNull;
|
||||
import com.sun.istack.internal.Nullable;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.util.AbstractMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
/**
|
||||
* A set of "properties" that can be accessed via strongly-typed fields
|
||||
* as well as reflexibly through the property name.
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
@SuppressWarnings("SuspiciousMethodCalls")
|
||||
public abstract class BasePropertySet implements PropertySet {
|
||||
|
||||
/**
|
||||
* Creates a new instance of TypedMap.
|
||||
*/
|
||||
protected BasePropertySet() {
|
||||
}
|
||||
|
||||
private Map<String,Object> mapView;
|
||||
|
||||
/**
|
||||
* Represents the list of strongly-typed known properties
|
||||
* (keyed by property names.)
|
||||
*
|
||||
* <p>
|
||||
* Just giving it an alias to make the use of this class more fool-proof.
|
||||
*/
|
||||
protected static class PropertyMap extends HashMap<String,Accessor> {
|
||||
|
||||
// the entries are often being iterated through so performance can be improved
|
||||
// by their caching instead of iterating through the original (immutable) map each time
|
||||
transient PropertyMapEntry[] cachedEntries = null;
|
||||
|
||||
PropertyMapEntry[] getPropertyMapEntries() {
|
||||
if (cachedEntries == null) {
|
||||
cachedEntries = createPropertyMapEntries();
|
||||
}
|
||||
return cachedEntries;
|
||||
}
|
||||
|
||||
private PropertyMapEntry[] createPropertyMapEntries() {
|
||||
final PropertyMapEntry[] modelEntries = new PropertyMapEntry[size()];
|
||||
int i = 0;
|
||||
for (final Entry<String, Accessor> e : entrySet()) {
|
||||
modelEntries[i++] = new PropertyMapEntry(e.getKey(), e.getValue());
|
||||
}
|
||||
return modelEntries;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* PropertyMapEntry represents a Map.Entry in the PropertyMap with more efficient access.
|
||||
*/
|
||||
static public class PropertyMapEntry {
|
||||
public PropertyMapEntry(String k, Accessor v) {
|
||||
key = k; value = v;
|
||||
}
|
||||
String key;
|
||||
Accessor value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Map representing the Fields and Methods annotated with {@link PropertySet.Property}.
|
||||
* Model of {@link PropertySet} class.
|
||||
*
|
||||
* <p>
|
||||
* At the end of the derivation chain this method just needs to be implemented
|
||||
* as:
|
||||
*
|
||||
* <pre>
|
||||
* private static final PropertyMap model;
|
||||
* static {
|
||||
* model = parse(MyDerivedClass.class);
|
||||
* }
|
||||
* protected PropertyMap getPropertyMap() {
|
||||
* return model;
|
||||
* }
|
||||
* </pre>
|
||||
*/
|
||||
protected abstract PropertyMap getPropertyMap();
|
||||
|
||||
/**
|
||||
* This method parses a class for fields and methods with {@link PropertySet.Property}.
|
||||
*/
|
||||
protected static PropertyMap parse(final Class clazz) {
|
||||
// make all relevant fields and methods accessible.
|
||||
// this allows runtime to skip the security check, so they runs faster.
|
||||
return AccessController.doPrivileged(new PrivilegedAction<PropertyMap>() {
|
||||
@Override
|
||||
public PropertyMap run() {
|
||||
PropertyMap props = new PropertyMap();
|
||||
for (Class c=clazz; c!=null; c=c.getSuperclass()) {
|
||||
for (Field f : c.getDeclaredFields()) {
|
||||
Property cp = f.getAnnotation(Property.class);
|
||||
if(cp!=null) {
|
||||
for(String value : cp.value()) {
|
||||
props.put(value, new FieldAccessor(f, value));
|
||||
}
|
||||
}
|
||||
}
|
||||
for (Method m : c.getDeclaredMethods()) {
|
||||
Property cp = m.getAnnotation(Property.class);
|
||||
if(cp!=null) {
|
||||
String name = m.getName();
|
||||
assert name.startsWith("get") || name.startsWith("is");
|
||||
|
||||
String setName = name.startsWith("is") ? "set"+name.substring(2) : // isFoo -> setFoo
|
||||
's' +name.substring(1); // getFoo -> setFoo
|
||||
Method setter;
|
||||
try {
|
||||
setter = clazz.getMethod(setName,m.getReturnType());
|
||||
} catch (NoSuchMethodException e) {
|
||||
setter = null; // no setter
|
||||
}
|
||||
for(String value : cp.value()) {
|
||||
props.put(value, new MethodAccessor(m, setter, value));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return props;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a typed property defined on a {@link PropertySet}.
|
||||
*/
|
||||
protected interface Accessor {
|
||||
String getName();
|
||||
boolean hasValue(PropertySet props);
|
||||
Object get(PropertySet props);
|
||||
void set(PropertySet props, Object value);
|
||||
}
|
||||
|
||||
static final class FieldAccessor implements Accessor {
|
||||
/**
|
||||
* Field with the annotation.
|
||||
*/
|
||||
private final Field f;
|
||||
|
||||
/**
|
||||
* One of the values in {@link Property} annotation on {@link #f}.
|
||||
*/
|
||||
private final String name;
|
||||
|
||||
protected FieldAccessor(Field f, String name) {
|
||||
this.f = f;
|
||||
f.setAccessible(true);
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasValue(PropertySet props) {
|
||||
return get(props)!=null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object get(PropertySet props) {
|
||||
try {
|
||||
return f.get(props);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new AssertionError();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(PropertySet props, Object value) {
|
||||
try {
|
||||
f.set(props,value);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new AssertionError();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static final class MethodAccessor implements Accessor {
|
||||
/**
|
||||
* Getter method.
|
||||
*/
|
||||
private final @NotNull Method getter;
|
||||
/**
|
||||
* Setter method.
|
||||
* Some property is read-only.
|
||||
*/
|
||||
private final @Nullable Method setter;
|
||||
|
||||
/**
|
||||
* One of the values in {@link Property} annotation on {@link #getter}.
|
||||
*/
|
||||
private final String name;
|
||||
|
||||
protected MethodAccessor(Method getter, Method setter, String value) {
|
||||
this.getter = getter;
|
||||
this.setter = setter;
|
||||
this.name = value;
|
||||
getter.setAccessible(true);
|
||||
if (setter!=null) {
|
||||
setter.setAccessible(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasValue(PropertySet props) {
|
||||
return get(props)!=null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object get(PropertySet props) {
|
||||
try {
|
||||
return getter.invoke(props);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new AssertionError();
|
||||
} catch (InvocationTargetException e) {
|
||||
handle(e);
|
||||
return 0; // never reach here
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(PropertySet props, Object value) {
|
||||
if(setter==null) {
|
||||
throw new ReadOnlyPropertyException(getName());
|
||||
}
|
||||
try {
|
||||
setter.invoke(props,value);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new AssertionError();
|
||||
} catch (InvocationTargetException e) {
|
||||
handle(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Since we don't expect the getter/setter to throw a checked exception,
|
||||
* it should be possible to make the exception propagation transparent.
|
||||
* That's what we are trying to do here.
|
||||
*/
|
||||
private Exception handle(InvocationTargetException e) {
|
||||
Throwable t = e.getTargetException();
|
||||
if (t instanceof Error) {
|
||||
throw (Error)t;
|
||||
}
|
||||
if (t instanceof RuntimeException) {
|
||||
throw (RuntimeException)t;
|
||||
}
|
||||
throw new Error(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Class allowing to work with PropertySet object as with a Map; it doesn't only allow to read properties from
|
||||
* the map but also to modify the map in a way it is in sync with original strongly typed fields. It also allows
|
||||
* (if necessary) to store additional properties those can't be found in strongly typed fields.
|
||||
*
|
||||
* @see com.sun.xml.internal.ws.api.PropertySet#asMap() method
|
||||
*/
|
||||
final class MapView extends HashMap<String, Object> {
|
||||
|
||||
// flag if it should allow store also different properties
|
||||
// than the from strongly typed fields
|
||||
boolean extensible;
|
||||
|
||||
MapView(boolean extensible) {
|
||||
super(getPropertyMap().getPropertyMapEntries().length);
|
||||
this.extensible = extensible;
|
||||
initialize();
|
||||
}
|
||||
|
||||
public void initialize() {
|
||||
// iterate (cached) array instead of map to speed things up ...
|
||||
PropertyMapEntry[] entries = getPropertyMap().getPropertyMapEntries();
|
||||
for (PropertyMapEntry entry : entries) {
|
||||
super.put(entry.key, entry.value);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object get(Object key) {
|
||||
Object o = super.get(key);
|
||||
if (o instanceof Accessor) {
|
||||
return ((Accessor) o).get(BasePropertySet.this);
|
||||
} else {
|
||||
return o;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Entry<String, Object>> entrySet() {
|
||||
Set<Entry<String, Object>> entries = new HashSet<Entry<String, Object>>();
|
||||
for (String key : keySet()) {
|
||||
entries.add(new SimpleImmutableEntry<String, Object>(key, get(key)));
|
||||
}
|
||||
return entries;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object put(String key, Object value) {
|
||||
|
||||
Object o = super.get(key);
|
||||
if (o != null && o instanceof Accessor) {
|
||||
|
||||
Object oldValue = ((Accessor) o).get(BasePropertySet.this);
|
||||
((Accessor) o).set(BasePropertySet.this, value);
|
||||
return oldValue;
|
||||
|
||||
} else {
|
||||
|
||||
if (extensible) {
|
||||
return super.put(key, value);
|
||||
} else {
|
||||
throw new IllegalStateException("Unknown property [" + key + "] for PropertySet [" +
|
||||
BasePropertySet.this.getClass().getName() + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
for (String key : keySet()) {
|
||||
remove(key);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object remove(Object key) {
|
||||
Object o;
|
||||
o = super.get(key);
|
||||
if (o instanceof Accessor) {
|
||||
((Accessor)o).set(BasePropertySet.this, null);
|
||||
}
|
||||
return super.remove(key);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsKey(Object key) {
|
||||
Accessor sp = getPropertyMap().get(key);
|
||||
if (sp != null) {
|
||||
return sp.get(this) != null;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name of the property.
|
||||
*
|
||||
* @param key
|
||||
* This field is typed as {@link Object} to follow the {@link Map#get(Object)}
|
||||
* convention, but if anything but {@link String} is passed, this method
|
||||
* just returns null.
|
||||
*/
|
||||
@Override
|
||||
public Object get(Object key) {
|
||||
Accessor sp = getPropertyMap().get(key);
|
||||
if (sp != null) {
|
||||
return sp.get(this);
|
||||
}
|
||||
throw new IllegalArgumentException("Undefined property "+key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a property.
|
||||
*
|
||||
* <h3>Implementation Note</h3>
|
||||
* This method is slow. Code inside JAX-WS should define strongly-typed
|
||||
* fields in this class and access them directly, instead of using this.
|
||||
*
|
||||
* @throws ReadOnlyPropertyException
|
||||
* if the given key is an alias of a strongly-typed field,
|
||||
* and if the name object given is not assignable to the field.
|
||||
*
|
||||
* @see Property
|
||||
*/
|
||||
@Override
|
||||
public Object put(String key, Object value) {
|
||||
Accessor sp = getPropertyMap().get(key);
|
||||
if(sp!=null) {
|
||||
Object old = sp.get(this);
|
||||
sp.set(this,value);
|
||||
return old;
|
||||
} else {
|
||||
throw new IllegalArgumentException("Undefined property "+key);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if this {@link PropertySet} supports a property of the given name.
|
||||
*/
|
||||
@Override
|
||||
public boolean supports(Object key) {
|
||||
return getPropertyMap().containsKey(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object remove(Object key) {
|
||||
Accessor sp = getPropertyMap().get(key);
|
||||
if(sp!=null) {
|
||||
Object old = sp.get(this);
|
||||
sp.set(this,null);
|
||||
return old;
|
||||
} else {
|
||||
throw new IllegalArgumentException("Undefined property "+key);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@link Map} view of this {@link PropertySet}.
|
||||
*
|
||||
* <p>
|
||||
* This map is partially live, in the sense that values you set to it
|
||||
* will be reflected to {@link PropertySet}.
|
||||
*
|
||||
* <p>
|
||||
* However, this map may not pick up changes made
|
||||
* to {@link PropertySet} after the view is created.
|
||||
*
|
||||
* @deprecated use newer implementation {@link PropertySet#asMap()} which produces
|
||||
* readwrite {@link Map}
|
||||
*
|
||||
* @return
|
||||
* always non-null valid instance.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public final Map<String,Object> createMapView() {
|
||||
final Set<Entry<String,Object>> core = new HashSet<Entry<String,Object>>();
|
||||
createEntrySet(core);
|
||||
|
||||
return new AbstractMap<String, Object>() {
|
||||
@Override
|
||||
public Set<Entry<String,Object>> entrySet() {
|
||||
return core;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a modifiable {@link Map} view of this {@link PropertySet}.
|
||||
* <p/>
|
||||
* Changes done on this {@link Map} or on {@link PropertySet} object work in both directions - values made to
|
||||
* {@link Map} are reflected to {@link PropertySet} and changes done using getters/setters on {@link PropertySet}
|
||||
* object are automatically reflected in this {@link Map}.
|
||||
* <p/>
|
||||
* If necessary, it also can hold other values (not present on {@link PropertySet}) -
|
||||
* {@see PropertySet#mapAllowsAdditionalProperties}
|
||||
*
|
||||
* @return always non-null valid instance.
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> asMap() {
|
||||
if (mapView == null) {
|
||||
mapView = createView();
|
||||
}
|
||||
return mapView;
|
||||
}
|
||||
|
||||
protected Map<String, Object> createView() {
|
||||
return new MapView(mapAllowsAdditionalProperties());
|
||||
}
|
||||
|
||||
/**
|
||||
* Used when constructing the {@link MapView} for this object - it controls if the {@link MapView} servers only to
|
||||
* access strongly typed values or allows also different values
|
||||
*
|
||||
* @return true if {@link Map} should allow also properties not defined as strongly typed fields
|
||||
*/
|
||||
protected boolean mapAllowsAdditionalProperties() {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected void createEntrySet(Set<Entry<String,Object>> core) {
|
||||
for (final Entry<String, Accessor> e : getPropertyMap().entrySet()) {
|
||||
core.add(new Entry<String, Object>() {
|
||||
@Override
|
||||
public String getKey() {
|
||||
return e.getKey();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue() {
|
||||
return e.getValue().get(BasePropertySet.this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object setValue(Object value) {
|
||||
Accessor acc = e.getValue();
|
||||
Object old = acc.get(BasePropertySet.this);
|
||||
acc.set(BasePropertySet.this,value);
|
||||
return old;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code 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 General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.oracle.webservices.internal.api.message;
|
||||
|
||||
//TODO Do we want to remove this implementation dependency?
|
||||
import com.sun.xml.internal.ws.encoding.ContentTypeImpl;
|
||||
|
||||
/**
|
||||
* A Content-Type transport header that will be returned by {@link MessageContext#write(java.io.OutputStream)}.
|
||||
* It will provide the Content-Type header and also take care of SOAP 1.1 SOAPAction header.
|
||||
*
|
||||
* @author Vivek Pandey
|
||||
*/
|
||||
public interface ContentType {
|
||||
|
||||
/**
|
||||
* Gives non-null Content-Type header value.
|
||||
*/
|
||||
public String getContentType();
|
||||
|
||||
/**
|
||||
* Gives SOAPAction transport header value. It will be non-null only for SOAP 1.1 messages. In other cases
|
||||
* it MUST be null. The SOAPAction transport header should be written out only when its non-null.
|
||||
*
|
||||
* @return It can be null, in that case SOAPAction header should be written.
|
||||
*/
|
||||
public String getSOAPActionHeader();
|
||||
|
||||
/**
|
||||
* Controls the Accept transport header, if the transport supports it.
|
||||
* Returning null means the transport need not add any new header.
|
||||
*
|
||||
* <p>
|
||||
* We realize that this is not an elegant abstraction, but
|
||||
* this would do for now. If another person comes and asks for
|
||||
* a similar functionality, we'll define a real abstraction.
|
||||
*/
|
||||
public String getAcceptHeader();
|
||||
|
||||
static public class Builder {
|
||||
private String contentType;
|
||||
private String soapAction;
|
||||
private String accept;
|
||||
private String charset;
|
||||
|
||||
public Builder contentType(String s) {contentType = s; return this; }
|
||||
public Builder soapAction (String s) {soapAction = s; return this; }
|
||||
public Builder accept (String s) {accept = s; return this; }
|
||||
public Builder charset (String s) {charset = s; return this; }
|
||||
public ContentType build() {
|
||||
//TODO Do we want to remove this implementation dependency?
|
||||
return new ContentTypeImpl(contentType, soapAction, accept, charset);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code 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 General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.oracle.webservices.internal.api.message;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import com.sun.istack.internal.Nullable;
|
||||
|
||||
/**
|
||||
* {@link PropertySet} that combines properties exposed from multiple
|
||||
* {@link PropertySet}s into one.
|
||||
*
|
||||
* <p>
|
||||
* This implementation allows one {@link PropertySet} to assemble
|
||||
* all properties exposed from other "satellite" {@link PropertySet}s.
|
||||
* (A satellite may itself be a {@link DistributedPropertySet}, so
|
||||
* in general this can form a tree.)
|
||||
*
|
||||
* <p>
|
||||
* This is useful for JAX-WS because the properties we expose to the application
|
||||
* are contributed by different pieces, and therefore we'd like each of them
|
||||
* to have a separate {@link PropertySet} implementation that backs up
|
||||
* the properties. For example, this allows FastInfoset to expose its
|
||||
* set of properties to {@link RequestContext} by using a strongly-typed fields.
|
||||
*
|
||||
* <p>
|
||||
* This is also useful for a client-side transport to expose a bunch of properties
|
||||
* into {@link ResponseContext}. It simply needs to create a {@link PropertySet}
|
||||
* object with methods for each property it wants to expose, and then add that
|
||||
* {@link PropertySet} to {@link Packet}. This allows property values to be
|
||||
* lazily computed (when actually asked by users), thus improving the performance
|
||||
* of the typical case where property values are not asked.
|
||||
*
|
||||
* <p>
|
||||
* A similar benefit applies on the server-side, for a transport to expose
|
||||
* a bunch of properties to {@link WebServiceContext}.
|
||||
*
|
||||
* <p>
|
||||
* To achieve these benefits, access to {@link DistributedPropertySet} is slower
|
||||
* compared to {@link PropertySet} (such as get/set), while adding a satellite
|
||||
* object is relatively fast.
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
public interface DistributedPropertySet extends com.oracle.webservices.internal.api.message.PropertySet {
|
||||
|
||||
public @Nullable <T extends com.oracle.webservices.internal.api.message.PropertySet> T getSatellite(Class<T> satelliteClass);
|
||||
|
||||
public Map<Class<? extends com.oracle.webservices.internal.api.message.PropertySet>, com.oracle.webservices.internal.api.message.PropertySet> getSatellites();
|
||||
|
||||
public void addSatellite(com.oracle.webservices.internal.api.message.PropertySet satellite);
|
||||
|
||||
public void addSatellite(Class<? extends com.oracle.webservices.internal.api.message.PropertySet> keyClass, com.oracle.webservices.internal.api.message.PropertySet satellite);
|
||||
|
||||
public void removeSatellite(com.oracle.webservices.internal.api.message.PropertySet satellite);
|
||||
|
||||
public void copySatelliteInto(com.oracle.webservices.internal.api.message.MessageContext r);
|
||||
}
|
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code 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 General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.oracle.webservices.internal.api.message;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.WritableByteChannel;
|
||||
|
||||
import javax.xml.soap.SOAPException;
|
||||
import javax.xml.soap.SOAPMessage;
|
||||
|
||||
/**
|
||||
* MessageContext represents a container of a SOAP message and all the properties
|
||||
* including the transport headers.
|
||||
*
|
||||
* MessageContext is a composite {@link PropertySet} that combines properties exposed from multiple
|
||||
* {@link PropertySet}s into one.
|
||||
*
|
||||
* <p>
|
||||
* This implementation allows one {@link PropertySet} to assemble
|
||||
* all properties exposed from other "satellite" {@link PropertySet}s.
|
||||
* (A satellite may itself be a {@link DistributedPropertySet}, so
|
||||
* in general this can form a tree.)
|
||||
*
|
||||
* @author shih-chang.chen@oracle.com
|
||||
*/
|
||||
public interface MessageContext extends DistributedPropertySet {
|
||||
/**
|
||||
* Gets the SAAJ SOAPMessage representation of the SOAP message.
|
||||
*
|
||||
* @return The SOAPMessage
|
||||
*/
|
||||
SOAPMessage getAsSOAPMessage() throws SOAPException;
|
||||
|
||||
/**
|
||||
* Gets the SAAJ SOAPMessage representation of the SOAP message.
|
||||
* @deprecated use getAsSOAPMessage
|
||||
* @return The SOAPMessage
|
||||
*/
|
||||
SOAPMessage getSOAPMessage() throws SOAPException;
|
||||
|
||||
/**
|
||||
* Writes the XML infoset portion of this MessageContext
|
||||
* (from <soap:Envelope> to </soap:Envelope>).
|
||||
*
|
||||
* @param out
|
||||
* Must not be null. The caller is responsible for closing the stream,
|
||||
* not the callee.
|
||||
*
|
||||
* @return
|
||||
* The MIME content type of the encoded message (such as "application/xml").
|
||||
* This information is often ncessary by transport.
|
||||
*
|
||||
* @throws IOException
|
||||
* if a {@link OutputStream} throws {@link IOException}.
|
||||
*/
|
||||
ContentType writeTo( OutputStream out ) throws IOException;
|
||||
|
||||
/**
|
||||
* The version of {@link #writeTo(OutputStream)}
|
||||
* that writes to NIO {@link ByteBuffer}.
|
||||
*
|
||||
* <p>
|
||||
* TODO: for the convenience of implementation, write
|
||||
* an adapter that wraps {@link WritableByteChannel} to {@link OutputStream}.
|
||||
*/
|
||||
// ContentType writeTo( WritableByteChannel buffer );
|
||||
|
||||
/**
|
||||
* Gets the Content-type of this message. For an out-bound message that this getContentType()
|
||||
* method returns a null, the Content-Type can be determined only by calling the writeTo
|
||||
* method to write the MessageContext to an OutputStream.
|
||||
*
|
||||
* @return The MIME content type of this message
|
||||
*/
|
||||
ContentType getContentType();
|
||||
}
|
@@ -0,0 +1,130 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code 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 General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.oracle.webservices.internal.api.message;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import com.oracle.webservices.internal.api.EnvelopeStyle;
|
||||
import com.sun.xml.internal.ws.api.SOAPVersion; // TODO leaking RI APIs
|
||||
import com.sun.xml.internal.ws.util.ServiceFinder;
|
||||
|
||||
import javax.xml.soap.MimeHeaders;
|
||||
import javax.xml.soap.SOAPMessage;
|
||||
import javax.xml.transform.Source;
|
||||
import javax.xml.ws.WebServiceFeature;
|
||||
|
||||
public abstract class MessageContextFactory
|
||||
{
|
||||
private static final MessageContextFactory DEFAULT = new com.sun.xml.internal.ws.api.message.MessageContextFactory(new WebServiceFeature[0]);
|
||||
|
||||
protected abstract MessageContextFactory newFactory(WebServiceFeature ... f);
|
||||
|
||||
public abstract MessageContext createContext();
|
||||
|
||||
public abstract MessageContext createContext(SOAPMessage m);
|
||||
|
||||
public abstract MessageContext createContext(Source m);
|
||||
|
||||
public abstract MessageContext createContext(Source m, EnvelopeStyle.Style envelopeStyle);
|
||||
|
||||
public abstract MessageContext createContext(InputStream in, String contentType) throws IOException;
|
||||
|
||||
/**
|
||||
* @deprecated http://java.net/jira/browse/JAX_WS-1077
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract MessageContext createContext(InputStream in, MimeHeaders headers) throws IOException;
|
||||
|
||||
static public MessageContextFactory createFactory(WebServiceFeature ... f) {
|
||||
return createFactory(null, f);
|
||||
}
|
||||
|
||||
static public MessageContextFactory createFactory(ClassLoader cl, WebServiceFeature ...f) {
|
||||
for (MessageContextFactory factory : ServiceFinder.find(MessageContextFactory.class, cl)) {
|
||||
MessageContextFactory newfac = factory.newFactory(f);
|
||||
if (newfac != null) return newfac;
|
||||
}
|
||||
return new com.sun.xml.internal.ws.api.message.MessageContextFactory(f);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public abstract MessageContext doCreate();
|
||||
|
||||
@Deprecated
|
||||
public abstract MessageContext doCreate(SOAPMessage m);
|
||||
|
||||
//public abstract MessageContext doCreate(InputStream x);
|
||||
|
||||
@Deprecated
|
||||
public abstract MessageContext doCreate(Source x, SOAPVersion soapVersion);
|
||||
|
||||
@Deprecated
|
||||
public static MessageContext create(final ClassLoader... classLoader) {
|
||||
return serviceFinder(classLoader,
|
||||
new Creator() {
|
||||
public MessageContext create(final MessageContextFactory f) {
|
||||
return f.doCreate();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static MessageContext create(final SOAPMessage m, final ClassLoader... classLoader) {
|
||||
return serviceFinder(classLoader,
|
||||
new Creator() {
|
||||
public MessageContext create(final MessageContextFactory f) {
|
||||
return f.doCreate(m);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static MessageContext create(final Source m, final SOAPVersion v, final ClassLoader... classLoader) {
|
||||
return serviceFinder(classLoader,
|
||||
new Creator() {
|
||||
public MessageContext create(final MessageContextFactory f) {
|
||||
return f.doCreate(m, v);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
private static MessageContext serviceFinder(final ClassLoader[] classLoader, final Creator creator) {
|
||||
final ClassLoader cl = classLoader.length == 0 ? null : classLoader[0];
|
||||
for (MessageContextFactory factory : ServiceFinder.find(MessageContextFactory.class, cl)) {
|
||||
final MessageContext messageContext = creator.create(factory);
|
||||
if (messageContext != null)
|
||||
return messageContext;
|
||||
}
|
||||
return creator.create(DEFAULT);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
private static interface Creator {
|
||||
public MessageContext create(MessageContextFactory f);
|
||||
}
|
||||
}
|
@@ -0,0 +1,134 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code 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 General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.oracle.webservices.internal.api.message;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Inherited;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.xml.ws.handler.MessageContext;
|
||||
|
||||
/**
|
||||
* A set of "properties" that can be accessed via strongly-typed fields
|
||||
* as well as reflexibly through the property name.
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
public interface PropertySet {
|
||||
|
||||
/**
|
||||
* Marks a field on {@link PropertySet} as a
|
||||
* property of {@link MessageContext}.
|
||||
*
|
||||
* <p>
|
||||
* To make the runtime processing easy, this annotation
|
||||
* must be on a public field (since the property name
|
||||
* can be set through {@link Map} anyway, you won't be
|
||||
* losing abstraction by doing so.)
|
||||
*
|
||||
* <p>
|
||||
* For similar reason, this annotation can be only placed
|
||||
* on a reference type, not primitive type.
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
@Inherited
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.FIELD,ElementType.METHOD})
|
||||
public @interface Property {
|
||||
/**
|
||||
* Name of the property.
|
||||
*/
|
||||
String[] value();
|
||||
}
|
||||
|
||||
public boolean containsKey(Object key);
|
||||
|
||||
/**
|
||||
* Gets the name of the property.
|
||||
*
|
||||
* @param key
|
||||
* This field is typed as {@link Object} to follow the {@link Map#get(Object)}
|
||||
* convention, but if anything but {@link String} is passed, this method
|
||||
* just returns null.
|
||||
*/
|
||||
public Object get(Object key);
|
||||
|
||||
/**
|
||||
* Sets a property.
|
||||
*
|
||||
* <h3>Implementation Note</h3>
|
||||
* This method is slow. Code inside JAX-WS should define strongly-typed
|
||||
* fields in this class and access them directly, instead of using this.
|
||||
*
|
||||
* @see Property
|
||||
*/
|
||||
public Object put(String key, Object value);
|
||||
|
||||
/**
|
||||
* Checks if this {@link PropertySet} supports a property of the given name.
|
||||
*/
|
||||
public boolean supports(Object key);
|
||||
|
||||
public Object remove(Object key);
|
||||
|
||||
/**
|
||||
* Creates a {@link Map} view of this {@link PropertySet}.
|
||||
*
|
||||
* <p>
|
||||
* This map is partially live, in the sense that values you set to it
|
||||
* will be reflected to {@link PropertySet}.
|
||||
*
|
||||
* <p>
|
||||
* However, this map may not pick up changes made
|
||||
* to {@link PropertySet} after the view is created.
|
||||
*
|
||||
* @deprecated use newer implementation {@link com.sun.xml.internal.ws.api.PropertySet#asMap()} which produces
|
||||
* readwrite {@link Map}
|
||||
*
|
||||
* @return
|
||||
* always non-null valid instance.
|
||||
*/
|
||||
@Deprecated
|
||||
public Map<String,Object> createMapView();
|
||||
|
||||
/**
|
||||
* Creates a modifiable {@link Map} view of this {@link PropertySet}.
|
||||
* <p/>
|
||||
* Changes done on this {@link Map} or on {@link PropertySet} object work in both directions - values made to
|
||||
* {@link Map} are reflected to {@link PropertySet} and changes done using getters/setters on {@link PropertySet}
|
||||
* object are automatically reflected in this {@link Map}.
|
||||
* <p/>
|
||||
* If necessary, it also can hold other values (not present on {@link PropertySet}) -
|
||||
* {@see PropertySet#mapAllowsAdditionalProperties}
|
||||
*
|
||||
* @return always non-null valid instance.
|
||||
*/
|
||||
public Map<String, Object> asMap();
|
||||
}
|
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code 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 General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.oracle.webservices.internal.api.message;
|
||||
|
||||
/**
|
||||
* Used to indicate that {@link PropertySet#put(String, Object)} failed
|
||||
* because a property is read-only.
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
public class ReadOnlyPropertyException extends IllegalArgumentException {
|
||||
private final String propertyName;
|
||||
|
||||
public ReadOnlyPropertyException(String propertyName) {
|
||||
super(propertyName+" is a read-only property.");
|
||||
this.propertyName = propertyName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name of the property that was read-only.
|
||||
*/
|
||||
public String getPropertyName() {
|
||||
return propertyName;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user