本文整理汇总了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);
}
}
示例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);
}
示例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);
}
}
示例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;
}
}
示例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;
}
}
示例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);
}
}
示例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;
}
示例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();
}
示例9: createEndpoint
import javax.resource.spi.UnavailableException; //导入依赖的package包/类
@Override
public MessageEndpoint createEndpoint(XAResource xaResource) throws UnavailableException {
if (xaResource != null) {
endpoint.setXAResource(xaResource);
}
return endpoint;
}
示例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;
}
示例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);
}
示例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());
}
}
示例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;
}
}
示例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;
}
示例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);
}
}