Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
  * #%L
  * Service Activity Monitoring :: Agent
  * %%
  * Copyright (C) 2011 Talend Inc.
  * %%
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * #L%
 */
package org.talend.esb.sam.agent.serviceclient;
Wraps business logic to web service logic. So web service should be changeable.
    private int numberOfRetries = 3;
    private long delayBetweenRetry = 1000;
    public void setNumberOfRetries(int numberOfRetries) {
        if (numberOfRetries <= 0) {
            throw new IllegalStateException("Number of retries must be > 0 but was " + numberOfRetries);
        }
        this. = numberOfRetries;
    }
    public void setDelayBetweenRetry(long delayBetweenRetry) {
        if (delayBetweenRetry <= 0) {
            throw new IllegalStateException("Delay between retries must be > 0 but was " + delayBetweenRetry);
        }
        this. = delayBetweenRetry;
    }

    
Set by Spring. Sets the web service implementation.

Parameters:
monitoringService
    public void setMonitoringService(MonitoringService monitoringService) {
        this. = monitoringService;
    }

    
Sends all events to the web service. Events will be transformed with mapper before sending.
    public void putEvents(List<Eventevents) {
        Exception lastException;
        List<EventTypeeventTypes = new ArrayList<EventType>();
        for (Event event : events) {
            EventType eventType = EventMapper.map(event);
            eventTypes.add(eventType);
        }
        int i = 0;
        lastException = null;
        while (i < ) {
            try {
                .putEvents(eventTypes);
                break;
            } catch (Exception e) {
                lastException = e;
                i++;
                try {
                    Thread.sleep();
                } catch (Exception e1) {
                }
            }
        }
        if (i == ) {
            throw new MonitoringException("1104""Could not send events to monitoring service after "
                                                  +  + " retries."lastExceptionevents);
        }
    }
New to GrepCode? Check out our FAQ X