javax.resource.spi.UnavailableException Java Examples
The following examples show how to use
javax.resource.spi.UnavailableException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MDBInvoker.java From cxf with Apache License 2.0 | 6 votes |
/** * Invokes endpoint factory to create message endpoint (event driven bean). * It will retry if the event driven bean is not yet available. */ private MessageEndpoint createMessageEndpoint() { MessageEndpoint ep = null; for (int i = 0; i < MAX_ATTEMPTS; i++) { try { ep = endpointFactory.createEndpoint(null); break; } catch (UnavailableException e) { LOG.fine("Target endpoint activation in progress. Will retry."); try { Thread.sleep(RETRY_SLEEP); } catch (InterruptedException e1) { // ignore } } } return ep; }
Example #2
Source File: EndpointFactory.java From tomee with Apache License 2.0 | 6 votes |
@Override public MessageEndpoint createEndpoint(final XAResource xaResource, final long timeout) throws UnavailableException { if (timeout <= 0) { return createEndpoint(xaResource); } final long end = System.currentTimeMillis() + timeout; MessageEndpoint messageEndpoint = null; while (System.currentTimeMillis() <= end) { try { messageEndpoint = createEndpoint(xaResource); break; } catch (final Exception ex) { // ignore so we can keep trying } } if (messageEndpoint != null) { return messageEndpoint; } else { throw new UnavailableException("Unable to create end point within the specified timeout " + timeout); } }
Example #3
Source File: MdbContainer.java From tomee with Apache License 2.0 | 6 votes |
public Object invoke(final Object deploymentId, final InterfaceType type, final Class callInterface, final Method method, final Object[] args, final Object primKey) throws OpenEJBException { final BeanContext beanContext = getBeanContext(deploymentId); final EndpointFactory endpointFactory = (EndpointFactory) beanContext.getContainerData(); final MdbInstanceFactory instanceFactory = endpointFactory.getInstanceFactory(); final Instance instance; try { instance = (Instance) instanceFactory.createInstance(true); } catch (final UnavailableException e) { throw new SystemException("Unable to create instance for invocation", e); } try { beforeDelivery(beanContext, instance, method, null); final Object value = invoke(instance, method, type, args); afterDelivery(instance); return value; } finally { instanceFactory.freeInstance(instance, true); } }
Example #4
Source File: AbstractEndpointHandler.java From tomee with Apache License 2.0 | 6 votes |
public void afterDelivery() throws ApplicationServerInternalException, UnavailableException { switch (state) { case RELEASED: throw new IllegalStateException("Message endpoint factory has been released"); case NONE: throw new IllegalStateException("afterDelivery may only be called if message delivery began with a beforeDelivery call"); } // call afterDelivery on the container boolean exceptionThrown = false; try { container.afterDelivery(instance); } catch (final SystemException se) { exceptionThrown = true; final Throwable throwable = se.getRootCause() != null ? se.getRootCause() : se; throw new ApplicationServerInternalException(throwable); } finally { if (state == State.SYSTEM_EXCEPTION) { recreateInstance(exceptionThrown); } // we are now in the default NONE state state = State.NONE; } }
Example #5
Source File: PoolEndpointHandler.java From tomee with Apache License 2.0 | 6 votes |
public void afterDelivery() throws ApplicationServerInternalException, UnavailableException { // verify current state switch (state) { case RELEASED: throw new IllegalStateException("Message endpoint factory has been released"); case NONE: throw new IllegalStateException("afterDelivery may only be called if message delivery began with a beforeDelivery call"); } // call afterDelivery on the container try { container.afterDelivery(instance); } catch (final SystemException se) { final Throwable throwable = se.getRootCause() != null ? se.getRootCause() : se; throw new ApplicationServerInternalException(throwable); } finally { // we are now in the default NONE state state = State.NONE; this.instance = null; } }
Example #6
Source File: AbstractMessageEndpointFactory.java From spring-analysis-note with MIT License | 5 votes |
/** * The standard JCA 1.5 version of {@code createEndpoint}. * <p>This implementation delegates to {@link #createEndpointInternal()}, * initializing the endpoint's XAResource before the endpoint gets invoked. */ @Override public MessageEndpoint createEndpoint(XAResource xaResource) throws UnavailableException { AbstractMessageEndpoint endpoint = createEndpointInternal(); endpoint.initXAResource(xaResource); return endpoint; }
Example #7
Source File: MDBMultipleHandlersServerDisconnectTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Override public MessageEndpoint createEndpoint(XAResource xaResource) throws UnavailableException { TestEndpoint retEnd = new TestEndpoint(); if (xaResource != null) { retEnd.setXAResource(xaResource); } return retEnd; }
Example #8
Source File: ActiveMQRATestBase.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Override public MessageEndpoint createEndpoint(XAResource xaResource) throws UnavailableException { if (xaResource != null) { endpoint.setXAResource(xaResource); } return endpoint; }
Example #9
Source File: GenericMessageEndpointFactory.java From spring4-understanding with Apache License 2.0 | 5 votes |
/** * Wrap each concrete endpoint instance with an AOP proxy, * exposing the message listener's interfaces as well as the * endpoint SPI through an AOP introduction. */ @Override public MessageEndpoint createEndpoint(XAResource xaResource) throws UnavailableException { GenericMessageEndpoint endpoint = (GenericMessageEndpoint) super.createEndpoint(xaResource); ProxyFactory proxyFactory = new ProxyFactory(this.messageListener); DelegatingIntroductionInterceptor introduction = new DelegatingIntroductionInterceptor(endpoint); introduction.suppressInterface(MethodInterceptor.class); proxyFactory.addAdvice(introduction); return (MessageEndpoint) proxyFactory.getProxy(); }
Example #10
Source File: EndpointFactory.java From tomee with Apache License 2.0 | 5 votes |
@Override public MessageEndpoint createEndpoint(XAResource xaResource) throws UnavailableException { if (xaResource != null && xaResourceWrapper != null) { xaResource = xaResourceWrapper.wrap(xaResource, container.getContainerID().toString()); } InvocationHandler endpointHandler = null; if (usePool) { endpointHandler = new PoolEndpointHandler(container, beanContext, instanceManager, xaResource); } else { endpointHandler = new EndpointHandler(container, beanContext, instanceFactory, xaResource); } try { return (MessageEndpoint) LocalBeanProxyFactory.constructProxy(proxy, endpointHandler); } catch (final InternalError e) { // should be useless //try to create the proxy with tccl once again. try { return MessageEndpoint.class.cast(LocalBeanProxyFactory.newProxyInstance(Thread.currentThread().getContextClassLoader(), endpointHandler, beanContext.getBeanClass(), interfaces)); } catch (final InternalError ie) { try { return MessageEndpoint.class.cast(LocalBeanProxyFactory.newProxyInstance(classLoader, endpointHandler, beanContext.getBeanClass(), interfaces)); } catch (final InternalError ie2) { // no-op } } throw e; } }
Example #11
Source File: AbstractMessageEndpointFactory.java From spring4-understanding with Apache License 2.0 | 5 votes |
/** * The standard JCA 1.5 version of {@code createEndpoint}. * <p>This implementation delegates to {@link #createEndpointInternal()}, * initializing the endpoint's XAResource before the endpoint gets invoked. */ @Override public MessageEndpoint createEndpoint(XAResource xaResource) throws UnavailableException { AbstractMessageEndpoint endpoint = createEndpointInternal(); endpoint.initXAResource(xaResource); return endpoint; }
Example #12
Source File: MdbInstanceFactory.java From tomee with Apache License 2.0 | 5 votes |
/** * Creates a new mdb instance preforming all necessary lifecycle callbacks * * @param ignoreInstanceCount * @return a new message driven bean instance * @throws UnavailableException if the instance limit has been exceeded or * if an exception occurs while creating the bean instance */ public Object createInstance(final boolean ignoreInstanceCount) throws UnavailableException { if (!ignoreInstanceCount) { synchronized (this) { // check the instance limit if (instanceLimit > 0 && instanceCount >= instanceLimit) { throw new UnavailableException("Only " + instanceLimit + " instances can be created"); } // increment the instance count instanceCount++; } } try { final Object bean = constructBean(); return bean; } catch (final UnavailableException e) { // decrement the instance count if (!ignoreInstanceCount) { synchronized (this) { instanceCount--; } } throw e; } }
Example #13
Source File: GenericMessageEndpointFactory.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Wrap each concrete endpoint instance with an AOP proxy, * exposing the message listener's interfaces as well as the * endpoint SPI through an AOP introduction. */ @Override public MessageEndpoint createEndpoint(XAResource xaResource) throws UnavailableException { GenericMessageEndpoint endpoint = (GenericMessageEndpoint) super.createEndpoint(xaResource); ProxyFactory proxyFactory = new ProxyFactory(this.messageListener); DelegatingIntroductionInterceptor introduction = new DelegatingIntroductionInterceptor(endpoint); introduction.suppressInterface(MethodInterceptor.class); proxyFactory.addAdvice(introduction); return (MessageEndpoint) proxyFactory.getProxy(); }
Example #14
Source File: MdbInstanceFactory.java From tomee with Apache License 2.0 | 5 votes |
/** * Recreates a bean instance that has thrown a system exception. As required by the EJB specification, lifecycle * callbacks are not invoked. To normally free a bean instance call the freeInstance method. * * @param bean the bean instance to discard * @return the new replacement bean instance */ public Object recreateInstance(final Object bean) throws UnavailableException { if (bean == null) { throw new NullPointerException("bean is null"); } final Object newBean = constructBean(); return newBean; }
Example #15
Source File: MdbInstanceFactory.java From tomee with Apache License 2.0 | 5 votes |
private Object constructBean() throws UnavailableException { final BeanContext beanContext = this.beanContext; final ThreadContext callContext = new ThreadContext(beanContext, null, Operation.INJECTION); final ThreadContext oldContext = ThreadContext.enter(callContext); try { final InstanceContext context = beanContext.newInstance(); if (context.getBean() instanceof MessageDrivenBean) { callContext.setCurrentOperation(Operation.CREATE); final Method create = beanContext.getCreateMethod(); final InterceptorStack ejbCreate = new InterceptorStack(context.getBean(), create, Operation.CREATE, new ArrayList(), new HashMap()); ejbCreate.invoke(); } return new Instance(context.getBean(), context.getInterceptors(), context.getCreationalContext()); } catch (Throwable e) { if (e instanceof InvocationTargetException) { e = ((InvocationTargetException) e).getTargetException(); } final String message = "The bean instance threw a system exception:" + e; MdbInstanceFactory.logger.error(message, e); throw new UnavailableException(message, e); } finally { ThreadContext.exit(oldContext); } }
Example #16
Source File: AbstractMessageEndpointFactory.java From lams with GNU General Public License v2.0 | 5 votes |
/** * The standard JCA 1.5 version of {@code createEndpoint}. * <p>This implementation delegates to {@link #createEndpointInternal()}, * initializing the endpoint's XAResource before the endpoint gets invoked. */ @Override public MessageEndpoint createEndpoint(XAResource xaResource) throws UnavailableException { AbstractMessageEndpoint endpoint = createEndpointInternal(); endpoint.initXAResource(xaResource); return endpoint; }
Example #17
Source File: EndpointHandler.java From tomee with Apache License 2.0 | 5 votes |
public EndpointHandler(final BaseMdbContainer container, final BeanContext deployment, final MdbInstanceFactory instanceFactory, final XAResource xaResource) throws UnavailableException { super(container); this.deployment = deployment; this.instanceFactory = instanceFactory; this.xaResource = xaResource; instance = instanceFactory.createInstance(false); }
Example #18
Source File: EndpointHandler.java From tomee with Apache License 2.0 | 5 votes |
@Override protected void recreateInstance(final boolean exceptionAlreadyThrown) throws UnavailableException { try { instance = instanceFactory.recreateInstance(instance); } catch (final UnavailableException e) { // an error occured wile attempting to create the replacement instance // this endpoint is now failed state = State.RELEASED; // if bean threw an exception, do not override that exception if (!exceptionAlreadyThrown) { throw e; } } }
Example #19
Source File: PoolEndpointHandler.java From tomee with Apache License 2.0 | 5 votes |
public PoolEndpointHandler(final BaseMdbContainer container, final BeanContext deployment, final MdbInstanceManager instanceManager, final XAResource xaResource) throws UnavailableException { super(container); this.deployment = deployment; this.instanceManager = instanceManager; this.xaResource = xaResource; this.callContext = ThreadContext.getThreadContext(); }
Example #20
Source File: GenericMessageEndpointFactory.java From java-technology-stack with MIT License | 5 votes |
/** * Wrap each concrete endpoint instance with an AOP proxy, * exposing the message listener's interfaces as well as the * endpoint SPI through an AOP introduction. */ @Override public MessageEndpoint createEndpoint(XAResource xaResource) throws UnavailableException { GenericMessageEndpoint endpoint = (GenericMessageEndpoint) super.createEndpoint(xaResource); ProxyFactory proxyFactory = new ProxyFactory(getMessageListener()); DelegatingIntroductionInterceptor introduction = new DelegatingIntroductionInterceptor(endpoint); introduction.suppressInterface(MethodInterceptor.class); proxyFactory.addAdvice(introduction); return (MessageEndpoint) proxyFactory.getProxy(); }
Example #21
Source File: AbstractMessageEndpointFactory.java From java-technology-stack with MIT License | 5 votes |
/** * The alternative JCA 1.6 version of {@code createEndpoint}. * <p>This implementation delegates to {@link #createEndpointInternal()}, * ignoring the specified timeout. It is only here for JCA 1.6 compliance. */ @Override public MessageEndpoint createEndpoint(XAResource xaResource, long timeout) throws UnavailableException { AbstractMessageEndpoint endpoint = createEndpointInternal(); endpoint.initXAResource(xaResource); return endpoint; }
Example #22
Source File: AbstractMessageEndpointFactory.java From java-technology-stack with MIT License | 5 votes |
/** * The standard JCA 1.5 version of {@code createEndpoint}. * <p>This implementation delegates to {@link #createEndpointInternal()}, * initializing the endpoint's XAResource before the endpoint gets invoked. */ @Override public MessageEndpoint createEndpoint(XAResource xaResource) throws UnavailableException { AbstractMessageEndpoint endpoint = createEndpointInternal(); endpoint.initXAResource(xaResource); return endpoint; }
Example #23
Source File: MdbConfigTest.java From tomee with Apache License 2.0 | 5 votes |
public void start(final BootstrapContext bootstrapContext) throws ResourceAdapterInternalException { assertFalse("Already started", started); assertNotNull("bootstrapContext is null", bootstrapContext); assertNotNull("bootstrapContext.getWorkManager() is null", bootstrapContext.getWorkManager()); assertNotNull("bootstrapContext.getXATerminator() is null", bootstrapContext.getXATerminator()); try { assertNotNull("bootstrapContext.createTimer() is null", bootstrapContext.createTimer()); } catch (final UnavailableException e) { throw new ResourceAdapterInternalException("bootstrapContext.createTimer() threw an exception", e); } }
Example #24
Source File: MdbTest.java From tomee with Apache License 2.0 | 5 votes |
public MessageEndpoint createEndpoint(final XAResource xaResource) throws UnavailableException { try { return new JmsEndpoint(connectionFactory); } catch (final JMSException e) { e.printStackTrace(); throw new UnavailableException(e); } }
Example #25
Source File: GenericMessageEndpointFactory.java From spring-analysis-note with MIT License | 5 votes |
/** * Wrap each concrete endpoint instance with an AOP proxy, * exposing the message listener's interfaces as well as the * endpoint SPI through an AOP introduction. */ @Override public MessageEndpoint createEndpoint(XAResource xaResource) throws UnavailableException { GenericMessageEndpoint endpoint = (GenericMessageEndpoint) super.createEndpoint(xaResource); ProxyFactory proxyFactory = new ProxyFactory(getMessageListener()); DelegatingIntroductionInterceptor introduction = new DelegatingIntroductionInterceptor(endpoint); introduction.suppressInterface(MethodInterceptor.class); proxyFactory.addAdvice(introduction); return (MessageEndpoint) proxyFactory.getProxy(); }
Example #26
Source File: AbstractMessageEndpointFactory.java From spring-analysis-note with MIT License | 5 votes |
/** * The alternative JCA 1.6 version of {@code createEndpoint}. * <p>This implementation delegates to {@link #createEndpointInternal()}, * ignoring the specified timeout. It is only here for JCA 1.6 compliance. */ @Override public MessageEndpoint createEndpoint(XAResource xaResource, long timeout) throws UnavailableException { AbstractMessageEndpoint endpoint = createEndpointInternal(); endpoint.initXAResource(xaResource); return endpoint; }
Example #27
Source File: InflowTestCase.java From ironjacamar with Eclipse Public License 1.0 | 4 votes |
/** * {@inheritDoc} */ public MessageEndpoint createEndpoint(XAResource xaResource, long timeout) throws UnavailableException { return new TestMessageEndpoint(this); }
Example #28
Source File: InflowTestCase.java From ironjacamar with Eclipse Public License 1.0 | 4 votes |
/** * {@inheritDoc} */ public MessageEndpoint createEndpoint(XAResource xaResource) throws UnavailableException { return new TestMessageEndpoint(this); }
Example #29
Source File: SimpleBootstrapContext.java From spring-analysis-note with MIT License | 4 votes |
@Override public Timer createTimer() throws UnavailableException { return new Timer(); }
Example #30
Source File: MdbTest.java From tomee with Apache License 2.0 | 4 votes |
public MessageEndpoint createEndpoint(final XAResource xaResource, final long timeout) throws UnavailableException { return createEndpoint(xaResource); }