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


Java Lock類代碼示例

本文整理匯總了Java中javax.ejb.Lock的典型用法代碼示例。如果您正苦於以下問題:Java Lock類的具體用法?Java Lock怎麽用?Java Lock使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Lock類屬於javax.ejb包,在下文中一共展示了Lock類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: checkout

import javax.ejb.Lock; //導入依賴的package包/類
@Lock(LockType.WRITE)
public Order checkout() {
    final Order order = new Order();
    order.getSelections().addAll(shoppingCart.getSelections());
    order.setPrice(priceCalculator.calculateTotal(order.getSelections()));

    final long id = orders.size() + 1;
    order.setId(id);
    order.setDate(LocalDateTime.now());
    order.setStatus(OrderStatus.CONFIRMED);

    shoppingCart.clear();

    orders.put(id, order);
    return order;
}
 
開發者ID:sdaschner,項目名稱:jaxrs-hypermedia,代碼行數:17,代碼來源:OrderStore.java

示例2: wasAnalyzed

import javax.ejb.Lock; //導入依賴的package包/類
@Override
   @Lock(LockType.READ)
   public boolean wasAnalyzed(HashId hashId) throws FileStoreException {
try (PreparedStatement preparedStatement = connection.prepareStatement(
	"SELECT successful FROM " + HBaseElementNames.ANALYSIS_ANALYSES_TABLE + " WHERE hashid=?")) {
    preparedStatement.setString(1, hashId.toString());
    try (ResultSet resultSet = preparedStatement.executeQuery()) {
	if (!resultSet.next()) {
	    return false;
	}
	boolean analyzed = resultSet.getBoolean(1);
	if (resultSet.next()) {
	    throw new FileStoreException(
		    "Could not check for successful analysis due to multiple restuls for '" + hashId + "'.");
	}
	return analyzed;
    }
} catch (SQLException e) {
    throw new FileStoreException("Could not read analysis status.", e);
}
   }
 
開發者ID:PureSolTechnologies,項目名稱:Purifinity,代碼行數:22,代碼來源:FileStoreBean.java

示例3: refreshCache

import javax.ejb.Lock; //導入依賴的package包/類
@Schedule(minute = "*/10")
@Lock(LockType.WRITE)
public void refreshCache() {
    cache = new HashMap<>();
    for (ConfigurationSetting configurationSetting : getAllConfigurationSettings()) {
        addToCache(configurationSetting);
    }
}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:9,代碼來源:ConfigurationServiceBean.java

示例4: setConfigurationSetting

import javax.ejb.Lock; //導入依賴的package包/類
@Override
@Lock(LockType.WRITE)
public void setConfigurationSetting(String informationId, String value) {
    ConfigurationSetting configSetting = new ConfigurationSetting(
            ConfigurationKey.valueOf(informationId),
            Configuration.GLOBAL_CONTEXT, value);
    setConfigurationSetting(configSetting);
}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:9,代碼來源:ConfigurationServiceBean.java

示例5: runTasks

import javax.ejb.Lock; //導入依賴的package包/類
@Lock(LockType.WRITE)
public void runTasks() {
    if (!busy) {
        busy = true;
        try {
            if (taskAppService.getRunningFlag()) {
                queueTasks();
            }
            checkThreads();
        } finally {
            busy = false;
        }
    }
}
 
開發者ID:jmd-stuff,項目名稱:task-app,代碼行數:15,代碼來源:TaskRunner.java

示例6: itemEvents

import javax.ejb.Lock; //導入依賴的package包/類
@GET
@Lock(READ)
@Produces(MediaType.SERVER_SENT_EVENTS)
public void itemEvents(@HeaderParam(HttpHeaders.LAST_EVENT_ID_HEADER)
                       @DefaultValue("-1") int lastEventId,
                       @Context SseEventSink eventSink) {

    if (lastEventId >= 0)
        replayLastMessages(lastEventId, eventSink);

    sseBroadcaster.register(eventSink);
}
 
開發者ID:PacktPublishing,項目名稱:Architecting-Modern-Java-EE-Applications,代碼行數:13,代碼來源:EventsResource.java

示例7: onEvent

import javax.ejb.Lock; //導入依賴的package包/類
@Lock(WRITE)
public void onEvent(@Observes DomainEvent domainEvent) {
    String message = domainEvent.getContents();
    messages.add(message);

    OutboundSseEvent event = createEvent(message, ++lastEventId);

    sseBroadcaster.broadcast(event);
}
 
開發者ID:PacktPublishing,項目名稱:Architecting-Modern-Java-EE-Applications,代碼行數:10,代碼來源:EventsResource.java

示例8: produce

import javax.ejb.Lock; //導入依賴的package包/類
@Lock(LockType.READ)
@Produces
@ApplicationScoped
public JestClient produce() {
    LOGGER.log(Level.INFO, "Producing ElasticSearch rest client");
    return client;
}
 
