Example usage for javax.resource.spi.endpoint MessageEndpoint release

List of usage examples for javax.resource.spi.endpoint MessageEndpoint release

Introduction

In this page you can find the example usage for javax.resource.spi.endpoint MessageEndpoint release.

Prototype

void release();

Source Link

Document

This method may be called by the resource adapter to indicate that it no longer needs a proxy endpoint instance.

Usage

From source file:me.jtalk.socketconnector.SocketResourceAdapter.java

private <T> void sendEndpoint(MessageEndpointFactory factory, Method target, T message) {
    try {/*from   w w  w  .j  a  v a  2s  . c  o m*/
        MessageEndpoint endpoint = factory.createEndpoint(null);
        endpoint.beforeDelivery(target);
        try {
            log.trace("Sending endpoint message to ''{}'': prepare", target.getName());

            if (message == null) {
                target.invoke(endpoint);
            } else {
                target.invoke(endpoint, message);
            }

            log.trace("Sending endpoint message to ''{}'': sent", target.getName());
        } catch (IllegalAccessException | InvocationTargetException e) {
            log.error("Exception on message endpoint invocation", e);
        }
        endpoint.afterDelivery();
        endpoint.release();
    } catch (UnavailableException e) {
        log.error("Message endpoint is unavailable", e);
    } catch (ResourceException | NoSuchMethodException e) {
        log.error("Exception on message endpoint processing", e);
    }
}