public Object construct(WireContext wireContext) { return Environment.getCurrent(); } }
protected static Environment getEnv() { final Environment environment = Environment.getCurrent(); Misc.badStateIfNull(environment, "Environment is null!"); return environment; }
@Override public Object construct(final WireContext wireContext) { if (LOG.isLoggable(Level.FINE)) { LOG.fine("looking up " + type + " by type in environment"); } if (type != null) { final 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; }
static ClassLoader resolveClassLoader(ClassLoader classLoader) { // 1) if the user provided a classloader through the API, use that one if (classLoader != null) { if (LOG.isLoggable(Level.FINE)) { LOG.fine("using provided classloader"); } return classLoader; } // 2) if the user provided a classloader through the environment, use that // one Environment environment = Environment.getCurrent(); if (environment != null) { classLoader = environment.getClassLoader(); if (classLoader != null) { if (LOG.isLoggable(Level.FINE)) { LOG.fine("using environment classloader"); } return classLoader; } } // 3) otherwise, use the current thread's context classloader if (LOG.isLoggable(Level.FINE)) { LOG.fine("using context classloader"); } return Thread.currentThread().getContextClassLoader(); }
static ClassLoader resolveClassLoader(ClassLoader classLoader) { // 1) if the user provided a classloader through the API, use that one if (classLoader != null) { if (LOG.isLoggable(Level.FINE)) { LOG.fine("using provided classloader"); } return classLoader; } // 2) if the user provided a classloader through the environment, use that // one Environment environment = Environment.getCurrent(); if (environment != null) { classLoader = environment.getClassLoader(); if (classLoader != null) { if (LOG.isLoggable(Level.FINE)) { LOG.fine("using environment classloader"); } return classLoader; } } // 3) otherwise, use the current thread's context classloader if (LOG.isLoggable(Level.FINE)) { LOG.fine("using context classloader"); } return Thread.currentThread().getContextClassLoader(); }
public <T> T execute(Command<T> command) { Environment environment = Environment.getCurrent(); try { return command.execute(environment); } catch (RuntimeException e) { if (LOG.isLoggable(Level.SEVERE)) { LOG.severe("exception while executing command " + command + ": " + e.getMessage()); } throw e; } catch (Exception e) { if (LOG.isLoggable(Level.SEVERE)) { LOG.severe("exception while executing command " + command + ": " + e.getMessage()); } String message = ExceptionManager.getInstance().getFullMessage("bp_DCS_1 ", command); throw new BonitaRuntimeException(message, e, DefaultCommandService.class.getName()); } } }
return command.execute(Environment.getCurrent()); } finally { Thread.currentThread().setContextClassLoader(contextClassLoader);
autoWireValue = Environment.getCurrent(); Environment currentEnvironment = Environment.getCurrent(); if (currentEnvironment != null) { autoWireValue = currentEnvironment.get(fieldName);
public boolean matches(String name, Object value) { boolean matches = false; Environment environment = Environment.getCurrent(); if (environment != null) { SessionFactory sessionFactory = null; if (hibernateSessionFactoryName != null) { sessionFactory = (SessionFactory) environment .get(hibernateSessionFactoryName); } else { sessionFactory = environment.get(SessionFactory.class); } if (sessionFactory != null) { ClassMetadata classMetadata = sessionFactory.getClassMetadata(value .getClass()); matches = ((classMetadata != null) && (classMetadata .getIdentifierType().getClass() == getIdType())); } } else { if (LOG.isLoggable(Level.FINE)) { LOG.fine("no current environment so valueClass cannot be stored as an id-ref to a hibernate object"); } matches = false; } return matches; }
public Object construct(WireContext wireContext) { if (contextName == null) { return wireContext; } Environment environment = Environment.getCurrent(); if (environment == null) { String message = ExceptionManager.getInstance().getFullMessage("bp_CRD_1", contextName); throw new WireException(message); } return environment.getContext(contextName); }
@Override public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable { if (Environment.getCurrent() != null) { return new RESTServerAPIInterceptorCommand(method, args, api) .execute(Environment.getCurrent()); } // If no environment: use directly the command Service with interceptors final EnvironmentFactory envFactory = GlobalEnvironmentFactory .getEnvironmentFactory(DomainOwner.getDomain()); try { return envFactory.get(CommandService.class).execute( new RESTServerAPIInterceptorCommand(method, args, api)); } catch (final BonitaWrapperException e) { throw e.getCause(); } catch (final BonitaRuntimeException e) { if (DefaultCommandService.class.getName().equals(e.getWrappedBy()) || UnRollbackableException.class.getName().equals(e.getWrappedBy())) { throw e.getCause(); } else { throw e; } } }
public Object construct(WireContext wireContext) { Environment environment = Environment.getCurrent(); if (environment == null) { throw new WireException("no environment");
public static <T> T getFromCurrent(Class<T> type, boolean required) { Environment environment = getCurrent(); if (environment == null) { if (required) { String message = ExceptionManager.getInstance().getFullMessage( "bp_E_1", type.getName()); throw new BonitaRuntimeException(message); } return null; } T object = environment.get(type); if (object == null) { if (required) { String message = ExceptionManager.getInstance().getFullMessage("bp_E_2", type.getName()); throw new BonitaRuntimeException(message); } return null; } return object; }
public static <T> T getFromCurrent(Class<T> type, boolean required) { Environment environment = getCurrent(); if (environment == null) { if (required) { String message = ExceptionManager.getInstance().getFullMessage( "bp_E_1", type.getName()); throw new BonitaRuntimeException(message); } return null; } T object = environment.get(type); if (object == null) { if (required) { String message = ExceptionManager.getInstance().getFullMessage("bp_E_2", type.getName()); throw new BonitaRuntimeException(message); } return null; } return object; }
final Environment environment = Environment.getCurrent(); if (environment != null) { if (LOG.isLoggable(Level.FINE)) {
public static Object getFromCurrent(String name, boolean required) { Environment environment = getCurrent(); if (environment == null) { if (required) { String message = ExceptionManager.getInstance().getFullMessage("bp_E_3", name); throw new BonitaRuntimeException(message); } return null; } Object object = environment.get(name); if (object == null) { if (required) { String message = ExceptionManager.getInstance().getFullMessage("bp_E_4", name); throw new BonitaRuntimeException(message); } return null; } return object; }
public static Object getFromCurrent(String name, boolean required) { Environment environment = getCurrent(); if (environment == null) { if (required) { String message = ExceptionManager.getInstance().getFullMessage("bp_E_3", name); throw new BonitaRuntimeException(message); } return null; } Object object = environment.get(name); if (object == null) { if (required) { String message = ExceptionManager.getInstance().getFullMessage("bp_E_4", name); throw new BonitaRuntimeException(message); } return null; } return object; }
if (Environment.getCurrent() != null) { return new APIInterceptorCommand(method, args, true).execute(Environment.getCurrent());
Environment environment = Environment.getCurrent(); if (environment != null) { try {