當前位置: 首頁>>代碼示例>>Java>>正文


Java Asynchronous類代碼示例

本文整理匯總了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);
}
 
開發者ID:polarsys,項目名稱:eplmp,代碼行數:22,代碼來源:ImporterBean.java

示例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);
}
 
開發者ID:psnc-dl,項目名稱:darceo,代碼行數:25,代碼來源:PluginExecutor.java

示例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);
}
 
開發者ID:aswroma3,項目名稱:asw,代碼行數:25,代碼來源:AsynchronousHelloImpl.java

示例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);
    }
}
 
開發者ID:biblelamp,項目名稱:JavaEE,代碼行數:24,代碼來源:OrderProcessorBean.java

示例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);
    }
}
 
開發者ID:polarsys,項目名稱:eplmp,代碼行數:18,代碼來源:NotifierBean.java

示例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);
    }
}
 
開發者ID:polarsys,項目名稱:eplmp,代碼行數:18,代碼來源:NotifierBean.java

示例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);
    }
}
 
開發者ID:polarsys,項目名稱:eplmp,代碼行數:17,代碼來源:NotifierBean.java

示例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);
    }
}
 
開發者ID:polarsys,項目名稱:eplmp,代碼行數:17,代碼來源:NotifierBean.java

示例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);
    }
}
 
開發者ID:polarsys,項目名稱:eplmp,代碼行數:17,代碼來源:NotifierBean.java

示例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())));
    }
}
 
開發者ID:polarsys,項目名稱:eplmp,代碼行數:27,代碼來源:IndexerManagerBean.java

示例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();
	}
}
 
開發者ID:ccem-dev,項目名稱:otus-domain-api,代碼行數:18,代碼來源:EmailNotifierServiceBean.java

示例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);
}
 
開發者ID:hawkular,項目名稱:hawkular-apm,代碼行數:26,代碼來源:AlertsPublisher.java

示例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;
    }));

}
 
開發者ID:projectomakase,項目名稱:omakase,代碼行數:32,代碼來源:PipelineExecutor.java

示例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);
}
 
開發者ID:psnc-dl,項目名稱:darceo,代碼行數:24,代碼來源:FileFormatProcessorBean.java

示例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);
}
 
開發者ID:adoc-editor,項目名稱:editor-backend,代碼行數:24,代碼來源:AsciidoctorEndpoint.java


注:本文中的javax.ejb.Asynchronous類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。