@Override public T create(CreationalContext<T> context) { throw new WebBeansException("You must not create an Interceptor instance of a self-intercepted bean!"); } }
@Override public String getLocalizedMessage() { return msg.getAdditionalInformation(super.getLocalizedMessage()); }
@Override public String getMessage() { return msg.getAdditionalInformation(super.getMessage()); }
Throwable exc = e.getCause(); if(exc instanceof InvocationTargetException) throw new WebBeansException(e);
private CompletableFuture invokeObserverMethodAsync(Object event, EventMetadataImpl metadata, ObserverMethod<? super Object> observer, NotificationOptions notificationOptions) { CompletableFuture<?> future = new CompletableFuture<>(); CompletableFuture.runAsync(() -> { try { runAsync(event, metadata, observer); future.complete(null); } catch (WebBeansException wbe) { future.completeExceptionally(wbe.getCause()); } }, notificationOptions.getExecutor() == null ? defaultNotificationOptions.getExecutor() : notificationOptions.getExecutor()); return future; }
/** * Gets jms related object. * @param jmsComponent jms bean * @param intf injection point class * @return proxy object */ public static Object createNewJmsProxy(JmsBean<?> jmsComponent, Class<?> intf) { try { Class<?>[] interfaces = {Closable.class, Serializable.class, intf}; //X TODO do we still need this? throw new WebBeansException("Support got temporarily removed while moving from Javassist to ASM"); } catch (Exception e) { throw new WebBeansException(e); } }
public GeronimoResourceInjectionService(WebBeansContext webBeansContext) { try { this.context = new InitialContext(); this.webBeansContext = webBeansContext; } catch (NamingException e) { throw new WebBeansException("could not set up naming context", e); } }
public static void clearConnections() { try { connectionFactory = null; for (Connection connection : connections.values()) { connection.close(); } connections = null; dests.clear(); dests = null; } catch (Exception e) { throw new WebBeansException(e); } }
@Override public void error(SAXParseException exception) throws SAXException { logger.log(Level.SEVERE, exception.getMessage(), exception.getCause()); throw new WebBeansException(exception); }
@Override public void fatalError(SAXParseException exception) throws SAXException { logger.log(Level.SEVERE, exception.getMessage(), exception.getCause()); throw new WebBeansException(exception); }
/** * Calls the given method on the given instance. * Used to determine the values of annotation instances. * * @param instance * @param method * @return */ private static Object callMethod(Object instance, Method method) { try { if (!method.isAccessible()) { method.setAccessible(true); } return method.invoke(instance, EMPTY_OBJECT_ARRAY); } catch (Exception e) { throw new WebBeansException("Exception in method call : " + method.getName(), e); } }
@Override public <X, T extends Annotation> X getResourceReference(ResourceReference<X, T> resourceReference) { String jndiName = resourceReference.getJndiName(); Class<X> type = resourceReference.getResourceType(); try { return type.cast(context.lookup(jndiName)); } catch (NamingException e) { throw new WebBeansException("Could not get resource of type " + type + " at jndi name " + jndiName, e); } }
@SuppressWarnings("unchecked") public static <T> T lookup(String name, Class<? extends T> expectedClass) throws WebBeansException { Asserts.assertNotNull(name, "name"); try { return (T) new InitialContext().lookup(name); } catch (NamingException e) { LOGGER.log(Level.SEVERE, e.getMessage(), e); throw new WebBeansException(WebBeansLoggerFacade.getTokenString(OWBLogConst.EXCEPT_0010) + name, e); } }
/** * Call method on the instance with given arguments. * * @param method method instance * @param instance object instance * @param args arguments * @return the method result */ public static Object callInstanceMethod(Method method, Object instance, Object[] args) { Asserts.nullCheckForMethod(method); try { if (args == null) { args = new Object[] {}; } return method.invoke(instance, args); } catch (Exception e) { throw new WebBeansException("Exception occurs in the method call with method : " + method.getName() + " in class : " + instance.getClass().getName(), e); } }
private Object get(String singletonName) { //Load class Class<?> clazz = ClassUtil.getClassFromName(singletonName); if (clazz == null) { throw new WebBeansException("Class not found exception in creating instance with class : " + singletonName, new ClassNotFoundException("Class with name: " + singletonName + " is not found in the system")); } return get(clazz); }
throw new WebBeansException("No suitable constructor : " + clazz.getName(), e.getCause()); throw new WebBeansException("Unable to instantiate class : " + clazz.getName(), e.getCause()); throw new WebBeansException("Unable to instantiate class : " + clazz.getName(), e.getCause()); throw new WebBeansException("Illegal access exception in creating instance with class : " + clazz.getName(), e);
/** * Returns servelt context otherwise throws exception. * @param object object * @return servlet context */ private ServletContext getServletContext(Object object) { if(object != null) { if(object instanceof ServletContextEvent) { object = ((ServletContextEvent) object).getServletContext(); return (ServletContext)object; } else { throw new WebBeansException(WebBeansLoggerFacade.getTokenString(OWBLogConst.EXCEPT_0018)); } } throw new IllegalArgumentException("ServletContextEvent object but found null"); }
public Object run() { try { switch (method) { case METHOD_CLASS_GETDECLAREDCONSTRUCTOR: return clazz.getDeclaredConstructor((Class<?>[])parameters); case METHOD_CLASS_GETDECLAREDCONSTRUCTORS: return clazz.getDeclaredConstructors(); case METHOD_CLASS_GETDECLAREDMETHOD: String name = (String)((Object[])parameters)[0]; Class<?>[] realParameters = (Class<?>[])((Object[])parameters)[1]; return clazz.getDeclaredMethod(name, realParameters); case METHOD_CLASS_GETDECLAREDMETHODS: return clazz.getDeclaredMethods(); case METHOD_CLASS_GETDECLAREDFIELD: return clazz.getDeclaredField((String)parameters); case METHOD_CLASS_GETDECLAREDFIELDS: return clazz.getDeclaredFields(); default: return new WebBeansException("unknown security method: " + method); } } catch (Exception exception) { return exception; } }
public static boolean isBusinessMethod(Method method, BaseEjbBean<?> bean) { List<Class<?>> businessLocals = bean.getBusinessLocalInterfaces(); for(Class<?> clz : businessLocals) { try { clz.getMethod(method.getName(), method.getParameterTypes()); return true; } catch (SecurityException e) { throw new WebBeansException("Security exception",e); } catch (NoSuchMethodException e) { continue; } } return false; } }
return clazz.getConstructor((Class<?>[])parameters); default: return new WebBeansException("unknown security method: " + method);