Search in sources :

Example 1 with MessageBeanListener

use of org.glassfish.ejb.api.MessageBeanListener 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

ConnectorRuntimeException (com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)1 ResourceHandle (com.sun.enterprise.resource.ResourceHandle)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 UnavailableException (javax.resource.spi.UnavailableException)1 MessageEndpoint (javax.resource.spi.endpoint.MessageEndpoint)1 MessageBeanListener (org.glassfish.ejb.api.MessageBeanListener)1