@Override public T create(CreationalContext<T> context) { throw new WebBeansException("You must not create an Interceptor instance of a self-intercepted bean!"); } }
/** * 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); }
@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); } }
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); }
/** * 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); } }
/** * 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"); }
private Session createSession() { Connection connection = null; try { connection = createOrReturnQueueOrTopicConnection(); return connection.createSession(false, Session.AUTO_ACKNOWLEDGE); } catch (JMSException e) { ensureConnectionClosing(connection); throw new WebBeansException("Unable to create jms session", e); } }
public static void unbind(String name) { Asserts.assertNotNull(name, "name"); try { new InitialContext().unbind(name); } catch (NamingException e) { LOGGER.log(Level.SEVERE, e.getMessage(), e); throw new WebBeansException(WebBeansLoggerFacade.getTokenString(OWBLogConst.EXCEPT_0009) + name, e); } }
private MessageProducer createMessageProducers() { Connection connection = null; try { connection = createOrReturnQueueOrTopicConnection(); return connection.createSession(false, Session.AUTO_ACKNOWLEDGE).createProducer(createOrReturnQueueOrTopic()); } catch (JMSException e) { ensureConnectionClosing(connection); throw new WebBeansException("Unable to create jms message producer", e); } }
private MessageConsumer createMessageConsumers() { Connection connection = null; try { connection = createOrReturnQueueOrTopicConnection(); return connection.createSession(false, Session.AUTO_ACKNOWLEDGE).createConsumer(createOrReturnQueueOrTopic()); } catch (JMSException e) { ensureConnectionClosing(connection); throw new WebBeansException("Unable to create jms message producer", e); } }
@Override public void attributeAdded(ServletContextAttributeEvent servletContextAttributeEvent) { if (InstanceManager.class.getName().equals(servletContextAttributeEvent.getName())) { // used as a hook to know we can override eagerly the InstanceManager try { StandardContext context = (StandardContext) getContext(servletContextAttributeEvent.getServletContext()); wrapInstanceManager(context); } catch (NoSuchFieldException e) { throw new WebBeansException(e.getMessage(), e); } catch (IllegalAccessException e) { throw new WebBeansException(e.getMessage(), e); } } }
private void close() { try { if(this.jmsObject != null) { Method method = this.jmsObject.getClass().getMethod("close"); if(!method.isAccessible()) { jmsComponent.getWebBeansContext().getSecurityService().doPrivilegedSetAccessible(method, true); } method.invoke(this.jmsObject); } } catch (Exception e) { throw new WebBeansException("Unable to close JMS resources"); } }
@Override public T get() { if (webBeansContext == null) { webBeansContext = WebBeansContext.currentInstance(); } try { ResourceInjectionService resourceService = webBeansContext.getService(ResourceInjectionService.class); return resourceService.getResourceReference(resourceReference); } catch (Exception e) { throw new WebBeansException(e); } }
/** * Creates the instance from the constructor. Each constructor parameter * instance is resolved using the resolution algorithm. */ public T doInjection() { try { if(!con.isAccessible()) { getWebBeansContext().getSecurityService().doPrivilegedSetAccessible(con, true); } instance = con.newInstance(createParameters()); transientCreationalContext.release(); return instance; } catch (Exception e) { throw new WebBeansException(e); } }
@SuppressWarnings({"unchecked"}) public static <T> T defineEjbBeanProxy(BaseEjbBean<T> bean, Class<?> iface, CreationalContext<?> creationalContext) { try { T proxyInstance = null; Class<?> clazz = JavassistProxyFactory.getInstance().getEjbBeanProxyClass(bean, iface); if(clazz == null) { ProxyFactory factory = new ProxyFactory(); factory.setInterfaces(new Class[]{iface}); clazz = JavassistProxyFactory.getInstance().defineEjbBeanProxyClass(bean, iface, factory); } proxyInstance = (T) ClassUtil.newInstance(clazz); EjbBeanProxyHandler handler = new EjbBeanProxyHandler(bean, creationalContext); ((ProxyObject)proxyInstance).setHandler(handler); return proxyInstance; } catch(Exception e) { throw new WebBeansException(e); } } }