001: /*
002: * JBoss, Home of Professional Open Source.
003: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004: * as indicated by the @author tags. See the copyright.txt file in the
005: * distribution for a full listing of individual contributors.
006: *
007: * This is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU Lesser General Public License as
009: * published by the Free Software Foundation; either version 2.1 of
010: * the License, or (at your option) any later version.
011: *
012: * This software is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this software; if not, write to the Free
019: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021: */
022: package javax.resource.spi.work;
023:
024: /**
025: * Interface used to associate the resource adapter with objects that implement
026: * this interface.
027: */
028: public interface WorkManager {
029: /** Unknown/unspecified start delay */
030: static final long UNKNOWN = -1l;
031: /** No start delay */
032: static final long IMMEDIATE = 0l;
033: /** Indefinite start delay */
034: static final long INDEFINITE = Long.MAX_VALUE;
035:
036: /**
037: * Executes the work, the call blocks until the work completes
038: *
039: * @param work the work
040: * @throws WorkException a generic error
041: * @throws WorkRejectedException if the work is rejected
042: * @throws WorkCompletedException if the work completes with an exception
043: */
044: void doWork(Work work) throws WorkException;
045:
046: /**
047: * Executes the work, the call blocks until the work completes
048: *
049: * @param work the work
050: * @param startTimeout the wait before execution
051: * @param ctx the execution context
052: * @param listener the work listener
053: * @throws WorkException a generic error
054: * @throws WorkRejectedException if the work is rejected
055: * @throws WorkCompletedException if the work completes with an exception
056: */
057: void doWork(Work work, long startTimeout, ExecutionContext ctx,
058: WorkListener listener) throws WorkException;
059:
060: /**
061: * Executes the work, the call blocks until the work starts
062: *
063: * @param work the work
064: * @return the time elapsed until the work starts
065: * @throws WorkException a generic error
066: * @throws WorkRejectedException if the work is rejected
067: */
068: long startWork(Work work) throws WorkException;
069:
070: /**
071: * Executes the work, the call blocks until the work starts
072: *
073: * @param work the work
074: * @param startTimeout the wait before execution
075: * @param ctx the execution context
076: * @param listener the work listener
077: * @return the time elapsed until the work starts
078: * @throws WorkException a generic error
079: * @throws WorkRejectedException if the work is rejected
080: */
081: long startWork(Work work, long startTimeout, ExecutionContext ctx,
082: WorkListener listener) throws WorkException;
083:
084: /**
085: * Executes the work, the call returns immediatley
086: *
087: * @param work the work
088: * @throws WorkException a generic error
089: * @throws WorkRejectedException if the work is rejected
090: */
091: void scheduleWork(Work work) throws WorkException;
092:
093: /**
094: * Executes the work, the call returns immediately
095: *
096: * @param work the work
097: * @param startTimeout the wait before execution
098: * @param ctx the execution context
099: * @param listener the work listener
100: * @throws WorkException a generic error
101: * @throws WorkRejectedException if the work is rejected
102: */
103: void scheduleWork(Work work, long startTimeout,
104: ExecutionContext ctx, WorkListener listener)
105: throws WorkException;
106: }
|