javax.resource.spi.work.Work Java Examples
The following examples show how to use
javax.resource.spi.work.Work.
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: 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 #2
Source File: WorkManagerImpl.java From ironjacamar with Eclipse Public License 1.0 | 5 votes |
/** * Fire complete for HintsContext * @param work The work instance */ private void fireHintsComplete(Work work) { if (work != null && work instanceof WorkContextProvider) { WorkContextProvider wcProvider = (WorkContextProvider) work; List<WorkContext> contexts = wcProvider.getWorkContexts(); if (contexts != null && !contexts.isEmpty()) { Iterator<WorkContext> it = contexts.iterator(); while (it.hasNext()) { WorkContext wc = it.next(); if (wc instanceof HintsContext) { HintsContext hc = (HintsContext) wc; if (hc instanceof WorkContextLifecycleListener) { WorkContextLifecycleListener listener = (WorkContextLifecycleListener)hc; listener.contextSetupComplete(); } } } } } }
Example #3
Source File: DistributedWorkManagerImpl.java From lams with GNU General Public License v2.0 | 5 votes |
/** * {@inheritDoc} */ @Override public void doWork(Work work) throws WorkException { if (policy == null || selector == null || transport == null || work == null || !(work instanceof DistributableWork) || !doWorkDistributionEnabled) { localDoWork(work); } else { doFirstChecks(work, WorkManager.INDEFINITE, null); checkTransport(); DistributableWork dw = (DistributableWork)work; boolean executed = false; if (policy.shouldDistribute(this, dw)) { Address dwmAddress = selector.selectDistributedWorkManager(getLocalAddress(), dw); if (dwmAddress != null && !getLocalAddress().equals(dwmAddress)) { transport.doWork(dwmAddress, dw); executed = true; } } if (!executed) { localDoWork(work); } } }
Example #4
Source File: SimpleTaskWorkManager.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Override public void doWork(Work work, long startTimeout, ExecutionContext executionContext, WorkListener workListener) throws WorkException { Assert.state(this.syncTaskExecutor != null, "No 'syncTaskExecutor' set"); executeWork(this.syncTaskExecutor, work, startTimeout, false, executionContext, workListener); }
Example #5
Source File: DistributedWorkManagerImpl.java From lams with GNU General Public License v2.0 | 5 votes |
/** * {@inheritDoc} */ @Override public void scheduleWork(Work work) throws WorkException { if (policy == null || selector == null || transport == null || work == null || !(work instanceof DistributableWork) || !scheduleWorkDistributionEnabled) { localScheduleWork(work); } else { doFirstChecks(work, WorkManager.INDEFINITE, null); checkTransport(); DistributableWork dw = (DistributableWork)work; boolean executed = false; if (policy.shouldDistribute(this, dw)) { Address dwmAddress = selector.selectDistributedWorkManager(getLocalAddress(), dw); if (dwmAddress != null && !getLocalAddress().equals(dwmAddress)) { transport.scheduleWork(dwmAddress, dw); executed = true; } } if (!executed) { localScheduleWork(work); } } }
Example #6
Source File: SimpleTaskWorkManager.java From java-technology-stack with MIT License | 5 votes |
@Override public void scheduleWork(Work work, long startTimeout, @Nullable ExecutionContext executionContext, @Nullable WorkListener workListener) throws WorkException { Assert.state(this.asyncTaskExecutor != null, "No 'asyncTaskExecutor' set"); executeWork(this.asyncTaskExecutor, work, startTimeout, false, executionContext, workListener); }
Example #7
Source File: DistributedWorkManagerImpl.java From ironjacamar with Eclipse Public License 1.0 | 5 votes |
/** * {@inheritDoc} */ @Override public void scheduleWork(Work work) throws WorkException { if (policy == null || selector == null || transport == null || work == null || !(work instanceof DistributableWork) || !scheduleWorkDistributionEnabled) { localScheduleWork(work); } else { doFirstChecks(work, WorkManager.INDEFINITE, null); checkTransport(); DistributableWork dw = (DistributableWork)work; boolean executed = false; if (policy.shouldDistribute(this, dw)) { Address dwmAddress = selector.selectDistributedWorkManager(getLocalAddress(), dw); if (dwmAddress != null && !getLocalAddress().equals(dwmAddress)) { transport.scheduleWork(dwmAddress, dw); executed = true; } } if (!executed) { localScheduleWork(work); } } }
Example #8
Source File: SimpleTaskWorkManager.java From java-technology-stack with MIT License | 5 votes |
@Override public long startWork(Work work, long startTimeout, @Nullable ExecutionContext executionContext, @Nullable WorkListener workListener) throws WorkException { Assert.state(this.asyncTaskExecutor != null, "No 'asyncTaskExecutor' set"); return executeWork(this.asyncTaskExecutor, work, startTimeout, true, executionContext, workListener); }
Example #9
Source File: SimpleWorkManager.java From ByteJTA with GNU Lesser General Public License v3.0 | 5 votes |
public void scheduleWork(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); // // ScheduledFuture<?> future = // this.scheduled.scheduleAtFixedRate(task, 0, 1000, TimeUnit.MILLISECONDS); throw new WorkException("not supported yet!"); }
Example #10
Source File: DistributedWorkManagerImpl.java From lams with GNU General Public License v2.0 | 5 votes |
/** * {@inheritDoc} */ public long localStartWork(Work work) throws WorkException { if (transport != null) { checkTransport(); if (getLongRunningThreadPool() != null && WorkManagerUtil.isLongRunning(work)) { transport.updateLongRunningFree(getLocalAddress(), getLongRunningThreadPool().getNumberOfFreeThreads() - 1); } else { transport.updateShortRunningFree(getLocalAddress(), getShortRunningThreadPool().getNumberOfFreeThreads() - 1); } WorkEventListener wel = new WorkEventListener(WorkManagerUtil.isLongRunning(work), getShortRunningThreadPool(), getLongRunningThreadPool(), getLocalAddress(), transport); return super.startWork(work, WorkManager.INDEFINITE, null, wel); } else { return super.startWork(work); } }
Example #11
Source File: ResourceAdapterImpl.java From ByteJTA with GNU Lesser General Public License v3.0 | 5 votes |
public void stop() { for (int i = 0; this.workList != null && i < this.workList.size(); i++) { Work work = this.workList.get(i); try { work.release(); } catch (RuntimeException rex) { logger.debug(rex.getMessage(), rex); } } }
Example #12
Source File: WorkManagerImpl.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Do first checks for work starting methods * @param work to check * @param startTimeout to check * @param execContext to check * @throws WorkException in case of check don't pass */ public void doFirstChecks(Work work, long startTimeout, ExecutionContext execContext) throws WorkException { if (isShutdown()) throw new WorkRejectedException(bundle.workmanagerShutdown()); if (work == null) throw new WorkRejectedException(bundle.workIsNull()); if (startTimeout < 0) throw new WorkRejectedException(bundle.startTimeoutIsNegative(startTimeout)); checkAndVerifyWork(work, execContext); }
Example #13
Source File: WorkManagerImpl.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Get the executor * @param work The work instance * @return The executor */ private BlockingExecutor getExecutor(Work work) { BlockingExecutor executor = shortRunningExecutor; if (longRunningExecutor != null && WorkManagerUtil.isLongRunning(work)) { executor = longRunningExecutor; } fireHintsComplete(work); return executor; }
Example #14
Source File: WorkManagerImpl.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Fire complete for HintsContext * @param work The work instance */ private void fireHintsComplete(Work work) { if (work != null && work instanceof WorkContextProvider) { WorkContextProvider wcProvider = (WorkContextProvider) work; List<WorkContext> contexts = wcProvider.getWorkContexts(); if (contexts != null && contexts.size() > 0) { Iterator<WorkContext> it = contexts.iterator(); while (it.hasNext()) { WorkContext wc = it.next(); if (wc instanceof HintsContext) { HintsContext hc = (HintsContext) wc; if (hc instanceof WorkContextLifecycleListener) { WorkContextLifecycleListener listener = (WorkContextLifecycleListener)hc; listener.contextSetupComplete(); } } } } } }
Example #15
Source File: DistributedWorkManagerImpl.java From lams with GNU General Public License v2.0 | 5 votes |
/** * {@inheritDoc} */ public void localDoWork(Work work) throws WorkException { if (transport != null) { checkTransport(); if (getLongRunningThreadPool() != null && WorkManagerUtil.isLongRunning(work)) { transport.updateLongRunningFree(getLocalAddress(), getLongRunningThreadPool().getNumberOfFreeThreads() - 1); } else { transport.updateShortRunningFree(getLocalAddress(), getShortRunningThreadPool().getNumberOfFreeThreads() - 1); } WorkEventListener wel = new WorkEventListener(WorkManagerUtil.isLongRunning(work), getShortRunningThreadPool(), getLongRunningThreadPool(), getLocalAddress(), transport); super.doWork(work, WorkManager.INDEFINITE, null, wel); } else { super.doWork(work); } }
Example #16
Source File: WorkWrapper.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Create a new WorkWrapper * * @param workManager the work manager * @param si The security integration * @param work the work * @param executionContext the execution context * @param workListener the WorkListener * @param startedLatch The latch for when work has started * @param completedLatch The latch for when work has completed * @param startTime The start time * @throws IllegalArgumentException for null work, execution context or a negative start timeout */ public WorkWrapper(WorkManagerImpl workManager, SecurityIntegration si, Work work, ExecutionContext executionContext, WorkListener workListener, CountDownLatch startedLatch, CountDownLatch completedLatch, long startTime) { super(); if (workManager == null) throw new IllegalArgumentException("Null work manager"); if (si == null) throw new IllegalArgumentException("Null security integration"); if (work == null) throw new IllegalArgumentException("Null work"); if (executionContext == null) throw new IllegalArgumentException("Null execution context"); this.workManager = workManager; this.securityIntegration = si; this.work = work; this.executionContext = executionContext; this.workListener = workListener; this.startedLatch = startedLatch; this.completedLatch = completedLatch; this.startTime = startTime; this.workContexts = null; }
Example #17
Source File: SimpleTaskWorkManager.java From spring-analysis-note with MIT License | 5 votes |
@Override public void scheduleWork(Work work, long startTimeout, @Nullable ExecutionContext executionContext, @Nullable WorkListener workListener) throws WorkException { Assert.state(this.asyncTaskExecutor != null, "No 'asyncTaskExecutor' set"); executeWork(this.asyncTaskExecutor, work, startTimeout, false, executionContext, workListener); }
Example #18
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 #19
Source File: WorkWrapper.java From ironjacamar with Eclipse Public License 1.0 | 5 votes |
/** * Create a new WorkWrapper * * @param workManager the work manager * @param si The security integration * @param work the work * @param executionContext the execution context * @param workListener the WorkListener * @param startedLatch The latch for when work has started * @param completedLatch The latch for when work has completed * @param startTime The start time * @throws IllegalArgumentException for null work, execution context or a negative start timeout */ public WorkWrapper(WorkManagerImpl workManager, SecurityIntegration si, Work work, ExecutionContext executionContext, WorkListener workListener, CountDownLatch startedLatch, CountDownLatch completedLatch, long startTime) { super(); if (workManager == null) throw new IllegalArgumentException("Null work manager"); if (si == null) throw new IllegalArgumentException("Null security integration"); if (work == null) throw new IllegalArgumentException("Null work"); if (executionContext == null) throw new IllegalArgumentException("Null execution context"); this.workManager = workManager; this.securityIntegration = si; this.work = work; this.executionContext = executionContext; this.workListener = workListener; this.startedLatch = startedLatch; this.completedLatch = completedLatch; this.startTime = startTime; this.workContexts = null; }
Example #20
Source File: DistributedWorkManagerImpl.java From ironjacamar with Eclipse Public License 1.0 | 5 votes |
/** * {@inheritDoc} */ public void localDoWork(Work work) throws WorkException { if (transport != null) { checkTransport(); if (getLongRunningThreadPool() != null && WorkManagerUtil.isLongRunning(work)) { transport.updateLongRunningFree(getLocalAddress(), getLongRunningThreadPool().getNumberOfFreeThreads() - 1); } else { transport.updateShortRunningFree(getLocalAddress(), getShortRunningThreadPool().getNumberOfFreeThreads() - 1); } WorkEventListener wel = new WorkEventListener(WorkManagerUtil.isLongRunning(work), getShortRunningThreadPool(), getLongRunningThreadPool(), getLocalAddress(), transport); super.doWork(work, WorkManager.INDEFINITE, null, wel); } else { super.doWork(work); } }
Example #21
Source File: SimpleTaskWorkManager.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public long startWork(Work work, long startTimeout, ExecutionContext executionContext, WorkListener workListener) throws WorkException { Assert.state(this.asyncTaskExecutor != null, "No 'asyncTaskExecutor' set"); return executeWork(this.asyncTaskExecutor, work, startTimeout, true, executionContext, workListener); }
Example #22
Source File: ActiveMQRATestBase.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Override public long startWork(Work work, long l, ExecutionContext executionContext, WorkListener workListener) throws WorkException { return 0; }
Example #23
Source File: WorkManagerImpl.java From ironjacamar with Eclipse Public License 1.0 | 5 votes |
/** * Check and verify work before submitting. * @param work the work instance * @param executionContext any execution context that is passed by apadater * @throws WorkException if any exception occurs */ private void checkAndVerifyWork(Work work, ExecutionContext executionContext) throws WorkException { if (specCompliant) { verifyWork(work); } if (work instanceof WorkContextProvider && executionContext != null) { //Implements WorkContextProvider and not-null ExecutionContext throw new WorkRejectedException(bundle.workExecutionContextMustNullImplementsWorkContextProvider()); } }
Example #24
Source File: WorkManagerImpl.java From ironjacamar with Eclipse Public License 1.0 | 5 votes |
/** * Do first checks for work starting methods * @param work to check * @param startTimeout to check * @param execContext to check * @throws WorkException in case of check don't pass */ public void doFirstChecks(Work work, long startTimeout, ExecutionContext execContext) throws WorkException { if (isShutdown()) throw new WorkRejectedException(bundle.workmanagerShutdown()); if (work == null) throw new WorkRejectedException(bundle.workIsNull()); if (startTimeout < 0) throw new WorkRejectedException(bundle.startTimeoutIsNegative(startTimeout)); checkAndVerifyWork(work, execContext); }
Example #25
Source File: XATerminatorImpl.java From lams with GNU General Public License v2.0 | 4 votes |
/** * {@inheritDoc} */ public void endWork(Work work, Xid xid) { }
Example #26
Source File: SimpleWork.java From ByteJTA with GNU Lesser General Public License v3.0 | 4 votes |
public void setWork(Work work) { this.work = work; }
Example #27
Source File: WorkManagerImpl.java From ironjacamar with Eclipse Public License 1.0 | 4 votes |
/** * {@inheritDoc} */ public void scheduleWork(Work work) throws WorkException { scheduleWork(work, WorkManager.INDEFINITE, null, null); }
Example #28
Source File: WorkManagerImpl.java From lams with GNU General Public License v2.0 | 4 votes |
/** * {@inheritDoc} */ public long startWork(Work work) throws WorkException { return startWork(work, WorkManager.INDEFINITE, null, null); }
Example #29
Source File: WorkManagerTaskExecutor.java From spring4-understanding with Apache License 2.0 | 4 votes |
@Override public long startWork(Work work, long delay, ExecutionContext executionContext, WorkListener workListener) throws WorkException { return this.workManager.startWork(work, delay, executionContext, workListener); }
Example #30
Source File: WorkManagerTaskExecutor.java From spring4-understanding with Apache License 2.0 | 4 votes |
@Override public void doWork(Work work, long delay, ExecutionContext executionContext, WorkListener workListener) throws WorkException { this.workManager.doWork(work, delay, executionContext, workListener); }