public InvocationResponse invoke(MessageContext msgContext) throws AxisFault {
String service = "";
String operation = "";
Counter counter = new Counter();
if (msgContext.getConfigurationContext().getProperty(
ClientStatisticsPublisherConstants.BAM_USER_DEFINED_SERVICE_PROPERTY) != null) {
service = msgContext.getConfigurationContext().getProperty(
ClientStatisticsPublisherConstants.BAM_USER_DEFINED_SERVICE_PROPERTY)
.toString();
} else {
log.error("ServiceName property not found");
}
if (msgContext.getConfigurationContext().getProperty(
ClientStatisticsPublisherConstants.BAM_USER_DEFINED_OPERATION_PROPERTY) != null) {
operation = msgContext.getConfigurationContext().getProperty(
ClientStatisticsPublisherConstants.BAM_USER_DEFINED_OPERATION_PROPERTY)
.toString();
} else {
log.error("OperationName property not found");
}
// Increment the global fault count
Object globalFaultCounterObject = msgContext
.getProperty(ClientStatisticsPublisherConstants.BAM_USER_DEFINED_GLOBAL_FAULT_COUNTER_PROPERTY);
if (globalFaultCounterObject == null) {
log
.warn(ClientStatisticsPublisherConstants.BAM_USER_DEFINED_GLOBAL_FAULT_COUNTER_PROPERTY
+ " is null");
} else {
if (globalFaultCounterObject instanceof Counter) {
counter.increment(((Counter) globalFaultCounterObject).getCount());
}
}
// Increment the service fault count
if (service != null) {
Object serviceFaultCountObj = msgContext
.getConfigurationContext()
.getProperty(
ClientStatisticsPublisherConstants.BAM_USER_DEFINED_SERVICE_FAULT_COUNTER_PROPERTY);
if (serviceFaultCountObj != null) {
if (serviceFaultCountObj instanceof Counter) {
counter.increment(((Counter) serviceFaultCountObj).getCount());
}
} else {
counter.increment();
msgContext
.getConfigurationContext()
.setProperty(
ClientStatisticsPublisherConstants.BAM_USER_DEFINED_SERVICE_FAULT_COUNTER_PROPERTY,
counter);
}
}
if (operation != null) {
Object operationFaultCountObject = msgContext
.getConfigurationContext()
.getProperty(
ClientStatisticsPublisherConstants.BAM_USER_DEFINED_OPERATION_FAULT_COUNTER_PROPERTY);
if (operationFaultCountObject != null) {
if (operationFaultCountObject instanceof Counter) {
counter.increment(((Counter) operationFaultCountObject).getCount());
}
} else {
counter.increment();
msgContext
.getConfigurationContext()
.setProperty(
ClientStatisticsPublisherConstants.BAM_USER_DEFINED_OPERATION_FAULT_COUNTER_PROPERTY,
counter);