本文整理汇总了Java中org.jivesoftware.util.cache.CacheFactory类的典型用法代码示例。如果您正苦于以下问题:Java CacheFactory类的具体用法?Java CacheFactory怎么用?Java CacheFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CacheFactory类属于org.jivesoftware.util.cache包,在下文中一共展示了CacheFactory类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: remove
import org.jivesoftware.util.cache.CacheFactory; //导入依赖的package包/类
@Override
public String remove(Object key) {
String value;
synchronized (this) {
value = properties.remove(key);
// Also remove any children.
Collection<String> propNames = getPropertyNames();
for (String name : propNames) {
if (name.startsWith((String)key)) {
properties.remove(name);
}
}
deleteProperty((String)key);
}
// Generate event.
Map<String, Object> params = Collections.emptyMap();
MUCServicePropertyEventDispatcher.dispatchEvent(subdomain, (String)key, MUCServicePropertyEventDispatcher.EventType.property_deleted, params);
// Send update to other cluster members.
CacheFactory.doClusterTask(MUCServicePropertyClusterEventTask.createDeleteTask(subdomain, (String) key));
return value;
}
开发者ID:igniterealtime,项目名称:Openfire,代码行数:25,代码来源:MUCServiceProperties.java
示例2: remove
import org.jivesoftware.util.cache.CacheFactory; //导入依赖的package包/类
/**
* Deletes the {@link PEPService} belonging to the specified owner.
*
* @param owner
* The JID of the owner of the service to be deleted.
*/
public void remove(JID owner) {
PEPService service = null;
final Lock lock = CacheFactory.getLock(owner, pepServices);
try {
lock.lock();
service = pepServices.remove(owner.toBareJID());
} finally {
lock.unlock();
}
if (service == null) {
return;
}
// Delete the user's PEP nodes from memory and the database.
CollectionNode rootNode = service.getRootCollectionNode();
for (final Node node : service.getNodes()) {
if (rootNode.isChildNode(node)) {
node.delete();
}
}
rootNode.delete();
}
开发者ID:idwanglu2010,项目名称:openfire,代码行数:31,代码来源:PEPServiceManager.java
示例3: getNumberConnectedUsers
import org.jivesoftware.util.cache.CacheFactory; //导入依赖的package包/类
/**
* Retuns the total number of occupants in all rooms in the server.
*
* @param onlyLocal true if only users connected to this JVM will be considered. Otherwise count cluster wise.
* @return the number of existing rooms in the server.
*/
@Override
public int getNumberConnectedUsers(boolean onlyLocal) {
int total = 0;
for (LocalMUCUser user : users.values()) {
if (user.isJoined()) {
total = total + 1;
}
}
// Add users from remote cluster nodes
if (!onlyLocal) {
Collection<Object> results =
CacheFactory.doSynchronousClusterTask(new GetNumberConnectedUsers(), false);
for (Object result : results) {
if (result == null) {
continue;
}
total = total + (Integer) result;
}
}
return total;
}
开发者ID:igniterealtime,项目名称:Openfire,代码行数:28,代码来源:MultiUserChatServiceImpl.java
示例4: removeComponentItem
import org.jivesoftware.util.cache.CacheFactory; //导入依赖的package包/类
/**
* Removes a disco item for a component that has been removed from the server.
*
* @param jid the jid of the component being removed.
*/
public void removeComponentItem(String jid) {
if (serverItems == null) {
// Safety check
return;
}
Lock lock = CacheFactory.getLock(jid, serverItems);
try {
lock.lock();
ClusteredServerItem item = serverItems.get(jid);
if (item != null && item.nodes.remove(XMPPServer.getInstance().getNodeID())) {
// Update the cache with latest info
if (item.nodes.isEmpty()) {
serverItems.remove(jid);
}
else {
serverItems.put(jid, item);
}
}
}
finally {
lock.unlock();
}
// Remove locally added server item
localServerItems.remove(jid);
}
开发者ID:coodeer,项目名称:g3server,代码行数:31,代码来源:IQDiscoItemsHandler.java
示例5: startup
import org.jivesoftware.util.cache.CacheFactory; //导入依赖的package包/类
/**
* Starts the cluster service if clustering is enabled. The process of starting clustering
* will recreate caches as distributed caches.<p>
*
* Before starting a cluster the
* {@link XMPPServer#setRemoteSessionLocator(org.jivesoftware.openfire.session.RemoteSessionLocator)} and
* {@link org.jivesoftware.openfire.RoutingTable#setRemotePacketRouter(org.jivesoftware.openfire.RemotePacketRouter)}
* need to be properly configured.
*/
public static synchronized void startup() {
if (isClusteringStarted()) {
return;
}
// See if clustering should be enabled.
if (isClusteringEnabled()) {
if (XMPPServer.getInstance().getRemoteSessionLocator() == null) {
throw new IllegalStateException("No RemoteSessionLocator was found.");
}
if (XMPPServer.getInstance().getRoutingTable().getRemotePacketRouter() == null) {
throw new IllegalStateException("No RemotePacketRouter was found.");
}
// Start up the cluster and reset caches
CacheFactory.startClustering();
}
}
开发者ID:coodeer,项目名称:g3server,代码行数:26,代码来源:ClusterManager.java
示例6: getPEPService
import org.jivesoftware.util.cache.CacheFactory; //导入依赖的package包/类
/**
* Retrieves a PEP service -- attempting first from memory, then from the
* database.
*
* @param jid
* the bare JID of the user that owns the PEP service.
* @return the requested PEP service if found or null if not found.
*/
public PEPService getPEPService(String jid) {
PEPService pepService = null;
final Lock lock = CacheFactory.getLock(jid, pepServices);
try {
lock.lock();
if (pepServices.containsKey(jid)) {
// lookup in cache
pepService = pepServices.get(jid);
} else {
// lookup in database.
pepService = loadPEPServiceFromDB(jid);
// always add to the cache, even if it doesn't exist. This will
// prevent future database lookups.
pepServices.put(jid, pepService);
}
} finally {
lock.unlock();
}
return pepService;
}
开发者ID:coodeer,项目名称:g3server,代码行数:32,代码来源:PEPServiceManager.java
示例7: joinedCluster
import org.jivesoftware.util.cache.CacheFactory; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public void joinedCluster(byte[] nodeID) {
Object result = CacheFactory.doSynchronousClusterTask(new GetNewMemberRoomsRequest(), nodeID);
if (result instanceof List<?>) {
List<RoomInfo> rooms = (List<RoomInfo>) result;
for (RoomInfo roomInfo : rooms) {
LocalMUCRoom remoteRoom = roomInfo.getRoom();
MultiUserChatServiceImpl service = (MultiUserChatServiceImpl)remoteRoom.getMUCService();
LocalMUCRoom localRoom = service.getLocalChatRoom(remoteRoom.getName());
if (localRoom == null) {
// Create local room with remote information
localRoom = remoteRoom;
service.chatRoomAdded(localRoom);
}
// Add remote occupants to local room
for (OccupantAddedEvent event : roomInfo.getOccupants()) {
event.setSendPresence(true);
event.run();
}
}
}
}
开发者ID:idwanglu2010,项目名称:openfire,代码行数:23,代码来源:MultiUserChatManager.java
示例8: approveSubscription
import org.jivesoftware.util.cache.CacheFactory; //导入依赖的package包/类
/**
* Approves or cancels a subscriptions that was pending to be approved by a node owner.
* Subscriptions that were not approved will be deleted. Approved subscriptions will be
* activated (i.e. will be able to receive event notifications) as long as the subscriber
* is not required to configure the subscription.
*
* @param subscription the subscriptions that was approved or rejected.
* @param approved true when susbcription was approved. Otherwise the subscription was rejected.
*/
public void approveSubscription(NodeSubscription subscription, boolean approved) {
if (!subscription.isAuthorizationPending()) {
// Do nothing if the subscription is no longer pending
return;
}
if (approved) {
// Mark that the subscription to the node has been approved
subscription.approved();
CacheFactory.doClusterTask(new ModifySubscriptionTask(subscription));
}
else {
// Cancel the subscription to the node
cancelSubscription(subscription);
}
}
开发者ID:igniterealtime,项目名称:Openfire,代码行数:25,代码来源:Node.java
示例9: updateOccupant
import org.jivesoftware.util.cache.CacheFactory; //导入依赖的package包/类
public Presence updateOccupant(UpdateOccupantRequest updateRequest) throws NotAllowedException {
MUCRole occupantRole = occupants.get(updateRequest.getNickname().toLowerCase());
if (occupantRole != null) {
if (updateRequest.isAffiliationChanged()) {
occupantRole.setAffiliation(updateRequest.getAffiliation());
}
occupantRole.setRole(updateRequest.getRole());
// Notify the othe cluster nodes to update the occupant
CacheFactory.doClusterTask(new UpdateOccupant(this, occupantRole));
return occupantRole.getPresence();
}
else {
Log.debug("LocalMUCRoom: Failed to update information of local room occupant. Occupant nickname: " +
updateRequest.getNickname());
}
return null;
}
开发者ID:coodeer,项目名称:g3server,代码行数:18,代码来源:LocalMUCRoom.java
示例10: getGroupNames
import org.jivesoftware.util.cache.CacheFactory; //导入依赖的package包/类
public Collection<String> getGroupNames(JID user) {
Cache<JID, Collection<String>> userMembershipCache = CacheFactory.createCache(USER_MEMBERSHIP_CACHE_NAME);
Collection<String> groups = userMembershipCache.get(user);
if (groups != null) {
return groups;
}
try {
groups = manager.getUserGroups(user.getNode());
userMembershipCache.put(user, groups);
return groups;
} catch (RemoteException re) {
LOG.error("Failure to load the groups of user:" + String.valueOf(user), re);
}
userMembershipCache.put(user, new ArrayList<String>());
return Collections.emptyList();
}
开发者ID:idwanglu2010,项目名称:openfire,代码行数:19,代码来源:CrowdGroupProvider.java
示例11: getSecretkey
import org.jivesoftware.util.cache.CacheFactory; //导入依赖的package包/类
/**
* Returns the secret key that was randomly generated. When running inside of a cluster
* the key will be unique to all cluster nodes.
*
* @return the secret key that was randomly generated.
*/
private static String getSecretkey() {
String key = "secretKey";
Lock lock = CacheFactory.getLock(key, secretKeyCache);
try {
lock.lock();
String secret = secretKeyCache.get(key);
if (secret == null) {
secret = StringUtils.randomString(10);
secretKeyCache.put(key, secret);
}
return secret;
}
finally {
lock.unlock();
}
}
开发者ID:idwanglu2010,项目名称:openfire,代码行数:23,代码来源:ServerDialback.java
示例12: getGroupNames
import org.jivesoftware.util.cache.CacheFactory; //导入依赖的package包/类
@Override
public Collection<String> getGroupNames(JID user) {
Cache<JID, Collection<String>> userMembershipCache = CacheFactory.createCache(USER_MEMBERSHIP_CACHE_NAME);
Collection<String> groups = userMembershipCache.get(user);
if (groups != null) {
return groups;
}
try {
groups = manager.getUserGroups(user.getNode());
userMembershipCache.put(user, groups);
return groups;
} catch (RemoteException re) {
LOG.error("Failure to load the groups of user:" + String.valueOf(user), re);
}
userMembershipCache.put(user, new ArrayList<String>());
return Collections.emptyList();
}
开发者ID:igniterealtime,项目名称:Openfire,代码行数:20,代码来源:CrowdGroupProvider.java
示例13: getNumberConnectedUsers
import org.jivesoftware.util.cache.CacheFactory; //导入依赖的package包/类
/**
* Retuns the total number of occupants in all rooms in the server.
*
* @param onlyLocal true if only users connected to this JVM will be considered. Otherwise count cluster wise.
* @return the number of existing rooms in the server.
*/
public int getNumberConnectedUsers(boolean onlyLocal) {
int total = 0;
for (LocalMUCUser user : users.values()) {
if (user.isJoined()) {
total = total + 1;
}
}
// Add users from remote cluster nodes
if (!onlyLocal) {
Collection<Object> results =
CacheFactory.doSynchronousClusterTask(new GetNumberConnectedUsers(), false);
for (Object result : results) {
if (result == null) {
continue;
}
total = total + (Integer) result;
}
}
return total;
}
开发者ID:idwanglu2010,项目名称:openfire,代码行数:27,代码来源:MultiUserChatServiceImpl.java
示例14: getConversations
import org.jivesoftware.util.cache.CacheFactory; //导入依赖的package包/类
/**
* Returns the set of active conversations.
*
* @return the active conversations.
*/
public Collection<Conversation> getConversations() {
if (ClusterManager.isSeniorClusterMember()) {
List<Conversation> conversationList = new ArrayList<Conversation>(conversations.values());
// Sort the conversations by creation date.
Collections.sort(conversationList, new Comparator<Conversation>() {
public int compare(Conversation c1, Conversation c2) {
return c1.getStartDate().compareTo(c2.getStartDate());
}
});
return conversationList;
} else {
// Get this info from the senior cluster member when running in a cluster
return (Collection<Conversation>) CacheFactory.doSynchronousClusterTask(new GetConversationsTask(), ClusterManager
.getSeniorClusterMember().toByteArray());
}
}
开发者ID:igniterealtime,项目名称:Openfire,代码行数:22,代码来源:ConversationManager.java
示例15: removeComponentRoute
import org.jivesoftware.util.cache.CacheFactory; //导入依赖的package包/类
@Override
public boolean removeComponentRoute(JID route) {
String address = route.getDomain();
boolean removed = false;
Lock lock = CacheFactory.getLock(address, componentsCache);
try {
lock.lock();
Set<NodeID> nodes = componentsCache.get(address);
if (nodes != null) {
removed = nodes.remove(server.getNodeID());
if (nodes.isEmpty()) {
componentsCache.remove(address);
}
else {
componentsCache.put(address, nodes);
}
}
} finally {
lock.unlock();
}
localRoutingTable.removeRoute(new DomainPair("", address));
return removed;
}
开发者ID:igniterealtime,项目名称:Openfire,代码行数:24,代码来源:RoutingTableImpl.java
示例16: getGroupMembers
import org.jivesoftware.util.cache.CacheFactory; //导入依赖的package包/类
private Collection<JID> getGroupMembers(String groupName) {
Cache<String, Collection<JID>> groupMembershipCache = CacheFactory.createLocalCache(GROUP_MEMBERSHIP_CACHE_NAME);
Collection<JID> members = groupMembershipCache.get(groupName);
if (members != null) {
return members;
}
try {
List<String> users = manager.getGroupMembers(groupName);
Collection<JID> results = new ArrayList<JID>();
for (String username : users) {
results.add(server.createJID(username, null));
}
groupMembershipCache.put(groupName, results);
return results;
} catch (RemoteException re) {
LOG.error("Failure to get the members of crowd group:" + String.valueOf(groupName), re);
}
groupMembershipCache.put(groupName, new ArrayList<JID>());
return Collections.emptyList();
}
开发者ID:idwanglu2010,项目名称:openfire,代码行数:26,代码来源:CrowdGroupProvider.java
示例17: init
import org.jivesoftware.util.cache.CacheFactory; //导入依赖的package包/类
@Override
public void init(ServletConfig config) throws ServletException {
super.init(config);
// Create a pool of HTTP connections to use to get the favicons
client = new HttpClient(new MultiThreadedHttpConnectionManager());
HttpConnectionManagerParams params = client.getHttpConnectionManager().getParams();
params.setConnectionTimeout(2000);
params.setSoTimeout(2000);
// Load the default favicon to use when no favicon was found of a remote host
try {
URL resource = config.getServletContext().getResource("/images/server_16x16.gif");
defaultBytes = getImage(resource.toString());
}
catch (MalformedURLException e) {
e.printStackTrace();
}
// Initialize caches.
missesCache = CacheFactory.createCache("Favicon Misses");
hitsCache = CacheFactory.createCache("Favicon Hits");
}
开发者ID:coodeer,项目名称:g3server,代码行数:21,代码来源:FaviconServlet.java
示例18: getPEPService
import org.jivesoftware.util.cache.CacheFactory; //导入依赖的package包/类
/**
* Retrieves a PEP service -- attempting first from memory, then from the
* database.
*
* @param jid
* the bare JID of the user that owns the PEP service.
* @return the requested PEP service if found or null if not found.
*/
public PEPService getPEPService(String jid) {
PEPService pepService = null;
final Lock lock = CacheFactory.getLock(jid, pepServices);
try {
lock.lock();
if (pepServices.containsKey(jid)) {
// lookup in cache
pepService = pepServices.get(jid);
} else {
// lookup in database.
pepService = loadPEPServiceFromDB(jid);
// always add to the cache, even if it doesn't exist. This will
// prevent future database lookups.
pepServices.put(jid, pepService);
}
} finally {
lock.unlock();
}
return pepService;
}
开发者ID:igniterealtime,项目名称:Openfire,代码行数:32,代码来源:PEPServiceManager.java
示例19: leftCluster
import org.jivesoftware.util.cache.CacheFactory; //导入依赖的package包/类
public void leftCluster(byte[] nodeID) {
if (ClusterManager.isSeniorClusterMember()) {
NodeID leftNode = NodeID.getInstance(nodeID);
// Remove server features added by node that is gone
for (Map.Entry<String, Set<NodeID>> entry : serverFeatures.entrySet()) {
String namespace = entry.getKey();
Lock lock = CacheFactory.getLock(namespace, serverFeatures);
try {
lock.lock();
Set<NodeID> nodeIDs = entry.getValue();
if (nodeIDs.remove(leftNode)) {
if (nodeIDs.isEmpty()) {
serverFeatures.remove(namespace);
}
else {
serverFeatures.put(namespace, nodeIDs);
}
}
}
finally {
lock.unlock();
}
}
}
}
开发者ID:idwanglu2010,项目名称:openfire,代码行数:26,代码来源:IQDiscoInfoHandler.java
示例20: getMaxLifetimeFromProperty
import org.jivesoftware.util.cache.CacheFactory; //导入依赖的package包/类
private static long getMaxLifetimeFromProperty(CacheInfo cacheInfo) {
String lifetimeProp = cacheInfo.getParams().get("back-expiry");
if (lifetimeProp != null) {
if ("0".equals(lifetimeProp)) {
return -1l;
}
long factor = 1;
if (lifetimeProp.endsWith("m")) {
factor = JiveConstants.MINUTE;
}
else if (lifetimeProp.endsWith("h")) {
factor = JiveConstants.HOUR;
}
else if (lifetimeProp.endsWith("d")) {
factor = JiveConstants.DAY;
}
try {
return Long.parseLong(lifetimeProp.substring(0, lifetimeProp.length()-1)) * factor;
}
catch (NumberFormatException nfe) {
Log.warn("Unable to parse back-expiry for cache: " + cacheInfo.getCacheName());
}
}
// Return default
return CacheFactory.DEFAULT_MAX_CACHE_LIFETIME;
}
开发者ID:coodeer,项目名称:g3server,代码行数:27,代码来源:PluginCacheRegistry.java
注:本文中的org.jivesoftware.util.cache.CacheFactory类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论