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 tomee by apache.
the class SampleResourceAdapter method endpointActivation.
public void endpointActivation(final MessageEndpointFactory messageEndpointFactory, final ActivationSpec activationSpec) throws ResourceException {
final SampleActivationSpec sampleActivationSpec = (SampleActivationSpec) activationSpec;
try {
final MessageEndpoint messageEndpoint = messageEndpointFactory.createEndpoint(null);
final EndpointTarget target = new EndpointTarget(messageEndpoint);
targets.put(sampleActivationSpec, target);
} catch (Exception e) {
e.printStackTrace();
}
}
use of javax.resource.spi.endpoint.MessageEndpoint in project tomee by apache.
the class EndpointFactory method createEndpoint.
@Override
public MessageEndpoint createEndpoint(final XAResource xaResource, final long timeout) throws UnavailableException {
if (timeout <= 0) {
return createEndpoint(xaResource);
}
final long end = System.currentTimeMillis() + timeout;
MessageEndpoint messageEndpoint = null;
while (System.currentTimeMillis() <= end) {
try {
messageEndpoint = createEndpoint(xaResource);
break;
} catch (final Exception ex) {
// ignore so we can keep trying
}
}
if (messageEndpoint != null) {
return messageEndpoint;
} else {
throw new UnavailableException("Unable to create end point within the specified timeout " + timeout);
}
}
use of javax.resource.spi.endpoint.MessageEndpoint in project tomee by apache.
the class SampleResourceAdapter method endpointActivation.
public void endpointActivation(final MessageEndpointFactory messageEndpointFactory, final ActivationSpec activationSpec) throws ResourceException {
final SampleActivationSpec sampleActivationSpec = (SampleActivationSpec) activationSpec;
try {
final MessageEndpoint messageEndpoint = messageEndpointFactory.createEndpoint(null);
final EndpointTarget target = new EndpointTarget(messageEndpoint);
targets.put(sampleActivationSpec, target);
} catch (Exception e) {
e.printStackTrace();
}
}
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();
}
}
}
Aggregations