javax.resource.spi.work.WorkContext Java Examples
The following examples show how to use
javax.resource.spi.work.WorkContext.
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: WorkWrapper.java From ironjacamar with Eclipse Public License 1.0 | 6 votes |
/** * Adds new work context. * * @param workContext new work context * @param workContextClass work context class */ public void addWorkContext(Class<? extends WorkContext> workContextClass, WorkContext workContext) { if (workContextClass == null) { throw new IllegalArgumentException("Work context class is null"); } if (workContext == null) { throw new IllegalArgumentException("Work context is null"); } if (workContexts == null) { workContexts = new HashMap<Class<? extends WorkContext>, WorkContext>(1); } if (trace) log.tracef("Adding work context %s for %s", workContextClass, this); workContexts.put(workContextClass, workContext); }
Example #2
Source File: WorkManagerImpl.java From ironjacamar with Eclipse Public License 1.0 | 6 votes |
/** * Returns work context class if given work context is supported by server, * returns null instance otherwise. * * @param <T> work context class * @param adaptorWorkContext adaptor supplied work context class * @return work context class */ @SuppressWarnings("unchecked") private <T extends WorkContext> Class<T> getSupportedWorkContextClass(Class<T> adaptorWorkContext) { for (Class<? extends WorkContext> supportedWorkContext : SUPPORTED_WORK_CONTEXT_CLASSES) { // Assignable or not if (supportedWorkContext.isAssignableFrom(adaptorWorkContext)) { Class clz = adaptorWorkContext; while (clz != null) { // Supported by the server if (clz.equals(supportedWorkContext)) { return clz; } clz = clz.getSuperclass(); } } } return null; }
Example #3
Source File: WorkManagerImpl.java From lams with GNU General Public License v2.0 | 6 votes |
/** * Returns work context class if given work context is supported by server, * returns null instance otherwise. * * @param <T> work context class * @param adaptorWorkContext adaptor supplied work context class * @return work context class */ @SuppressWarnings("unchecked") private <T extends WorkContext> Class<T> getSupportedWorkContextClass(Class<T> adaptorWorkContext) { for (Class<? extends WorkContext> supportedWorkContext : SUPPORTED_WORK_CONTEXT_CLASSES) { // Assignable or not if (supportedWorkContext.isAssignableFrom(adaptorWorkContext)) { Class clz = adaptorWorkContext; while (clz != null) { // Supported by the server if (clz.equals(supportedWorkContext)) { return clz; } clz = clz.getSuperclass(); } } } return null; }
Example #4
Source File: WorkWrapper.java From lams with GNU General Public License v2.0 | 6 votes |
/** * Adds new work context. * * @param workContext new work context * @param workContextClass work context class */ public void addWorkContext(Class<? extends WorkContext> workContextClass, WorkContext workContext) { if (workContextClass == null) { throw new IllegalArgumentException("Work context class is null"); } if (workContext == null) { throw new IllegalArgumentException("Work context is null"); } if (workContexts == null) { workContexts = new HashMap<Class<? extends WorkContext>, WorkContext>(1); } log.tracef("Adding work context %s for %s", workContextClass, this); workContexts.put(workContextClass, workContext); }
Example #5
Source File: UniversalProviderWork.java From ironjacamar with Eclipse Public License 1.0 | 5 votes |
/** * Adds work context to the list * @param wc - added work context */ public void addContext(WorkContext wc) { if (ctxs == null) ctxs = new ArrayList<WorkContext>(); if (wc != null) ctxs.add(wc); }
Example #6
Source File: SimpleBootstrapContext.java From tomee with Apache License 2.0 | 5 votes |
public boolean isContextSupported(final Class<? extends WorkContext> cls) { if (workManager instanceof GeronimoWorkManager) { final GeronimoWorkManager geronimoWorkManager = (GeronimoWorkManager) workManager; return geronimoWorkManager.isContextSupported(cls); } return false; }
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 |
/** * Returns true if contexts is a security context. * * @param workContextType context type * @return true if contexts is a security context */ private boolean isSecurityContext(Class<? extends WorkContext> workContextType) { if (workContextType.isAssignableFrom(SecurityContext.class)) { return true; } return false; }
Example #11
Source File: WorkManagerImpl.java From ironjacamar with Eclipse Public License 1.0 | 5 votes |
/** * Returns true if contexts is a transaction context. * * @param workContextType context type * @return true if contexts is a transaction context */ private boolean isTransactionContext(Class<? extends WorkContext> workContextType) { if (workContextType.isAssignableFrom(TransactionContext.class)) { return true; } return false; }
Example #12
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 #13
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 #14
Source File: BootstrapContextImpl.java From ironjacamar with Eclipse Public License 1.0 | 5 votes |
/** * Is the work context supported ? * @param workContextClass The work context class * @return True if supported; otherwise false */ public boolean isContextSupported(Class<? extends WorkContext> workContextClass) { if (workContextClass == null) return false; return supportedContexts.contains(workContextClass); }
Example #15
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 #16
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 #17
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 #18
Source File: WorkManagerImpl.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Returns true if contexts is a security context. * * @param workContextType context type * @return true if contexts is a security context */ private boolean isSecurityContext(Class<? extends WorkContext> workContextType) { if (workContextType.isAssignableFrom(SecurityContext.class)) { return true; } return false; }
Example #19
Source File: WorkManagerImpl.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Returns true if contexts is a transaction context. * * @param workContextType context type * @return true if contexts is a transaction context */ private boolean isTransactionContext(Class<? extends WorkContext> workContextType) { if (workContextType.isAssignableFrom(TransactionContext.class)) { return true; } return false; }
Example #20
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 #21
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 #22
Source File: BaseCloneableBootstrapContext.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Is the work context supported ? * @param workContextClass The work context class * @return True if supported; otherwise false */ public boolean isContextSupported(Class<? extends WorkContext> workContextClass) { if (workContextClass == null) return false; return supportedContexts.contains(workContextClass); }
Example #23
Source File: SimpleBootstrapContext.java From spring-analysis-note with MIT License | 4 votes |
@Override public boolean isContextSupported(Class<? extends WorkContext> workContextClass) { return false; }
Example #24
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 #25
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; }
Example #26
Source File: SecurityContextHandler.java From tomee with Apache License 2.0 | 4 votes |
@Override public boolean supports(final Class<? extends WorkContext> clazz) { return SecurityContext.class.isAssignableFrom(clazz); }
Example #27
Source File: SimpleBootstrapContext.java From java-technology-stack with MIT License | 4 votes |
@Override public boolean isContextSupported(Class<? extends WorkContext> workContextClass) { return false; }
Example #28
Source File: BootstrapContext.java From ironjacamar with Eclipse Public License 1.0 | 2 votes |
/** * A resource adapter can check an application server’s support * for a particular WorkContext type through this method. * This mechanism enables a resource adapter developer to * dynamically change the WorkContexts submitted with a Work instance * based on the support provided by the application server. * * The application server must employ an exact type equality check (that is * <code>java.lang.Class.equals(java.lang.Class)</code> check) in * this method, to check if it supports the WorkContext type provided * by the resource adapter. This method must be idempotent, that is all * calls to this method by a resource adapter for a particular * <code>WorkContext</code> type must return the same boolean value * throughout the lifecycle of that resource adapter instance. * * @param workContextClass The work context class * @return true if the <code>workContextClass</code> is supported * by the application server. false if the <code>workContextClass</code> * is unsupported or unknown to the application server. * * @since 1.6 */ boolean isContextSupported(Class<? extends WorkContext> workContextClass);
Example #29
Source File: UniversalProviderWork.java From ironjacamar with Eclipse Public License 1.0 | 2 votes |
/** * Gets an instance of <code>WorkContexts</code> that needs to be used * by the <code>WorkManager</code> to set up the execution context while * executing a <code>Work</code> instance. * * @return an <code>List</code> of <code>WorkContext</code> instances. */ public List<WorkContext> getWorkContexts() { return ctxs; }