public abstract class AbstractCAPI extends Object
This class should not be derived from manually. This class is only
intended to be used as a superclass of CAPI
classes generated
by the XINS framework.
The constructors of this class are considered internal to XINS and should not be used directly. The behavior of the constructors may be changed in later releases of XINS or they may even be removed.
Modifier | Constructor and Description |
---|---|
protected |
AbstractCAPI(Descriptor descriptor)
Creates a new
AbstractCAPI object, using the specified
service descriptor. |
protected |
AbstractCAPI(Descriptor descriptor,
XINSCallConfig callConfig)
Creates a new
AbstractCAPI object, using the specified
XINSServiceCaller . |
protected |
AbstractCAPI(Map<String,String> properties,
String apiName)
Creates a new
AbstractCAPI object based on the specified
set of properties and the specified name. |
Modifier and Type | Method and Description |
---|---|
protected XINSCallResult |
callImpl(AbstractCAPICallRequest request)
Executes the specified call request.
|
protected AbstractCAPIErrorCodeException |
createErrorCodeException(XINSCallRequest request,
TargetDescriptor target,
long duration,
XINSCallResultData resultData)
Creates an
AbstractCAPIErrorCodeException for the specified
error code. |
String |
getAPIName()
Determines the name of the API.
|
protected String |
getAPINameImpl()
Retrieves the name of the API (implementation method).
|
APISpec |
getAPISpecification()
Get the specification of the API.
|
protected XINSServiceCaller |
getCaller()
Returns the XINS service caller to use.
|
XINSCallConfig |
getXINSCallConfig()
Retrieves the call configuration currently associated with this CAPI
object.
|
abstract String |
getXINSVersion()
Returns the version of XINS used to build this CAPI class.
|
protected boolean |
isFunctionalError(String errorCode)
Returns
true of the error code is a functional error code. |
void |
setXINSCallConfig(XINSCallConfig config)
Assigns the specified call configuration to this CAPI object.
|
protected AbstractCAPI(Descriptor descriptor, XINSCallConfig callConfig) throws IllegalArgumentException, UnsupportedProtocolException
AbstractCAPI
object, using the specified
XINSServiceCaller
.
This constructor is considered internal to XINS. Do not use it directly.
descriptor
- the descriptor for the service(s), cannot be null
.callConfig
- fallback configuration for the calls, or null
if a
default should be used.IllegalArgumentException
- if descriptor == null
.UnsupportedProtocolException
- if any of the target descriptors in descriptor
specifies
an unsupported protocol.protected AbstractCAPI(Descriptor descriptor) throws IllegalArgumentException, UnsupportedProtocolException
AbstractCAPI
object, using the specified
service descriptor.
A default XINS call configuration will be used.
This constructor is considered internal to XINS. Do not use it directly.
descriptor
- the descriptor for the service(s), cannot be null
.IllegalArgumentException
- if descriptor == null
.UnsupportedProtocolException
- if any of the target descriptors in descriptor
specifies
an unsupported protocol (since XINS 1.1.0).protected AbstractCAPI(Map<String,String> properties, String apiName) throws IllegalArgumentException, MissingRequiredPropertyException, InvalidPropertyValueException
AbstractCAPI
object based on the specified
set of properties and the specified name.
A default XINS call configuration will be used.
This constructor is considered internal to XINS. Do not use it directly.
properties
- the properties to read from, cannot be null
.apiName
- the name of the API, cannot be null
and must be a valid
API name.IllegalArgumentException
- if properties == null || apiName == null
or if
apiName
is not considered to be a valid API name.MissingRequiredPropertyException
- if a required property is missing in the specified properties set.InvalidPropertyValueException
- if one of the properties in the specified properties set is used to
create a CAPI
instance but its value is considered
invalid.public final String getAPIName()
"<unknown>"
) if the name cannot be determined;
never null
.protected boolean isFunctionalError(String errorCode)
true
of the error code is a functional error code.
If unknown, false is returned.errorCode
- the error code to check, cannot be null
.true
if the error code is functional, false
if the error code is technical.protected String getAPINameImpl()
The implementation of this method in class AbstractCAPI
returns null
.
null
if unknown.public final APISpec getAPISpecification() throws InvalidSpecificationException
APISpec
specification object.InvalidSpecificationException
- if the specification cannot be found or is invalid.public final void setXINSCallConfig(XINSCallConfig config)
config
- the call configuration to apply when executing a call with this CAPI
object, or null
if no specific call configuration should be
associated with CAPI object; note that the call configuration can be
overridden by the request, see
AbstractCAPICallRequest.configure(XINSCallConfig)
.public final XINSCallConfig getXINSCallConfig()
null
if no specific call configuration is associated
with this cAPI object; note that the call configuration can be
overridden by the request, see
AbstractCAPICallRequest.configuration()
.protected final XINSServiceCaller getCaller()
This method is considered internal to XINS. It should not be called directly, nor overridden.
This method is expected to be marked final
in XINS
2.0. This is not done yet to remain fully compatible with XINS 1.x.
XINSServiceCaller
to use, never null
.public abstract String getXINSVersion()
String
, cannot be null
.protected final XINSCallResult callImpl(AbstractCAPICallRequest request) throws IllegalArgumentException, UnacceptableRequestException, GenericCallException, HTTPCallException, XINSCallException
This method is provided for CAPI subclasses.
request
- the call request to execute, cannot be null
.null
.IllegalArgumentException
- if request == null
.UnacceptableRequestException
- if the request is considered to be unacceptable; this is determined
by calling
request.
checkParameters()
.GenericCallException
- if the first call attempt failed due to a generic reason and all the
other call attempts (if any) failed as well.HTTPCallException
- if the first call attempt failed due to an HTTP-related reason and
all the other call attempts (if any) failed as well.XINSCallException
- if the first call attempt failed due to a XINS-related reason and
all the other call attempts (if any) failed as well.protected AbstractCAPIErrorCodeException createErrorCodeException(XINSCallRequest request, TargetDescriptor target, long duration, XINSCallResultData resultData) throws IllegalArgumentException, UnacceptableErrorCodeXINSCallException
AbstractCAPIErrorCodeException
for the specified
error code. If the specified error code is not recognized, then
null
is returned.request
- the original request, should not be null
.target
- descriptor for the target that was attempted to be called, should not
be null
.duration
- the call duration in milliseconds, should be >= 0.resultData
- the result data, should not be null
and should have an
error code set.AbstractCAPIErrorCodeException
instance, otherwise
null
.IllegalArgumentException
- if request == null
|| target == null
|| duration < 0
|| resultData == null
|| resultData.getErrorCode() == null
.UnacceptableErrorCodeXINSCallException
- if the specified error code is recognized but is considered
unacceptable for the function specified in the request.See http://www.xins.org/.