public Object construct(WireContext wireContext) { return Environment.getCurrent(); } }
public EnvironmentBindings(String[] readContextNames, String writeContextName) { this.readContextNames = readContextNames; this.writeContextName = writeContextName; environment = Environment.getCurrent(); }
protected T resolveValueExpression() { Environment environment = Environment.getCurrent(); return null; }
public static ScriptManager getScriptManager() { Environment environment = Environment.getCurrent(); if (environment != null) { ScriptManager scriptManager = environment.get(ScriptManager.class); if (scriptManager != null) { return scriptManager; } } return defaultScriptManager; }
protected BlobStrategy getBlobStrategy() { BlobStrategy blobStrategy = null; Environment environment = Environment.getCurrent(); if (environment != null) { blobStrategy = environment.get(BlobStrategy.class); } if (blobStrategy == null) { blobStrategy = DEFAULT_BLOB_STRATEGY; } return blobStrategy; }
protected ClobStrategy getClobStrategy() { ClobStrategy clobStrategy = null; Environment environment = Environment.getCurrent(); if (environment != null) { clobStrategy = environment.get(ClobStrategy.class); } if (clobStrategy == null) { clobStrategy = DEFAULT_CLOB_STRATEGY; } return clobStrategy; }
protected static Environment getEnv() { final Environment environment = Environment.getCurrent(); Misc.badStateIfNull(environment, "Environment is null!"); return environment; } @SuppressWarnings("unchecked")
public Object construct(WireContext wireContext) { return Environment.getCurrent().get(Transaction.class); }
public Object construct(WireContext wireContext) { if (contextName == null) { return wireContext; } Environment environment = Environment.getCurrent(); if (environment == null) { throw new WireException("can't get context '" + contextName + "': no current environment"); } return environment.getContext(contextName); }
public CommentImpl(String message) { this.message = message; this.time = Clock.getCurrentTime(); Environment environment = Environment.getCurrent(); if (environment != null) { this.userId = environment.getUserId(); } }
public Object construct(WireContext wireContext) { log.trace("looking up " + type + " by type in environment"); if (type != null) { Environment environment = Environment.getCurrent(); if (environment == null) { throw new WireException("no environment to search an object of type " + type.getName()); } return environment.get(type); } return null; } }
public void deploy(Deployment deployment) { Environment environment = Environment.getCurrent(); if (environment == null) { throw new PvmException("environment is required by " + getClass().getName()); } PvmDbSession pvmDbSession = environment.get(PvmDbSession.class); if (pvmDbSession == null) { throw new PvmException(PvmDbSession.class.getName() + " is required in the environment by " + getClass().getName()); } ProcessDefinition processDefinition = deployment.getProcessDefinition(); if (processDefinition == null) { throw new PvmException( "a process definition in the deployment is required by " + getClass().getName()); } pvmDbSession.save(processDefinition); }
protected void destroyTimers(final CompositeElementImpl scope) { log.debug("destroying timers of " + toString()); if (this.jobs != null && !this.jobs.isEmpty()) { // get the TimerSession from the environment final Environment environment = Environment.getCurrent(); if (environment == null) { throw new PvmException("non environment for initializing timers"); } final TimerSession timerSession = environment.get(TimerSession.class); if (timerSession == null) { throw new PvmException( "no TimerSession in environment for initializing timers"); } final Set<Job> jobsSnapshot = new HashSet<Job>(this.jobs); for (final Job job : jobsSnapshot) { if (job instanceof Timer) { timerSession.cancel((Timer) job); this.jobs.remove(job); } } } }
public static Object getFromCurrent(String name, boolean required) { Environment environment = getCurrent(); if (environment == null) { if (required) { throw new PvmException("no environment to get '" + name + "'"); } return null; } Object object = environment.get(name); if (object == null) { if (required) { throw new PvmException("no '" + name + "' in current environment"); } return null; } return object; }
public <T> T execute(Command<T> command) { Environment environment = Environment.getCurrent(); try { return command.execute(environment); } catch (RuntimeException e) { log.error("exception while executing command " + command, e); throw e; } catch (Exception e) { log.error("exception while executing command " + command, e); throw new PvmException("exception while executing command " + command, e); } } }
public void sendContinuationMessage(final AtomicOperation operation) { final Environment environment = Environment.getCurrent(); final MessageSession messageSession = environment.get(MessageSession.class); if (messageSession == null) { throw new PvmException( "no message-session configured to send asynchronous continuation message"); } final MessageImpl<?> asyncMessage = operation.createAsyncMessage(this); lock("async continuation message " + asyncMessage); messageSession.send(asyncMessage); }
public void addLog(final ProcessLog processLog) { final Environment environment = Environment.getCurrent(); if (environment != null) { final LogSession logSession = environment.get(LogSession.class); if (logSession != null) { processLog.setExecution(this); processLog.setTime(Clock.getCurrentTime()); logSession.add(processLog); } } }
public <T> T execute(Command<T> command) { Environment environment = Environment.getCurrent(); if (environment == null) { throw new PvmException("no environment for verifying authorization"); } AuthorizationSession authorizationSession = environment .get(AuthorizationSession.class); if (authorizationSession == null) { throw new PvmException( "no AuthorizationSession in environment for verifying authorization"); } authorizationSession.checkPermission(command, environment); // if the authorization check succeeded, proceed return next.execute(command); }
public <T> T execute(Command<T> command) { Environment environment = Environment.getCurrent(); if (environment == null) { throw new PvmException("no environment for verifying authorization"); } MessageSession messageSession = environment.get(MessageSession.class); if (messageSession == null) { throw new PvmException( "no message session for executing command asynchronously"); } String userId = (propagateUserId ? environment.getUserId() : null); messageSession.send(new AsyncCommandMessage(command, userId)); return null; }
public void schedule(Timer timer) { log.debug("scheduling " + timer); // flush timer to database DbSession dbSession = Environment.getCurrent().get(DbSession.class); dbSession.save(timer); dbSession.flush(); // retrieve timer as entity bean, contact timer service try { LocalTimer timerBean = timerHome.findByPrimaryKey(timer.getDbid()); timerBean.schedule(); } catch (FinderException e) { throw new PvmException("could not find bean for timer: " + timer); } }