/** * Assigns the given Option to the cache's {@link InvocationContext}. Does * nothing if <code>option</code> is <code>null</code>. * * @param cache * the cache. Cannot be <code>null</code>. * @param option * the option. May be <code>null</code>. * * @see {@link Cache#getInvocationContext()} * @see {@link InvocationContext#setOptionOverrides(Option)} */ public static void setInvocationOption(Cache cache, Option option) { if (option != null) { cache.getInvocationContext().setOptionOverrides(option); } }
/** * Assigns the given Option to the cache's {@link InvocationContext}. Does * nothing if <code>option</code> is <code>null</code>. * * @param cache * the cache. Cannot be <code>null</code>. * @param option * the option. May be <code>null</code>. * * @see {@link Cache#getInvocationContext()} * @see {@link InvocationContext#setOptionOverrides(Option)} */ public static void setInvocationOption(Cache cache, Option option) { if (option != null) { cache.getInvocationContext().setOptionOverrides(option); } }
private void restoreInvocationContext(InvocationContext backup) { InvocationContext currentIC = cache.getInvocationContext(); backup.putLookedUpNodes(currentIC.getLookedUpNodes()); cache.setInvocationContext(backup); }
/** * Resets the current (passed-in) invocation, and returns a temp InvocationContext containing its state so it can * be restored later using {@link #restoreInvocationContext(org.jboss.cache.InvocationContext)} * * @param ctx the current context to be reset * @return a clone of ctx, before it was reset */ private InvocationContext resetInvocationContext(InvocationContext ctx) { // wipe current context. cache.setInvocationContext(null); // get a new Invocation Context InvocationContext newContext = cache.getInvocationContext(); newContext.putLookedUpNodes(ctx.getLookedUpNodes()); return ctx; }
public void put(Object key, Object value, Date expired) { Map<String, Object> map = new HashMap<String, Object>(3); map.put(RESOURCE, value); if (expired != null) { map.put(ExpirationAlgorithmConfig.EXPIRATION_KEY, expired.getTime()); } cache.put(createFqn(key), map); Transaction transaction = cache.getInvocationContext().getTransaction(); try { // TODO: to review if ((transaction != null) && (transaction.getStatus() == Status.STATUS_ACTIVE)) { transaction.commit(); } } catch (SystemException e) { LOGGER.error(e.getMessage(), e); } catch (SecurityException e) { LOGGER.error(e.getMessage(), e); } catch (IllegalStateException e) { LOGGER.error(e.getMessage(), e); } catch (RollbackException e) { LOGGER.error(e.getMessage(), e); } catch (HeuristicMixedException e) { LOGGER.error(e.getMessage(), e); } catch (HeuristicRollbackException e) { LOGGER.error(e.getMessage(), e); } }
public void destroy() throws CacheException { try { // NOTE : this is being used from the process of shutting down a // SessionFactory. Specific things to consider: // (1) this clearing of the region should not propagate to // other nodes on the cluster (if any); this is the // cache-mode-local option bit... // (2) really just trying a best effort to cleanup after // ourselves; lock failures, etc are not critical here; // this is the fail-silently option bit... Option option = new Option(); option.setCacheModeLocal(true); option.setFailSilently(true); if (optimistic) { option.setDataVersion(NonLockingDataVersion.INSTANCE); } jbcCache.getInvocationContext().setOptionOverrides(option); jbcCache.removeNode(regionFqn); deactivateLocalNode(); } catch (Exception e) { throw new CacheException(e); } // finally { // if (listener != null) // jbcCache.removeCacheListener(listener); // } }
public void destroy() throws CacheException { try { // NOTE : this is being used from the process of shutting down a // SessionFactory. Specific things to consider: // (1) this clearing of the region should not propagate to // other nodes on the cluster (if any); this is the // cache-mode-local option bit... // (2) really just trying a best effort to cleanup after // ourselves; lock failures, etc are not critical here; // this is the fail-silently option bit... Option option = new Option(); option.setCacheModeLocal(true); option.setFailSilently(true); if (optimistic) { option.setDataVersion(NonLockingDataVersion.INSTANCE); } jbcCache.getInvocationContext().setOptionOverrides(option); jbcCache.removeNode(regionFqn); deactivateLocalNode(); } catch (Exception e) { throw new CacheException(e); } finally { jbcCache.removeCacheListener(this); } }