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


Java CacheFactory.doClusterTask方法代码示例

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


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

示例1: changeSubject

import org.jivesoftware.util.cache.CacheFactory; //导入方法依赖的package包/类
public void changeSubject(Message packet, MUCRole role) throws ForbiddenException {
    if ((canOccupantsChangeSubject() && role.getRole().compareTo(MUCRole.Role.visitor) < 0) ||
            MUCRole.Role.moderator == role.getRole()) {
        // Do nothing if the new subject is the same as the existing one
        if (packet.getSubject().equals(subject)) {
            return;
        }
        // Set the new subject to the room
        subject = packet.getSubject();
        MUCPersistenceManager.updateRoomSubject(this);
        // Notify all the occupants that the subject has changed
        packet.setFrom(role.getRoleAddress());
        send(packet);

        // Fire event signifying that the room's subject has changed.
        MUCEventDispatcher.roomSubjectChanged(getJID(), role.getUserAddress(), subject);

        if (!"local-only".equals(packet.getID())) {
         // Let other cluster nodes that the room has been updated
         CacheFactory.doClusterTask(new RoomUpdatedEvent(this));
        }
    }
    else {
        throw new ForbiddenException();
    }
}
 
开发者ID:idwanglu2010,项目名称:openfire,代码行数:27,代码来源:LocalMUCRoom.java

示例2: 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();
    PropertyEventDispatcher.dispatchEvent((String)key, PropertyEventDispatcher.EventType.property_deleted, params);

    // Send update to other cluster members.
    CacheFactory.doClusterTask(PropertyClusterEventTask.createDeleteTask((String) key));

    return value;
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:25,代码来源:JiveProperties.java

示例3: 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:idwanglu2010,项目名称:openfire,代码行数:25,代码来源:Node.java

示例4: remove

import org.jivesoftware.util.cache.CacheFactory; //导入方法依赖的package包/类
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:coodeer,项目名称:g3server,代码行数:24,代码来源:MUCServiceProperties.java

示例5: updateOccupant

import org.jivesoftware.util.cache.CacheFactory; //导入方法依赖的package包/类
public Presence updateOccupant(UpdateOccupantRequest updateRequest) throws NotAllowedException {
	Presence result = null;
	List <MUCRole> occupants = occupantsByNickname.get(updateRequest.getNickname().toLowerCase());
	if (occupants == null || occupants.size() == 0) {
        Log.debug("Failed to update information of local room occupant; nickname: " + updateRequest.getNickname());
	} else {
		for (MUCRole occupant : occupants) {
            if (updateRequest.isAffiliationChanged()) {
            	occupant.setAffiliation(updateRequest.getAffiliation());
            }
            occupant.setRole(updateRequest.getRole());
            // Notify the the cluster nodes to update the occupant
            CacheFactory.doClusterTask(new UpdateOccupant(this, occupant));
            if (result == null) {
            	result = occupant.getPresence();
            }
		}
	}
    return result;
}
 
开发者ID:idwanglu2010,项目名称:openfire,代码行数:21,代码来源:LocalMUCRoom.java

示例6: setType

import org.jivesoftware.util.cache.CacheFactory; //导入方法依赖的package包/类
/**
 * Set the type of history strategy being used.
 *
 * @param newType The new type of chat history to use.
 */
