public static void setThreadProperties(final Properties p) { ActiveMQFactory.init(); try { setThreadProperties.invoke(instance, p); } catch (final IllegalAccessException e) { throw new OpenEJBRuntimeException("ActiveMQFactory.setThreadProperties.IllegalAccessException", e); } catch (final IllegalArgumentException e) { throw new OpenEJBRuntimeException("ActiveMQFactory.setThreadProperties.IllegalArgumentException", e); } catch (final InvocationTargetException e) { throw new OpenEJBRuntimeException("ActiveMQFactory.setThreadProperties.InvocationTargetException", e); } }
public static void setThreadProperties(final Properties p) { ActiveMQFactory.init(); try { setThreadProperties.invoke(instance, p); } catch (final IllegalAccessException e) { throw new OpenEJBRuntimeException("ActiveMQFactory.setThreadProperties.IllegalAccessException", e); } catch (final IllegalArgumentException e) { throw new OpenEJBRuntimeException("ActiveMQFactory.setThreadProperties.IllegalArgumentException", e); } catch (final InvocationTargetException e) { throw new OpenEJBRuntimeException("ActiveMQFactory.setThreadProperties.InvocationTargetException", e); } }
public ImportSql(final ClassLoader cl, final String resource, final DataSource ds) { dataSource = ds; done = false; if (dataSource == null) { throw new NullPointerException("datasource can't be null"); } try { imports = cl.getResources(IMPORT_FILE_PREFIX.concat(resource).concat(IMPORT_FILE_EXTENSION)); } catch (final IOException e) { throw new OpenEJBRuntimeException("can't look for init sql script", e); } }
private T rethrow(final Throwable t) throws Exception { if (Exception.class.isInstance(t)) { throw Exception.class.cast(t); } else if (Error.class.isInstance(t)) { throw Error.class.cast(t); } throw new OpenEJBRuntimeException(t.getMessage(), t); }
private Convert(final Class primitiveClass, final Class objectClass, final String toPrimitiveMethodName) { objectType = Type.getType(objectClass); try { toObject = objectClass.getMethod("valueOf", primitiveClass); toPrimitive = objectClass.getMethod(toPrimitiveMethodName); } catch (final NoSuchMethodException e) { throw new OpenEJBRuntimeException(e); } conversionsByPrimitive.put(primitiveClass, this); }
@Override public void afterInvocation(final IInvokedMethod method, final ITestResult testResult) { try { delegate.after(); } catch (final Exception e) { throw new OpenEJBRuntimeException(e); } } }
public void unregister() { try { LocalMBeanServer.get().unregisterMBean(objectName); } catch (final Exception e) { throw new OpenEJBRuntimeException(e); } }
private Convert(final Class primitiveClass, final Class objectClass, final String toPrimitiveMethodName) { objectType = Type.getType(objectClass); try { toObject = objectClass.getMethod("valueOf", primitiveClass); toPrimitive = objectClass.getMethod(toPrimitiveMethodName); } catch (final NoSuchMethodException e) { throw new OpenEJBRuntimeException(e); } conversionsByPrimitive.put(primitiveClass, this); }
@Override public void afterInvocation(final IInvokedMethod method, final ITestResult testResult) { try { delegate.after(); } catch (final Exception e) { throw new OpenEJBRuntimeException(e); } } }
public IvmJndiFactory() { jndiRootContext = IvmContext.createRootContext(); try { jndiRootContext.bind("openejb/local/.", ""); jndiRootContext.bind("openejb/remote/.", ""); jndiRootContext.bind("openejb/client/.", ""); jndiRootContext.bind("openejb/Deployment/.", ""); jndiRootContext.bind("openejb/global/.", ""); } catch (final NamingException e) { throw new OpenEJBRuntimeException("this should not happen", e); } }
@SuppressWarnings("unchecked") private void setComponent(final Object testInstance, final Method method) throws IllegalAccessException, InvocationTargetException, InstantiationException { Object value = method.invoke(testInstance); if (value instanceof Class<?>) { value = ((Class<?>) value).newInstance(); } final Class<?> key = method.getReturnType(); if (!key.isInstance(value)) { // we can't do it in validate to avoid to instantiate the value twice throw new OpenEJBRuntimeException(value + " is not an instance of " + key.getName()); } SystemInstance.get().setComponent((Class<Object>) key, value); }
public static Object resolve(final Collection<ServiceInfo> services, final String id) { if (id == null) { return null; } try { return build(services, find(services, id)); } catch (final OpenEJBException e) { throw new OpenEJBRuntimeException(e); } }
public static Object resolve(final Collection<ServiceInfo> services, final String id) { if (id == null) { return null; } try { return build(services, find(services, id)); } catch (final OpenEJBException e) { throw new OpenEJBRuntimeException(e); } }
public <T> T resource(final Class<T> type, final String name) { try { return type.cast( SystemInstance.get().getComponent(ContainerSystem.class) .getJNDIContext().lookup("java:" + Assembler.OPENEJB_RESOURCE_JNDI_PREFIX + name) ); } catch (final NamingException e) { throw new OpenEJBRuntimeException(e); } }
public static Object newProxy(final Class<?> type, final InvocationHandler invocationHandler) { try { return ProxyManager.newProxyInstance(type, new Handler(invocationHandler)); } catch (final IllegalAccessException e) { throw new OpenEJBRuntimeException("illegal access", e); } }
public Object beanFromClass(final String appName, final String classname) { final AppContext appContext = appContext(appName); final BeanManager bm = appContext.getBeanManager(); final Class<?> clazz; try { clazz = appContext.getClassLoader().loadClass(classname); } catch (final ClassNotFoundException e) { throw new OpenEJBRuntimeException(e); } final Set<Bean<?>> beans = bm.getBeans(clazz); return instance(bm, beans, clazz); }
private AppContext appContext(final String appName) { final ContainerSystem cs = SystemInstance.get().getComponent(ContainerSystem.class); final AppContext appContext = cs.getAppContext(appName); if (appContext == null) { throw new OpenEJBRuntimeException("can't find application " + appName); } return appContext; } }
private AppContext appContext(final String appName) { final ContainerSystem cs = SystemInstance.get().getComponent(ContainerSystem.class); final AppContext appContext = cs.getAppContext(appName); if (appContext == null) { throw new OpenEJBRuntimeException("can't find application " + appName); } return appContext; } }
public IvmContext createSubcontext(final ParsedName name) throws NameAlreadyBoundException { try { bind(name, null); name.reset(); return (IvmContext) resolve(name); } catch (final NameNotFoundException exception) { exception.printStackTrace(); throw new OpenEJBRuntimeException(exception); } }
@Override public void beforeInvocation(final IInvokedMethod method, final ITestResult testResult) { delegate = new ApplicationComposers(method.getTestMethod().getRealClass()); try { delegate.before(testResult.getInstance()); } catch (final Exception e) { throw new OpenEJBRuntimeException(e); } }