当前位置: 首页>>代码示例>>Java>>正文


Java UnavailableException类代码示例

本文整理汇总了Java中javax.resource.spi.UnavailableException的典型用法代码示例。如果您正苦于以下问题:Java UnavailableException类的具体用法?Java UnavailableException怎么用?Java UnavailableException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


UnavailableException类属于javax.resource.spi包,在下文中一共展示了UnavailableException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setup

import javax.resource.spi.UnavailableException; //导入依赖的package包/类
public void setup() throws Exception {
	if (log.isTraceEnabled()) {
		log.trace("setup()");
	}
	this.consumer = new DefaultConsumer(this.channel) {
		
		@Override
		public void handleDelivery(String consumerTag, Envelope envelope,
				BasicProperties properties, byte[] body) throws IOException {
			MessageEndpoint localEndpoint;
			try {
				localEndpoint = endpointFactory.createEndpoint(null);
				RabbitmqBytesMessage m = new RabbitmqBytesMessage(consumerTag,envelope,properties,body);
				onMessage(localEndpoint, m);
			} catch (UnavailableException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		
	};
	if ("javax.jms.Queue".equals(this.spec.getDestinationType())) {
		RabbitmqAdminQueueImpl queue = Util.lookup(new InitialContext(), this.spec.getDestination(), RabbitmqAdminQueueImpl.class);
		this.channel.basicConsume(queue.getDestinationAddress(),true, consumer);
	}
}
 
开发者ID:leogsilva,项目名称:rabbitmq-resource-adapter,代码行数:27,代码来源:RabbitmqMessageHandler.java

示例2: start

import javax.resource.spi.UnavailableException; //导入依赖的package包/类
@Override
public void start(BootstrapContext ctx) throws ResourceAdapterInternalException {
	log.debug("");

	workManager = ctx.getWorkManager();
	xaTerminator = ctx.getXATerminator();
	try {
		timer = ctx.createTimer();

		perMinuteTimerTask = new PerMinuteTimerTask();
		perMinuteTimerTask.init();
		timer.schedule(perMinuteTimerTask, perMinuteTimerTask.getDelay(), perMinuteTimerTask.getPeriod());
	} catch (UnavailableException e) {
		log.warn("", e);
		//throw new ResourceAdapterInternalException(e);
	}
	//bind();
	log.debug("workManager={}, xaTerminator={}, timer={}", workManager, xaTerminator, timer);
}
 
开发者ID:dlmiles,项目名称:full-example-ee7-jca-eis,代码行数:20,代码来源:ResourceAdapterImpl.java

示例3: createEndpoint

import javax.resource.spi.UnavailableException; //导入依赖的package包/类
@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);
    }
}
 
开发者ID:apache,项目名称:tomee,代码行数:25,代码来源:EndpointFactory.java

示例4: afterDelivery

import javax.resource.spi.UnavailableException; //导入依赖的package包/类
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;
    }
}
 
开发者ID:apache,项目名称:tomee,代码行数:27,代码来源:AbstractEndpointHandler.java

示例5: afterDelivery

import javax.resource.spi.UnavailableException; //导入依赖的package包/类
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;
    }
}
 
开发者ID:apache,项目名称:tomee,代码行数:23,代码来源:PoolEndpointHandler.java

示例6: invoke

import javax.resource.spi.UnavailableException; //导入依赖的package包/类
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);
    }
}
 
开发者ID:apache,项目名称:tomee,代码行数:22,代码来源:MdbContainer.java

示例7: createEndpoint

import javax.resource.spi.UnavailableException; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:12,代码来源:AbstractMessageEndpointFactory.java

示例8: createEndpoint

import javax.resource.spi.UnavailableException; //导入依赖的package包/类
/**
 * 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();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:15,代码来源:GenericMessageEndpointFactory.java

示例9: createEndpoint

import javax.resource.spi.UnavailableException; //导入依赖的package包/类
@Override
public MessageEndpoint createEndpoint(XAResource xaResource) throws UnavailableException {
   if (xaResource != null) {
      endpoint.setXAResource(xaResource);
   }
   return endpoint;
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:8,代码来源:ActiveMQRATestBase.java

示例10: createEndpoint

import javax.resource.spi.UnavailableException; //导入依赖的package包/类
@Override
public MessageEndpoint createEndpoint(XAResource xaResource) throws UnavailableException {
   TestEndpoint retEnd = new TestEndpoint();
   if (xaResource != null) {
      retEnd.setXAResource(xaResource);
   }
   return retEnd;
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:9,代码来源:MDBMultipleHandlersServerDisconnectTest.java

示例11: createEndpoint

import javax.resource.spi.UnavailableException; //导入依赖的package包/类
@Override
public MessageEndpoint createEndpoint(XAResource xaResource, long timeout)
        throws UnavailableException {
    EndpointProxy handler = new EndpointProxy(_metadata, this, xaResource);
    return (MessageEndpoint) Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(),
                                                    new Class<?>[] {_metadata.getListenerInterface(),MessageEndpoint.class},
                                                    handler);
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:9,代码来源:InboundHandler.java

示例12: run

import javax.resource.spi.UnavailableException; //导入依赖的package包/类
@Override
public void run() {
    log.info("[ObtainEndpointWork] run()");
    try {
        /* Use the endpoint factory passed by the container upon
         * activation to obtain the MDB endpoint */
        endpoint = mef.createEndpoint(null);
        /* Return back to the resource adapter class */
        ra.endpointAvailable(endpoint);
    } catch (UnavailableException ex ) {
        log.info(ex.getMessage());
    }
}
 
开发者ID:osmanpub,项目名称:oracle-samples,代码行数:14,代码来源:ObtainEndpointWork.java

示例13: createInstance

import javax.resource.spi.UnavailableException; //导入依赖的package包/类
/**
 * 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;
    }
}
 
开发者ID:apache,项目名称:tomee,代码行数:35,代码来源:MdbInstanceFactory.java

示例14: recreateInstance

import javax.resource.spi.UnavailableException; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:apache,项目名称:tomee,代码行数:15,代码来源:MdbInstanceFactory.java

示例15: constructBean

import javax.resource.spi.UnavailableException; //导入依赖的package包/类
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);
    }
}
 
开发者ID:apache,项目名称:tomee,代码行数:29,代码来源:MdbInstanceFactory.java


注:本文中的javax.resource.spi.UnavailableException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。