Example usage for javax.resource.spi.endpoint MessageEndpointFactory getEndpointClass

List of usage examples for javax.resource.spi.endpoint MessageEndpointFactory getEndpointClass

Introduction

In this page you can find the example usage for javax.resource.spi.endpoint MessageEndpointFactory getEndpointClass.

Prototype

public Class<?> getEndpointClass();

Source Link

Document

Return the Class object corresponding to the message endpoint class.

Usage

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

@Override
public void endpointDeactivation(MessageEndpointFactory endpointFactory, ActivationSpec spec) {
    log.info("Endpoint deactivation request received for class {0}",
            endpointFactory.getEndpointClass().getCanonicalName());
    if (!this.running.get()) {
        log.error("Endpoint deactivation called on disabled resource adapter");
        return;//from   w  w  w .  j a  va2 s.co m
    }
    if (!(spec instanceof TCPActivationSpec)) {
        log.error("Endpoint deactivation called with invalid ActivationSpec type");
    } else {
        log.info("Endpoint deactivation for class {0}", endpointFactory.getEndpointClass().getCanonicalName());
        this.deactivateTCP(endpointFactory, (TCPActivationSpec) spec);
        log.info("Endpoint deactivated for class {0}", endpointFactory.getEndpointClass().getCanonicalName());
    }
}

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

@Override
public void endpointActivation(MessageEndpointFactory endpointFactory, ActivationSpec spec)
        throws ResourceException {
    log.info("Endpoint activation request received for class {0}",
            endpointFactory.getEndpointClass().getCanonicalName());
    if (!this.running.get()) {
        throw new ResourceException("This resource adapter is stopped");
    }// ww  w .j a v a 2s  .c om
    if (!(spec instanceof TCPActivationSpec)) {
        throw new NotSupportedException(
                "Activation spec supplied has unsupported type " + spec.getClass().getCanonicalName());
    } else {
        log.info("Endpoint activation for class {0}", endpointFactory.getEndpointClass().getCanonicalName());
        this.activateTCP(endpointFactory, (TCPActivationSpec) spec);
        log.info("Endpoint activated for class {0}", endpointFactory.getEndpointClass().getCanonicalName());
    }
}

From source file:org.tomitribe.chatterbox.slack.adapter.SlackResourceAdapter.java

public void endpointActivation(final MessageEndpointFactory messageEndpointFactory,
        final ActivationSpec activationSpec) throws ResourceException {
    final SlackActivationSpec slackActivationSpec = (SlackActivationSpec) activationSpec;

    workManager.scheduleWork(new Work() {

        @Override//from  w  w  w. ja va 2s  . com
        public void run() {
            try {
                final MessageEndpoint messageEndpoint = messageEndpointFactory.createEndpoint(null);

                final EndpointTarget target = new EndpointTarget(messageEndpoint);
                final Class<?> endpointClass = slackActivationSpec.getBeanClass() != null
                        ? slackActivationSpec.getBeanClass()
                        : messageEndpointFactory.getEndpointClass();

                target.commands.addAll(Commands.get(endpointClass, target, null).values());

                for (Cmd cmd : target.commands) {
                    main.add(cmd);
                }

                targets.put(slackActivationSpec, target);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        @Override
        public void release() {
        }

    });

}