View Javadoc

1   /* This file is part of COPAL (COntext Provisioning for All).
2    *
3    * COPAL is a part of SM4All (Smart hoMes for All) project.
4    *
5    * COPAL is free software: you can redistribute it and/or modify
6    * it under the terms of the GNU Lesser General Public License as published by
7    * the Free Software Foundation, either version 3 of the License, or
8    * (at your option) any later version.
9    *
10   * COPAL is distributed in the hope that it will be useful,
11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13   * GNU Lesser General Public License for more details.
14   *
15   * You should have received a copy of the GNU Lesser General Public License
16   * along with COPAL. If not, see <http://www.gnu.org/licenses/>.
17   */
18  package at.ac.tuwien.infosys.sm4all.copal.api.service;
19  
20  import at.ac.tuwien.infosys.sm4all.copal.api.ContextException;
21  import at.ac.tuwien.infosys.sm4all.copal.api.event.ContextEvent;
22  
23  /**
24   * Exception when publishing of a {@link ContextEvent} fails.
25   * 
26   * @author sanjin
27   */
28  public class FailedPublishingException extends ContextException {
29  
30      private static final long serialVersionUID = -6343622501326244826L;
31  
32      private final ContextEvent event;
33  
34      /**
35       * Create instance of failed publishing of specified {@link ContextEvent}
36       * exception with the specified detail message.
37       * 
38       * @param message the detail message (which is saved for later retrieval by
39       *        the {@link #getMessage()} method).
40       * @param event the {@link ContextEvent} (which is saved for later retrieval
41       *        by the {@link #getEvent()} method).
42       */
43      public FailedPublishingException(final String message,
44              final ContextEvent event) {
45          this(message, event, null);
46      }
47  
48      /**
49       * Create instance of failed publishing of specified {@link ContextEvent}
50       * with the specified detail message and cause.
51       * 
52       * @param message the detail message (which is saved for later retrieval by
53       *        the {@link #getMessage()} method).
54       * @param event the {@link ContextEvent} (which is saved for later retrieval
55       *        by the {@link #getEvent()} method).
56       * @param cause the cause (which is saved for later retrieval by the
57       *        {@link Throwable#getCause()} method). A <code>null</code> value is
58       *        permitted, and indicates that the cause is nonexistent or unknown.
59       */
60      public FailedPublishingException(final String message,
61              final ContextEvent event, final Throwable cause) {
62          super(message, cause);
63  
64          this.event = event;
65      }
66  
67      /**
68       * Returns the {@link ContextEvent} which failed to be published.
69       * 
70       * @return the {@link ContextEvent} which failed to be published.
71       */
72      public ContextEvent getEvent() {
73          return this.event;
74      }
75  }