javax.resource.spi.work.WorkEvent Java Examples
The following examples show how to use
javax.resource.spi.work.WorkEvent.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SimpleTaskWorkManager.java From java-technology-stack with MIT License | 6 votes |
@Override public void run() { if (this.acceptOnExecution) { this.workListener.workAccepted(new WorkEvent(this, WorkEvent.WORK_ACCEPTED, this.work, null)); } synchronized (this.monitor) { this.started = true; this.monitor.notify(); } this.workListener.workStarted(new WorkEvent(this, WorkEvent.WORK_STARTED, this.work, null)); try { this.work.run(); } catch (RuntimeException | Error ex) { this.workListener.workCompleted( new WorkEvent(this, WorkEvent.WORK_COMPLETED, this.work, new WorkCompletedException(ex))); throw ex; } this.workListener.workCompleted(new WorkEvent(this, WorkEvent.WORK_COMPLETED, this.work, null)); }
Example #2
Source File: SimpleTaskWorkManager.java From lams with GNU General Public License v2.0 | 6 votes |
@Override public void run() { if (this.acceptOnExecution) { this.workListener.workAccepted(new WorkEvent(this, WorkEvent.WORK_ACCEPTED, work, null)); } synchronized (this.monitor) { this.started = true; this.monitor.notify(); } this.workListener.workStarted(new WorkEvent(this, WorkEvent.WORK_STARTED, this.work, null)); try { this.work.run(); } catch (RuntimeException ex) { this.workListener.workCompleted( new WorkEvent(this, WorkEvent.WORK_COMPLETED, this.work, new WorkCompletedException(ex))); throw ex; } catch (Error err) { this.workListener.workCompleted( new WorkEvent(this, WorkEvent.WORK_COMPLETED, this.work, new WorkCompletedException(err))); throw err; } this.workListener.workCompleted(new WorkEvent(this, WorkEvent.WORK_COMPLETED, this.work, null)); }
Example #3
Source File: SimpleTaskWorkManager.java From spring-analysis-note with MIT License | 6 votes |
@Override public void run() { if (this.acceptOnExecution) { this.workListener.workAccepted(new WorkEvent(this, WorkEvent.WORK_ACCEPTED, this.work, null)); } synchronized (this.monitor) { this.started = true; this.monitor.notify(); } this.workListener.workStarted(new WorkEvent(this, WorkEvent.WORK_STARTED, this.work, null)); try { this.work.run(); } catch (RuntimeException | Error ex) { this.workListener.workCompleted( new WorkEvent(this, WorkEvent.WORK_COMPLETED, this.work, new WorkCompletedException(ex))); throw ex; } this.workListener.workCompleted(new WorkEvent(this, WorkEvent.WORK_COMPLETED, this.work, null)); }
Example #4
Source File: SimpleTaskWorkManager.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Override public void run() { if (this.acceptOnExecution) { this.workListener.workAccepted(new WorkEvent(this, WorkEvent.WORK_ACCEPTED, work, null)); } synchronized (this.monitor) { this.started = true; this.monitor.notify(); } this.workListener.workStarted(new WorkEvent(this, WorkEvent.WORK_STARTED, this.work, null)); try { this.work.run(); } catch (RuntimeException ex) { this.workListener.workCompleted( new WorkEvent(this, WorkEvent.WORK_COMPLETED, this.work, new WorkCompletedException(ex))); throw ex; } catch (Error err) { this.workListener.workCompleted( new WorkEvent(this, WorkEvent.WORK_COMPLETED, this.work, new WorkCompletedException(err))); throw err; } this.workListener.workCompleted(new WorkEvent(this, WorkEvent.WORK_COMPLETED, this.work, null)); }
Example #5
Source File: ContextWorkAdapter.java From ironjacamar with Eclipse Public License 1.0 | 6 votes |
/** * complete work * * @param e workEvent */ @Override public void workCompleted(WorkEvent e) { if (e.getType() != WorkEvent.WORK_COMPLETED) fail("Wrong completed type"); timeCompleted = System.currentTimeMillis(); super.workCompleted(e); Work work = e.getWork(); if (work instanceof NestProviderWork) { NestProviderWork nw = (NestProviderWork) work; done.append(nw.getName()); exception = e.getException(); } }
Example #6
Source File: ContextWorkAdapter.java From ironjacamar with Eclipse Public License 1.0 | 6 votes |
/** * start work * * @param e workEvent */ @Override public void workRejected(WorkEvent e) { if (e.getType() != WorkEvent.WORK_REJECTED) fail("Wrong rejected type"); timeRejected = System.currentTimeMillis(); super.workRejected(e); Work work = e.getWork(); if (work instanceof NestProviderWork) { NestProviderWork nw = (NestProviderWork) work; reject.append(nw.getName()); } }
Example #7
Source File: ContextWorkAdapter.java From ironjacamar with Eclipse Public License 1.0 | 6 votes |
/** * start work * * @param e workEvent */ @Override public void workStarted(WorkEvent e) { if (e.getType() != WorkEvent.WORK_STARTED) fail("Wrong started type"); timeStarted = System.currentTimeMillis(); super.workStarted(e); Work work = e.getWork(); if (work instanceof NestProviderWork) { NestProviderWork nw = (NestProviderWork) work; start.append(nw.getName()); } }
Example #8
Source File: StatusWorkAdapter.java From ironjacamar with Eclipse Public License 1.0 | 6 votes |
/** * complete work * * @param e workEvent */ @Override public void workCompleted(WorkEvent e) { if (e.getType() != WorkEvent.WORK_COMPLETED) fail("Wrong completed type"); if (callbackCount != null) { synchronized (this) { callbackCount.setCompletedCount(callbackCount.getCompletedCount() + 1); } } super.workCompleted(e); }
Example #9
Source File: StatusWorkAdapter.java From ironjacamar with Eclipse Public License 1.0 | 6 votes |
/** * start work * * @param e workEvent */ @Override public void workRejected(WorkEvent e) { if (e.getType() != WorkEvent.WORK_REJECTED) fail("Wrong rejected type"); source = e.getSource(); work = e.getWork(); startDuration = e.getStartDuration(); exception = e.getException(); if (callbackCount != null) { synchronized (this) { callbackCount.setRejectedCount(callbackCount.getRejectedCount() + 1); } } super.workRejected(e); }
Example #10
Source File: StatusWorkAdapter.java From ironjacamar with Eclipse Public License 1.0 | 6 votes |
/** * start work * * @param e workEvent */ @Override public void workStarted(WorkEvent e) { if (e.getType() != WorkEvent.WORK_STARTED) fail("Wrong started type"); if (callbackCount != null) { synchronized (this) { callbackCount.setStartCount(callbackCount.getStartCount() + 1); } } super.workStarted(e); }
Example #11
Source File: StatusWorkAdapter.java From ironjacamar with Eclipse Public License 1.0 | 6 votes |
/** * accept work * * @param e workEvent */ @Override public void workAccepted(WorkEvent e) { if (e.getType() != WorkEvent.WORK_ACCEPTED) fail("Wrong accepted type"); source = e.getSource(); work = e.getWork(); startDuration = e.getStartDuration(); exception = e.getException(); if (callbackCount != null) { synchronized (this) { callbackCount.setAcceptCount(callbackCount.getAcceptCount() + 1); } } super.workAccepted(e); }
Example #12
Source File: SimpleWorkManager.java From tomee with Apache License 2.0 | 5 votes |
public void workCompleted(final WorkEvent event) { // Don't log doWork since exception is propagated to caller if (workType == WorkType.DO) { return; } Throwable cause = event.getException(); if (cause != null && cause.getCause() != null) { cause = cause.getCause(); } if (cause != null) { logger.error(event.getWork().toString(), cause); } }
Example #13
Source File: SimpleWorkManager.java From tomee with Apache License 2.0 | 5 votes |
public void workRejected(final WorkEvent event) { // Don't log doWork or startWork since exception is propagated to caller if (workType == WorkType.DO || workType == WorkType.START) { return; } final WorkException exception = event.getException(); if (exception != null) { if (WorkException.START_TIMED_OUT.equals(exception.getErrorCode())) { logger.error(exception.getMessage()); } } }
Example #14
Source File: ContextWorkAdapter.java From ironjacamar with Eclipse Public License 1.0 | 5 votes |
/** * accept work * * @param e workEvent */ @Override public void workAccepted(WorkEvent e) { if (e.getType() != WorkEvent.WORK_ACCEPTED) fail("Wrong accepted type"); timeAccepted = System.currentTimeMillis(); super.workAccepted(e); }
Example #15
Source File: WorkManagerThreadPool.java From cxf with Apache License 2.0 | 5 votes |
@Override public void workRejected(WorkEvent e) { super.workRejected(e); WorkException we = e.getException(); if (WorkException.START_TIMED_OUT.equals(we.getErrorCode()) && !isLowOnThreads) { setIsLowOnThreads(true); dispatch(theJob); } }
Example #16
Source File: SimpleWorkListener.java From ByteJTA with GNU Lesser General Public License v3.0 | 5 votes |
public void workStarted(WorkEvent event) { if (this.delegate != null) { delegate.workStarted(event); } this.startedTime = System.currentTimeMillis(); this.signalStarted(); }
Example #17
Source File: SimpleWorkManager.java From ByteJTA with GNU Lesser General Public License v3.0 | 5 votes |
public long startWork(Work work, long startTimeout, ExecutionContext execContext, WorkListener workListener) throws WorkException { SimpleWorkListener wrappedListener = new SimpleWorkListener(workListener); wrappedListener.workAccepted(new WorkEvent(this, WorkEvent.WORK_ACCEPTED, work, null)); SimpleWork task = new SimpleWork(); task.setSource(this); task.setWork(work); task.setWorkListener(wrappedListener); this.executor.submit(task); return wrappedListener.waitForStart(); }
Example #18
Source File: CXFWorkAdapter.java From cxf with Apache License 2.0 | 4 votes |
public void workStarted(WorkEvent e) { LOG.fine("workStarted: [" + e.getWork() + "], source is [" + e.getSource() + "]"); }
Example #19
Source File: CXFWorkAdapter.java From cxf with Apache License 2.0 | 4 votes |
public void workRejected(WorkEvent e) { LOG.severe("workRejected: [" + e.getWork() + "], source is [" + e.getSource() + "]"); LOG.severe("root cause is:" + e.getException().getMessage()); e.getException().printStackTrace(); }
Example #20
Source File: CXFWorkAdapter.java From cxf with Apache License 2.0 | 4 votes |
public void workCompleted(WorkEvent e) { LOG.fine("workCompleted: [" + e.getWork() + "], source is [" + e.getSource() + "]"); }
Example #21
Source File: CXFWorkAdapter.java From cxf with Apache License 2.0 | 4 votes |
public void workAccepted(WorkEvent e) { LOG.fine("workAccepted: [" + e.getWork() + "], source is [" + e.getSource() + "]"); }
Example #22
Source File: SimpleWorkListener.java From ByteJTA with GNU Lesser General Public License v3.0 | 4 votes |
public void workRejected(WorkEvent event) { if (this.delegate != null) { delegate.workRejected(event); } }
Example #23
Source File: SimpleWorkListener.java From ByteJTA with GNU Lesser General Public License v3.0 | 4 votes |
public void workCompleted(WorkEvent event) { if (this.delegate != null) { delegate.workCompleted(event); } }
Example #24
Source File: SimpleWorkListener.java From ByteJTA with GNU Lesser General Public License v3.0 | 4 votes |
public void workAccepted(WorkEvent event) { if (this.delegate != null) { delegate.workAccepted(event); } this.acceptedTime = System.currentTimeMillis(); }
Example #25
Source File: SimpleWork.java From ByteJTA with GNU Lesser General Public License v3.0 | 4 votes |
public void run() { this.workListener.workStarted(new WorkEvent(this.source, WorkEvent.WORK_STARTED, this.work, null)); this.work.run(); this.workListener.workCompleted(new WorkEvent(this.source, WorkEvent.WORK_COMPLETED, this.work, null)); }
Example #26
Source File: WorkEventListener.java From ironjacamar with Eclipse Public License 1.0 | 4 votes |
/** * {@inheritDoc} */ @Override public void workCompleted(WorkEvent e) { done(); }
Example #27
Source File: WorkEventListener.java From ironjacamar with Eclipse Public License 1.0 | 4 votes |
/** * {@inheritDoc} */ @Override public void workRejected(WorkEvent e) { done(); }
Example #28
Source File: WorkWrapper.java From ironjacamar with Eclipse Public License 1.0 | 4 votes |
/** * Run */ public void run() { ClassLoader oldCL = SecurityActions.getThreadContextClassLoader(); SecurityActions.setThreadContextClassLoader(work.getClass().getClassLoader()); org.ironjacamar.core.spi.security.SecurityContext oldSC = securityIntegration.getSecurityContext(); try { start(); workManager.addWorkWrapper(this); if (startedLatch != null) startedLatch.countDown(); work.run(); end(); } catch (Throwable t) { exception = new WorkCompletedException(t.getMessage(), t); cancel(); } finally { workManager.removeWorkWrapper(this); work.release(); if (workListener != null) { WorkEvent event = new WorkEvent(workManager, WorkEvent.WORK_COMPLETED, work, exception); workListener.workCompleted(event); } securityIntegration.setSecurityContext(oldSC); SecurityActions.setThreadContextClassLoader(oldCL); if (startedLatch != null) { while (startedLatch.getCount() != 0) startedLatch.countDown(); } if (completedLatch != null) completedLatch.countDown(); if (trace) log.tracef("Executed work: %s", this); } }
Example #29
Source File: WorkEventListener.java From lams with GNU General Public License v2.0 | 4 votes |
/** * {@inheritDoc} */ @Override public void workRejected(WorkEvent e) { done(); }
Example #30
Source File: WorkEventListener.java From lams with GNU General Public License v2.0 | 4 votes |
/** * {@inheritDoc} */ @Override public void workCompleted(WorkEvent e) { done(); }