本文整理汇总了Java中javax.ejb.Asynchronous类的典型用法代码示例。如果您正苦于以下问题:Java Asynchronous类的具体用法?Java Asynchronous怎么用?Java Asynchronous使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Asynchronous类属于javax.ejb包,在下文中一共展示了Asynchronous类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: importIntoPathData
import javax.ejb.Asynchronous; //导入依赖的package包/类
@Override
@Asynchronous
@FileImport
public Future<ImportResult> importIntoPathData(String workspaceId, File file, String originalFileName, String revisionNote, boolean autoFreezeAfterUpdate, boolean permissiveUpdate) {
PathDataImporter selectedImporter = selectPathDataImporter(file);
Locale userLocale = getUserLocale(workspaceId);
Properties properties = PropertiesLoader.loadLocalizedProperties(userLocale, I18N_CONF, ImporterBean.class);
PathDataImporterResult pathDataImporterResult;
if (selectedImporter != null) {
pathDataImporterResult = selectedImporter.importFile(getUserLocale(workspaceId), workspaceId, file, autoFreezeAfterUpdate, permissiveUpdate);
} else {
List<String> errors = getNoImporterAvailableError(properties);
pathDataImporterResult = new PathDataImporterResult(file, new ArrayList<>(), errors, null, null, null);
}
ImportResult result = doPathDataImport(properties, workspaceId, revisionNote, autoFreezeAfterUpdate, permissiveUpdate, pathDataImporterResult);
return new AsyncResult<>(result);
}
示例2: execute
import javax.ejb.Asynchronous; //导入依赖的package包/类
/**
* Executes the plugin with the given name. Internal use only.
*
* @param pluginName
* plugin name
* @return execution status
*/
@Asynchronous
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public Future<Void> execute(String pluginName) {
PluginExecutor proxy = ctx.getBusinessObject(PluginExecutor.class);
boolean finished = false;
while (!ctx.wasCancelCalled() && !finished) {
finished = !proxy.executeOnce(pluginName);
if (finished) {
proxy.finishCycle(pluginName);
}
}
return new AsyncResult<Void>(null);
}
示例3: hello
import javax.ejb.Asynchronous; //导入依赖的package包/类
/** Un'operazione asincrona (che puo' essere interrotta). */
@Asynchronous
public Future<String> hello(String name) throws HelloException, InterruptedException {
String result = null;
logger.info("AsynchronousHello.hello(" + name + ") called");
if (name==null) {
throw new HelloException("Invalid parameters for hello()");
}
/* diciamo che questa operazione perde un po' di tempo e
* poi restituisce proprio il saluto desiderato */
for (int i=0; i<name.length()*10; i++) {
sleep(40);
if (ctx.wasCancelCalled()) {
logger.info("AsynchronousHello.hello(" + name + ") was cancelled");
/* credo che la cosa giusta da fare qui sia sollevare un'eccezione */
throw new InterruptedException("Operation AsynchronousHello.hello(" + name + ") was cancelled");
}
}
result = "Hello, " + name.toUpperCase() + "!";
logger.info("AsynchronousHello.hello(" + name + ") ==> " + result);
return new AsyncResult<String>(result);
}
示例4: placeOrder
import javax.ejb.Asynchronous; //导入依赖的package包/类
/**
* Places an order
*/
@Asynchronous
@Remove
@Override
public void placeOrder() {
Order order = new Order();
order.setBidder(bidder);
order.setItem(item);
order.setShipping(shipping);
order.setBilling(billing);
try {
bill(order);
notifyBillingSuccess(order);
order.setStatus(OrderStatus.COMPLETE);
} catch (BillingException be) {
notifyBillingFailure(be, order);
order.setStatus(OrderStatus.BILLING_FAILED);
} finally {
saveOrder(order);
}
}
示例5: sendPasswordRecovery
import javax.ejb.Asynchronous; //导入依赖的package包/类
@Asynchronous
@Override
public void sendPasswordRecovery(Account account, String recoveryUUID) {
LOGGER.info("Sending recovery message \n\tfor the user which login is " + account.getLogin());
Object[] args = {
getRecoveryUrl(recoveryUUID),
account.getLogin()
};
try {
sendMessage(account, "Recovery_title", "Recovery_text", args);
} catch (MessagingException pMEx) {
logMessagingException(pMEx);
}
}
示例6: sendWorkspaceDeletionNotification
import javax.ejb.Asynchronous; //导入依赖的package包/类
@Asynchronous
@Override
public void sendWorkspaceDeletionNotification(Account admin, String workspaceId) {
LOGGER.info("Sending workspace deletion notification message \n\tfor the user which login is " + admin.getLogin());
Object[] args = {
workspaceId
};
try {
User adminUser = new User(new Workspace(workspaceId), admin);
sendMessage(adminUser, "WorkspaceDeletion_title", "WorkspaceDeletion_text", args);
} catch (MessagingException pMEx) {
logMessagingException(pMEx);
}
}
示例7: sendWorkspaceDeletionErrorNotification
import javax.ejb.Asynchronous; //导入依赖的package包/类
@Asynchronous
@Override
public void sendWorkspaceDeletionErrorNotification(Account admin, String workspaceId) {
LOGGER.info("Sending workspace deletion error notification message \n\tfor the user which login is " + admin.getLogin());
Object[] args = {
workspaceId
};
try {
User adminUser = new User(new Workspace(workspaceId), admin);
sendMessage(adminUser, "WorkspaceDeletion_title", "WorkspaceDeletionError_text", args);
} catch (MessagingException pMEx) {
logMessagingException(pMEx);
}
}
示例8: sendWorkspaceIndexationSuccess
import javax.ejb.Asynchronous; //导入依赖的package包/类
@Asynchronous
@Override
public void sendWorkspaceIndexationSuccess(Account account, String workspaceId, String extraMessage) {
Object[] args = {
workspaceId,
extraMessage
};
try {
User adminUser = new User(new Workspace(workspaceId), account);
sendMessage(adminUser, "Indexer_success_title", "Indexer_success_text", args);
} catch (MessagingException pMEx) {
logMessagingException(pMEx);
}
}
示例9: sendWorkspaceIndexationFailure
import javax.ejb.Asynchronous; //导入依赖的package包/类
@Asynchronous
@Override
public void sendWorkspaceIndexationFailure(Account account, String workspaceId, String extraMessage) {
Object[] args = {
workspaceId,
extraMessage
};
try {
User adminUser = new User(new Workspace(workspaceId), account);
sendMessage(adminUser, "Indexer_failure_title", "Indexer_failure_text", args);
} catch (MessagingException pMEx) {
logMessagingException(pMEx);
}
}
示例10: indexWorkspaceData
import javax.ejb.Asynchronous; //导入依赖的package包/类
@Override
@Asynchronous
@RolesAllowed({UserGroupMapping.ADMIN_ROLE_ID, UserGroupMapping.REGULAR_USER_ROLE_ID})
public void indexWorkspaceData(String workspaceId) throws AccountNotFoundException {
Account account = accountManager.getMyAccount();
try {
// Clear workspace if exists, or recreate
doDeleteWorkspaceIndex(workspaceId);
Bulk.Builder bb = new Bulk.Builder().defaultIndex(workspaceId);
bulkWorkspaceRequestBuilder(bb, workspaceId);
BulkResult result = esClient.execute(bb.build());
if (result.isSucceeded()) {
mailer.sendBulkIndexationSuccess(account);
} else {
String failureMessage = result.getErrorMessage();
LOGGER.log(Level.SEVERE, "Failures while bulk indexing workspace [" + workspaceId + "]: \n" + failureMessage);
mailer.sendBulkIndexationFailure(account, failureMessage);
}
} catch (IOException e) {
LOGGER.log(Level.WARNING, "Cannot index the whole workspace: The Elasticsearch server does not seem to respond");
mailer.sendBulkIndexationFailure(account, getString("IndexerNotAvailableForRequest", new Locale(account.getLanguage())));
}
}
示例11: sendEmail
import javax.ejb.Asynchronous; //导入依赖的package包/类
@Override
@Asynchronous
public void sendEmail(StudioEmail email) throws EmailNotificationException {
GMailer mailer = GMailer.createTLSMailer();
mailer.setFrom(email.getFrom());
mailer.addRecipients(email.getRecipients());
mailer.setSubject(email.getSubject());
mailer.setContentType(email.getContentType());
mailer.setContent(mergeTemplate(email.getContentDataMap(), email.getTemplatePath()));
try {
mailer.send();
} catch (Exception e) {
throw new EmailNotificationException();
}
}
示例12: publish
import javax.ejb.Asynchronous; //导入依赖的package包/类
@Asynchronous
public void publish(final Event event) {
if (BASE_URL == null || BASE_URL.isEmpty()) {
logger.hawkularServerNotConfigured();
return;
}
if (USERNAME == null || USERNAME.isEmpty()) {
logger.hawkularServerUsernameNotConfigured();
return;
}
if (PASSWORD == null || PASSWORD.isEmpty()) {
logger.hawkularServerPasswordNotConfigured();
return;
}
HystrixFeign.builder()
.requestInterceptor(new BasicAuthRequestInterceptor(USERNAME, PASSWORD))
.encoder(new JacksonEncoder())
.decoder(new JacksonDecoder())
.retryer(new Retryer.Default())
.target(AlertsService.class, TARGET)
.addEvent(event);
}
示例13: executePipeline
import javax.ejb.Asynchronous; //导入依赖的package包/类
/**
* Executes a pipeline, executing each stage in turn until the pipeline completes, fails or halts while waiting for an asynchronous process to complete.
* <p>
* Only pipelines that are in their initial state can be executed, if the pipeline is not in it's initial state it is marked as failed.
* </p>
*
* @param pipeline
* the pipeline
*/
@Asynchronous
public void executePipeline(@Observes(during = TransactionPhase.AFTER_SUCCESS) Pipeline pipeline) {
Throwables.voidInstance(() -> OmakaseSecurity.doAsSystem(() -> {
if (!pipeline.isFirstPipelineStage() && !PipelineStageStatus.QUEUED.equals(pipeline.getStatusOfCurrentStage())) {
LOGGER.error("Pipeline " + pipeline.getId() + " is not in it's initial state");
updatePipeline(PipelineStageResult.builder(pipeline.getId(), PipelineStageStatus.FAILED).addMessages(ImmutableSet.of("The pipeline is not in it's initial state")).build());
}
// the first stage is executed outside of recursion as, the recursion relies on the the previous stage
// being complete before executing the next one which is not the case for the first stage.
PipelineContext pipelineContext = createPipelineContext(pipeline);
PipelineStageResult pipelineStageResult = pipelineStageExecutor.execute(pipelineContext, pipeline.getCurrentPipelineStage());
executePipelineFailureStage(pipelineStageResult);
Pipeline updatedPipeline = updatePipeline(pipelineStageResult);
// execute subsequent stages until the pipeline is halted or completed.
executePipelineStages(updatedPipeline);
return true;
}));
}
示例14: processAll
import javax.ejb.Asynchronous; //导入依赖的package包/类
@Override
@Asynchronous
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public Future<Void> processAll() {
logger.info("Format processing started");
FileFormatProcessor proxy = ctx.getBusinessObject(FileFormatProcessor.class);
int count = 0;
boolean finished = false;
while (!ctx.wasCancelCalled() && !finished) {
boolean processed = proxy.processOne();
if (processed) {
count++;
}
finished = !processed;
}
logger.info("Format processing stopped: checked {} format(s)", count);
return new AsyncResult<Void>(null);
}
示例15: convert
import javax.ejb.Asynchronous; //导入依赖的package包/类
@POST
@Path("/convert/{backend}")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.TEXT_PLAIN)
@Asynchronous
public void convert(@PathParam("backend") String backend,
String asciidocContent, @Suspended AsyncResponse response) {
Converter converter;
switch (backend) {
case "pdf":
converter = Converter.pdf;
break;
case "dzslides":
converter = Converter.dzslides;
break;
default:
converter = Converter.html5;
}
OutputMessage out = new OutputMessage(converter);
out.setContent(processor.convertToDocument(asciidocContent, converter));
response.resume(out);
}