use of javax.resource.spi.endpoint.MessageEndpoint in project wildfly by wildfly.
the class TelnetResourceAdapter method endpointActivation.
@Override
public void endpointActivation(MessageEndpointFactory messageEndpointFactory, ActivationSpec activationSpec) throws ResourceException {
final TelnetActivationSpec telnetActivationSpec = (TelnetActivationSpec) activationSpec;
final MessageEndpoint messageEndpoint = messageEndpointFactory.createEndpoint(null);
// This messageEndpoint instance is also castable to the ejbClass of the MDB
final TelnetListener telnetListener = (TelnetListener) messageEndpoint;
try {
final TelnetServer telnetServer = new TelnetServer(telnetActivationSpec, telnetListener, port);
workManager.scheduleWork(new Work() {
@Override
public void release() {
}
@Override
public void run() {
try {
telnetServer.activate();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}, 0, null, null);
activated.put(port, telnetServer);
} catch (IOException e) {
throw new ResourceException(e);
}
}
use of javax.resource.spi.endpoint.MessageEndpoint in project wildfly by wildfly.
the class SimpleResourceAdapter method endpointActivation.
/**
* Send a message to the MDB right after the MDB endpoint is activated.
* Using reflection to pick a method to invoke - see EJB 3.2 spec section 5.4.3
*/
@Override
public void endpointActivation(MessageEndpointFactory messageEndpointFactory, ActivationSpec activationSpec) throws ResourceException {
log.trace("SimpleResourceAdapter activating MDB endpoint and sending a message to it");
Class<?> endpointClass = messageEndpointFactory.getEndpointClass();
try {
Method methodToInvoke = endpointClass.getMethod(((SimpleActivationSpec) activationSpec).getMethodName(), String.class);
MessageEndpoint endpoint = messageEndpointFactory.createEndpoint(null);
this.endpoint = endpoint;
methodToInvoke.invoke(endpoint, "Hello world");
} catch (Exception e) {
throw new ResourceException(e);
}
}
use of javax.resource.spi.endpoint.MessageEndpoint in project tomee by apache.
the class QuartzResourceAdapter method endpointActivation.
@Override
public void endpointActivation(final MessageEndpointFactory messageEndpointFactory, final ActivationSpec activationSpec) throws ResourceException {
final Scheduler s = scheduler.get();
if (null == s) {
throw new ResourceException("Quartz Scheduler is not available");
}
try {
final JobSpec spec = (JobSpec) activationSpec;
final MessageEndpoint endpoint = messageEndpointFactory.createEndpoint(null);
spec.setEndpoint(endpoint);
final Job job = (Job) endpoint;
final JobDataMap jobDataMap = spec.getDetail().getJobDataMap();
jobDataMap.put(Data.class.getName(), new Data(job));
s.scheduleJob(spec.getDetail(), spec.getTrigger());
} catch (final SchedulerException e) {
throw new ResourceException("Failed to schedule job", e);
}
}
use of javax.resource.spi.endpoint.MessageEndpoint in project javaee7-samples by javaee-samples.
the class WatchingThread method dispatchEvents.
private void dispatchEvents(List<WatchEvent<?>> events, MessageEndpointFactory messageEndpointFactory) {
for (WatchEvent<?> event : events) {
Path path = (Path) event.context();
try {
MessageEndpoint endpoint = messageEndpointFactory.createEndpoint(null);
Class<?> beanClass = resourceAdapter.getBeanClass(messageEndpointFactory);
for (Method m : beanClass.getMethods()) {
if (StandardWatchEventKinds.ENTRY_CREATE.equals(event.kind()) && m.isAnnotationPresent(Created.class) && path.toString().matches(m.getAnnotation(Created.class).value())) {
invoke(endpoint, m, path);
} else if (StandardWatchEventKinds.ENTRY_DELETE.equals(event.kind()) && m.isAnnotationPresent(Deleted.class) && path.toString().matches(m.getAnnotation(Deleted.class).value())) {
invoke(endpoint, m, path);
} else if (StandardWatchEventKinds.ENTRY_MODIFY.equals(event.kind()) && m.isAnnotationPresent(Modified.class) && path.toString().matches(m.getAnnotation(Modified.class).value())) {
invoke(endpoint, m, path);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
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();
}
Aggregations