本文整理汇总了Java中net.sf.ehcache.search.Attribute类的典型用法代码示例。如果您正苦于以下问题:Java Attribute类的具体用法?Java Attribute怎么用?Java Attribute使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Attribute类属于net.sf.ehcache.search包,在下文中一共展示了Attribute类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: lookup
import net.sf.ehcache.search.Attribute; //导入依赖的package包/类
/**
* Use the Ehcache provided search API to perform criteria queries on defined search attributes.
* NOTE: Requires search attributes to be previously defined in Ehcache config!
* DEPRECATED because at observed large cache quantities the search noticeably slows down the system
* @param params the search parameters as key/value pairs
* @return the first found cache hit
*/
@Deprecated
@SuppressWarnings("unchecked")
public VALUE lookup(Map<String, String> params) {
Query q = cache.createQuery();
for (Map.Entry<String, String> param : params.entrySet()) {
Attribute<String> theAttribute = ((Ehcache) cache).getSearchAttribute(param.getKey());
q.addCriteria(theAttribute.eq(param.getValue()));
}
q.includeKeys().includeValues();
Results results = q.execute();
if (results == null || results.size() == 0) {
return null;
}
if (results.size() > 1) {
log.warn("There are multiple entries registered for params: {}", params.toString());
}
return (VALUE) results.all().get(0).getValue();
}
开发者ID:RWTH-i5-IDSG,项目名称:xsharing-services-router,代码行数:31,代码来源:EhCacheWrapper.java
示例2: getByDeviceClassId
import net.sf.ehcache.search.Attribute; //导入依赖的package包/类
@Override
public List<Device> getByDeviceClassId(Long deviceClassId) {
List<Device> deviceCacheObjects = new ArrayList<>();
Results results = null;
try {
Query query = getCache().createQuery();
Attribute<Long> id = getCache().getSearchAttribute("deviceClassId");
results = query.includeKeys().includeValues().addCriteria(id.eq(deviceClassId)).execute();
if (results.size() == 0) {
throw new CacheElementNotFoundException("Failed to get device ids from cache");
}
results.all().forEach((result) -> deviceCacheObjects.add((DeviceCacheObject) result.getValue()));
} finally {
if (results != null) {
results.discard();
}
}
return deviceCacheObjects;
}
开发者ID:c2mon,项目名称:c2mon,代码行数:25,代码来源:DeviceCacheImpl.java
示例3: init
import net.sf.ehcache.search.Attribute; //导入依赖的package包/类
protected void init() {
super.init();
if(!initialized) {
synchronized (this) {
if(!initialized){
if(delegatedCache == null)
throw new CacheException("Delegated cache does not exist...");
final Attribute<Integer> partitionSearchAttribute = delegatedCache.getSearchAttribute(PROPNAME_PARTITIONID);
if(null == partitionSearchAttribute)
throw new CacheException("Delegated cache should have a searchable attribute named " + PROPNAME_PARTITIONID);
//schedule the timer pool to execute a cache search every 5 seconds...which in turn will execute the cache sync operations
cacheTimerService.scheduleAtFixedRate(new TimedRefreshSyncOp(partitionSearchAttribute, this.partitionId), 0L, refreshInterval, refreshIntervalUnit);
initialized = true;
}
}
}
}
开发者ID:lanimall,项目名称:ehcache-extensions,代码行数:21,代码来源:CacheFailoverDecorator.java
示例4: getDomainRole
import net.sf.ehcache.search.Attribute; //导入依赖的package包/类
@Override
public DomainRoleEntry getDomainRole(String uid, Role role) {
Cache cache = getCache(CacheId.DOMAIN_ROLES);
Attribute<String> uidAttribute = cache.getSearchAttribute(UserRoleKey.USER_ID);
Attribute<Role> roleAttribute = cache.getSearchAttribute(UserRoleKey.ROLE);
// query is the fastest if you search for keys and if you need value then call Cache.get(key)
Query queryRequestedUid = cache.createQuery()
.addCriteria(uidAttribute.eq(uid))
.addCriteria(roleAttribute.eq(role))
.includeKeys()
.end();
Results results = queryRequestedUid.execute();
DomainRoleEntry domainRole = null;
if (!results.all().isEmpty()) {
// Note: since (uid, role) is the primary key in domain role table
// results is either empty or contains exactly one entry
assert (results.all().size() == 1);
domainRole = (DomainAccessControlStoreEhCache.<DomainRoleEntry> getElementValue(cache.get(results.all()
.get(0)
.getKey())));
}
return domainRole;
}
开发者ID:bmwcarit,项目名称:joynr,代码行数:25,代码来源:DomainAccessControlStoreEhCache.java
示例5: getAces
import net.sf.ehcache.search.Attribute; //导入依赖的package包/类
private <T extends ControlEntry> List<T> getAces(String uid, CacheId cacheId) {
Cache cache = getCache(cacheId);
List<T> aces = new ArrayList<T>();
// here search on uid take place
Attribute<String> uidAttribute = cache.getSearchAttribute(UserDomainInterfaceOperationKey.USER_ID);
// query is the fastest if you search for keys and if you need value then call Cache.get(key)
Query queryRequestedUid = cache.createQuery().addCriteria(uidAttribute.eq(uid).or(uidAttribute.eq(WILDCARD)))
// have specific user ids appear before wildcards
.addOrderBy(uidAttribute, Direction.DESCENDING)
.includeKeys()
.end();
Results results = queryRequestedUid.execute();
for (Result result : results.all()) {
aces.add(DomainAccessControlStoreEhCache.<T> getElementValue(cache.get(result.getKey())));
}
return aces;
}
开发者ID:bmwcarit,项目名称:joynr,代码行数:19,代码来源:DomainAccessControlStoreEhCache.java
示例6: getDeviceClassIdByName
import net.sf.ehcache.search.Attribute; //导入依赖的package包/类
@Override
public Long getDeviceClassIdByName(String deviceClassName) {
Long deviceClassId;
if (deviceClassName == null || deviceClassName.equalsIgnoreCase("")) {
throw new IllegalArgumentException("Attempting to retrieve a DeviceClass from the cache with a NULL or empty name parameter.");
}
Results results = null;
try {
Attribute<String> className = getCache().getSearchAttribute("deviceClassName");
Query query = getCache().createQuery();
results = query.includeKeys().addCriteria(className.eq(deviceClassName)).maxResults(1).execute();
if (results.size() == 0) {
throw new CacheElementNotFoundException("Failed to find a device class with name " + deviceClassName + " in the cache.");
}
deviceClassId = (long) results.all().get(0).getKey();
} finally {
if (results != null) {
results.discard();
}
}
return deviceClassId;
}
开发者ID:c2mon,项目名称:c2mon,代码行数:28,代码来源:DeviceClassCacheImpl.java
示例7: hasTagWithName
import net.sf.ehcache.search.Attribute; //导入依赖的package包/类
@Override
public boolean hasTagWithName(String name) {
if (name == null || name.equalsIgnoreCase("")) {
throw new IllegalArgumentException("Attempting to retrieve a Tag from the cache with a NULL or empty name parameter.");
}
// This will prevent wildcard searches
if (name.contains("*")) {
name = name.replace("*", "\\*");
}
if (name.contains("?")) {
name = name.replace("?", "\\?");
}
Results results = null;
try {
Ehcache ehcache = getCache();
Attribute<String> tagName = ehcache.getSearchAttribute("tagName");
Query query = ehcache.createQuery();
results = query.includeKeys().addCriteria(tagName.ilike(name)).maxResults(1).execute();
return results.hasKeys();
}
finally {
if (results != null) {
// Discard the results when done to free up cache resources.
results.discard();
}
}
}
开发者ID:c2mon,项目名称:c2mon,代码行数:34,代码来源:AbstractTagCache.java
示例8: findAlarm
import net.sf.ehcache.search.Attribute; //导入依赖的package包/类
@Override
public Collection<Long> findAlarm(AlarmQuery query) {
Ehcache ehcache = getCache();
ArrayList<Long> result = new ArrayList<Long>();
Query cacheQuery = ehcache.createQuery();
if (query.getFaultCode() != 0) {
Attribute<Integer> fc = ehcache.getSearchAttribute("faultCode");
cacheQuery.addCriteria(fc.eq(query.getFaultCode()));
}
if (query.getFaultFamily() != null && !"".equals(query.getFaultFamily())) {
Attribute<String> ff = ehcache.getSearchAttribute("faultFamily");
cacheQuery.addCriteria(ff.ilike(query.getFaultFamily()));
}
if (query.getFaultMember() != null && !"".equals(query.getFaultMember())) {
Attribute<String> fm = ehcache.getSearchAttribute("faultMember");
cacheQuery.addCriteria(fm.ilike(query.getFaultMember()));
}
if (query.getPriority() != 0) {
Attribute<Integer> prio = ehcache.getSearchAttribute("priority");
cacheQuery.addCriteria(prio.eq(query.getPriority()));
}
if (query.getActive() != null) {
Attribute<Boolean> active = ehcache.getSearchAttribute("isActive");
cacheQuery.addCriteria(active.eq(query.getActive()));
}
for (Result res: cacheQuery.maxResults(query.getMaxResultSize()).includeKeys().execute().all()) {
result.add((Long) res.getKey());
}
return result;
}
开发者ID:c2mon,项目名称:c2mon,代码行数:36,代码来源:AlarmCacheImpl.java
示例9: getDataTagIds
import net.sf.ehcache.search.Attribute; //导入依赖的package包/类
/**
* Receives a list of all DataTag ids which are attached to the given equipment or sub-equipment.
* @param id The id of the (sub-)equipment
* @param searchAttribute The ehcache search attribute, which is specified in the wrapper method
* @return A list of all DataTag ids belonging to the given (sub-)equipment
*/
private List<Long> getDataTagIds(Long id, String searchAttribute) {
List<Long> tagIds = new LinkedList<>();
Results results = null;
if (id == null) {
throw new IllegalArgumentException("Attempting to retrieve a List of DataTag ids from the cache with a NULL " +
"parameter.");
}
try {
Attribute<Long> cacheEquipmentId = getCache().getSearchAttribute(searchAttribute);
results = getCache().createQuery().includeKeys().addCriteria(cacheEquipmentId.eq(id)).execute();
if (results == null) {
throw new CacheElementNotFoundException("Failed to execute query with (sub)EquipmentId " + id + " : " +
"Result is null.");
}
results.all().forEach(r -> tagIds.add((Long) r.getKey()));
} finally {
if (results != null) {
// Discard the results when done to free up cache resources.
results.discard();
}
}
return tagIds;
}
开发者ID:c2mon,项目名称:c2mon,代码行数:35,代码来源:DataTagCacheImpl.java
示例10: getProcessId
import net.sf.ehcache.search.Attribute; //导入依赖的package包/类
@Override
public Long getProcessId(final String name) {
Long processKey = null;
Results results = null;
if (name == null || name.equalsIgnoreCase("")) {
throw new IllegalArgumentException("Attempting to retrieve a Process from the cache with a NULL or empty name parameter.");
}
try {
Attribute<String> processName = getCache().getSearchAttribute("processName");
// By limiting the query result list to 1 it is up to the administrator to
// make
// sure that the process name is unique. Otherwise this will result in an
// unpredictable behaviour.
Query query = getCache().createQuery();
results = query.includeKeys().addCriteria(processName.eq(name)).maxResults(1).execute();
// Find the number of results -- the number of hits.
int size = results.size();
if (size == 0) {
throw new CacheElementNotFoundException("Failed to find a process with name " + name + " in the cache.");
}
processKey = (Long) results.all().get(0).getKey();
}
finally {
if (results != null) {
// Discard the results when done to free up cache resources.
results.discard();
}
}
return processKey;
}
开发者ID:c2mon,项目名称:c2mon,代码行数:36,代码来源:ProcessCacheImpl.java
示例11: getCommandTagId
import net.sf.ehcache.search.Attribute; //导入依赖的package包/类
@Override
public Long getCommandTagId(final String name) {
Long commandTagKey = null;
Results results = null;
if (name == null || name.equalsIgnoreCase("")) {
throw new IllegalArgumentException("Attempting to retrieve a CommandTag from the cache with a NULL or empty name parameter.");
}
try {
Attribute<String> commandTagName = getCache().getSearchAttribute("commandTagName");
Query query = getCache().createQuery();
results = query.includeKeys().addCriteria(commandTagName.eq(name)).maxResults(1).execute();
// Find the number of results -- the number of hits.
int size = results.size();
if (size == 0) {
log.info("Failed to find a command tag with name " + name + " in the cache.");
}
commandTagKey = results.all().size() > 0 ? (Long) results.all().get(0).getKey() : null;
}
finally {
if (results != null) {
// Discard the results when done to free up cache resources.
results.discard();
}
}
return commandTagKey;
}
开发者ID:c2mon,项目名称:c2mon,代码行数:32,代码来源:CommandTagCacheImpl.java
示例12: TimedRefreshSyncOp
import net.sf.ehcache.search.Attribute; //导入依赖的package包/类
public TimedRefreshSyncOp(Attribute<Integer> partitionSearchAttribute, Integer partitionId) {
this.query = delegatedCache.createQuery();
Criteria searchCriteria = partitionSearchAttribute.eq(partitionId);
query.addCriteria(searchCriteria);
query.includeKeys();
query.end();
}
开发者ID:lanimall,项目名称:ehcache-extensions,代码行数:8,代码来源:CacheFailoverDecorator.java
示例13: getSearchAttribute
import net.sf.ehcache.search.Attribute; //导入依赖的package包/类
/**
* Retrieve the Cache attribute
*
* @param attributeName the name of search attribute
* @param <T> the type of search attribute
* @return the search attribute
* @throws CacheException in the event ehcache throws an exception it will be wrapped.
*/
@Override
public <T> Attribute<T> getSearchAttribute( String attributeName ) throws CacheException
{
if ( cache == null )
{
String error = "getSearchAttribute detected null cache name [" + name + "]";
throw new CacheException( GlobalErrIds.FT_NULL_CACHE, error );
}
return this.cache.getSearchAttribute( attributeName );
}
开发者ID:apache,项目名称:directory-fortress-core,代码行数:19,代码来源:EhCacheImpl.java
示例14: clearDsdCacheEntry
import net.sf.ehcache.search.Attribute; //导入依赖的package包/类
/**
* Given DSD entry name, clear its corresponding object values from the cache.
*
* @param name contains the name of object to be cleared.
* @param contextId maps to sub-tree in DIT, e.g. ou=contextId, dc=example, dc=com. *
* @throws SecurityException in the event of system or rule violation.
*/
void clearDsdCacheEntry(String name, String contextId)
{
Attribute<String> context = m_dsdCache.getSearchAttribute(CONTEXT_ID);
Attribute<String> dsdName = m_dsdCache.getSearchAttribute(DSD_NAME);
Query query = m_dsdCache.createQuery();
query.includeKeys();
query.includeValues();
query.addCriteria(dsdName.eq(name).and(context.eq(contextId)));
Results results = query.execute();
for (Result result : results.all())
{
m_dsdCache.clear(result.getKey());
}
}
开发者ID:apache,项目名称:directory-fortress-core,代码行数:22,代码来源:SDUtil.java
示例15: getDsdCache
import net.sf.ehcache.search.Attribute; //导入依赖的package包/类
/**
* Given a role name, return the set of DSD's that have a matching member.
*
* @param name contains name of authorized Role used to search the cache.
* @param contextId maps to sub-tree in DIT, e.g. ou=contextId, dc=example, dc=com.
* @return un-ordered set of matching DSD's.
* @throws SecurityException in the event of system or rule violation.
*/
private Set<SDSet> getDsdCache(String name, String contextId)
throws SecurityException
{
contextId = getContextId(contextId);
Set<SDSet> finalSet = new HashSet<>();
Attribute<String> context = m_dsdCache.getSearchAttribute(CONTEXT_ID);
Attribute<String> member = m_dsdCache.getSearchAttribute(SchemaConstants.MEMBER_AT);
Query query = m_dsdCache.createQuery();
query.includeKeys();
query.includeValues();
query.addCriteria(member.eq(name).and(context.eq(contextId)));
Results results = query.execute();
boolean empty = false;
for (Result result : results.all())
{
DsdCacheEntry entry = (DsdCacheEntry) result.getValue();
if (!entry.isEmpty())
{
finalSet.add(entry.getSdSet());
finalSet = putDsdCache(name, contextId);
}
else
{
empty = true;
}
finalSet.add(entry.getSdSet());
}
// If nothing was found in the cache, determine if it needs to be seeded:
if (finalSet.size() == 0 && !empty)
{
finalSet = putDsdCache(name, contextId);
}
return finalSet;
}
开发者ID:apache,项目名称:directory-fortress-core,代码行数:43,代码来源:SDUtil.java
示例16: runTests
import net.sf.ehcache.search.Attribute; //导入依赖的package包/类
void runTests()
{
loadCache();
Attribute<String> member = cache.getSearchAttribute( "member" );
Query query = cache.createQuery();
query.includeKeys();
query.includeValues();
Set<String> roles = new HashSet<>();
roles.add( "oamt17dsd1" );
roles.add( "oamt17dsd4" );
roles.add( "oamT13DSD6" );
roles.add( "oamT16SDR7" );
query.addCriteria( member.in( roles ) );
Results results = query.execute();
System.out.println( " Size: " + results.size() );
System.out.println( "----Results-----\n" );
Set<SDSet> resultSet = new HashSet<>();
for ( Result result : results.all() )
{
DsdCacheEntry entry = ( DsdCacheEntry ) result.getValue();
resultSet.add( entry.getSdSet() );
}
for ( SDSet sdSet : resultSet )
{
LOG.info( "Found SDSet: " + sdSet.getName() );
}
}
开发者ID:apache,项目名称:directory-fortress-core,代码行数:30,代码来源:CacheSample.java
示例17: getDomainRoles
import net.sf.ehcache.search.Attribute; //导入依赖的package包/类
@Override
public List<DomainRoleEntry> getDomainRoles(String uid) {
Cache cache = getCache(CacheId.DOMAIN_ROLES);
List<DomainRoleEntry> domainRoles = new ArrayList<DomainRoleEntry>();
Attribute<String> uidAttribute = cache.getSearchAttribute(UserRoleKey.USER_ID);
// query is the fastest if you search for keys and if you need value then call Cache.get(key)
Query queryRequestedUid = cache.createQuery().addCriteria(uidAttribute.eq(uid)).includeKeys().end();
Results results = queryRequestedUid.execute();
for (Result result : results.all()) {
domainRoles.add(DomainAccessControlStoreEhCache.<DomainRoleEntry> getElementValue(cache.get(result.getKey())));
}
return domainRoles;
}
开发者ID:bmwcarit,项目名称:joynr,代码行数:15,代码来源:DomainAccessControlStoreEhCache.java
示例18: getAce
import net.sf.ehcache.search.Attribute; //导入依赖的package包/类
private <T extends ControlEntry> T getAce(CacheId cacheId,
String uid,
String domain,
String interfaceName,
String operation) {
Cache cache = getCache(cacheId);
Attribute<String> uidAttribute = cache.getSearchAttribute(UserDomainInterfaceOperationKey.USER_ID);
Attribute<String> domainAttribute = cache.getSearchAttribute(UserDomainInterfaceOperationKey.DOMAIN);
Attribute<String> interfaceAttribute = cache.getSearchAttribute(UserDomainInterfaceOperationKey.INTERFACE);
Attribute<String> operationAttribute = cache.getSearchAttribute(UserDomainInterfaceOperationKey.OPERATION);
Query queryAllOperations = cache.createQuery()
.addCriteria(uidAttribute.eq(uid).or(uidAttribute.eq(WILDCARD)))
.addCriteria(domainAttribute.eq(domain))
.addCriteria(interfaceAttribute.eq(interfaceName))
.addCriteria(operationAttribute.eq(operation))
// have specific user ids appear before wildcards
.addOrderBy(uidAttribute, Direction.DESCENDING)
.includeKeys()
.end();
Results results = queryAllOperations.execute();
T ace = null;
if (!results.all().isEmpty()) {
ace = DomainAccessControlStoreEhCache.<T> getElementValue(cache.get(results.all().get(0).getKey()));
}
return ace;
}
开发者ID:bmwcarit,项目名称:joynr,代码行数:28,代码来源:DomainAccessControlStoreEhCache.java
示例19: getEditableAces
import net.sf.ehcache.search.Attribute; //导入依赖的package包/类
private <T extends ControlEntry> List<T> getEditableAces(String uid, CacheId cacheId, Role role) {
List<T> aces = new ArrayList<T>();
// find out first on which domains uid has specified role
Cache drtCache = getCache(CacheId.DOMAIN_ROLES);
UserRoleKey dreKey = new UserRoleKey(uid, role);
String[] uidDomains = null;
// read domains from DRE
if (drtCache.isKeyInCache(dreKey)) {
DomainRoleEntry dre = DomainAccessControlStoreEhCache.<DomainRoleEntry> getElementValue(drtCache.get(dreKey));
uidDomains = dre.getDomains();
}
// if uid has no domains with specified role return empty list
if (uidDomains == null || uidDomains.length == 0) {
return aces;
}
Cache cache = getCache(cacheId);
// here should search on uid and domain take place
Attribute<String> uidAttribute = cache.getSearchAttribute(UserDomainInterfaceOperationKey.USER_ID);
Attribute<String> domainAttribute = cache.getSearchAttribute(UserDomainInterfaceOperationKey.DOMAIN);
for (String domain : uidDomains) {
Query query = cache.createQuery()
.addCriteria(uidAttribute.eq(uid).and(domainAttribute.eq(domain)))
.includeKeys()
.end();
Results results = query.execute();
for (Result result : results.all()) {
aces.add(DomainAccessControlStoreEhCache.<T> getElementValue(cache.get(result.getKey())));
}
}
return aces;
}
开发者ID:bmwcarit,项目名称:joynr,代码行数:35,代码来源:DomainAccessControlStoreEhCache.java
示例20: getSearchAttribute
import net.sf.ehcache.search.Attribute; //导入依赖的package包/类
@Override
public <T> Attribute<T> getSearchAttribute(String attributeName)
throws CacheException {
init();
return super.getSearchAttribute(attributeName);
}
开发者ID:lanimall,项目名称:ehcache-extensions,代码行数:7,代码来源:EhcacheDelegateAdapter.java
注:本文中的net.sf.ehcache.search.Attribute类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论