/** * Removes the <code>Destination</code> from the list of destinations known * by the <code>AbstractService</code>. * * @param id The id of the <code>Destination</code>. * @return Previous <code>Destination</code> associated with the id. */ public Destination removeDestination(String id) { Destination destination = destinations.get(id); if (destination != null) { destination.stop(); destinations.remove(id); getMessageBroker().unregisterDestination(id); } return destination; }
/** * Removes the <code>Destination</code> from the list of destinations known * by the <code>AbstractService</code>. * * @param id The id of the <code>Destination</code>. * @return Previous <code>Destination</code> associated with the id. */ public Destination removeDestination(String id) { Destination destination = destinations.get(id); if (destination != null) { destination.stop(); destinations.remove(id); getMessageBroker().unregisterDestination(id); } return destination; }
/** * Removes the <code>Destination</code> from the list of destinations known * by the <code>AbstractService</code>. * * @param id The id of the <code>Destination</code>. * @return Previous <code>Destination</code> associated with the id. */ public Destination removeDestination(String id) { Destination destination = (Destination)destinations.get(id); if (destination != null) { destination.stop(); destinations.remove(id); getMessageBroker().unregisterDestination(id); } return destination; }
/** * Sets the channel list of the <code>AbstractService</code>. * <code>MessageBroker</code> has to know the channels, otherwise they * are not added to the list. * * @param ids List of channel ids. */ public void setDefaultChannels(List ids) { if (ids != null && isStarted()) { List channelIds = getMessageBroker().getChannelIds(); for (Iterator iter = ids.iterator(); iter.hasNext();) { String id = (String) iter.next(); if (channelIds == null || !channelIds.contains(id)) { iter.remove(); if (Log.isWarn()) { Log.getLogger(getLogCategory()).warn("No channel with id '{0}' is known by the MessageBroker." + " Not adding the channel.", new Object[]{id}); } } } } // Otherwise, channels will be checked before startup defaultChannels = ids; }
/** * Sets the channel list of the <code>AbstractService</code>. * <code>MessageBroker</code> has to know the channels, otherwise they * are not added to the list. * * @param ids List of channel ids. */ public void setDefaultChannels(List<String> ids) { if (ids != null && isStarted()) { List<String> channelIds = getMessageBroker().getChannelIds(); for (Iterator<String> iter = ids.iterator(); iter.hasNext();) { String id = iter.next(); if (channelIds == null || !channelIds.contains(id)) { iter.remove(); if (Log.isWarn()) { Log.getLogger(getLogCategory()).warn("No channel with id '{0}' is known by the MessageBroker." + " Not adding the channel.", new Object[]{id}); } } } } // Otherwise, channels will be checked before startup defaultChannels = ids; }
List<String> channelIds = getMessageBroker().getChannelIds(); if (channelIds == null || !channelIds.contains(id))
protected Object serviceCommonCommands(CommandMessage message) { Object commandResult = null; if (message.getOperation() == CommandMessage.CLIENT_PING_OPERATION) { commandResult = Boolean.TRUE; } else if (message.getOperation() == CommandMessage.CLUSTER_REQUEST_OPERATION) { ClusterManager clusterManager = getMessageBroker().getClusterManager(); String serviceType = getClass().getName(); String destinationName = message.getDestination(); if (clusterManager.isDestinationClustered(serviceType, destinationName)) { commandResult = clusterManager.getEndpointsForDestination(serviceType, destinationName); } else { // client should never send this message if its local // config declares the destination is not clustered commandResult = Boolean.FALSE; } } return commandResult; }
/** * Sets the id of the <code>AbstractService</code>. If the <code>AbstractService</code> * has a <code>MessageBroker</code> assigned, it also updates the id in the * <code>MessageBroker</code>. */ public void setId(String id) { String oldId = getId(); super.setId(id); // Update the service id in the broker MessageBroker broker = getMessageBroker(); if (broker != null) { // broker must have the service then broker.removeService(oldId); broker.addService(this); } }
/** * Sets the id of the <code>AbstractService</code>. If the <code>AbstractService</code> * has a <code>MessageBroker</code> assigned, it also updates the id in the * <code>MessageBroker</code>. * * @param id the id */ @Override public void setId(String id) { String oldId = getId(); super.setId(id); // Update the service id in the broker MessageBroker broker = getMessageBroker(); if (broker != null) { // broker must have the service then broker.removeService(oldId); broker.addService(this); } }
protected Object serviceCommonCommands(CommandMessage message) { Object commandResult = null; if (message.getOperation() == CommandMessage.CLIENT_PING_OPERATION) { commandResult = Boolean.TRUE; } else if (message.getOperation() == CommandMessage.CLUSTER_REQUEST_OPERATION) { ClusterManager clusterManager = getMessageBroker().getClusterManager(); String serviceType = getClass().getName(); String destinationName = message.getDestination(); if (clusterManager.isDestinationClustered(serviceType, destinationName)) { commandResult = clusterManager.getEndpointsForDestination(serviceType, destinationName); } else { // client should never send this message if its local // config declares the destination is not clustered commandResult = Boolean.FALSE; } } return commandResult; }
protected Object serviceCommonCommands(CommandMessage message) { Object commandResult = null; if (message.getOperation() == CommandMessage.CLIENT_PING_OPERATION) { commandResult = Boolean.TRUE; } else if (message.getOperation() == CommandMessage.CLUSTER_REQUEST_OPERATION) { ClusterManager clusterManager = getMessageBroker().getClusterManager(); String serviceType = getClass().getName(); String destinationName = message.getDestination(); if (clusterManager.isDestinationClustered(serviceType, destinationName)) { commandResult = clusterManager.getEndpointsForDestination(serviceType, destinationName); } else { // client should never send this message if its local // config declares the destination is not clustered commandResult = Boolean.FALSE; } } return commandResult; }
/** * Sets the id of the <code>AbstractService</code>. If the <code>AbstractService</code> * has a <code>MessageBroker</code> assigned, it also updates the id in the * <code>MessageBroker</code>. * * @param id the id */ @Override public void setId(String id) { String oldId = getId(); super.setId(id); // Update the service id in the broker MessageBroker broker = getMessageBroker(); if (broker != null) { // broker must have the service then broker.removeService(oldId); broker.addService(this); } }
/** * Sets the <code>MessageBroker</code> of the <code>AbstractService</code>. * Removes the <code>AbstractService</code> from the old broker * (if there was one) and adds to the list of services in the new broker. * * @param broker <code>MessageBroker</code> of the <code>AbstractService</code>. */ public void setMessageBroker(MessageBroker broker) { MessageBroker oldBroker = getMessageBroker(); setParent(broker); if (oldBroker != null) { oldBroker.removeService(getId()); } // Add service to the new broker if needed if (broker.getService(getId()) != this) broker.addService(this); }
/** * Sets the <code>MessageBroker</code> of the <code>AbstractService</code>. * Removes the <code>AbstractService</code> from the old broker * (if there was one) and adds to the list of services in the new broker. * * @param broker <code>MessageBroker</code> of the <code>AbstractService</code>. */ public void setMessageBroker(MessageBroker broker) { MessageBroker oldBroker = getMessageBroker(); setParent(broker); if (oldBroker != null) { oldBroker.removeService(getId()); } // Add service to the new broker if needed if (broker.getService(getId()) != this) broker.addService(this); }
/** * Sets the <code>MessageBroker</code> of the <code>AbstractService</code>. * Removes the <code>AbstractService</code> from the old broker * (if there was one) and adds to the list of services in the new broker. * * @param broker <code>MessageBroker</code> of the <code>AbstractService</code>. */ public void setMessageBroker(MessageBroker broker) { MessageBroker oldBroker = getMessageBroker(); setParent(broker); if (oldBroker != null) { oldBroker.removeService(getId()); } // Add service to the new broker if needed if (broker.getService(getId()) != this) broker.addService(this); }
/** * Creates a <code>Destination</code> instance, sets its id, sets it manageable * if the <code>AbstractService</code> that created it is manageable, * and sets its <code>Service</code> to the <code>AbstractService</code> that * created it. Note that it cannot have a null id and cannot have an id of * a <code>Destination</code> already registered with the <code>AbstractService</code>. * * @param id The id of the <code>Destination</code>. * @return The <code>Destination</code> instanced created. */ public Destination createDestination(String id) { if (id == null) { // Cannot add ''{0}'' with null id to the ''{1}'' ConfigurationException ex = new ConfigurationException(); ex.setMessage(ConfigurationConstants.NULL_COMPONENT_ID, new Object[]{"Destination", "Service"}); throw ex; } // check with the message broker to make sure that no destination with the id already exists getMessageBroker().isDestinationRegistered(id, getId(), true); Destination destination = new Destination(); destination.setId(id); destination.setManaged(isManaged()); destination.setService(this); return destination; }
/** * Creates a <code>Destination</code> instance, sets its id, sets it manageable * if the <code>AbstractService</code> that created it is manageable, * and sets its <code>Service</code> to the <code>AbstractService</code> that * created it. Note that it cannot have a null id and cannot have an id of * a <code>Destination</code> already registered with the <code>AbstractService</code>. * * @param id The id of the <code>Destination</code>. * @return The <code>Destination</code> instanced created. */ public Destination createDestination(String id) { if (id == null) { // Cannot add ''{0}'' with null id to the ''{1}'' ConfigurationException ex = new ConfigurationException(); ex.setMessage(ConfigurationConstants.NULL_COMPONENT_ID, new Object[]{"Destination", "Service"}); throw ex; } // check with the message broker to make sure that no destination with the id already exists getMessageBroker().isDestinationRegistered(id, getId(), true); Destination destination = new Destination(); destination.setId(id); destination.setManaged(isManaged()); destination.setService(this); return destination; }
/** * The default implementation of this method stops all of the destinations * of the service. * If subclasses override, they must call <code>super.stop()</code>. */ public void stop() { if (!isStarted()) { return; } stopDestinations(); super.stop(); // Remove management if (isManaged() && getMessageBroker().isManaged()) { if (getControl() != null) { getControl().unregister(); setControl(null); } setManaged(false); } }
/** * The default implementation of this method stops all of the destinations * of the service. * If subclasses override, they must call <code>super.stop()</code>. */ @Override public void stop() { if (!isStarted()) { return; } stopDestinations(); super.stop(); // Remove management if (isManaged() && getMessageBroker().isManaged()) { if (getControl() != null) { getControl().unregister(); setControl(null); } setManaged(false); } }
/** * The default implementation of this method stops all of the destinations * of the service. * If subclasses override, they must call <code>super.stop()</code>. */ @Override public void stop() { if (!isStarted()) { return; } stopDestinations(); super.stop(); // Remove management if (isManaged() && getMessageBroker().isManaged()) { if (getControl() != null) { getControl().unregister(); setControl(null); } setManaged(false); } }