@Autowired public SubEquipmentCacheImpl(final ClusterCache clusterCache, @Qualifier("subEquipmentEhcache") final Ehcache ehcache, @Qualifier("subEquipmentEhcacheLoader") final CacheLoader cacheLoader, @Qualifier("subEquipmentCacheLoader") final C2monCacheLoader c2monCacheLoader, @Qualifier("subEquipmentDAO") final SimpleCacheLoaderDAO<SubEquipment> cacheLoaderDAO, final ControlTagCache controlCache, final EquipmentCache equipmentCache, final CacheProperties properties) { super(clusterCache, ehcache, cacheLoader, c2monCacheLoader, cacheLoaderDAO, properties); this.controlCache = controlCache; this.equipmentCache = equipmentCache; }
@Autowired public ControlTagCacheImpl(@Qualifier("clusterCache") final ClusterCache clusterCache, @Qualifier("controlTagEhcache") final Ehcache ehcache, @Qualifier("controlTagEhcacheLoader") final CacheLoader cacheLoader, @Qualifier("controlTagCacheLoader") final C2monCacheLoader c2monCacheLoader, @Qualifier("controlTagLoaderDAO") final SimpleCacheLoaderDAO<ControlTag> cacheLoaderDAO, final CacheProperties properties) { super(clusterCache, ehcache, cacheLoader, c2monCacheLoader, cacheLoaderDAO, properties); }
@Autowired public DeviceCacheImpl(@Qualifier("clusterCache") final ClusterCache clusterCache, @Qualifier("deviceEhcache") final Ehcache ehcache, @Qualifier("deviceEhcacheLoader") final CacheLoader cacheLoader, @Qualifier("deviceCacheLoader") final C2monCacheLoader c2monCacheLoader, @Qualifier("deviceDAO") final SimpleCacheLoaderDAO<Device> cacheLoaderDAO, final CacheProperties properties) { super(clusterCache, ehcache, cacheLoader, c2monCacheLoader, cacheLoaderDAO, properties); }
@Autowired public DeviceClassCacheImpl(final ClusterCache clusterCache, @Qualifier("deviceClassEhcache") final Ehcache ehcache, @Qualifier("deviceClassEhcacheLoader") final CacheLoader cacheLoader, @Qualifier("deviceClassCacheLoader") final C2monCacheLoader c2monCacheLoader, @Qualifier("deviceClassDAO") final SimpleCacheLoaderDAO<DeviceClass> cacheLoaderDAO, final CacheProperties properties) { super(clusterCache, ehcache, cacheLoader, c2monCacheLoader, cacheLoaderDAO, properties); }
@Autowired public CommFaultTagCacheImpl(final ClusterCache clusterCache, @Qualifier("commFaultTagEhcache") final Ehcache ehcache, @Qualifier("commFaultTagEhcacheLoader") final CacheLoader cacheLoader, @Qualifier("commFaultTagCacheLoader") final C2monCacheLoader c2monCacheLoader, @Qualifier("commFaultTagDAO") final SimpleCacheLoaderDAO<CommFaultTag> cacheLoaderDAO, final CacheProperties properties) { super(clusterCache, ehcache, cacheLoader, c2monCacheLoader, cacheLoaderDAO, properties); }
/** * Constructor. */ public AbstractTagCache(final ClusterCache clusterCache, final Ehcache ehcache, final CacheLoader cacheLoader, final C2monCacheLoader c2monCacheLoader, final SimpleCacheLoaderDAO<T> cacheLoaderDAO, final CacheProperties properties) { super(clusterCache, ehcache, cacheLoader, c2monCacheLoader, cacheLoaderDAO, properties); listenersWithSupervision = new ArrayList<>(); listenerLock = new ReentrantReadWriteLock(); }
@Autowired public EquipmentCacheImpl(final ClusterCache clusterCache, @Qualifier("equipmentEhcache") final Ehcache ehcache, @Qualifier("equipmentEhcacheLoader") final CacheLoader cacheLoader, @Qualifier("equipmentCacheLoader") final C2monCacheLoader c2monCacheLoader, @Qualifier("equipmentDAO") final SimpleCacheLoaderDAO<Equipment> cacheLoaderDAO, final ControlTagCache controlCache, final CacheProperties properties) { super(clusterCache, ehcache, cacheLoader, c2monCacheLoader, cacheLoaderDAO, properties); this.controlCache = controlCache; }
@Autowired public AlarmCacheImpl(@Qualifier("clusterCache") final ClusterCache clusterCache, @Qualifier("alarmEhcache") final Ehcache ehcache, @Qualifier("alarmEhcacheLoader") final CacheLoader cacheLoader, @Qualifier("alarmCacheLoader") final C2monCacheLoader c2monCacheLoader, @Qualifier("alarmLoaderDAO") final AlarmLoaderDAO cacheLoaderDAO, final CacheProperties properties) { super(clusterCache, ehcache, cacheLoader, c2monCacheLoader, cacheLoaderDAO, properties); }
@Autowired public RuleTagCacheImpl(@Qualifier("clusterCache") final ClusterCache clusterCache, @Qualifier("ruleTagEhcache") final Ehcache ehcache, @Qualifier("ruleTagEhcacheLoader") final CacheLoader cacheLoader, @Qualifier("ruleTagCacheLoader") final C2monCacheLoader c2monCacheLoader, @Qualifier("ruleTagLoaderDAO") final SimpleCacheLoaderDAO<RuleTag> cacheLoaderDAO, @Qualifier("dataTagCache") final DataTagCache dataTagCache, final CacheProperties properties) { super(clusterCache, ehcache, cacheLoader, c2monCacheLoader, cacheLoaderDAO, properties); this.dataTagCache = dataTagCache; }
@Autowired public DataTagCacheImpl(@Qualifier("clusterCache") final ClusterCache clusterCache, @Qualifier("dataTagEhcache") final Ehcache ehcache, @Qualifier("dataTagEhcacheLoader") final CacheLoader cacheLoader, @Qualifier("dataTagCacheLoader") final C2monCacheLoader c2monCacheLoader, @Qualifier("dataTagLoaderDAO") final SimpleCacheLoaderDAO<DataTag> cacheLoaderDAO, final CacheProperties properties) { super(clusterCache, ehcache, cacheLoader, c2monCacheLoader, cacheLoaderDAO, properties); }
@Autowired public ProcessCacheImpl(final ClusterCache clusterCache, @Qualifier("processEhcache") final Ehcache ehcache, @Qualifier("processEhcacheLoader") final CacheLoader cacheLoader, @Qualifier("processCacheLoader") final C2monCacheLoader c2monCacheLoader, @Qualifier("processDAO") final SimpleCacheLoaderDAO<Process> cacheLoaderDAO, @Qualifier("controlTagCache") final ControlTagCache controlCache, final CacheProperties properties) { super(clusterCache, ehcache, cacheLoader, c2monCacheLoader, cacheLoaderDAO, properties); this.processDAO = (ProcessDAO) cacheLoaderDAO; this.controlCache = controlCache; }
public AbstractCache(final ClusterCache clusterCache, final Ehcache cache, final CacheLoader cacheLoader, final C2monCacheLoader c2monCacheLoader, final SimpleCacheLoaderDAO<T> cacheLoaderDAO, final CacheProperties properties) { super(); this.clusterCache = clusterCache; this.cache = cache; this.cacheLoader = cacheLoader; this.c2monCacheLoader = c2monCacheLoader; this.cacheLoaderDAO = cacheLoaderDAO; this.properties = properties; }
@Autowired public AliveTimerCacheImpl(final ClusterCache clusterCache, @Qualifier("aliveTimerEhcache") final Ehcache ehcache, @Qualifier("aliveTimerEhcacheLoader") final CacheLoader cacheLoader, @Qualifier("aliveTimerCacheLoader") final C2monCacheLoader c2monCacheLoader, @Qualifier("aliveTimerDAO") final SimpleCacheLoaderDAO<AliveTimer> cacheLoaderDAO, final CacheProperties properties) { super(clusterCache, ehcache, cacheLoader, c2monCacheLoader, cacheLoaderDAO, properties); }
@Autowired public CommandTagCacheImpl(final ClusterCache clusterCache, @Qualifier("commandTagEhcache") final Ehcache ehcache, @Qualifier("commandTagEhcacheLoader") final CacheLoader cacheLoader, @Qualifier("commandTagCacheLoader") final C2monCacheLoader c2monCacheLoader, @Qualifier("commandTagDAO") final SimpleCacheLoaderDAO<CommandTag> cacheLoaderDAO, final CacheProperties properties) { super(clusterCache, ehcache, cacheLoader, c2monCacheLoader, cacheLoaderDAO, properties); }
@Before public void init() { clusterCache = mockControl.createMock(ClusterCache.class); cache = mockControl.createMock(Cache.class); cacheLoader = mockControl.createMock(CacheLoader.class); c2monCacheLoader = mockControl.createMock(C2monCacheLoader.class); cacheLoaderDAO = mockControl.createMock(CacheLoaderDAO.class); supervisionAppender = mockControl.createMock(SupervisionAppender.class); registeredEventListeners = new RegisteredEventListeners(cache); dataTagCache = new DataTagCacheImpl(clusterCache, cache, cacheLoader, c2monCacheLoader, cacheLoaderDAO, new CacheProperties()); }
@Override public CacheLoader createCacheLoader(Ehcache cache, Properties properties) { CamFactory camFactory = FactoryHelper.factory(); PersistentDao persistentDao = null; if(camFactory!=null){ persistentDao = camFactory.getPersistentDao(); } return new CamCacheLoader(persistentDao); }
@Override public CacheLoader clone(Ehcache arg0) throws CloneNotSupportedException { // TODO Auto-generated method stub return null; }
protected CacheLoader getCacheLoader() { return cacheLoader; }
@Test public void testConfig() throws Exception { producerTemplate.send(new Processor() { public void process(Exchange exchange) throws Exception { exchange.setProperty(Exchange.CHARSET_NAME, "UTF-8"); Message in = exchange.getIn(); in.setHeader(CacheConstants.CACHE_OPERATION, CacheConstants.CACHE_OPERATION_ADD); in.setHeader(CacheConstants.CACHE_KEY, "greeting"); in.setBody("Hello World"); } }); CacheManager cm = cacheEndpoint.getCacheManagerFactory().getInstance(); Cache cache = cm.getCache(cacheEndpoint.getConfig().getCacheName()); Set<CacheEventListener> ehcacheEventListners = cache.getCacheEventNotificationService().getCacheEventListeners(); List<CacheLoader> cacheLoaders = cache.getRegisteredCacheLoaders(); CacheEventListenerRegistry configuredEventRegistry = cacheEndpoint.getConfig().getEventListenerRegistry(); CacheLoaderRegistry configuredLoaderRegistry = cacheEndpoint.getConfig().getCacheLoaderRegistry(); //Test if CacheEventListenerRegistry was referenced correctly assertEquals("CacheEventListenerRegistry size", 1, configuredEventRegistry.size()); //Expecting 1 loader to be configured via spring assertEquals("configuredLoaderRegistry size", 1, configuredLoaderRegistry.size()); //Expecting 1 listener added by us: TestCacheEventListener assertEquals("Number of registered listeners", 1, ehcacheEventListners.size()); assertEquals("Number of registered loaders", 1, cacheLoaders.size()); //Is our TestCacheEventListener really invoked? int puts = 0; for (Object listener : ehcacheEventListners) { if (listener instanceof TestCacheEventListener) { puts = ((TestCacheEventListener)listener).getNumberOfPuts(); break; } } assertEquals("TestCacheEventListener put invocations", 1, puts); //Is cache loader initialized by ehcache assertEquals("loader initialized", cacheLoaders.get(0).getStatus(), Status.STATUS_ALIVE); }
@Override public CacheLoader clone(Ehcache arg0) throws CloneNotSupportedException { return null; }
@Override public final void registerCacheLoader(CacheLoader cacheLoader) { throw new UnsupportedOperationException("Cache is read-only...operation not supported"); }
@Override public List<CacheLoader> getRegisteredCacheLoaders() { init(); return super.getRegisteredCacheLoaders(); }
@Override public Element getWithLoader(Object key, CacheLoader loader, Object loaderArgument) throws CacheException { init(); return super.getWithLoader(key, loader, loaderArgument); }
@Override public void registerCacheLoader(CacheLoader cacheLoader) { init(); super.registerCacheLoader(cacheLoader); }
@Override public void unregisterCacheLoader(CacheLoader cacheLoader) { init(); super.unregisterCacheLoader(cacheLoader); }
@Override public CacheLoader clone(Ehcache cache) throws CloneNotSupportedException { return null; }