protected void startListeningForService(AxisService service) {
if (service.getName().startsWith("__")) {
return;
}
Parameter param = service.getParameter(BaseConstants.TRANSPORT_POLL_INTERVAL);
long pollInterval = BaseConstants.DEFAULT_POLL_INTERVAL;
if (param != null && param.getValue() instanceof String) {
try {
pollInterval = Integer.parseInt(param.getValue().toString());
} catch (NumberFormatException e) {
log.error("Invalid poll interval : " + param.getValue() + " for service : " +
service.getName() + " default to : "
+ (BaseConstants.DEFAULT_POLL_INTERVAL/1000) + "sec", e);
disableTransportForService(service);
}
}
PollTableEntry entry = new PollTableEntry();
try {
entry.setFileURI(
BaseUtils.getRequiredServiceParam(service, VFSConstants.TRANSPORT_FILE_FILE_URI));
entry.setFileNamePattern(BaseUtils.getOptionalServiceParam(service,
VFSConstants.TRANSPORT_FILE_FILE_NAME_PATTERN));
entry.setContentType(BaseUtils.getRequiredServiceParam(service,
VFSConstants.TRANSPORT_FILE_CONTENT_TYPE));
String option = BaseUtils.getOptionalServiceParam(
service, VFSConstants.TRANSPORT_FILE_ACTION_AFTER_PROCESS);
entry.setActionAfterProcess(
MOVE.equals(option) ? PollTableEntry.MOVE : PollTableEntry.DELETE);
option = BaseUtils.getOptionalServiceParam(
service, VFSConstants.TRANSPORT_FILE_ACTION_AFTER_ERRORS);
entry.setActionAfterErrors(
MOVE.equals(option) ? PollTableEntry.MOVE : PollTableEntry.DELETE);
option = BaseUtils.getOptionalServiceParam(
service, VFSConstants.TRANSPORT_FILE_ACTION_AFTER_FAILURE);
entry.setActionAfterFailure(
MOVE.equals(option) ? PollTableEntry.MOVE : PollTableEntry.DELETE);
String moveDirectoryAfterProcess = BaseUtils.getOptionalServiceParam(
service, VFSConstants.TRANSPORT_FILE_MOVE_AFTER_PROCESS);
entry.setMoveAfterProcess(moveDirectoryAfterProcess);
String moveDirectoryAfterErrors = BaseUtils.getOptionalServiceParam(
service, VFSConstants.TRANSPORT_FILE_MOVE_AFTER_ERRORS);
entry.setMoveAfterErrors(moveDirectoryAfterErrors);
String moveDirectoryAfterFailure = BaseUtils.getOptionalServiceParam(
service, VFSConstants.TRANSPORT_FILE_MOVE_AFTER_FAILURE);
entry.setMoveAfterFailure(moveDirectoryAfterFailure);
String moveFileTimestampFormat = BaseUtils.getOptionalServiceParam(
service, VFSConstants.TRANSPORT_FILE_MOVE_TIMESTAMP_FORMAT);
if(moveFileTimestampFormat != null) {
DateFormat moveTimestampFormat = new SimpleDateFormat(moveFileTimestampFormat);
entry.setMoveTimestampFormat(moveTimestampFormat);
}
String strMaxRetryCount = BaseUtils.getOptionalServiceParam(
service, VFSConstants.MAX_RETRY_COUNT);
if(strMaxRetryCount != null)
entry.setMaxRetryCount(Integer.parseInt(strMaxRetryCount));
String strReconnectTimeout = BaseUtils.getOptionalServiceParam(
service, VFSConstants.RECONNECT_TIMEOUT);
if(strReconnectTimeout != null)
entry.setReconnectTimeout(Integer.parseInt(strReconnectTimeout) * 1000);
entry.setServiceName(service.getName());
schedulePoll(service, pollInterval);
pollTable.add(entry);
} catch (AxisFault axisFault) {
String msg = "Error configuring the File/VFS transport for Service : " +
service.getName() + " :: " + axisFault.getMessage();
log.warn(msg);
disableTransportForService(service);
}
}
|