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.
This artifact provides a single jar that contains all classes required to use remote Jakarta Enterprise Beans and Jakarta Messaging, including
all dependencies. It is intended for use by those not using maven, maven users should just import the Jakarta Enterprise Beans and
Jakarta Messaging BOM's instead (shaded JAR's cause lots of problems with maven, as it is very easy to inadvertently end up
with different versions on classes on the class path).
package org.jgroups.stack;
import org.jgroups.Event;
import org.jgroups.Message;
import org.jgroups.annotations.ManagedAttribute;
import org.jgroups.annotations.ManagedOperation;
import org.jgroups.annotations.Property;
import org.jgroups.conf.ClassConfigurator;
import org.jgroups.jmx.ResourceDMBean;
import org.jgroups.logging.Log;
import org.jgroups.logging.LogFactory;
import org.jgroups.protocols.TP;
import org.jgroups.util.MessageBatch;
import org.jgroups.util.SocketFactory;
import org.jgroups.util.ThreadFactory;
import org.jgroups.util.Util;
import org.w3c.dom.Node;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.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
*/
public abstract class Protocol {
protected Protocol up_prot, down_prot;
protected ProtocolStack stack;
@Property(description="Determines whether to collect statistics (and expose them via JMX). Default is true",writable=true)
protected boolean stats=true;
@Property(description="Enables ergonomics: dynamically find the best values for properties at runtime")
protected boolean ergonomics=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 (also change ID)",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=false)
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)
*/
public Protocol setLevel(String level) {log.setLevel(level); return this;}
@Property(name="level", description="logger level (see javadocs)")
public String getLevel() {return log.getLevel();}
public Protocol level(String level) {this.log.setLevel(level); return this;}
public boolean isErgonomics() {return ergonomics;}
public Protocol setErgonomics(boolean ergonomics) {this.ergonomics=ergonomics; return this;}
public ProtocolStack getProtocolStack() {return stack;}
public boolean statsEnabled() {return stats;}
public void enableStats(boolean flag) {stats=flag;}
public String getName() {return name;}
public short getId() {return id;}
public Protocol setId(short id) {this.id=id; return this;}
public Protocol getUpProtocol() {return up_prot;}
public Protocol getDownProtocol() {return down_prot;}
public Protocol setUpProtocol(Protocol prot) {this.up_prot=prot; return this;}
public Protocol setDownProtocol(Protocol prot) {this.down_prot=prot; return this;}
public Protocol setProtocolStack(ProtocolStack s) {this.stack=s; return this;}
public Object getValue(String name) {
if(name == null) return null;
Field field=Util.getField(getClass(), name);
if(field == null)
throw new IllegalArgumentException("field \"" + name + "\n not found");
return Util.getField(field, this);
}
public Protocol setValues(Map values) {
if(values == null)
return this;
for(Map.Entry entry: values.entrySet()) {
String attrname=entry.getKey();
Object value=entry.getValue();
Field field=Util.getField(getClass(), attrname);
if(field != null) {
Util.setField(field, this, value);
}
}
return this;
}
public Protocol setValue(String name, Object value) {
if(name == null || value == null)
return this;
Field field=Util.getField(getClass(), name);
if(field == null)
throw new IllegalArgumentException("field \"" + name + "\n not found");
Property prop=field.getAnnotation(Property.class);
if(prop != null) {
String deprecated_msg=prop.deprecatedMessage();
if(deprecated_msg != null && !deprecated_msg.isEmpty())
log.warn("Field " + getName() + "." + name + " is deprecated: " + deprecated_msg);
}
Util.setField(field, this, value);
return this;
}
/**
* 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