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();
}
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);
}
}
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();
}
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();
}
}
}
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;
}
Aggregations