Java tutorial
/** * Copyright (c) 2014 Baidu, Inc. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.baidu.rigel.biplatform.cache; import java.util.EventObject; import java.util.concurrent.locks.Lock; import org.apache.commons.lang.StringUtils; import org.springframework.cache.Cache; import org.springframework.cache.Cache.ValueWrapper; /** * * ??? * * @author lijin * */ public interface StoreManager { /** * TOPICS */ public static final String TOPICS = "topics"; /** * EVENT_QUEUE */ public static final String EVENT_QUEUE = "eventQueue"; /** * String ?storeManager */ String CURRENT_STORE_MANAGER = "CURRENT_STORE_MANAGER"; /** * * ? * * @param name * ?? * @return Cache */ Cache getDataStore(String name); /** * cache?KEY??? * * @param cache * ?cache * @param key * key * @param clazz * ? * @return * @throws IllegalArgumentException * ? */ @SuppressWarnings("unchecked") public static <T> T getFromCache(Cache cache, String key, Class<T> clazz) { if (cache == null || StringUtils.isBlank(key)) { throw new IllegalArgumentException("illegal params ,cache:" + cache + " key:" + key); } ValueWrapper valueWrapper = cache.get(key); if (valueWrapper != null) { return (T) valueWrapper.get(); } return null; } /** * * * * @param event * * @throws Exception * ? */ void putEvent(EventObject event) throws Exception; /** * * ?? ??? * * @return EventObject * @throws Exception */ EventObject getNextEvent() throws Exception; /** * * postEvent * * @param event * ?? * @throws Exception * */ void postEvent(EventObject event) throws Exception; /** * * ? * @return Lock */ Lock getClusterLock(); Lock getClusterLock(String lockName); }