開發者ID:polarsys,項目名稱:eplmp,代碼行數:8,代碼來源:IndexerClientProducer.java

示例9: addBookSelection

import javax.ejb.Lock; //導入依賴的package包/類
@Lock(LockType.WRITE)
public void addBookSelection(BookSelection selection) {
    final Optional<BookSelection> existentSelection = selections.stream().filter(s -> s.getBook().equals(selection.getBook())).findFirst();

    if (existentSelection.isPresent()) {
        final BookSelection bookSelection = existentSelection.get();
        bookSelection.setQuantity(bookSelection.getQuantity() + selection.getQuantity());
        updatePrice(bookSelection);
    } else {
        updatePrice(selection);
        selections.add(selection);
        selection.setId(nextSelectionId++);
    }
}
 
開發者ID:sdaschner,項目名稱:jaxrs-hypermedia,代碼行數:15,代碼來源:ShoppingCart.java

示例10: updateBookSelection

import javax.ejb.Lock; //導入依賴的package包/類
@Lock(LockType.WRITE)
public void updateBookSelection(long selectionId, int quantity) {
    final BookSelection selection = selections.stream()
            .filter(s -> s.getId() == selectionId).findFirst()
            .orElseThrow(() -> new IllegalArgumentException("No selection found"));

    selection.setQuantity(quantity);
    updatePrice(selection);

    if (quantity == 0)
        selections.remove(selection);
}
 
開發者ID:sdaschner,項目名稱:jaxrs-hypermedia,代碼行數:13,代碼來源:ShoppingCart.java

示例11: getOrders

import javax.ejb.Lock; //導入依賴的package包/類
@Lock(LockType.READ)
public List<Order> getOrders() {
    final ArrayList<Order> orders = new ArrayList<>(this.orders.values());
    orders.sort(Comparator.comparing(Order::getId));

    return orders;
}
 
開發者ID:sdaschner,項目名稱:jaxrs-hypermedia,代碼行數:8,代碼來源:OrderStore.java

示例12: registerService

import javax.ejb.Lock; //導入依賴的package包/類
@Override
   @Lock(LockType.WRITE)
   public void registerService(PluginInformation pluginInformation, String jndiName,
    EvaluatorServiceInformation serviceInformation) {
super.registerService(pluginInformation, jndiName, serviceInformation);
addInformationToDatabase(pluginInformation, serviceInformation);
   }
 
開發者ID:PureSolTechnologies,項目名稱:Purifinity,代碼行數:8,代碼來源:EvaluatorServiceManagerImpl.java

示例13: createProxy

import javax.ejb.Lock; //導入依賴的package包/類
@Override
   @Lock(LockType.READ)
   public Evaluator createProxy(String jndi) {
Evaluator evaluator = JndiUtils.createRemoteEJBInstance(Evaluator.class, jndi);
EvaluatorInformation information = evaluator.getInformation();
for (ConfigurationParameter<?> configurationParameter : evaluator.getConfigurationParameters()) {
    PreferencesValue<?> value = preferencesStore.getPluginDefaultPreference(information.getId(),
	    configurationParameter);
    if (value != null) {
	evaluator.setConfigurationParameter(configurationParameter, value.getValue());
    }
}
return evaluator;
   }
 
開發者ID:PureSolTechnologies,項目名稱:Purifinity,代碼行數:15,代碼來源:EvaluatorServiceManagerImpl.java

示例14: getEvaluatorPluginInformation

import javax.ejb.Lock; //導入依賴的package包/類
@Override
   @Lock(LockType.READ)
   public EvaluatorServiceInformation getEvaluatorPluginInformation(String evaluatorId) {
for (EvaluatorServiceInformation evaluator : getServices()) {
    if (evaluator.getId().equals(evaluatorId)) {
	return evaluator;
    }
}
return null;
   }
 
開發者ID:PureSolTechnologies,項目名稱:Purifinity,代碼行數:11,代碼來源:EvaluatorServiceManagerImpl.java

示例15: createProxy

import javax.ejb.Lock; //導入依賴的package包/類
@Override
   @Lock(LockType.READ)
   public Repository createProxy(String jndi) {
Repository repository = JndiUtils.createRemoteEJBInstance(Repository.class, jndi);
String repositoryName = repository.getName();
RepositoryServiceInformation information = findByName(repositoryName);
for (ConfigurationParameter<?> configurationParameter : repository.getConfigurationParameters()) {
    PreferencesValue<?> value = preferencesStore.getPluginDefaultPreference(information.getId(),
	    configurationParameter);
    if (value != null) {
	repository.setConfigurationParameter(configurationParameter, value.getValue());
    }
}
return repository;
   }
 
開發者ID:PureSolTechnologies,項目名稱:Purifinity,代碼行數:16,代碼來源:RepositoryServiceManagerImpl.java


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