public void setType(Type newType){
    if (type == newType) {
        // Do nothing since value has not changed
        return;
    }
    if (newType != null){
        type = newType;
    }
    if (contextPrefix != null){
        MUCPersistenceManager.setProperty(contextSubdomain, contextPrefix + ".type", type.toString());
    }
    if (parent == null) {
        // Update the history strategy of the MUC service
        CacheFactory.doClusterTask(new UpdateHistoryStrategy(contextSubdomain, this));
    }
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:22,代码来源:HistoryStrategy.java

示例7: createCollectionNode

import org.jivesoftware.util.cache.CacheFactory; //导入方法依赖的package包/类
CollectionNode createCollectionNode(String creatorUsername, String nodeId, CollectionNode parentNode) {
  CollectionNode parent = (parentNode == null) ? mPubSubModule.getRootCollectionNode() : parentNode;
  Node result = mPubSubModule.getNode(nodeId);
  if (result != null && !result.isCollectionNode()) {
    result.delete();
    result = null;
    // TODO cleanup existing published Items for this node
  }

  if (result == null) {
    ConfigureForm form = new ConfigureForm(DataForm.Type.submit);
    form.setSendItemSubscribe(true);
    form.setDeliverPayloads(true);
    form.setNotifyRetract(false);
    form.setNotifyDelete(false);
    form.setNotifyConfig(false);
    form.setNodeType(ConfigureForm.NodeType.collection);
    form.setPublishModel(ConfigureForm.PublishModel.open);
    LOGGER.trace("Collection config form: " + form);

    JID jid = new JID(creatorUsername, mServer.getServerInfo().getXMPPDomain(), null);
    CollectionNode node = new CollectionNode(mPubSubModule, parent, nodeId, jid);
    node.addOwner(jid);
    try {
      node.configure(form);
    } catch (NotAcceptableException e) {
      LOGGER.warn("NotAcceptableException", e);
    }
    node.saveToDB();
    CacheFactory.doClusterTask(new RefreshNodeTask(node));
    result = node;
  }
  return (CollectionNode) result;
}
 
开发者ID:magnetsystems,项目名称:message-server,代码行数:35,代码来源:MMXChannelManager.java

示例8: put

import org.jivesoftware.util.cache.CacheFactory; //导入方法依赖的package包/类
public String put(String key, String value) {
    if (value == null) {
        // This is the same as deleting, so remove it.
        return remove(key);
    }
    if (key == null) {
        throw new NullPointerException("Key cannot be null. Key=" +
                key + ", value=" + value);
    }
    if (key.endsWith(".")) {
        key = key.substring(0, key.length()-1);
    }
    key = key.trim();
    String result;
    synchronized (this) {
        if (properties.containsKey(key)) {
            if (!properties.get(key).equals(value)) {
                updateProperty(key, value);
            }
        }
        else {
            insertProperty(key, value);
        }

        result = properties.put(key, value);
    }

    // Generate event.
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("value", value);
    PropertyEventDispatcher.dispatchEvent(key, PropertyEventDispatcher.EventType.property_set, params);

    // Send update to other cluster members.
    CacheFactory.doClusterTask(PropertyClusterEventTask.createPutTask(key, value));

    return result;
}
 
开发者ID:coodeer,项目名称:g3server,代码行数:38,代码来源:JiveProperties.java

示例9: put

import org.jivesoftware.util.cache.CacheFactory; //导入方法依赖的package包/类
public String put(String key, String value) {
    if (key == null || value == null) {
        throw new NullPointerException("Key or value cannot be null. Key=" +
                key + ", value=" + value);
    }
    if (key.endsWith(".")) {
        key = key.substring(0, key.length()-1);
    }
    key = key.trim();
    String result;
    synchronized (this) {
        if (properties.containsKey(key)) {
            if (!properties.get(key).equals(value)) {
                updateProperty(key, value);
            }
        }
        else {
            insertProperty(key, value);
        }

        result = properties.put(key, value);
    }

    // Generate event.
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("value", value);
    MUCServicePropertyEventDispatcher.dispatchEvent(subdomain, key, MUCServicePropertyEventDispatcher.EventType.property_set, params);

    // Send update to other cluster members.
    CacheFactory.doClusterTask(MUCServicePropertyClusterEventTask.createPutTask(subdomain, key, value));

    return result;
}
 
开发者ID:coodeer,项目名称:g3server,代码行数:34,代码来源:MUCServiceProperties.java

示例10: addAffiliation

import org.jivesoftware.util.cache.CacheFactory; //导入方法依赖的package包/类
private NodeAffiliate addAffiliation(JID jid, NodeAffiliate.Affiliation affiliation) {
    boolean created = false;
    // Get the current affiliation of the specified JID
    NodeAffiliate affiliate = getAffiliate(jid);
    // Check if the user already has the same affiliation
    if (affiliate != null && affiliation == affiliate.getAffiliation()) {
        // Do nothing since the user already has the expected affiliation
        return affiliate;
    }
    else if (affiliate != null) {
        // Update existing affiliation with new affiliation type
        affiliate.setAffiliation(affiliation);
    }
    else {
        // User did not have any affiliation with the node so create a new one
        affiliate = new NodeAffiliate(this, jid);
        affiliate.setAffiliation(affiliation);
        addAffiliate(affiliate);
        created = true;
    }

    if (savedToDB) {
        // Add or update the affiliate in the database
        PubSubPersistenceManager.saveAffiliation(this, affiliate, created);
    }
    
    // Update the other members with the new affiliation
    CacheFactory.doClusterTask(new AffiliationTask(this, jid, affiliation));

    return affiliate;
}
 
开发者ID:idwanglu2010,项目名称:openfire,代码行数:32,代码来源:Node.java

示例11: getChatRoom

import org.jivesoftware.util.cache.CacheFactory; //导入方法依赖的package包/类
public MUCRoom getChatRoom(String roomName) {
    boolean loaded = false;
    LocalMUCRoom room = rooms.get(roomName);
    if (room == null) {
        // Check if the room exists in the databclase and was not present in memory
        synchronized (roomName.intern()) {
            room = rooms.get(roomName);
            if (room == null) {
                room = new LocalMUCRoom(this, roomName, router);
                // If the room is persistent load the configuration values from the DB
                try {
                    // Try to load the room's configuration from the database (if the room is
                    // persistent but was added to the DB after the server was started up or the
                    // room may be an old room that was not present in memory)
                    MUCPersistenceManager.loadFromDB(room);
                    loaded = true;
                    rooms.put(roomName, room);
                }
                catch (IllegalArgumentException e) {
                    // The room does not exist so do nothing
                    room = null;
                }
            }
        }
    }
    if (loaded) {
        // Notify other cluster nodes that a new room is available
        CacheFactory.doClusterTask(new RoomAvailableEvent(room));
    }
    return room;
}
 
开发者ID:idwanglu2010,项目名称:openfire,代码行数:32,代码来源:MultiUserChatServiceImpl.java

示例12: removeComponent

import org.jivesoftware.util.cache.CacheFactory; //导入方法依赖的package包/类
/**
 * Removes a given component. Unlike {@link #removeComponent(String)} this method will just
 * remove a single component instead of all components associated to the subdomain. External
 * components may connect several times and register for the same subdomain. This method
 * just removes a singled connection not all of them.
 *
 * @param subdomain the subdomain of the component's address.
 * @param component specific component to remove.
 */
public void removeComponent(String subdomain, Component component) {
    if (component == null) {
        return;
    }
    synchronized (routables) {
        Log.debug("InternalComponentManager: Unregistering component for domain: " + subdomain);
        RoutableComponents routable = routables.get(subdomain);
        routable.removeComponent(component);
        if (routable.numberOfComponents() == 0) {
            routables.remove(subdomain);

            JID componentJID = new JID(subdomain + "." + serverDomain);

            // Remove the route for the service provided by the component
            routingTable.removeComponentRoute(componentJID);

            // Ask the component to shutdown
            component.shutdown();

            if (!routingTable.hasComponentRoute(componentJID)) {
                // Remove the disco item from the server for the component that is being removed
                IQDiscoItemsHandler iqDiscoItemsHandler = XMPPServer.getInstance().getIQDiscoItemsHandler();
                if (iqDiscoItemsHandler != null) {
                    iqDiscoItemsHandler.removeComponentItem(componentJID.toBareJID());
                }
                removeComponentInfo(componentJID);
                // Notify listeners that an existing component has been unregistered
                notifyComponentUnregistered(componentJID);
                // Alert other nodes of component removed event
                CacheFactory.doClusterTask(new NotifyComponentUnregistered(componentJID));
            }
            Log.debug("InternalComponentManager: Component unregistered for domain: " + subdomain);
        }
        else {
            Log.debug("InternalComponentManager: Other components still tied to domain: " + subdomain);
        }
    }
}
 
开发者ID:coodeer,项目名称:g3server,代码行数:48,代码来源:InternalComponentManager.java

示例13: routePacket

import org.jivesoftware.util.cache.CacheFactory; //导入方法依赖的package包/类
public boolean routePacket(byte[] nodeID, JID receipient, Packet packet) {
    // Send the packet to the specified node and let the remote node deliver the packet to the recipient
    try {
        CacheFactory.doClusterTask(new RemotePacketExecution(receipient, packet), nodeID);
        return true;
    } catch (IllegalStateException  e) {
        logger.warn("Error while routing packet to remote node: " + e);
        return false;
    }
}
 
开发者ID:idwanglu2010,项目名称:openfire,代码行数:11,代码来源:ClusterPacketRouter.java

示例14: configureNode

import org.jivesoftware.util.cache.CacheFactory; //导入方法依赖的package包/类
private void configureNode(PubSubService service, IQ iq, Element configureElement, String nodeID) {
    Node node = service.getNode(nodeID);
    if (node == null) {
        // Node does not exist. Return item-not-found error
        sendErrorPacket(iq, PacketError.Condition.item_not_found, null);
        return;
    }
    if (!node.isAdmin(iq.getFrom())) {
        // Requesting entity is not allowed to get node configuration. Return forbidden error
        sendErrorPacket(iq, PacketError.Condition.forbidden, null);
        return;
    }

    // Get the data form that contains the parent nodeID
    DataForm completedForm = getSentConfigurationForm(configureElement);
    if (completedForm != null) {
        try {
            // Update node configuration with the provided data form
            // (and update the backend store)
            node.configure(completedForm);

            CacheFactory.doClusterTask(new RefreshNodeTask(node));
            // Return that node configuration was successful
            router.route(IQ.createResultIQ(iq));
        }
        catch (NotAcceptableException e) {
            // Node should have at least one owner. Return not-acceptable error.
            sendErrorPacket(iq, PacketError.Condition.not_acceptable, null);
        }
    }
    else {
        // No data form was included so return bad-request error
        sendErrorPacket(iq, PacketError.Condition.bad_request, null);
    }
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:36,代码来源:PubSubEngine.java

示例15: createLeafNode

import org.jivesoftware.util.cache.CacheFactory; //导入方法依赖的package包/类
/**
   * Create a channel using the channel request.
   *
   * @param createUsername
   * @param channelId
   * @param parentNode
   * @throws ChannelExistsException   -- if channel already exists
   * @throws NotAcceptableException -- if an exception is thrown by openfire during channel creation.
   */
  private LeafNode createLeafNode(String createUsername, String channelId,
                    CollectionNode parentNode, ChannelCreateInfo channelInfo)
                        throws ChannelExistsException, NotAcceptableException {

    String channelName = channelInfo.getChannelName();
    String channelDescription = channelInfo.getDescription();
    int maxItems = channelInfo.getMaxItems();

    Node result = mPubSubModule.getNode(channelId);
    if (result != null) {
      throw new ChannelExistsException("Channel with id: " + channelId + " exists");
    }
    LeafNode createdNode = null;
    if (result == null) {
      // This config form should use the same values from setOptions().
      ConfigureForm form = new ConfigureForm(DataForm.Type.submit);
      form.setAccessModel(ChannelHelper.isUserChannel(channelId) ?
          ConfigureForm.AccessModel.authorize : ConfigureForm.AccessModel.open);
      form.setPersistentItems(maxItems != 0);
      form.setMaxItems(maxItems);
      form.setSendItemSubscribe(true);
      form.setMaxPayloadSize(Constants.MAX_PAYLOAD_SIZE);
      form.setDeliverPayloads(true);
      form.setNotifyRetract(false);
      form.setNotifyDelete(false);
      form.setNotifyConfig(false);
      form.setNodeType(ConfigureForm.NodeType.leaf);
      // TODO: default permission for channels created from console is subscribers
      TopicAction.PublisherType permission = channelInfo.getPublishPermission();
      if (permission == null) {
        permission = TopicAction.PublisherType.subscribers;
      }
      form.setPublishModel(ConfigureForm.convert(permission));
      form.setTitle(channelName);
      form.setSubscribe(channelInfo.isSubscriptionEnabled());
      if (channelDescription != null) {
        form.setDescription(channelDescription);
      }
//      LOGGER.trace("Leaf config form: "+form);

      JID jid = new JID(createUsername, mServer.getServerInfo().getXMPPDomain(), null);
      LeafNode node = new LeafNode(mPubSubModule, parentNode, channelId, jid);
      node.addOwner(jid);
      try {
        node.configure(form);
      } catch (NotAcceptableException e) {
        LOGGER.warn("NotAcceptableException", e);
        throw e;
      }

      if (channelInfo.isSubscribeOnCreate()) {
        NodeSubscription subscription = subscribeToNode(node, jid, jid);
        // TODO: not returning the subscription ID yet.
      }

      node.saveToDB();
      CacheFactory.doClusterTask(new RefreshNodeTask(node));
      createdNode = node;
    }
    return createdNode;
  }
 
开发者ID:magnetsystems,项目名称:message-server,代码行数:71,代码来源:MMXChannelManager.java


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