Java 类javax.ejb.LockType 实例源码
项目:jaxrs-hypermedia
文件:OrderStore.java
@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;
}
项目:jaxrs-hypermedia
文件:OrderStore.java
@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;
}
项目:Purifinity
文件:FileStoreBean.java
@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);
}
}
项目:oscm
文件:ConfigurationServiceBean.java
@Schedule(minute = "*/10")
@Lock(LockType.WRITE)
public void refreshCache() {
cache = new HashMap<>();
for (ConfigurationSetting configurationSetting : getAllConfigurationSettings()) {
addToCache(configurationSetting);
}
}
项目:oscm
文件:ConfigurationServiceBean.java
@Override
@Lock(LockType.WRITE)
public void setConfigurationSetting(String informationId, String value) {
ConfigurationSetting configSetting = new ConfigurationSetting(
ConfigurationKey.valueOf(informationId),
Configuration.GLOBAL_CONTEXT, value);
setConfigurationSetting(configSetting);
}
项目:task-app
文件:TaskRunner.java
@Lock(LockType.WRITE)
public void runTasks() {
if (!busy) {
busy = true;
try {
if (taskAppService.getRunningFlag()) {
queueTasks();
}
checkThreads();
} finally {
busy = false;
}
}
}
项目:eplmp
文件:IndexerClientProducer.java
@Lock(LockType.READ)
@Produces
@ApplicationScoped
public JestClient produce() {
LOGGER.log(Level.INFO, "Producing ElasticSearch rest client");
return client;
}
项目:jaxrs-hypermedia
文件:ShoppingCart.java
@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++);
}
}
项目:jaxrs-hypermedia
文件:ShoppingCart.java
@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);
}
项目:jaxrs-hypermedia
文件:OrderStore.java
@Lock(LockType.READ)
public List<Order> getOrders() {
final ArrayList<Order> orders = new ArrayList<>(this.orders.values());
orders.sort(Comparator.comparing(Order::getId));
return orders;
}
项目:jaxrs-hypermedia
文件:ShoppingCart.java
@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++);
}
}
项目:jaxrs-hypermedia
文件:ShoppingCart.java
@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);
}
项目:jaxrs-hypermedia
文件:ShoppingCart.java
@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++);
}
}
项目:jaxrs-hypermedia
文件:ShoppingCart.java
@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);
}
项目:jaxrs-hypermedia
文件:OrderStore.java
@Lock(LockType.READ)
public List<Order> getOrders() {
final ArrayList<Order> orders = new ArrayList<>(this.orders.values());
orders.sort(Comparator.comparing(Order::getId));
return orders;
}
项目:Purifinity
文件:EvaluatorServiceManagerImpl.java
@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;
}
项目:Purifinity
文件:EvaluatorServiceManagerImpl.java
@Override
@Lock(LockType.READ)
public EvaluatorServiceInformation getEvaluatorPluginInformation(String evaluatorId) {
for (EvaluatorServiceInformation evaluator : getServices()) {
if (evaluator.getId().equals(evaluatorId)) {
return evaluator;
}
}
return null;
}
项目:Purifinity
文件:EvaluatorServiceManagerImpl.java
@Override
@Lock(LockType.READ)
public boolean isActive(String evaluatorId) {
Boolean active = analyzerActivations.get(evaluatorId);
if (active != null) {
return active;
}
active = preferencesStore.isServiceActive(evaluatorId);
analyzerActivations.put(evaluatorId, active);
return active;
}
项目:Purifinity
文件:EvaluatorServiceManagerImpl.java
@Override
@Lock(LockType.READ)
public Evaluator getInstanceById(String evaluatorId) {
for (EvaluatorServiceInformation evaluator : getServices()) {
if (evaluator.getId().equals(evaluatorId)) {
return createProxy(evaluator.getJndiName());
}
}
return null;
}
项目:Purifinity
文件:RepositoryServiceManagerImpl.java
@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;
}
项目:Purifinity
文件:RepositoryServiceManagerImpl.java
@Override
@Lock(LockType.READ)
public Repository getInstanceById(String analyzerId) {
for (RepositoryServiceInformation repository : getServices()) {
if (repository.getId().equals(analyzerId)) {
return createProxy(repository.getJndiName());
}
}
return null;
}
项目:Purifinity
文件:RepositoryServiceManagerImpl.java
@Override
@Lock(LockType.READ)
public RepositoryLocation createFromSerialization(Properties repositoryLocation) {
String repositoryId = repositoryLocation.getProperty(RepositoryManager.REPOSITORY_ID_PROPERTY);
Repository instance = getInstanceById(repositoryId);
return new RepositoryLocation() {
private static final long serialVersionUID = 1084534331267078708L;
@Override
public List<SourceCodeLocation> getSourceCodes(FileSearchConfiguration fileSearchConfiguration) {
return instance.getSourceCodes(repositoryLocation, fileSearchConfiguration);
}
@Override
public Properties getSerialization() {
return repositoryLocation;
}
@Override
public String getName() {
return instance.getName();
}
@Override
public String getHumanReadableLocationString() {
return instance.getHumanReadableLocationString(repositoryLocation);
}
};
}
项目:Purifinity
文件:AnalyzerServiceManagerImpl.java
@Override
@Lock(LockType.READ)
public ProgrammingLanguageAnalyzer createProxy(String jndi) {
ProgrammingLanguageAnalyzer analyzer = JndiUtils.createRemoteEJBInstance(ProgrammingLanguageAnalyzer.class,
jndi);
AnalyzerServiceInformation information = findByName(analyzer.getName(), analyzer.getVersion());
for (ConfigurationParameter<?> configurationParameter : analyzer.getConfigurationParameters()) {
PreferencesValue<?> value = preferencesStore.getPluginDefaultPreference(information.getId(),
configurationParameter);
if (value != null) {
analyzer.setConfigurationParameter(configurationParameter, value.getValue());
}
}
return analyzer;
}
项目:Purifinity
文件:AnalyzerServiceManagerImpl.java
@Override
@Lock(LockType.READ)
public AnalyzerServiceInformation findByName(String languageName, String languageVersion) {
for (AnalyzerServiceInformation analyzerServiceInformation : getServices()) {
if (analyzerServiceInformation.getName().equals(languageName)
&& analyzerServiceInformation.getVersion().equals(languageVersion)) {
return analyzerServiceInformation;
}
}
return null;
}
项目:Purifinity
文件:AnalyzerServiceManagerImpl.java
@Override
@Lock(LockType.READ)
public boolean isActive(String analyzerId) {
Boolean active = analyzerActivations.get(analyzerId);
if (active != null) {
return active;
}
active = preferencesStore.isServiceActive(analyzerId);
analyzerActivations.put(analyzerId, active);
return active;
}
项目:Purifinity
文件:AnalyzerServiceManagerImpl.java
@Override
@Lock(LockType.READ)
public ProgrammingLanguageAnalyzer getInstanceById(String analyzerId) {
for (AnalyzerServiceInformation analyzer : getServices()) {
if (analyzer.getId().equals(analyzerId)) {
return createProxy(analyzer.getJndiName());
}
}
return null;
}
项目:Purifinity
文件:FileStoreBean.java
@Override
@Lock(LockType.READ)
public InputStream readRawFile(HashId hashId) throws FileStoreException {
try {
return bloob.readRawFile(hashId);
} catch (IOException e) {
throw new FileStoreException(e);
}
}
项目:Purifinity
文件:AbstractServiceManager.java
@Override
@Lock(LockType.WRITE)
public void registerService(PluginInformation pluginInformation,
String jndiName, ServiceInfo serviceInformation) {
logger.info("Register new service '" + jndiName + "' from plugin '"
+ pluginInformation.getName() + "'.");
services.put(jndiName, serviceInformation);
plugins.put(jndiName, pluginInformation);
logger.info("New service '" + jndiName + "' registered.");
}
项目:Purifinity
文件:AbstractServiceManager.java
/**
* This method returns a list of all plugins which provide services which
* are registered already.
*
* @return A {@link Collection} of {@link PluginInformation} is returned.
*/
@Override
@Lock(LockType.READ)
public Collection<PluginInformation> getPlugins() {
Set<PluginInformation> plugins = new HashSet<>();
plugins.addAll(this.plugins.values());
return plugins;
}
项目:oscm
文件:TenantConfigurationBean.java
@Schedule(minute = "*/10")
@Lock(LockType.WRITE)
public void refreshCache() {
tenantSettings = getAllSettings();
}
项目:oscm
文件:ConfigurationServiceBean.java
@Override
@TransactionAttribute(TransactionAttributeType.MANDATORY)
@Lock(LockType.WRITE)
public void setConfigurationSetting(ConfigurationSetting configSetting) {
ConfigurationSetting setting = getConfigurationSettingExactMatch(
configSetting.getInformationId(), configSetting.getContextId());
if (!isEmpty(configSetting.getValue())) {
// check the type and trim the string if necessary
String value = configSetting.getValue();
if (configSetting.getInformationId()
.getType() == ConfigurationKey.TYPE_BOOLEAN
|| configSetting.getInformationId()
.getType() == ConfigurationKey.TYPE_LONG
|| configSetting.getInformationId()
.getType() == ConfigurationKey.TYPE_URL
|| configSetting.getInformationId()
.getType() == ConfigurationKey.TYPE_STRING
|| configSetting.getInformationId()
.getType() == ConfigurationKey.TYPE_PASSWORD) {
value = value.trim();
}
// if the value is not empty, update or create the setting
if (setting != null) {
// if entry is already present, update it
setting.setValue(value);
} else {
// if not, create a new one
try {
configSetting.setValue(value);
dm.persist(configSetting);
} catch (NonUniqueBusinessKeyException e) {
logger.logError(Log4jLogger.SYSTEM_LOG, e,
LogMessageIdentifier.ERROR_PERSIST_CONFIGURATION_SETTING);
}
}
} else {
// remove optional empty settings so that the default value can be
// used again
if (setting != null) {
dm.remove(setting);
}
}
refreshCache();
}
项目:testing_security_development_enterprise_systems
文件:SingletonExample02.java
@Lock(LockType.READ)
@Override
public void incrementCounter() {
x = x + 1;
}
项目:task-app
文件:TaskRunner.java
@Lock(LockType.READ)
public boolean isBusy() {
return busy;
}
项目:Architecting-Modern-Java-EE-Applications
文件:CarStorage.java
@Lock(LockType.READ)
public Car retrieve(String id) {
return cars.get(id);
}
项目:Architecting-Modern-Java-EE-Applications
文件:CarStorage.java
@Lock(LockType.READ)
public Car retrieve(String id) {
return cars.get(id);
}
项目:jaxrs-hypermedia
文件:ShoppingCart.java
@Lock(LockType.WRITE)
public void clear() {
selections.clear();
}
项目:jaxrs-hypermedia
文件:ShoppingCart.java
@Lock(LockType.READ)
public Set<BookSelection> getSelections() {
return Collections.unmodifiableSet(selections);
}
项目:jaxrs-hypermedia
文件:ShoppingCart.java
@Lock(LockType.READ)
public BookSelection getSelection(final long selectionId) {
return selections.stream().filter(s -> s.getId() == selectionId).findFirst().orElse(null);
}
项目:jaxrs-hypermedia
文件:OrderStore.java
@Lock(LockType.READ)
public Order getOrder(long id) {
return orders.get(id);
}
项目:jaxrs-hypermedia
文件:ShoppingCart.java
@Lock(LockType.WRITE)
public void clear() {
selections.clear();
}