You are viewing a plain text version of this content. The canonical link for it is here.
Posted to wsrf-commits@ws.apache.org by ip...@apache.org on 2005/08/01 21:49:09 UTC
svn commit: r226863 - in /webservices/wsrf/trunk/src/java/org/apache/ws:
addressing/XmlBeansEndpointReference.java resource/AbstractPortType.java
Author: ips
Date: Mon Aug 1 12:49:06 2005
New Revision: 226863
URL: http://svn.apache.org/viewcvs?rev=226863&view=rev
Log:
fixed exception handling bug in AbstractPortType's ctor
Modified:
webservices/wsrf/trunk/src/java/org/apache/ws/addressing/XmlBeansEndpointReference.java
webservices/wsrf/trunk/src/java/org/apache/ws/resource/AbstractPortType.java
Modified: webservices/wsrf/trunk/src/java/org/apache/ws/addressing/XmlBeansEndpointReference.java
URL: http://svn.apache.org/viewcvs/webservices/wsrf/trunk/src/java/org/apache/ws/addressing/XmlBeansEndpointReference.java?rev=226863&r1=226862&r2=226863&view=diff
==============================================================================
--- webservices/wsrf/trunk/src/java/org/apache/ws/addressing/XmlBeansEndpointReference.java (original)
+++ webservices/wsrf/trunk/src/java/org/apache/ws/addressing/XmlBeansEndpointReference.java Mon Aug 1 12:49:06 2005
@@ -29,126 +29,154 @@
/**
* This class wraps XmlBean-generated XmlBeansEndpointReference types for use throughout the system.
- *
- * As a new version of the schema is generated, a new constructor should be added to encompass
- * the new version.
- *
+ * <p/>
+ * As a new version of the schema is generated, a new constructor should be added to encompass the new version.
+ * <p/>
* Note..Use fully qualified class name in constructors for different versions.
*
* @author Sal Campana
*/
public class XmlBeansEndpointReference
- implements XmlObjectWrapper,
- EndpointReference
+ implements XmlObjectWrapper,
+ EndpointReference
{
- private XmlObject m_xmlObjectEPR;
- private String m_address;
- private QName m_portTypeQName;
- private String m_servicePortName;
- private QName m_serviceQName;
- private Object[] m_referenceProps;
- private String m_addressingVersionURI;
- private Object[] m_referenceParameters;
- private Object m_resourceId;
- private QName m_resourceIdRefParamName;
+ private XmlObject m_xmlObjectEPR;
+ private String m_address;
+ private QName m_portTypeQName;
+ private String m_servicePortName;
+ private QName m_serviceQName;
+ private Object[] m_referenceProps;
+ private String m_addressingVersionURI;
+ private Object[] m_referenceParameters;
+ private Object m_resourceId;
+ private QName m_resourceIdRefParamName;
/**
* Constructs an EPR (and the underlying XmlObject representation) given the params.
*
- * @param address - Endpoint Address. Must Not Be Null
+ * @param address - Endpoint Address. Must Not Be Null
* @param addressingURI - WS-Addressing URI - Must Not Be Null
*/
- public XmlBeansEndpointReference(String address,
- String addressingURI)
+ public XmlBeansEndpointReference( String address,
+ String addressingURI )
{
- if(address == null) throw new IllegalArgumentException("Address must not be null!");
- if(addressingURI == null) throw new IllegalArgumentException("WS-Addressing addresingURI must not be null!");
+ if ( address == null )
+ {
+ throw new IllegalArgumentException( "Address must not be null!" );
+ }
+ if ( addressingURI == null )
+ {
+ throw new IllegalArgumentException( "WS-Addressing addresingURI must not be null!" );
+ }
m_address = address;
m_addressingVersionURI = addressingURI;
}
- /**
- * Creates a new {@link XmlBeansEndpointReference} object.
- *
- * @param epr org.xmlsoap.schemas.ws.x2003.x03.addressing.EndpointReferenceType XMLBean generated type
- */
- public XmlBeansEndpointReference( org.xmlsoap.schemas.ws.x2003.x03.addressing.EndpointReferenceType epr )
- {
- m_xmlObjectEPR = epr;
-
- if(epr.getAddress()!=null)
- m_address = epr.getAddress( ).getStringValue( );
- if(epr.isSetPortType())
- m_portTypeQName = epr.getPortType( ).getQNameValue( );
- if(epr.isSetServiceName() && epr.getServiceName( ).isSetPortName())
- m_servicePortName = epr.getServiceName( ).getPortName( );
- if(epr.isSetServiceName())
- m_serviceQName = epr.getServiceName( ).getQNameValue( );
- if(epr.isSetReferenceProperties())
- m_referenceProps = XmlBeanUtils.getChildElements(epr.getReferenceProperties());
- }
-
- /**
- * Creates a new {@link XmlBeansEndpointReference} object.
- *
- * @param epr org.xmlsoap.schemas.ws.x2004.x08.addressing.EndpointReferenceType XMLBean generated type
- */
- public XmlBeansEndpointReference( org.xmlsoap.schemas.ws.x2004.x08.addressing.EndpointReferenceType epr )
- {
- m_xmlObjectEPR = epr;
- if(epr.getAddress()!=null)
- m_address = epr.getAddress( ).getStringValue( );
- if(epr.isSetPortType())
- m_portTypeQName = epr.getPortType( ).getQNameValue( );
- if(epr.isSetServiceName() && epr.getServiceName( ).isSetPortName())
- m_servicePortName = epr.getServiceName( ).getPortName( );
- if(epr.isSetServiceName() )
- m_serviceQName = epr.getServiceName( ).getQNameValue( );
- if(epr.isSetReferenceProperties())
- m_referenceProps = XmlBeanUtils.getChildElements(epr.getReferenceProperties());
- if(epr.isSetReferenceParameters())
- m_referenceParameters = XmlBeanUtils.getChildElements(epr.getReferenceParameters());
- }
- /**
- * Returns the Address from the EPR as a String.
- *
- * @return Address
- */
- public String getAddress( )
- {
- return m_address;
- }
-
- /**
- * Returns the PortName associated with the Service in the EPR as a String
- *
- * @return Service's Port Name
- */
- public String getPortName( )
- {
- return m_servicePortName;
- }
-
- /**
- * Returns the PortType QName
- *
- * @return PortType QName
- */
- public QName getPortType( )
- {
- return m_portTypeQName;
- }
-
- /**
- * Returns the ReferenceProperties directly from the underlying XmlBean-generated class.
- * The signature returns Object to make it generic for other impls.
- *
- * @return Object[] containing the Reference Property elements
- */
- public Object[] getReferenceProperties( )
- {
- return m_referenceProps;
- }
+ /**
+ * Creates a new {@link XmlBeansEndpointReference} object.
+ *
+ * @param epr org.xmlsoap.schemas.ws.x2003.x03.addressing.EndpointReferenceType XMLBean generated type
+ */
+ public XmlBeansEndpointReference( org.xmlsoap.schemas.ws.x2003.x03.addressing.EndpointReferenceType epr )
+ {
+ m_xmlObjectEPR = epr;
+
+ if ( epr.getAddress() != null )
+ {
+ m_address = epr.getAddress().getStringValue();
+ }
+ if ( epr.isSetPortType() )
+ {
+ m_portTypeQName = epr.getPortType().getQNameValue();
+ }
+ if ( epr.isSetServiceName() && epr.getServiceName().isSetPortName() )
+ {
+ m_servicePortName = epr.getServiceName().getPortName();
+ }
+ if ( epr.isSetServiceName() )
+ {
+ m_serviceQName = epr.getServiceName().getQNameValue();
+ }
+ if ( epr.isSetReferenceProperties() )
+ {
+ m_referenceProps = XmlBeanUtils.getChildElements( epr.getReferenceProperties() );
+ }
+ }
+
+ /**
+ * Creates a new {@link XmlBeansEndpointReference} object.
+ *
+ * @param epr org.xmlsoap.schemas.ws.x2004.x08.addressing.EndpointReferenceType XMLBean generated type
+ */
+ public XmlBeansEndpointReference( org.xmlsoap.schemas.ws.x2004.x08.addressing.EndpointReferenceType epr )
+ {
+ m_xmlObjectEPR = epr;
+ if ( epr.getAddress() != null )
+ {
+ m_address = epr.getAddress().getStringValue();
+ }
+ if ( epr.isSetPortType() )
+ {
+ m_portTypeQName = epr.getPortType().getQNameValue();
+ }
+ if ( epr.isSetServiceName() && epr.getServiceName().isSetPortName() )
+ {
+ m_servicePortName = epr.getServiceName().getPortName();
+ }
+ if ( epr.isSetServiceName() )
+ {
+ m_serviceQName = epr.getServiceName().getQNameValue();
+ }
+ if ( epr.isSetReferenceProperties() )
+ {
+ m_referenceProps = XmlBeanUtils.getChildElements( epr.getReferenceProperties() );
+ }
+ if ( epr.isSetReferenceParameters() )
+ {
+ m_referenceParameters = XmlBeanUtils.getChildElements( epr.getReferenceParameters() );
+ }
+ }
+
+ /**
+ * Returns the Address from the EPR as a String.
+ *
+ * @return Address
+ */
+ public String getAddress()
+ {
+ return m_address;
+ }
+
+ /**
+ * Returns the PortName associated with the Service in the EPR as a String
+ *
+ * @return Service's Port Name
+ */
+ public String getPortName()
+ {
+ return m_servicePortName;
+ }
+
+ /**
+ * Returns the PortType QName
+ *
+ * @return PortType QName
+ */
+ public QName getPortType()
+ {
+ return m_portTypeQName;
+ }
+
+ /**
+ * Returns the ReferenceProperties directly from the underlying XmlBean-generated class. The signature returns
+ * Object to make it generic for other impls.
+ *
+ * @return Object[] containing the Reference Property elements
+ */
+ public Object[] getReferenceProperties()
+ {
+ return m_referenceProps;
+ }
/**
* Returns the ReferenceParameters Object.
@@ -161,108 +189,111 @@
}
/**
- * Service QName
- *
- * @return Service QName
- */
- public QName getServiceName( )
- {
- return m_serviceQName;
- }
-
- /**
- * The underlying XmlBean-Generated EPR
- *
- * @return The generated EPR
- */
- public XmlObject getXmlObject( )
- {
- XmlObject epr = null;
-
- if(m_xmlObjectEPR != null)
- {
- epr = m_xmlObjectEPR;
- }
-
- else if(m_addressingVersionURI != null && m_address != null)
- {
- if(org.apache.ws.addressing.v2003_03.AddressingConstants.NSURI_ADDRESSING_SCHEMA.equals(m_addressingVersionURI))
- {
- EndpointReferenceType endpointReferenceType = build2003_03_EPR();
-
- m_xmlObjectEPR = endpointReferenceType;
- epr = endpointReferenceType;
- }
- else if(org.apache.ws.addressing.v2004_08_10.AddressingConstants.NSURI_ADDRESSING_SCHEMA.equals(m_addressingVersionURI))
- {
- org.xmlsoap.schemas.ws.x2004.x08.addressing.EndpointReferenceType endpointReferenceType = build2004_08_EPR();
-
- m_xmlObjectEPR = endpointReferenceType;
- epr = endpointReferenceType;
- }
- }
-
- return epr;
-
- }
- /**
- * Returns a version-specific XmlBean-Generated EPR
- *
- * @param namespace the WS-Addressing namespace for which you would like an EPR returned.
- *
- * @return Version-Specific EPR
- */
- public XmlObject getXmlObject( String namespace )
- {
- XmlObject epr = null;
-
- if(namespace != null && m_address != null)
- {
- if(org.apache.ws.addressing.v2003_03.AddressingConstants.NSURI_ADDRESSING_SCHEMA.equals(namespace))
- {
- EndpointReferenceType endpointReferenceType = build2003_03_EPR();
- epr = endpointReferenceType;
- }
- else if(org.apache.ws.addressing.v2004_08_10.AddressingConstants.NSURI_ADDRESSING_SCHEMA.equals(namespace))
- {
- org.xmlsoap.schemas.ws.x2004.x08.addressing.EndpointReferenceType endpointReferenceType = build2004_08_EPR();
- epr = endpointReferenceType;
- }
- }
+ * Service QName
+ *
+ * @return Service QName
+ */
+ public QName getServiceName()
+ {
+ return m_serviceQName;
+ }
- return epr;
+ /**
+ * The underlying XmlBean-Generated EPR
+ *
+ * @return The generated EPR
+ */
+ public XmlObject getXmlObject()
+ {
+ XmlObject epr = null;
+
+ if ( m_xmlObjectEPR != null )
+ {
+ epr = m_xmlObjectEPR;
+ }
+
+ else if ( m_addressingVersionURI != null && m_address != null )
+ {
+ if ( org.apache.ws.addressing.v2003_03.AddressingConstants.NSURI_ADDRESSING_SCHEMA.equals(
+ m_addressingVersionURI ) )
+ {
+ EndpointReferenceType endpointReferenceType = build2003_03_EPR();
+
+ m_xmlObjectEPR = endpointReferenceType;
+ epr = endpointReferenceType;
+ }
+ else if ( org.apache.ws.addressing.v2004_08_10.AddressingConstants.NSURI_ADDRESSING_SCHEMA.equals(
+ m_addressingVersionURI ) )
+ {
+ org.xmlsoap.schemas.ws.x2004.x08.addressing.EndpointReferenceType endpointReferenceType = build2004_08_EPR();
+
+ m_xmlObjectEPR = endpointReferenceType;
+ epr = endpointReferenceType;
+ }
+ }
+
+ return epr;
}
+ /**
+ * Returns a version-specific XmlBean-Generated EPR
+ *
+ * @param namespace the WS-Addressing namespace for which you would like an EPR returned.
+ *
+ * @return Version-Specific EPR
+ */
+ public XmlObject getXmlObject( String namespace )
+ {
+ XmlObject epr = null;
+
+ if ( namespace != null && m_address != null )
+ {
+ if ( org.apache.ws.addressing.v2003_03.AddressingConstants.NSURI_ADDRESSING_SCHEMA.equals( namespace ) )
+ {
+ EndpointReferenceType endpointReferenceType = build2003_03_EPR();
+ epr = endpointReferenceType;
+ }
+ else if ( org.apache.ws.addressing.v2004_08_10.AddressingConstants.NSURI_ADDRESSING_SCHEMA.equals(
+ namespace ) )
+ {
+ org.xmlsoap.schemas.ws.x2004.x08.addressing.EndpointReferenceType endpointReferenceType = build2004_08_EPR();
+ epr = endpointReferenceType;
+ }
+ }
+
+ return epr;
+
+ }
private EndpointReferenceType build2003_03_EPR()
{
EndpointReferenceType endpointReferenceType = EndpointReferenceType.Factory.newInstance();
AttributedURI attributedURI = endpointReferenceType.addNewAddress();
- attributedURI.setStringValue(m_address);
+ attributedURI.setStringValue( m_address );
- if(m_portTypeQName != null)
+ if ( m_portTypeQName != null )
{
- AttributedQName attributedQName = endpointReferenceType.addNewPortType();
- attributedQName.setQNameValue(m_portTypeQName);
+ AttributedQName attributedQName = endpointReferenceType.addNewPortType();
+ attributedQName.setQNameValue( m_portTypeQName );
}
- if(m_servicePortName != null)
+ if ( m_servicePortName != null )
{
- ServiceNameType serviceNameType = endpointReferenceType.addNewServiceName();
- serviceNameType.setPortName(m_servicePortName);
+ ServiceNameType serviceNameType = endpointReferenceType.addNewServiceName();
+ serviceNameType.setPortName( m_servicePortName );
}
- ReferencePropertiesType referencePropertiesType = endpointReferenceType.addNewReferenceProperties();
+ ReferencePropertiesType refPropsType = endpointReferenceType.addNewReferenceProperties();
- if(m_referenceProps != null)
+ if ( m_referenceProps != null )
{
- addToProperties(referencePropertiesType, m_referenceProps);
+ addToProperties( refPropsType, m_referenceProps );
}
- if(m_resourceId != null)
+ if ( m_resourceId != null )
{
- XmlObject resourceKey = XmlBeanUtils.addChildElement(referencePropertiesType, m_resourceIdRefParamName);
- XmlBeanUtils.setValue(resourceKey, String.valueOf( m_resourceId ));
+ XmlObject resourceIdRefParam = XmlBeanUtils.addChildElement( refPropsType, m_resourceIdRefParamName );
+ XmlBeanUtils.setValue( resourceIdRefParam, m_resourceId.toString() );
}
return endpointReferenceType;
@@ -272,60 +303,60 @@
{
org.xmlsoap.schemas.ws.x2004.x08.addressing.EndpointReferenceType endpointReferenceType = org.xmlsoap.schemas.ws.x2004.x08.addressing.EndpointReferenceType.Factory.newInstance();
org.xmlsoap.schemas.ws.x2004.x08.addressing.AttributedURI attributedURI = endpointReferenceType.addNewAddress();
- attributedURI.setStringValue(m_address);
+ attributedURI.setStringValue( m_address );
- if(m_portTypeQName != null)
+ if ( m_portTypeQName != null )
{
- org.xmlsoap.schemas.ws.x2004.x08.addressing.AttributedQName attributedQName = endpointReferenceType.addNewPortType();
- attributedQName.setQNameValue(m_portTypeQName);
+ org.xmlsoap.schemas.ws.x2004.x08.addressing.AttributedQName attributedQName = endpointReferenceType.addNewPortType();
+ attributedQName.setQNameValue( m_portTypeQName );
}
- if(m_servicePortName != null)
+ if ( m_servicePortName != null )
{
- org.xmlsoap.schemas.ws.x2004.x08.addressing.ServiceNameType serviceNameType = endpointReferenceType.addNewServiceName();
- serviceNameType.setPortName(m_servicePortName);
+ org.xmlsoap.schemas.ws.x2004.x08.addressing.ServiceNameType serviceNameType = endpointReferenceType.addNewServiceName();
+ serviceNameType.setPortName( m_servicePortName );
}
org.xmlsoap.schemas.ws.x2004.x08.addressing.ReferencePropertiesType referencePropertiesType = endpointReferenceType.addNewReferenceProperties();
- if(m_referenceProps != null)
+ if ( m_referenceProps != null )
{
- addToProperties(referencePropertiesType, m_referenceProps);
+ addToProperties( referencePropertiesType, m_referenceProps );
}
- if(m_resourceId != null)
+ if ( m_resourceId != null )
{
- XmlObject resourceKey = XmlBeanUtils.addChildElement(referencePropertiesType, m_resourceIdRefParamName);
- XmlBeanUtils.setValue(resourceKey, (String.valueOf( m_resourceId ) ));
+ XmlObject resourceKey = XmlBeanUtils.addChildElement( referencePropertiesType, m_resourceIdRefParamName );
+ XmlBeanUtils.setValue( resourceKey, ( String.valueOf( m_resourceId ) ) );
}
- if(m_referenceParameters != null)
+ if ( m_referenceParameters != null )
{
- ReferenceParametersType referenceParametersType = endpointReferenceType.addNewReferenceParameters();
- addToProperties(referenceParametersType, m_referenceParameters);
+ ReferenceParametersType referenceParametersType = endpointReferenceType.addNewReferenceParameters();
+ addToProperties( referenceParametersType, m_referenceParameters );
}
return endpointReferenceType;
}
- private void addToProperties(XmlObject propertiesType, Object[] referenceProps)
+ private void addToProperties( XmlObject propertiesType, Object[] referenceProps )
{
- for (int i = 0; i < referenceProps.length; i++)
+ for ( int i = 0; i < referenceProps.length; i++ )
{
Object referenceProp = referenceProps[i];
- XmlBeanUtils.addChildElement(propertiesType, (XmlObject)referenceProp);
+ XmlBeanUtils.addChildElement( propertiesType, (XmlObject) referenceProp );
}
}
- public void setPortTypeQName(QName portTypeQName)
+ public void setPortTypeQName( QName portTypeQName )
{
m_portTypeQName = portTypeQName;
}
- public void setServicePortName(String servicePortName)
+ public void setServicePortName( String servicePortName )
{
m_servicePortName = servicePortName;
}
- public void setServiceQName(QName serviceQName)
+ public void setServiceQName( QName serviceQName )
{
m_serviceQName = serviceQName;
}
@@ -333,18 +364,24 @@
/**
* @param referenceProps XmlObject[] of refernece properties to be added
*/
- public void setReferenceProperties(Object[] referenceProps)
+ public void setReferenceProperties( Object[] referenceProps )
{
- if( !(referenceProps instanceof XmlObject[]) ) throw new IllegalArgumentException("Refernece Props are expected to be an XmlObject[]!");
+ if ( !( referenceProps instanceof XmlObject[] ) )
+ {
+ throw new IllegalArgumentException( "Refernece Props are expected to be an XmlObject[]!" );
+ }
m_referenceProps = referenceProps;
}
/**
* @param referenceParameters XmlObject[] of refernece parameters to be added
*/
- public void setReferenceParameters(Object[] referenceParameters)
+ public void setReferenceParameters( Object[] referenceParameters )
{
- if( !(referenceParameters instanceof XmlObject[]) ) throw new IllegalArgumentException("Refernece Params are expected to be an XmlObject[]!");
+ if ( !( referenceParameters instanceof XmlObject[] ) )
+ {
+ throw new IllegalArgumentException( "Refernece Params are expected to be an XmlObject[]!" );
+ }
m_referenceParameters = referenceParameters;
}
@@ -353,7 +390,7 @@
*
* @param resourceId
*/
- public void setResourceIdentifier(Object resourceId)
+ public void setResourceIdentifier( Object resourceId )
{
m_resourceId = resourceId;
}
@@ -363,10 +400,9 @@
*
* @param name
*/
- public void setResourceIdentifierReferenceParameterName(QName name)
+ public void setResourceIdentifierReferenceParameterName( QName name )
{
m_resourceIdRefParamName = name;
}
-
}
Modified: webservices/wsrf/trunk/src/java/org/apache/ws/resource/AbstractPortType.java
URL: http://svn.apache.org/viewcvs/webservices/wsrf/trunk/src/java/org/apache/ws/resource/AbstractPortType.java?rev=226863&r1=226862&r2=226863&view=diff
==============================================================================
--- webservices/wsrf/trunk/src/java/org/apache/ws/resource/AbstractPortType.java (original)
+++ webservices/wsrf/trunk/src/java/org/apache/ws/resource/AbstractPortType.java Mon Aug 1 12:49:06 2005
@@ -15,21 +15,20 @@
*=============================================================================*/
package org.apache.ws.resource;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.apache.ws.Soap1_1Constants;
+import org.apache.ws.resource.faults.FaultException;
import org.apache.ws.resource.i18n.MessagesImpl;
import org.apache.ws.resource.properties.NamespaceVersionHolder;
import org.apache.ws.util.i18n.Messages;
/**
- * LOG-DONE
+ * A base class that can be extended by portType implementations.
*
- * @author Ian P. Springer
+ * @author Ian Springer
*/
public abstract class AbstractPortType
{
- private static final Log LOG = LogFactory.getLog( AbstractPortType.class );
public static final Messages MSG = MessagesImpl.getInstance();
private ResourceContext m_resourceContext;
@@ -38,7 +37,7 @@
/**
* Creates a new {@link AbstractPortType} object.
*
- * @param resourceContext DOCUMENT_ME
+ * @param resourceContext resource context
*/
public AbstractPortType( ResourceContext resourceContext )
{
@@ -51,9 +50,9 @@
{
throw new org.apache.ws.resource.properties.faults.ResourceUnknownFaultException( getNamespaceSet(), rue );
}
- catch ( Exception e )
+ catch ( ResourceException re )
{
- throw new RuntimeException( "Failed to obtain WS-Resource instance for request.", e );
+ throw new FaultException( Soap1_1Constants.FAULT_SERVER, "Internal server error." );
}
}
@@ -78,4 +77,5 @@
}
protected abstract NamespaceVersionHolder getNamespaceSet();
+
}