Commit 83882b86 authored by Alex Wenckus's avatar Alex Wenckus Committed by alex

Initial work on component lifecycle management.

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@8589 b35dd754-fafc-0310-a699-88a17e54d16e
parent 3784cd3c
package org.jivesoftware.openfire.component;
import org.jivesoftware.openfire.lifecycle.JiveLifecycle;
/**
* Manages a components lifecycle. A component can be started and stopped, either by explicitly
* calling the start and stop methods or if a jive property is set on the LifeCycle object to be
* either true or false. True causing the the component to be started, if it is not already started,
* and false causing it to be stopped. Note that either the property needs to be expliticity set or
* the component needs to be explicitly stopped in order for the component to enter the stopped
* state.
*
* @author Alexander Wenckus
*/
public interface ComponentLifecycle extends JiveLifecycle {
/**
* Starts the component, setting the JiveProperty to true if it exists.
*/
void start();
/**
* Stops the component, setting the JiveProperty to false if it exists.
*/
void stop();
}
package org.jivesoftware.openfire.lifecycle;
/**
* Provide a JiveProperty which manages the lifecycle of your object. If the provided property
* is true or does not exist, the Object should be considered to be in a running state. Otherwise, if
* the property is explicitly set to false the Lifecycle object is considered to not be running.
*/
public interface JiveLifecycle {
/**
* The JiveProperty which either when it doesn't exist or is set to true. If no property has been
* set the Lifecycle should be considered to be in a running state. If the JivePropety
* is not explicitly set to the value "false" then the Lifecycle object should be considered
* to be not in a running state.
*
* @param jiveProperty the JiveProperty which defines the
*/
void setJiveProperty(String jiveProperty);
/**
* The only way this method will return False is if a JiveProperty has been specified and it has been
* explicitly set to "false".
*
* @return true if this Lifecycle object is running and false if it is not.
*/
boolean isRunning();
}
......@@ -11,9 +11,9 @@
package org.jivesoftware.util;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArraySet;
/**
* Dispatches property events. Each event has a {@link EventType type}
......@@ -33,8 +33,8 @@ import java.util.concurrent.CopyOnWriteArrayList;
*/
public class PropertyEventDispatcher {
private static List<PropertyEventListener> listeners =
new CopyOnWriteArrayList<PropertyEventListener>();
private static Set<PropertyEventListener> listeners =
new CopyOnWriteArraySet<PropertyEventListener>();
private PropertyEventDispatcher() {
// Not instantiable.
......
......@@ -8,6 +8,7 @@
package org.xmpp.component;
import org.jivesoftware.openfire.IQResultListener;
import org.jivesoftware.openfire.component.ComponentLifecycle;
import org.xmpp.packet.IQ;
import org.xmpp.packet.Packet;
......@@ -27,14 +28,19 @@ public interface ComponentManager {
*
* @param subdomain the subdomain of the component's address.
* @param component the component.
* @throws ComponentException
*/
public void addComponent(String subdomain, Component component) throws ComponentException;
ComponentLifecycle addComponent(String subdomain, Component component, String jiveProperty)
throws ComponentException;
/**
* Removes a component. The {@link Component#shutdown} method will be called on the
* component.
*
* @param subdomain the subdomain of the component's address.
* @throws ComponentException
*/
public void removeComponent(String subdomain) throws ComponentException;
......@@ -47,6 +53,7 @@ public interface ComponentManager {
*
* @param component the component sending the packet.
* @param packet the packet to send.
* @throws ComponentException
*/
public void sendPacket(Component component, Packet packet) throws ComponentException;
......@@ -66,6 +73,7 @@ public interface ComponentManager {
* @param timeout the number of milliseconds to wait before returning an IQ error.
* @return the answer sent by the server. The answer could be an IQ of type result or
* error.
* @throws ComponentException
*/
public IQ query(Component component, IQ packet, int timeout) throws ComponentException;
......@@ -76,6 +84,7 @@ public interface ComponentManager {
* @param component the component sending the packet.
* @param packet the IQ packet to send.
* @param listener the listener that will be invoked when an answer is received.
* @throws ComponentException
*/
public void query(Component component, IQ packet, IQResultListener listener) throws ComponentException;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment