tigase.server
Class AbstractMessageReceiver

java.lang.Object
  extended by tigase.server.AbstractMessageReceiver
All Implemented Interfaces:
Configurable, MessageReceiver, ServerComponent, StatisticsContainer, VHostListener
Direct Known Subclasses:
ConnectionManager, Gateway, MessageRouter, SessionManager, StanzaReceiver, StanzaSender

public abstract class AbstractMessageReceiver
extends java.lang.Object
implements StatisticsContainer, MessageReceiver, Configurable, VHostListener

Describe class AbstractMessageReceiver here. Created: Tue Nov 22 07:07:11 2005

Version:
$Rev: 1856 $
Author:
Artur Hefczyc

Field Summary
protected static long HOUR
           
static java.lang.String MAX_QUEUE_SIZE_PROP_KEY
           
static java.lang.Integer MAX_QUEUE_SIZE_PROP_VAL
           
protected  int maxQueueSize
           
protected static long MINUTE
           
protected static long SECOND
           
protected  VHostManagerIfc vHostManager
           
 
Fields inherited from interface tigase.conf.Configurable
ADMINS_PROP_KEY, AUTH_REPO_CLASS_PROP_KEY, AUTH_REPO_PARAMS_NODE, AUTH_REPO_URL_PROP_KEY, BOSH_COMP_CLASS_NAME, C2S_CLUST_COMP_CLASS_NAME, C2S_COMP_CLASS_NAME, CL_COMP_CLASS_NAME, CLUSTER_CONECT, CLUSTER_CONTR_CLASS_NAME, CLUSTER_LISTEN, CLUSTER_MODE, CLUSTER_NODES, CLUSTER_NODES_PROP_KEY, COMPONENT_ID_PROP_KEY, DEF_BOSH_NAME, DEF_C2S_NAME, DEF_CL_COMP_NAME, DEF_CLUST_CONTR_NAME, DEF_EXT_COMP_NAME, DEF_HOSTNAME_PROP_KEY, DEF_S2S_NAME, DEF_SM_NAME, DEF_SRECV_NAME, DEF_SSEND_NAME, DEF_STATS_NAME, DEF_VHOST_MAN_NAME, DERBY_REPO_CLASS_PROP_VAL, DERBY_REPO_URL_PROP_VAL, DRUPAL_REPO_CLASS_PROP_VAL, DRUPAL_REPO_URL_PROP_VAL, EXT_COMP_CLASS_NAME, GEN_ADMINS, GEN_AUTH_DB, GEN_AUTH_DB_URI, GEN_COMP_CLASS, GEN_COMP_NAME, GEN_CONF, GEN_CONFIG, GEN_CONFIG_ALL, GEN_CONFIG_COMP, GEN_CONFIG_CS, GEN_CONFIG_DEF, GEN_CONFIG_SM, GEN_DEBUG, GEN_DEBUG_PACKAGES, GEN_EXT_COMP, GEN_MAX_QUEUE_SIZE, GEN_SM_PLUGINS, GEN_SREC_ADMINS, GEN_SREC_DB, GEN_SREC_DB_URI, GEN_TEST, GEN_TRUSTED, GEN_USER_DB, GEN_USER_DB_URI, GEN_VIRT_HOSTS, HOSTNAMES_PROP_KEY, LIBRESOURCE_REPO_CLASS_PROP_VAL, LIBRESOURCE_REPO_URL_PROP_VAL, MONITORING, MYSQL_REPO_CLASS_PROP_VAL, MYSQL_REPO_URL_PROP_VAL, NULL_ROUTING, PGSQL_REPO_CLASS_PROP_VAL, PGSQL_REPO_URL_PROP_VAL, ROUTER_COMP_CLASS_NAME, S2S_CLUST_COMP_CLASS_NAME, S2S_COMP_CLASS_NAME, SHARED_AUTH_REPO_PARAMS_PROP_KEY, SHARED_AUTH_REPO_PROP_KEY, SHARED_USER_REPO_PARAMS_PROP_KEY, SHARED_USER_REPO_POOL_PROP_KEY, SHARED_USER_REPO_PROP_KEY, SM_CLUS_COMP_CLASS_NAME, SM_COMP_CLASS_NAME, SRECV_COMP_CLASS_NAME, SSEND_COMP_CLASS_NAME, STATS_CLASS_NAME, TIGASE_AUTH_REPO_CLASS_PROP_VAL, TIGASE_AUTH_REPO_URL_PROP_VAL, TIGASE_CUSTOM_AUTH_REPO_CLASS_PROP_VAL, TRUSTED_PROP_KEY, USER_REPO_CLASS_PROP_KEY, USER_REPO_PARAMS_NODE, USER_REPO_POOL_SIZE, USER_REPO_POOL_SIZE_PROP_KEY, USER_REPO_URL_PROP_KEY, VHOST_MAN_CLASS_NAME, XML_REPO_CLASS_PROP_VAL, XML_REPO_URL_PROP_VAL
 
