javax.resource.spi.work.HintsContext Java Examples
The following examples show how to use
javax.resource.spi.work.HintsContext.
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: BaseCloneableBootstrapContext.java From lams with GNU General Public License v2.0 | 6 votes |
/** * Constructor */ public BaseCloneableBootstrapContext() { this.transactionSynchronizationRegistry = null; this.workManager = null; this.workManagerName = null; this.xaTerminator = null; this.supportedContexts = new HashSet<Class>(4); this.supportedContexts.add(HintsContext.class); this.supportedContexts.add(SecurityContext.class); this.supportedContexts.add(TransactionContext.class); this.supportedContexts.add(DistributableContext.class); this.timers = null; this.id = null; this.name = null; }
Example #2
Source File: BootstrapContextImpl.java From ironjacamar with Eclipse Public License 1.0 | 6 votes |
/** * Constructor * @param wm The WorkManager * @param tsr The TransactionSynchronizationRegistry * @param terminator The XATerminator * @param validatorFactory the ValidatorFactory */ public BootstrapContextImpl(WorkManager wm, TransactionSynchronizationRegistry tsr, XATerminator terminator, ValidatorFactory validatorFactory) { this.workManager = wm; this.transactionSynchronizationRegistry = tsr; this.xaTerminator = terminator; this.supportedContexts = new HashSet<Class>(3); this.validatorFactory = validatorFactory; this.supportedContexts.add(HintsContext.class); this.supportedContexts.add(SecurityContext.class); this.supportedContexts.add(TransactionContext.class); this.timers = null; }
Example #3
Source File: NestedWorkAndContextsTestCase.java From ironjacamar with Eclipse Public License 1.0 | 6 votes |
/** * Test for paragraph 4 * startWork method: this provides a FIFO execution start ordering guarantee, * but no execution completion ordering guarantee. * @throws Throwable throwable exception */ //@Test public void testFifoStart() throws Throwable { ContextWorkAdapter wa = new ContextWorkAdapter(); NestProviderWork workA = new NestProviderWork("A", wa); workA.addContext(new NestedWorkSecurityContext()); NestProviderWork workB = new NestProviderWork("B", null); workB.addContext(new HintsContext()); WorkConnection wc = wcf.getConnection(); workA.setNestDo(false); workA.setWorkManager(wc.getWorkManager()); workA.setWork(workB); CyclicBarrier barrier = new CyclicBarrier(3); workA.setBarrier(barrier); workB.setBarrier(barrier); wc.startWork(workA, WorkManager.INDEFINITE, null, wa); barrier.await(); assertEquals(wa.getStart(), "AB"); wc.close(); }
Example #4
Source File: NestedWorkAndContextsTestCase.java From ironjacamar with Eclipse Public License 1.0 | 6 votes |
/** * Test for paragraph 4 * scheduletWork method: this provides a FIFO execution start ordering guarantee, * but no execution completion ordering guarantee. * @throws Throwable throwable exception */ //@Test public void testFifoSchedule() throws Throwable { ContextWorkAdapter wa = new ContextWorkAdapter(); NestProviderWork workA = new NestProviderWork("A", wa); workA.addContext(new NestedWorkSecurityContext()); NestProviderWork workB = new NestProviderWork("B", null); workB.addContext(new HintsContext()); WorkConnection wc = wcf.getConnection(); workA.setNestDo(false); workA.setWorkManager(wc.getWorkManager()); workA.setWork(workB); CyclicBarrier barrier = new CyclicBarrier(3); workA.setBarrier(barrier); workB.setBarrier(barrier); wc.scheduleWork(workA, WorkManager.INDEFINITE, null, wa); barrier.await(); assertEquals(wa.getStart(), "AB"); wc.close(); }
Example #5
Source File: NestedWorkAndContextsTestCase.java From ironjacamar with Eclipse Public License 1.0 | 6 votes |
/** * Test unsupported context nested startWork * @throws Throwable throwable exception */ //@Test public void testStartWorkUnsupportedContext() throws Throwable { ContextWorkAdapter wa = new ContextWorkAdapter(); NestProviderWork workA = new NestProviderWork("A", wa); workA.addContext(new HintsContext()); NestProviderWork workB = new NestProviderWork("B", null); workB.addContext(new UnsupportedContext()); WorkConnection wc = wcf.getConnection(); workA.setNestDo(false); workA.setWorkManager(wc.getWorkManager()); workA.setWork(workB); CyclicBarrier barrier = new CyclicBarrier(2); workA.setBarrier(barrier); workB.setBarrier(barrier); wc.startWork(workA, WorkManager.INDEFINITE, null, wa); barrier.await(); assertNotNull(wa.getException()); wc.close(); }
Example #6
Source File: NestedWorkAndContextsTestCase.java From ironjacamar with Eclipse Public License 1.0 | 6 votes |
/** * Test unsupported context nested scheduleWork * @throws Throwable throwable exception */ //@Test public void testScheduleWorkUnsupportedContext() throws Throwable { ContextWorkAdapter wa = new ContextWorkAdapter(); NestProviderWork workA = new NestProviderWork("A", wa); workA.addContext(new HintsContext()); NestProviderWork workB = new NestProviderWork("B", null); workB.addContext(new UnsupportedContext()); WorkConnection wc = wcf.getConnection(); workA.setNestDo(false); workA.setWorkManager(wc.getWorkManager()); workA.setWork(workB); CyclicBarrier barrier = new CyclicBarrier(2); workA.setBarrier(barrier); workB.setBarrier(barrier); wc.getWorkManager().scheduleWork(workA, WorkManager.INDEFINITE, null, wa); barrier.await(); assertNotNull(wa.getException()); wc.close(); }
Example #7
Source File: WorkManagerUtil.java From ironjacamar with Eclipse Public License 1.0 | 5 votes |
/** * Get explicit work manager override * @param work The work instance * @return The override, if none return null */ public static String getWorkManager(DistributableWork work) { if (work != null && work instanceof WorkContextProvider) { List<WorkContext> contexts = ((WorkContextProvider)work).getWorkContexts(); if (contexts != null) { for (WorkContext wc : contexts) { if (wc instanceof DistributableContext) { DistributableContext dc = (DistributableContext)wc; return dc.getWorkManager(); } else if (wc instanceof HintsContext) { HintsContext hc = (HintsContext)wc; if (hc.getHints().keySet().contains(DistributableContext.WORKMANAGER)) { Serializable value = hc.getHints().get(DistributableContext.WORKMANAGER); if (value != null && value instanceof String) { return (String)value; } } } } } } return null; }
Example #8
Source File: WorkManagerUtil.java From ironjacamar with Eclipse Public License 1.0 | 5 votes |
/** * Get should distribute override * @param work The work instance * @return The override, if none return null */ public static Boolean getShouldDistribute(DistributableWork work) { if (work != null && work instanceof WorkContextProvider) { List<WorkContext> contexts = ((WorkContextProvider)work).getWorkContexts(); if (contexts != null) { for (WorkContext wc : contexts) { if (wc instanceof DistributableContext) { DistributableContext dc = (DistributableContext)wc; return dc.getDistribute(); } else if (wc instanceof HintsContext) { HintsContext hc = (HintsContext)wc; if (hc.getHints().keySet().contains(DistributableContext.DISTRIBUTE)) { Serializable value = hc.getHints().get(DistributableContext.DISTRIBUTE); if (value != null && value instanceof Boolean) { return (Boolean)value; } } } } } } return null; }
Example #9
Source File: WorkManagerImpl.java From ironjacamar with Eclipse Public License 1.0 | 5 votes |
/** * Returns true if contexts is a hint context. * * @param workContextType context type * @return true if contexts is a hint context */ private boolean isHintContext(Class<? extends WorkContext> workContextType) { if (workContextType.isAssignableFrom(HintsContext.class)) { return true; } return false; }
Example #10
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 #11
Source File: AbstractPolicy.java From ironjacamar with Eclipse Public License 1.0 | 5 votes |
/** * Get should distribute override * @param work The work instance * @return The override, if none return null */ protected Boolean getShouldDistribute(DistributableWork work) { if (work != null && work instanceof WorkContextProvider) { List<WorkContext> contexts = ((WorkContextProvider)work).getWorkContexts(); if (contexts != null) { for (WorkContext wc : contexts) { if (wc instanceof DistributableContext) { DistributableContext dc = (DistributableContext)wc; return dc.getDistribute(); } else if (wc instanceof HintsContext) { HintsContext hc = (HintsContext)wc; if (hc.getHints().keySet().contains(DistributableContext.DISTRIBUTE)) { Serializable value = hc.getHints().get(DistributableContext.DISTRIBUTE); if (value != null && value instanceof Boolean) { return (Boolean)value; } } } } } } return null; }
Example #12
Source File: WorkManagerUtil.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Get explicit work manager override * @param work The work instance * @return The override, if none return null */ public static String getWorkManager(DistributableWork work) { if (work != null && work instanceof WorkContextProvider) { List<WorkContext> contexts = ((WorkContextProvider)work).getWorkContexts(); if (contexts != null) { for (WorkContext wc : contexts) { if (wc instanceof DistributableContext) { DistributableContext dc = (DistributableContext)wc; return dc.getWorkManager(); } else if (wc instanceof HintsContext) { HintsContext hc = (HintsContext)wc; if (hc.getHints().keySet().contains(DistributableContext.WORKMANAGER)) { Serializable value = hc.getHints().get(DistributableContext.WORKMANAGER); if (value != null && value instanceof String) { return (String)value; } } } } } } return null; }
Example #13
Source File: WorkManagerUtil.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Get should distribute override * @param work The work instance * @return The override, if none return null */ public static Boolean getShouldDistribute(DistributableWork work) { if (work != null && work instanceof WorkContextProvider) { List<WorkContext> contexts = ((WorkContextProvider)work).getWorkContexts(); if (contexts != null) { for (WorkContext wc : contexts) { if (wc instanceof DistributableContext) { DistributableContext dc = (DistributableContext)wc; return dc.getDistribute(); } else if (wc instanceof HintsContext) { HintsContext hc = (HintsContext)wc; if (hc.getHints().keySet().contains(DistributableContext.DISTRIBUTE)) { Serializable value = hc.getHints().get(DistributableContext.DISTRIBUTE); if (value != null && value instanceof Boolean) { return (Boolean)value; } } } } } } return null; }
Example #14
Source File: WorkManagerImpl.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Returns true if contexts is a hint context. * * @param workContextType context type * @return true if contexts is a hint context */ private boolean isHintContext(Class<? extends WorkContext> workContextType) { if (workContextType.isAssignableFrom(HintsContext.class)) { return true; } return false; }
Example #15
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 #16
Source File: AbstractPolicy.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Get should distribute override * @param work The work instance * @return The override, if none return null */ protected Boolean getShouldDistribute(DistributableWork work) { if (work != null && work instanceof WorkContextProvider) { List<WorkContext> contexts = ((WorkContextProvider)work).getWorkContexts(); if (contexts != null) { for (WorkContext wc : contexts) { if (wc instanceof DistributableContext) { DistributableContext dc = (DistributableContext)wc; return dc.getDistribute(); } else if (wc instanceof HintsContext) { HintsContext hc = (HintsContext)wc; if (hc.getHints().keySet().contains(DistributableContext.DISTRIBUTE)) { Serializable value = hc.getHints().get(DistributableContext.DISTRIBUTE); if (value != null && value instanceof Boolean) { return (Boolean)value; } } } } } } return null; }
Example #17
Source File: WorkManagerUtil.java From lams with GNU General Public License v2.0 | 4 votes |
/** * * Utility method to decide if a work will have to run under long running thread pool * * @param work the work * @return true if long running thread pool is required */ public static boolean isLongRunning(Work work) { if (work != null && work instanceof WorkContextProvider) { WorkContextProvider wcProvider = (WorkContextProvider) work; List<WorkContext> contexts = wcProvider.getWorkContexts(); if (contexts != null && contexts.size() > 0) { boolean found = false; Iterator<WorkContext> it = contexts.iterator(); while (!found && it.hasNext()) { WorkContext wc = it.next(); if (wc instanceof HintsContext) { HintsContext hc = (HintsContext) wc; if (hc.getHints().containsKey(HintsContext.LONGRUNNING_HINT)) { Serializable value = hc.getHints().get(HintsContext.LONGRUNNING_HINT); if (value != null) { if (value instanceof String) { return Boolean.valueOf((String)value); } else if (value instanceof Boolean) { return ((Boolean)value).booleanValue(); } } else { // Assume true return true; } } } } } } return false; }
Example #18
Source File: WorkManagerUtil.java From ironjacamar with Eclipse Public License 1.0 | 4 votes |
/** * * Utility method to decide if a work will have to run under long running thread pool * * @param work the work * @return true if long running thread pool is required */ public static boolean isLongRunning(Work work) { if (work != null && work instanceof WorkContextProvider) { WorkContextProvider wcProvider = (WorkContextProvider) work; List<WorkContext> contexts = wcProvider.getWorkContexts(); if (contexts != null && !contexts.isEmpty()) { boolean found = false; Iterator<WorkContext> it = contexts.iterator(); while (!found && it.hasNext()) { WorkContext wc = it.next(); if (wc instanceof HintsContext) { HintsContext hc = (HintsContext) wc; if (hc.getHints().containsKey(HintsContext.LONGRUNNING_HINT)) { Serializable value = hc.getHints().get(HintsContext.LONGRUNNING_HINT); if (value != null) { if (value instanceof String) { return Boolean.valueOf((String)value); } else if (value instanceof Boolean) { return ((Boolean)value).booleanValue(); } } else { // Assume true return true; } } } } } } return false; }