Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
package bboss.org.jgroups.stack;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Vector;
import bboss.org.jgroups.Event;
import bboss.org.jgroups.annotations.DeprecatedProperty;
import bboss.org.jgroups.annotations.ManagedAttribute;
import bboss.org.jgroups.annotations.Property;
import bboss.org.jgroups.conf.ClassConfigurator;
import bboss.org.jgroups.jmx.ResourceDMBean;
import bboss.org.jgroups.logging.Log;
import bboss.org.jgroups.logging.LogFactory;
import bboss.org.jgroups.protocols.TP;
import bboss.org.jgroups.util.SocketFactory;
import bboss.org.jgroups.util.ThreadFactory;
import bboss.org.jgroups.util.Util;
/**
* The Protocol class provides a set of common services for protocol layers. Each layer has to
* be a subclass of Protocol and override a number of methods (typically just up(),
* down() and getName(). Layers are stacked in a certain order to form
* a protocol stack. Events are passed from lower
* layers to upper ones and vice versa. E.g. a Message received by the UDP layer at the bottom
* will be passed to its higher layer as an Event. That layer will in turn pass the Event to
* its layer and so on, until a layer handles the Message and sends a response or discards it,
* the former resulting in another Event being passed down the stack.
*
* The important thing to bear in mind is that Events have to passed on between layers in FIFO
* order which is guaranteed by the Protocol implementation and must be guranteed by subclasses
* implementing their on Event queuing.
* Note that each class implementing interface Protocol MUST provide an empty, public
* constructor !
*
* @author Bela Ban
* @version $Id: Protocol.java,v 1.77 2010/06/15 10:10:44 belaban Exp $
*/
@DeprecatedProperty(names={"down_thread","down_thread_prio","up_thread","up_thread_prio"})
public abstract class Protocol {
protected Protocol up_prot=null, down_prot=null;
protected ProtocolStack stack=null;
@Property(description="Determines whether to collect statistics (and expose them via JMX). Default is true")
@ManagedAttribute(description="Determines whether to collect statistics (and expose them via JMX). Default is true",writable=true)
protected boolean stats=true;
/** The name of the protocol. Is by default set to the protocol's classname. This property should rarely need to
* be set, e.g. only in cases where we want to create more than 1 protocol of the same class in the same stack */
@Property(name="name",description="Give the protocol a different name if needed so we can have multiple " +
"instances of it in the same stack",writable=false)
protected String name=getClass().getSimpleName();
@Property(description="Give the protocol a different ID if needed so we can have multiple " +
"instances of it in the same stack",writable=true)
protected short id=ClassConfigurator.getProtocolId(getClass());
protected final Log log=LogFactory.getLog(this.getClass());
/**
* Sets the level of a logger. This method is used to dynamically change the logging level of a
* running system, e.g. via JMX. The appender of a level needs to exist.
* @param level The new level. Valid values are "fatal", "error", "warn", "info", "debug", "trace"
* (capitalization not relevant)
*/
@Property(name="level", description="Sets the logger level (see javadocs)")
public void setLevel(String level) {
log.setLevel(level);
}
public String getLevel() {
return log.getLevel();
}
/**
* Configures the protocol initially. A configuration string consists of name=value
* items, separated by a ';' (semicolon), e.g.:
* "loopback=false;unicast_inport=4444"
*
* @deprecated The properties are now set through the @Property annotation on the attribute or setter
*/
protected boolean setProperties(Properties props) {
throw new UnsupportedOperationException("deprecated; use a setter instead");
}
/**
* Sets a property
* @param key
* @param val
* @deprecated Use the corresponding setter instead
*/
public void setProperty(String key, String val) {
throw new UnsupportedOperationException("deprecated; use a setter instead");
}
/** Called by Configurator. Removes 2 properties which are used by the Protocol directly and then
* calls setProperties(), which might invoke the setProperties() method of the actual protocol instance.
* @deprecated Use a setter instead
*/
public boolean setPropertiesInternal(Properties props) {
throw new UnsupportedOperationException("use a setter instead");
}
/**
* @return
* @deprecated Use a getter to get the actual instance variable
*/
public Properties getProperties() {
if(log.isWarnEnabled())
log.warn("deprecated feature: please use a setter instead");
return new Properties();
}
public ProtocolStack getProtocolStack(){
return stack;
}
/**
* After configuring the protocol itself from the properties defined in the XML config, a protocol might have
* additional objects which need to be configured. This callback allows a protocol developer to configure those
* other objects. This call is guaranteed to be invoked after the protocol itself has
* been configured. See AUTH for an example.
* @return
*/
protected List