Constructor Summary
AbstractMessageReceiver()
           
 
Method Summary
protected  boolean addOutPacket(Packet packet)
           
protected  boolean addOutPacketNB(Packet packet)
          Non blocking version of addOutPacket.
protected  boolean addOutPackets(java.util.Queue<Packet> packets)
           
protected  boolean addOutPacketWithTimeout(Packet packet, ReceiverEventHandler handler, long delay, java.util.concurrent.TimeUnit unit)
           
 boolean addPacket(Packet packet)
          Describe addPacket method here.
 boolean addPacketNB(Packet packet)
           
 boolean addPackets(java.util.Queue<Packet> packets)
          Describe addPackets method here.
 void addRegexRouting(java.lang.String address)
           
 void clearRegexRoutings()
           
 void everyHour()
           
 void everyMinute()
           
 void everySecond()
           
 java.lang.String getComponentId()
          Describe getComponentId method here.
 java.util.Map<java.lang.String,java.lang.Object> getDefaults(java.util.Map<java.lang.String,java.lang.Object> params)
          Returns defualt configuration settings for this object.
 java.lang.String getDefHostName()
           
protected  java.lang.Integer getMaxQueueSize(int def)
           
 java.lang.String getName()
          Get object name.
 java.util.Set<java.util.regex.Pattern> getRegexRoutings()
           
 void getStatistics(StatisticsList list)
           
 VHostItem getVHostItem(java.lang.String domain)
           
 boolean handlesLocalDomains()
          Indicates whether the component accepts packets to all local domains.
 boolean handlesNameSubdomains()
          Indicates whether the component can handle packets to 'name' subdomain.
 boolean handlesNonLocalDomains()
          Indicates whether the component can handle all packets to non-local domains.
 int hashCodeForPacket(Packet packet)
          This method can be overwritten in extending classes to get a different packets distribution to different threads.
 void initializationCompleted()
           
 boolean isInRegexRoutings(java.lang.String address)
           
 boolean isLocalDomain(java.lang.String domain)
           
 boolean isLocalDomainOrComponent(java.lang.String domain)
           
 java.lang.String newPacketId(java.lang.String prefix)
           
 int processingThreads()
           
abstract  void processPacket(Packet packet)
           
 void processPacket(Packet packet, java.util.Queue<Packet> results)
          processPacket is a blocking processing method implemented by all components.
 void release()
           
 boolean removeRegexRouting(java.lang.String address)
           
 void setMaxQueueSize(int maxQueueSize)
           
 void setName(java.lang.String name)
           
 void setParent(MessageReceiver parent)
          Describe setParent method here.
 void setProperties(java.util.Map<java.lang.String,java.lang.Object> props)
          Sets all configuration properties for object.
 void setVHostManager(VHostManagerIfc manager)
          Sets the VHostManager which works on this server installation.
 void start()
           
 void stop()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SECOND

protected static final long SECOND
See Also:
Constant Field Values

MINUTE

protected static final long MINUTE
See Also:
Constant Field Values

HOUR

protected static final long HOUR
See Also:
Constant Field Values

MAX_QUEUE_SIZE_PROP_KEY

public static final java.lang.String MAX_QUEUE_SIZE_PROP_KEY
See Also:
Constant Field Values

MAX_QUEUE_SIZE_PROP_VAL

public static final java.lang.Integer MAX_QUEUE_SIZE_PROP_VAL

maxQueueSize

protected int maxQueueSize

vHostManager

protected VHostManagerIfc vHostManager
Constructor Detail

AbstractMessageReceiver

public AbstractMessageReceiver()
Method Detail

getComponentId

public java.lang.String getComponentId()
Describe getComponentId method here.

Specified by:
getComponentId in interface ServerComponent
Returns:
a String value

initializationCompleted

public void initializationCompleted()
Specified by:
initializationCompleted in interface ServerComponent

hashCodeForPacket

public int hashCodeForPacket(Packet packet)
This method can be overwritten in extending classes to get a different packets distribution to different threads. For PubSub, probably better packets distribution to different threads would be based on the sender address rather then destination address.

Parameters:
packet -
Returns:

newPacketId

public java.lang.String newPacketId(java.lang.String prefix)

addPacketNB

public boolean addPacketNB(Packet packet)
Specified by:
addPacketNB in interface MessageReceiver

addPackets

public boolean addPackets(java.util.Queue<Packet> packets)
Description copied from interface: MessageReceiver
Describe addPackets method here.

Specified by:
addPackets in interface MessageReceiver
Returns:
a boolean value

addPacket

public boolean addPacket(Packet packet)
Description copied from interface: MessageReceiver
Describe addPacket method here.

Specified by:
addPacket in interface MessageReceiver
Parameters:
packet - a Packet value
Returns:
a boolean value true if packet has been successfully added, false otherwise.

addOutPacketNB

protected boolean addOutPacketNB(Packet packet)
Non blocking version of addOutPacket.

