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


Java Factory.create方法代码示例

本文整理汇总了Java中javax.cache.configuration.Factory.create方法的典型用法代码示例。如果您正苦于以下问题:Java Factory.create方法的具体用法?Java Factory.create怎么用?Java Factory.create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.cache.configuration.Factory的用法示例。


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

示例1: JCache

import javax.cache.configuration.Factory; //导入方法依赖的package包/类
public JCache(JCacheManager cacheManager, Redisson redisson, String name, JCacheConfiguration<K, V> config, boolean hasOwnRedisson) {
    super(redisson.getConfig().getCodec(), redisson.getCommandExecutor(), name);
    
    this.hasOwnRedisson = hasOwnRedisson;
    this.redisson = redisson;
    
    Factory<CacheLoader<K, V>> cacheLoaderFactory = config.getCacheLoaderFactory();
    if (cacheLoaderFactory != null) {
        cacheLoader = cacheLoaderFactory.create();
    }
    Factory<CacheWriter<? super K, ? super V>> cacheWriterFactory = config.getCacheWriterFactory();
    if (config.getCacheWriterFactory() != null) {
        cacheWriter = (CacheWriter<K, V>) cacheWriterFactory.create();
    }
    
    this.cacheManager = cacheManager;
    this.config = config;
    
    redisson.getEvictionScheduler().scheduleJCache(getName(), getTimeoutSetName(), getExpiredChannelName());
    
    for (CacheEntryListenerConfiguration<K, V> listenerConfig : config.getCacheEntryListenerConfigurations()) {
        registerCacheEntryListener(listenerConfig, false);
    }
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:25,代码来源:JCache.java

示例2: deregisterCacheEntryListener

import javax.cache.configuration.Factory; //导入方法依赖的package包/类
@Override
public void deregisterCacheEntryListener(CacheEntryListenerConfiguration<K, V> cacheEntryListenerConfiguration) {
    verifyCacheConnectivity();
    final Factory<CacheEntryListener<? super K,? super V>> factory = cacheEntryListenerConfiguration.getCacheEntryListenerFactory();
    final CacheEntryListener cacheEntryListener = factory.create();
    final CacheEventListener<K,V> cacheEventListener = new CacheEventListener<K, V>(cacheEntryListener, this, cacheEntryListenerConfiguration);
    try {
    if(cacheEventListener.isOnCreatedListenerConfigured() && addEventDescriptor != null) 
        innerCache.removeCacheDataModificationListener(addEventDescriptor);
    if(cacheEventListener.isOnUpdatedListenerConfigured() && updateEventDescriptor != null)
        innerCache.removeCacheDataModificationListener(updateEventDescriptor);
    if(cacheEventListener.isOnRemovedListenerConfigured() && deleteEventDescriptor != null) {
        if(!isExpiryEventConfigured)
            innerCache.removeCacheDataModificationListener(deleteEventDescriptor);
    }
    if(cacheEventListener.isOnExpiredListenerConfigured() && deleteEventDescriptor != null) {
        isExpiryEventConfigured = false;
        innerCache.removeCacheDataModificationListener(deleteEventDescriptor);
    }
    }
    catch (Exception e) {
        
    }
}
 
开发者ID:Alachisoft,项目名称:TayzGrid,代码行数:25,代码来源:TayzGridCache.java

示例3: startStoreSessionListeners

import javax.cache.configuration.Factory; //导入方法依赖的package包/类
/**
 * Creates and starts store session listeners.
 *
 * @param ctx Kernal context.
 * @param factories Factories.
 * @return Listeners.
 * @throws IgniteCheckedException In case of error.
 */
public static Collection<CacheStoreSessionListener> startStoreSessionListeners(GridKernalContext ctx,
    Factory<CacheStoreSessionListener>[] factories) throws IgniteCheckedException {
    if (factories == null)
        return null;

    Collection<CacheStoreSessionListener> lsnrs = new ArrayList<>(factories.length);

    for (Factory<CacheStoreSessionListener> factory : factories) {
        CacheStoreSessionListener lsnr = factory.create();

        if (lsnr != null) {
            ctx.resource().injectGeneric(lsnr);

            if (lsnr instanceof LifecycleAware)
                ((LifecycleAware)lsnr).start();

            lsnrs.add(lsnr);
        }
    }

    return lsnrs;
}
 
开发者ID:apache,项目名称:ignite,代码行数:31,代码来源:GridCacheUtils.java

示例4: registerCacheEntryListener

import javax.cache.configuration.Factory; //导入方法依赖的package包/类
@Override
public void registerCacheEntryListener(CacheEntryListenerConfiguration<K, V> cacheEntryListenerConfiguration) {
    verifyCacheConnectivity();
    final Factory<CacheEntryListener<? super K, ? super V> > factory = cacheEntryListenerConfiguration.getCacheEntryListenerFactory();
    final CacheEntryListener cacheEntryListener = factory.create();
    final CacheEventListener<K,V> cacheEventListener = new CacheEventListener<K, V>(cacheEntryListener, this, cacheEntryListenerConfiguration);
    try {
        EnumSet<EventType> eventType = null;
        if(cacheEventListener.isOnCreatedListenerConfigured()) {
            eventType = EnumSet.of(EventType.ItemAdded);
            addEventDescriptor = innerCache.addCacheDataModificationListener(cacheEventListener, eventType, EventDataFilter.DataWithMetaData);
        }
        if(cacheEventListener.isOnUpdatedListenerConfigured()) {
            eventType = EnumSet.of(EventType.ItemUpdated);
            updateEventDescriptor = innerCache.addCacheDataModificationListener(cacheEventListener, eventType, EventDataFilter.DataWithMetaData);
        }
        if(cacheEventListener.isOnExpiredListenerConfigured() || cacheEventListener.isOnRemovedListenerConfigured()) {
            if(cacheEventListener.isOnExpiredListenerConfigured())
                isExpiryEventConfigured = true;
            eventType = EnumSet.of(EventType.ItemRemoved);
            deleteEventDescriptor = innerCache.addCacheDataModificationListener(cacheEventListener, eventType, EventDataFilter.DataWithMetaData);
        }
        
    }
    catch (Exception e) {
        
    }
}
 
开发者ID:Alachisoft,项目名称:TayzGrid,代码行数:29,代码来源:TayzGridCache.java

示例5: cacheConfiguration

import javax.cache.configuration.Factory; //导入方法依赖的package包/类
/**
 * @param igniteInstanceName Ignite instance name.
 * @return Cache configuration.
 * @throws Exception In case of error.
 */
@SuppressWarnings("unchecked")
protected CacheConfiguration cacheConfiguration(String igniteInstanceName) throws Exception {
    CacheConfiguration cfg = defaultCacheConfiguration();

    if (storeStgy != null) {
        Factory<? extends CacheStore<Object, Object>> storeFactory = storeStgy.getStoreFactory();

        CacheStore<?, ?> store = storeFactory.create();

        if (store != null) {
            cfg.setCacheStoreFactory(storeFactory);
            cfg.setReadThrough(true);
            cfg.setWriteThrough(true);
            cfg.setLoadPreviousValue(true);
            storeStgy.updateCacheConfiguration(cfg);
        }
    }

    cfg.setCacheMode(cacheMode());
    cfg.setAtomicityMode(atomicityMode());
    cfg.setWriteSynchronizationMode(writeSynchronization());
    cfg.setNearConfiguration(nearConfiguration());
    cfg.setOnheapCacheEnabled(onheapCacheEnabled());

    Class<?>[] idxTypes = indexedTypes();

    if (!F.isEmpty(idxTypes))
        cfg.setIndexedTypes(idxTypes);

    if (cacheMode() == PARTITIONED)
        cfg.setBackups(1);

    return cfg;
}
 
开发者ID:apache,项目名称:ignite,代码行数:40,代码来源:GridCacheAbstractSelfTest.java

示例6: createByFactory

import javax.cache.configuration.Factory; //导入方法依赖的package包/类
@Override
protected Object createByFactory(Factory factory) {
    inject(factory, false);
    Object result = factory.create();
    return inject(result, true);
}
 
开发者ID:epam,项目名称:Lagerta,代码行数:7,代码来源:Injection.java

示例7: ListenerEntry

import javax.cache.configuration.Factory; //导入方法依赖的package包/类
/**
 * Creates a ListenerEntry from the factories in CacheEntryListenerConfiguration.
 * Both CacheEntryEventFilter and CacheEntryListener are created.
 * The {@link #dispatchMode} regulates how events get dispatched, for example synchronous, asynchronous batched or timed
 * 
 * @param config The CacheEntryListenerConfiguration
 * @param tcache The cache which events should be listened to 
 * @param dispatchMode How events are dispatched to listeners
 */
ListenerEntry(CacheEntryListenerConfiguration<K, V> config, Cache<K,V> tcache, DispatchMode dispatchMode)
{
	this.config = config;
	this.tcache = tcache;
	this.dispatchMode = dispatchMode;

	CacheEventManager<K,V> em = null;
	Factory<CacheEntryListener<? super K, ? super V>> listenerFactory = config.getCacheEntryListenerFactory();
	if (listenerFactory != null)
	{
		listener = listenerFactory.create();
		if (listener != null)
		{
			Factory<CacheEntryEventFilter<? super K, ? super V>> filterFactory = config
					.getCacheEntryEventFilterFactory();
			if (filterFactory != null)
				filter = filterFactory.create();
			
			em = new ListenerCacheEventManager<K,V>();
		}
	}

	eventManager = em;


       /**
        * Initialize dispatchQueue and corresponding Thread. This has to be done even for the synchronous
        * DispatchMode#SYNC, as it can be forced to operate asynchronously for internal operations like
        * expiration and eviction.
        */
       this.dispatchQueue = new ArrayBlockingQueue<TCacheEntryEventCollection<K, V>>(1024);
       /**
        * Future directions: Starting the listener in the constructor is problematic. If this class would be
        * subclassed, the Thread would start too early. Right now it cannot happen, as this class is final.
        * Second, we possibly want a Thread restart mechanism anyhow, like we have with the expiration and
        * eviction threads. For the latter, there should be a dedicated "BackgroundThreadController<T>" class
        * that controls/restarts background threads.
        */
       dispatchThread = ensureListenerThreadIsRunning();
   }
 
开发者ID:trivago,项目名称:triava,代码行数:50,代码来源:ListenerEntry.java


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