Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * #%L
   * Service Activity Monitoring :: Common
   * %%
   * Copyright (C) 2011 - 2012 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.common.event;
 
 import java.util.List;
The Class MonitoringException describes the monitoring exception.
 
 public class MonitoringException extends RuntimeException {
 
     private static final Logger LOG = Logger.getLogger(MonitoringException.class.getName());
     private static final long serialVersionUID = 3127641209174705808L;
 
     private final String code;
     private final String message;
     private final List<Eventevents = new ArrayList<Event>();

    
Instantiates a new monitoring exception.

Parameters:
code the code
message the message
t the Trowable type for exeption definition
 
     public MonitoringException(String codeString messageThrowable t) {
         this(codemessaget, Collections.<Event>emptyList());
     }

    
Instantiates a new monitoring exception.

Parameters:
code the monitoring exception code
message the message
t Trowable type for exeption definition
event the event
 
     public MonitoringException(String codeString messageThrowable t,
             Event event) {
         this(codemessaget, Collections.singletonList(event));
     }

    
Instantiates a new monitoring exception.

Parameters:
code the monitoring exception code
message the message
t Trowable type for exeption definition
events the events
 
     public MonitoringException(String codeString messageThrowable t,
             List<Eventevents) {
         super(t);
         this. = code;
         this. = message;
         this..addAll(events);
     }

    
Gets the code.

Returns:
the code
 
     public String getCode() {
         return ;
     }
 
     /* (non-Javadoc)
      * @see java.lang.Throwable#getMessage()
      */
     public String getMessage() {
         return ;
     }

    
Prints the error message as log message.

Parameters:
level the log level
    public void logException(Level level) {
        if (!.isLoggable(level)) {
            return;
        }
        final StringBuilder builder = new StringBuilder();
        builder.append("\n----------------------------------------------------");
        builder.append("\nMonitoringException");
        builder.append("\n----------------------------------------------------");
        builder.append("\nCode:    ").append();
        builder.append("\nMessage: ").append();
        builder.append("\n----------------------------------------------------");
        if ( != null) {
            for (Event event : ) {
                builder.append("\nEvent:");
                if (event.getMessageInfo() != null) {
                    builder.append("\nMessage id: ").append(event.getMessageInfo().getMessageId());
                    builder.append("\nFlow id:    ").append(event.getMessageInfo().getFlowId());
                    builder.append("\n----------------------------------------------------");
                } else {
                    builder.append("\nNo message id and no flow id");
                }
            }
        }
        builder.append("\n----------------------------------------------------\n");
        .log(levelbuilder.toString(), this);
    }

    
Adds the event.

Parameters:
event the event
    public void addEvent(Event event) {
        .add(event);
    }

    
Adds the events.

Parameters:
eventCollection the event collection
    public void addEvents(Collection<EventeventCollection) {
        .addAll(eventCollection);
    }
New to GrepCode? Check out our FAQ X