Parameters:
packet - a Packet value
Returns:
a boolean value

addOutPacketWithTimeout

protected boolean addOutPacketWithTimeout(Packet packet,
                                          ReceiverEventHandler handler,
                                          long delay,
                                          java.util.concurrent.TimeUnit unit)

addOutPacket

protected boolean addOutPacket(Packet packet)

addOutPackets

protected boolean addOutPackets(java.util.Queue<Packet> packets)

processPacket

public abstract void processPacket(Packet packet)

getStatistics

public void getStatistics(StatisticsList list)
Specified by:
getStatistics in interface StatisticsContainer

setProperties

@TODO(note="Replace fixed filers loading with configurable options for that")
public void setProperties(java.util.Map<java.lang.String,java.lang.Object> props)
Sets all configuration properties for object.

Specified by:
setProperties in interface Configurable
Parameters:
props -

setMaxQueueSize

public void setMaxQueueSize(int maxQueueSize)

getMaxQueueSize

protected java.lang.Integer getMaxQueueSize(int def)

getDefaults

public java.util.Map<java.lang.String,java.lang.Object> getDefaults(java.util.Map<java.lang.String,java.lang.Object> params)
Returns defualt configuration settings for this object.

Specified by:
getDefaults in interface Configurable
Returns:

release

public void release()
Specified by:
release in interface ServerComponent

setParent

public void setParent(MessageReceiver parent)
Description copied from interface: MessageReceiver
Describe setParent method here.

Specified by:
setParent in interface MessageReceiver
Parameters:
parent - a MessageReceiver value

setName

public void setName(java.lang.String name)
Specified by:
setName in interface ServerComponent

getName

public java.lang.String getName()
Description copied from interface: Configurable
Get object name. This name corresponds to section in configuration.

Specified by:
getName in interface Configurable
Specified by:
getName in interface ServerComponent
Returns:
a String value of object name.

everySecond

public void everySecond()

everyMinute

public void everyMinute()

everyHour

public void everyHour()

start

public void start()
Specified by:
start in interface MessageReceiver

stop

public void stop()

getDefHostName

public java.lang.String getDefHostName()
Specified by:
getDefHostName in interface MessageReceiver

handlesLocalDomains

public boolean handlesLocalDomains()
Description copied from interface: VHostListener
Indicates whether the component accepts packets to all local domains. The best example would be SM component which usually handles all requests sent to any local domain.

Specified by:
handlesLocalDomains in interface VHostListener
Returns:
'true' if the component accepts packets to local domains 'false' otherwise.

handlesNameSubdomains

public boolean handlesNameSubdomains()
Description copied from interface: VHostListener
Indicates whether the component can handle packets to 'name' subdomain. Name subdomain is an artificial domain created from the component name and the domain name. The best example would be a 'MUC' component or a 'PubSub' component. They are usually named respectively 'muc' and 'pubsub' and they accept requests sent to domains 'muc.tigase.org' or 'pubsub.tigase.org', even though a local domain is just 'tigase.org'.

Specified by:
handlesNameSubdomains in interface VHostListener
Returns:
'true' if the component accepts packets to 'name' subdomains 'false' otherwise.

handlesNonLocalDomains

public boolean handlesNonLocalDomains()
Description copied from interface: VHostListener
Indicates whether the component can handle all packets to non-local domains. S2s connection manager component is the best example of the component which handles all requests sent to non-local domains.

Specified by:
handlesNonLocalDomains in interface VHostListener
Returns:
'true' if the component accepts packets to non-local domains 'false' otherwise.

setVHostManager

public void setVHostManager(VHostManagerIfc manager)
Description copied from interface: VHostListener
Sets the VHostManager which works on this server installation. The VHostManager allows for accessing vritual domain data.

Specified by:
setVHostManager in interface VHostListener
Parameters:
manager - is a reference to VHostManager available on the server installation.

isLocalDomain

public boolean isLocalDomain(java.lang.String domain)

isLocalDomainOrComponent

public boolean isLocalDomainOrComponent(java.lang.String domain)

getVHostItem

public VHostItem getVHostItem(java.lang.String domain)

getRegexRoutings

public java.util.Set<java.util.regex.Pattern> getRegexRoutings()

addRegexRouting

public void addRegexRouting(java.lang.String address)

removeRegexRouting

public boolean removeRegexRouting(java.lang.String address)

clearRegexRoutings

public void clearRegexRoutings()

isInRegexRoutings

public boolean isInRegexRoutings(java.lang.String address)
Specified by:
isInRegexRoutings in interface MessageReceiver

processPacket

public final void processPacket(Packet packet,
                                java.util.Queue<Packet> results)
Description copied from interface: ServerComponent
processPacket is a blocking processing method implemented by all components. This method processes packet and returns results instantly without waiting for any resources.

Specified by:
processPacket in interface ServerComponent
Parameters:
packet - a Packet value

processingThreads

public int processingThreads()


Copyright © 2009 Tigase. All Rights Reserved.