001: /*
002: * Copyright (c) 1998-2008 Caucho Technology -- all rights reserved
003: *
004: * This file is part of Resin(R) Open Source
005: *
006: * Each copy or derived work must preserve the copyright notice and this
007: * notice unmodified.
008: *
009: * Resin Open Source is free software; you can redistribute it and/or modify
010: * it under the terms of the GNU General Public License as published by
011: * the Free Software Foundation; either version 2 of the License, or
012: * (at your option) any later version.
013: *
014: * Resin Open Source is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
017: * of NON-INFRINGEMENT. See the GNU General Public License for more
018: * details.
019: *
020: * You should have received a copy of the GNU General Public License
021: * along with Resin Open Source; if not, write to the
022: *
023: * Free Software Foundation, Inc.
024: * 59 Temple Place, Suite 330
025: * Boston, MA 02111-1307 USA
026: *
027: * @author Scott Ferguson
028: */
029:
030: package javax.resource.spi.work;
031:
032: import java.util.EventObject;
033:
034: /**
035: * A work event.
036: */
037: public class WorkEvent extends EventObject {
038: public final static int WORK_ACCEPTED = 1;
039: public final static int WORK_COMPLETED = 4;
040: public final static int WORK_REJECTED = 2;
041: public final static int WORK_STARTED = 3;
042:
043: private int type;
044: private Work work;
045: private WorkException exc;
046: private long startDuration = -1;
047:
048: /**
049: * Called with a Work instance has been accepted.
050: */
051: public WorkEvent(Object source, int type, Work work,
052: WorkException exn) {
053: super (source);
054:
055: this .type = type;
056: this .work = work;
057: this .exc = exn;
058: }
059:
060: /**
061: * Called with a Work instance has been accepted.
062: */
063: public WorkEvent(Object source, int type, Work work,
064: WorkException exn, long startDuration) {
065: super (source);
066:
067: this .type = type;
068: this .work = work;
069: this .exc = exn;
070: this .startDuration = startDuration;
071: }
072:
073: /**
074: * Returns the type of the event.
075: */
076: public int getType() {
077: return this .type;
078: }
079:
080: /**
081: * Returns the work instance.
082: */
083: public Work getWork() {
084: return this .work;
085: }
086:
087: /**
088: * Returns the start duration.
089: */
090: public long getStartDuration() {
091: return this .startDuration;
092: }
093:
094: /**
095: * Returns the work exception
096: */
097: public WorkException getException() {
098: return this.exc;
099: }
100: }
|