Search in sources :

Example 11 with MessageEndpoint

use of javax.resource.spi.endpoint.MessageEndpoint in project spring-framework by spring-projects.

the class GenericMessageEndpointFactory method createEndpoint.

/**
	 * 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();
}
Also used : DelegatingIntroductionInterceptor(org.springframework.aop.support.DelegatingIntroductionInterceptor) MessageEndpoint(javax.resource.spi.endpoint.MessageEndpoint) ProxyFactory(org.springframework.aop.framework.ProxyFactory)

Example 12 with MessageEndpoint

use of javax.resource.spi.endpoint.MessageEndpoint in project wildfly by wildfly.

the class TransactionInflowWork method run.

public void run() {
    MessageEndpoint messageEndpoint;
    try {
        messageEndpoint = messageFactory.createEndpoint(null);
        if (messageEndpoint instanceof MessageListener) {
            log.tracef("Calling on message on endpoint '%s' with data message '%s'", messageEndpoint, msg);
            TransactionInflowTextMessage textMessage = new TransactionInflowTextMessage(msg);
            ((MessageListener) messageEndpoint).onMessage(textMessage);
        } else {
            throw new IllegalStateException("Not supported message endpoint: " + messageEndpoint);
        }
    } catch (UnavailableException ue) {
        String msg = String.format("Not capable to create message factory '%s' endpoint", messageFactory);
        throw new IllegalStateException(msg, ue);
    }
}
Also used : MessageEndpoint(javax.resource.spi.endpoint.MessageEndpoint) MessageListener(javax.jms.MessageListener) UnavailableException(javax.resource.spi.UnavailableException)

Example 13 with MessageEndpoint

use of javax.resource.spi.endpoint.MessageEndpoint in project wildfly by wildfly.

the class TelnetResourceAdapter method endpointDeactivation.

@Override
public void endpointDeactivation(MessageEndpointFactory messageEndpointFactory, ActivationSpec activationSpec) {
    final TelnetActivationSpec telnetActivationSpec = (TelnetActivationSpec) activationSpec;
    final TelnetServer telnetServer = activated.remove(port);
    try {
        telnetServer.deactivate();
    } catch (IOException e) {
        e.printStackTrace();
    }
    final MessageEndpoint endpoint = (MessageEndpoint) telnetServer.getListener();
    endpoint.release();
}
Also used : MessageEndpoint(javax.resource.spi.endpoint.MessageEndpoint) IOException(java.io.IOException) TelnetServer(org.jboss.as.test.integration.ejb.mdb.dynamic.impl.TelnetServer)

Example 14 with MessageEndpoint

use of javax.resource.spi.endpoint.MessageEndpoint in project wildfly by wildfly.

the class Cmd method exec.

public void exec(Object impl, String[] args, PrintStream out) throws Throwable {
    try {
        if (impl instanceof MessageEndpoint) {
            MessageEndpoint endpoint = (MessageEndpoint) impl;
            endpoint.beforeDelivery(method);
        }
        final Object result = method.invoke(impl, toParams(args));
        if (result != null) {
            final String text = result.toString().replaceAll("\n*$", "");
            out.println(text);
            out.println();
        }
    } catch (InvocationTargetException e) {
        throw e.getTargetException();
    } finally {
        if (impl instanceof MessageEndpoint) {
            MessageEndpoint endpoint = (MessageEndpoint) impl;
            endpoint.afterDelivery();
        }
    }
}
Also used : MessageEndpoint(javax.resource.spi.endpoint.MessageEndpoint) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 15 with MessageEndpoint

use of javax.resource.spi.endpoint.MessageEndpoint in project Payara by payara.

the class ConnectorMessageBeanClient method createEndpoint.

/**
 * {@inheritDoc}
 */
public MessageEndpoint createEndpoint(XAResource xaResource, long timeout) throws UnavailableException {
    synchronized (this) {
        while (myState == BLOCKED) {
            try {
                wait(timeout);
            } catch (Exception e) {
            // This exception should not affect the functionality.
            } finally {
                // Once the first thread comes out of wait, block is
                // is removed. This makes sure that the time for which the
                // the block remains is limited. Max 2x6000.
                myState = UNBLOCKED;
            }
        }
    }
    if (!started_) {
        logger.log(Level.WARNING, "endpointfactory.unavailable");
        throw new UnavailableException("EndpointFactory is currently not available");
    }
    MessageEndpoint endpoint = null;
    try {
        ResourceHandle resourceHandle = allocator_.createResource(xaResource);
        MessageBeanListener listener = messageBeanPM_.createMessageBeanListener(resourceHandle);
        MessageEndpointInvocationHandler handler = new MessageEndpointInvocationHandler(listener, messageBeanPM_);
        endpoint = (MessageEndpoint) messageBeanPM_.createMessageBeanProxy(handler);
    } catch (Exception ex) {
        throw (UnavailableException) (new UnavailableException()).initCause(ex);
    }
    return endpoint;
}
Also used : MessageEndpoint(javax.resource.spi.endpoint.MessageEndpoint) MessageBeanListener(org.glassfish.ejb.api.MessageBeanListener) UnavailableException(javax.resource.spi.UnavailableException) ResourceHandle(com.sun.enterprise.resource.ResourceHandle) ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException) UnavailableException(javax.resource.spi.UnavailableException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException)

Aggregations

MessageEndpoint (javax.resource.spi.endpoint.MessageEndpoint)15 ResourceException (javax.resource.ResourceException)5 ResourceAdapterInternalException (javax.resource.spi.ResourceAdapterInternalException)3 UnavailableException (javax.resource.spi.UnavailableException)3 IOException (java.io.IOException)2 Method (java.lang.reflect.Method)2 TelnetServer (org.jboss.as.test.integration.ejb.mdb.dynamic.impl.TelnetServer)2 ConnectorRuntimeException (com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)1 ResourceHandle (com.sun.enterprise.resource.ResourceHandle)1 IllegalStateException (java.lang.IllegalStateException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 MessageListener (javax.jms.MessageListener)1 Work (javax.resource.spi.work.Work)1 WorkException (javax.resource.spi.work.WorkException)1 Job (org.apache.openejb.quartz.Job)1 JobDataMap (org.apache.openejb.quartz.JobDataMap)1 Scheduler (org.apache.openejb.quartz.Scheduler)1 SchedulerException (org.apache.openejb.quartz.SchedulerException)1 MessageBeanListener (org.glassfish.ejb.api.MessageBeanListener)1