当前位置: 首页>>代码示例>>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;未经允许,请勿转载。