当前位置: 首页>>代码示例>>Java>>正文


Java ChangeSet类代码示例

本文整理汇总了Java中com.gigaspaces.client.ChangeSet的典型用法代码示例。如果您正苦于以下问题:Java ChangeSet类的具体用法?Java ChangeSet怎么用?Java ChangeSet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ChangeSet类属于com.gigaspaces.client包,在下文中一共展示了ChangeSet类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addAndGet

import com.gigaspaces.client.ChangeSet; //导入依赖的package包/类
/**
 * Atomically adds the given value to the current value of an entry's property.
 * @param gigaSpace the gigaspace which stores the entry.
 * @param idQuery id the query which is used to locate the entry.
 * @param path the path to the number property which is being modified.
 * @param delta the value to add.
 * @param modifiers the change modifiers to use.
 * @param timeout time to wait if the entry is locked under a transaction.
 * @param timeUnit units for the timeout.
 * @return the updated value, null of no matching entry found for the given id query. Therefore you must use the 
 * primitive wrapper types as the result value (e.g. Integer/Long) otherwise you may get {@link NullPointerException} if no entry was found.
 */
public static <T, D extends Number> D addAndGet(GigaSpace gigaSpace,
        IdQuery<T> idQuery, String path, D delta, ChangeModifiers modifiers, long timeout, TimeUnit timeUnit) {
    if (idQuery == null)
        throw new IllegalArgumentException("query cannot be null");
    if (!StringUtils.hasLength(path))
        throw new IllegalArgumentException("path cannot be null or empty");
    
    ChangeResult<T> changeResult = gigaSpace.change(idQuery, new ChangeSet().increment(path, delta), modifiers.add(ChangeModifiers.RETURN_DETAILED_RESULTS), timeUnit.toMillis(timeout));
    
    ChangedEntryDetails<T> changedEntryDetails = getSingleChangedEntryDetails(changeResult);
    if (changedEntryDetails == null)
        return null;
        
    ChangeOperationResult changeOperationResult = changedEntryDetails.getChangeOperationsResults().get(0);
    return (D)IncrementOperation.getNewValue(changeOperationResult);
}
 
开发者ID:Gigaspaces,项目名称:xap-openspaces,代码行数:29,代码来源:ChangeExtension.java

示例2: ChangeSet

import com.gigaspaces.client.ChangeSet; //导入依赖的package包/类
public void ChangeSet() {
	User user = new User();
	user.setId(new Long(1));
	user.setName("John Dow");
	user.setStatus(EAccountStatus.ACTIVE);
	space.write(user);

	IdQuery<User> idQuery = new IdQuery<User>(User.class, new Long(1));
	ChangeResult<User> changeResult = space.change(idQuery,
			new ChangeSet().set("status", EAccountStatus.BLOCKED));

	if (changeResult.getNumberOfChangedEntries() == 0) {
		System.out.println("Entry does not exist");
	}
}
 
开发者ID:Gigaspaces,项目名称:xap-tutorial,代码行数:16,代码来源:CRUDService.java

示例3: addRule

import com.gigaspaces.client.ChangeSet; //导入依赖的package包/类
public void addRule(KnowledgePackage knowledgePackage, String ruleName, DroolsRule rule) {
	IdQuery<KnowledgePackage> idQuery = new IdQuery<KnowledgePackage>(KnowledgePackage.class, knowledgePackage.getId(), knowledgePackage.getRuleSet());
	gigaSpace.change(idQuery, new ChangeSet().set("lastUpdateDate", new Date(System.currentTimeMillis()))
											 .putInMap("rules", ruleName, rule)
											 .increment("totalRules" , 1));
}
 
开发者ID:Gigaspaces,项目名称:xap-drools-integration,代码行数:7,代码来源:KnowledgePackageDao.java

示例4: removeRule

import com.gigaspaces.client.ChangeSet; //导入依赖的package包/类
public void removeRule(KnowledgePackage knowledgePackage, String ruleName) {
	IdQuery<KnowledgePackage> idQuery = new IdQuery<KnowledgePackage>(KnowledgePackage.class, knowledgePackage.getId(), knowledgePackage.getRuleSet());
	gigaSpace.change(idQuery, new ChangeSet().removeFromMap("rules", ruleName)
											 .decrement("totalRules" , 1));
}
 
开发者ID:Gigaspaces,项目名称:xap-drools-integration,代码行数:6,代码来源:KnowledgePackageDao.java


注:本文中的com.gigaspaces.client.ChangeSet类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。