sashenka
Class Sashenka

java.lang.Object
  |
  +--sashenka.irc.IRCConnectionHandlerAdapter
        |
        +--sashenka.Sashenka
All Implemented Interfaces:
IRCConnectionHandler, java.lang.Runnable, javax.servlet.ServletContext

public class Sashenka
extends IRCConnectionHandlerAdapter
implements java.lang.Runnable, javax.servlet.ServletContext


Nested Class Summary
 class Sashenka.MessageComparator
           
 
Field Summary
protected  java.util.Hashtable attributes
           
protected  java.util.Properties initParams
           
 
Constructor Summary
Sashenka()
           
 
Method Summary
 void debug(java.lang.String message)
          Write a debug message.
 sashenka.Sashenka.Message dequeue()
           
 void enqueue(sashenka.Sashenka.Message m)
          Toss another message into the queue.
 java.lang.Object getAttribute(java.lang.String name)
           
 java.util.Enumeration getAttributeNames()
           
 javax.servlet.ServletContext getContext(java.lang.String uripath)
          Per the spec, in a security conscious environment we may return null here.
 java.lang.String getInitParameter(java.lang.String name)
          Get the named context-wide parameter if it exists or null if it does not.
 java.util.Enumeration getInitParameterNames()
           
 int getMajorVersion()
           
 java.lang.String getMimeType(java.lang.String file)
          Return the mime type of the given file.
 int getMinorVersion()
           
 javax.servlet.RequestDispatcher getNamedDispatcher(java.lang.String name)
          Returns a named dispatcher.
 java.lang.String getRealPath(java.lang.String path)
          Get the real (system) path for a given relative path.
 javax.servlet.RequestDispatcher getRequestDispatcher(java.lang.String path)
          Returns a request dispatcher object that acts as a wrapper for the resource at the given path.
 java.net.URL getResource(java.lang.String path)
          Return a URL to the resource mapped to a specific path.
 java.io.InputStream getResourceAsStream(java.lang.String path)
          Returns the resource located at the named path as an InputStream object.
 java.util.Set getResourcePaths(java.lang.String path)
           
 java.lang.String getServerInfo()
          Return some general information about the servlet container server.
 java.lang.String getServetContextName()
           
 javax.servlet.Servlet getServlet(java.lang.String name)
          Deprecated.  
 java.util.Enumeration getServletNames()
          Deprecated.  
 java.util.Enumeration getServlets()
          Deprecated.  
 void idleChannel(Channel channel, long idleTime)
           
 void incomingMessage(java.lang.String prefix, java.lang.String command, java.lang.String[] params)
          Process an incoming message from the server.
 void internal(java.lang.String prefix, java.lang.String message)
           
 void invite(IRCUser inviter, IRCUser invitee, Channel channel)
           
 void join(IRCUser who, java.util.Collection channels)
           
 void kick(IRCUser who, IRCUser kicked, Channel channel, java.lang.String reason)
           
protected  void loadAllModules()
           
protected  void loadModule(java.lang.String classname, java.lang.String name, java.util.Properties p)
           
protected  void loadPropertiesFromFile(java.util.Properties p, java.lang.String fileName)
           
 void log(java.lang.Exception e, java.lang.String message)
          Deprecated.  
 void log(java.lang.String message)
          Write a log message.
 void log(java.lang.String message, java.lang.Throwable t)
          Write a log message.
static void main(java.lang.String[] args)
           
 void notice(Source from, java.lang.String message)
           
 void part(IRCUser who, java.util.Collection channels)
           
 void privmsg(IRCUser from, java.util.Collection to, java.lang.String message)
           
 void removeAttribute(java.lang.String name)
           
 void run()
           
 void setAttribute(java.lang.String name, java.lang.Object o)
           
 void status(java.lang.String message)
          Process status messages from the IO subsystem.
protected  void unloadAllModules()
           
 
Methods inherited from class sashenka.irc.IRCConnectionHandlerAdapter
connected, connecting, disconnected, disconnecting, getMOTD, getNick, getUser, mode, nick, ping, processERR_ALREADYREGISTRED, processERR_BADCHANMASK, processERR_BADCHANNELKEY, processERR_BANNEDFROMCHAN, processERR_CANNOTSENDTOCHAN, processERR_CANTKILLSERVER, processERR_CHANNELISFULL, processERR_CHANOPRIVSNEEDED, processERR_ERRONEUSNICKNAME, processERR_FILEERROR, processERR_INVITEONLYCHAN, processERR_KEYSET, processERR_NEEDMOREPARAMS, processERR_NICKCOLLISION, processERR_NICKNAMEINUSE, processERR_NOADMININFO, processERR_NOLOGIN, processERR_NOMOTD, processERR_NONICKNAMEGIVEN, processERR_NOOPERHOST, processERR_NOORIGIN, processERR_NOPERMFORHOST, processERR_NOPRIVILEGES, processERR_NORECIPIENT, processERR_NOSERVICEHOST, processERR_NOSUCHCHANNEL, processERR_NOSUCHNICK, processERR_NOSUCHSERVER, processERR_NOTEXTTOSEND, processERR_NOTONCHANNEL, processERR_NOTOPLEVEL, processERR_NOTREGISTERED, processERR_PASSWDMISMATCH, processERR_SUMMONDISABLED, processERR_TOOMANYCHANNELS, processERR_TOOMANYTARGETS, processERR_UMODEUNKNOWNFLAG, processERR_UNKNOWNCOMMAND, processERR_UNKNOWNMODE, processERR_USERNOTINCHANNEL, processERR_USERONCHANNEL, processERR_USERSDISABLED, processERR_USERSDONTMATCH, processERR_WASNOSUCHNICK, processERR_WILDTOPLEVEL, processERR_YOUREBANNEDCREEP, processERR_YOUWILLBEBANNED, processIGNORE, processINTERNAL, processINVITE, processJOIN, processKICK, processMODE, processNICK, processNOTICE, processPART, processPING, processPRIVMSG, processRPL_ADMINEMAIL, processRPL_ADMINLOC1, processRPL_ADMINLOC2, processRPL_ADMINME, processRPL_AWAY, processRPL_BANLIST, processRPL_BOUNCE, processRPL_CHANNELMODEIS, processRPL_CLOSEEND, processRPL_CLOSING, processRPL_CREATED, processRPL_ENDOFBANLIST, processRPL_ENDOFINFO, processRPL_ENDOFLINKS, processRPL_ENDOFMOTD, processRPL_ENDOFNAMES, processRPL_ENDOFSERVICES, processRPL_ENDOFSTATS, processRPL_ENDOFUSERS, processRPL_ENDOFWHO, processRPL_ENDOFWHOIS, processRPL_ENDOFWHOWAS, processRPL_GLOBALUSERS, processRPL_INFO, processRPL_INFOSTART, processRPL_INVITING, processRPL_ISON, processRPL_KILLDONE, processRPL_LINKS, processRPL_LIST, processRPL_LISTEND, processRPL_LISTSTART, processRPL_LOCALUSERS, processRPL_LUSERCHANNELS, processRPL_LUSERCLIENT, processRPL_LUSERME, processRPL_LUSEROP, processRPL_LUSERUNKNOWN, processRPL_MOTD, processRPL_MOTDSTART, processRPL_MYINFO, processRPL_MYPORTIS, processRPL_NAMREPLY, processRPL_NONE, processRPL_NOTOPIC, processRPL_NOUSERS, processRPL_NOWAWAY, processRPL_REHASHING, processRPL_SERVICE, processRPL_SERVICEINFO, processRPL_SERVLIST, processRPL_SERVLISTEND, processRPL_STATSCLINE, processRPL_STATSCOMMANDS, processRPL_STATSCONN, processRPL_STATSHLINE, processRPL_STATSILINE, processRPL_STATSKLINE, processRPL_STATSLINKINFO, processRPL_STATSLLINE, processRPL_STATSNLINE, processRPL_STATSOLINE, processRPL_STATSQLINE, processRPL_STATSUPTIME, processRPL_STATSYLINE, processRPL_SUMMONING, processRPL_TIME, processRPL_TOPIC, processRPL_TRACECLASS, processRPL_TRACECONNECTING, processRPL_TRACEHANDSHAKE, processRPL_TRACELINK, processRPL_TRACELOG, processRPL_TRACENEWTYPE, processRPL_TRACEOPERATOR, processRPL_TRACESERVER, processRPL_TRACEUNKNOWN, processRPL_TRACEUSER, processRPL_UMODEIS, processRPL_UNAWAY, processRPL_USERHOST, processRPL_USERS, processRPL_USERSSTART, processRPL_VERSION, processRPL_WELCOME, processRPL_WHOISCHANNELS, processRPL_WHOISCHANOP, processRPL_WHOISIDENTIFIED, processRPL_WHOISIDLE, processRPL_WHOISOPERATOR, processRPL_WHOISSERVER, processRPL_WHOISUSER, processRPL_WHOREPLY, processRPL_WHOWASUSER, processRPL_YOUREOPER, processRPL_YOURHOST, processTOPIC, processUNKNOWN, processUSER, setNick, setPassword, topic, user
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

initParams

protected java.util.Properties initParams

attributes

protected java.util.Hashtable attributes
Constructor Detail

Sashenka

public Sashenka()
Method Detail

run

public void run()
Specified by:
run in interface java.lang.Runnable

unloadAllModules

protected void unloadAllModules()

loadAllModules

protected void loadAllModules()

loadPropertiesFromFile

protected void loadPropertiesFromFile(java.util.Properties p,
                                      java.lang.String fileName)

loadModule

protected void loadModule(java.lang.String classname,
                          java.lang.String name,
                          java.util.Properties p)

enqueue

public void enqueue(sashenka.Sashenka.Message m)
Toss another message into the queue.


dequeue

public sashenka.Sashenka.Message dequeue()

incomingMessage

public void incomingMessage(java.lang.String prefix,
                            java.lang.String command,
                            java.lang.String[] params)
Process an incoming message from the server. This method overrides the verison in the adapter, but after passing the message through the loaded servlets, it will default to the adapter's implementation should nobody affix a reply. In order to be speedy we will actually just dump the incoming request into a queue and let the caller return while the thread pool services the request queue.

Specified by:
incomingMessage in interface IRCConnectionHandler
Overrides:
incomingMessage in class IRCConnectionHandlerAdapter

invite

public void invite(IRCUser inviter,
                   IRCUser invitee,
                   Channel channel)
Specified by:
invite in interface IRCConnectionHandler
Overrides:
invite in class IRCConnectionHandlerAdapter

kick

public void kick(IRCUser who,
                 IRCUser kicked,
                 Channel channel,
                 java.lang.String reason)
Specified by:
kick in interface IRCConnectionHandler
Overrides:
kick in class IRCConnectionHandlerAdapter

part

public void part(IRCUser who,
                 java.util.Collection channels)
Specified by:
part in interface IRCConnectionHandler
Overrides:
part in class IRCConnectionHandlerAdapter

join

public void join(IRCUser who,
                 java.util.Collection channels)
Specified by:
join in interface IRCConnectionHandler
Overrides:
join in class IRCConnectionHandlerAdapter

idleChannel

public void idleChannel(Channel channel,
                        long idleTime)

internal

public void internal(java.lang.String prefix,
                     java.lang.String message)
Overrides:
internal in class IRCConnectionHandlerAdapter

privmsg

public void privmsg(IRCUser from,
                    java.util.Collection to,
                    java.lang.String message)
Specified by:
privmsg in interface IRCConnectionHandler
Specified by:
privmsg in class IRCConnectionHandlerAdapter

notice

public void notice(Source from,
                   java.lang.String message)
Specified by:
notice in interface IRCConnectionHandler
Specified by:
notice in class IRCConnectionHandlerAdapter

status

public void status(java.lang.String message)
Process status messages from the IO subsystem. (Essentially update what would be a status line.

Specified by:
status in interface IRCConnectionHandler
Specified by:
status in class IRCConnectionHandlerAdapter

getContext

public javax.servlet.ServletContext getContext(java.lang.String uripath)
Per the spec, in a security conscious environment we may return null here.

Specified by:
getContext in interface javax.servlet.ServletContext

getMajorVersion

public int getMajorVersion()
Specified by:
getMajorVersion in interface javax.servlet.ServletContext

getMinorVersion

public int getMinorVersion()
Specified by:
getMinorVersion in interface javax.servlet.ServletContext

getMimeType

public java.lang.String getMimeType(java.lang.String file)
Return the mime type of the given file. This container does not permit filesystem access. Therefore all files have a null mime type.

Specified by:
getMimeType in interface javax.servlet.ServletContext

getResource

public java.net.URL getResource(java.lang.String path)
Return a URL to the resource mapped to a specific path. Nothing is mapped in this container therefore we return null for all paths. There are no external resources the container makes available to the bot modules.

Specified by:
getResource in interface javax.servlet.ServletContext

getResourceAsStream

public java.io.InputStream getResourceAsStream(java.lang.String path)
Returns the resource located at the named path as an InputStream object. No resources exist at any path, therefore this method always returns null.

Specified by:
getResourceAsStream in interface javax.servlet.ServletContext

getRequestDispatcher

public javax.servlet.RequestDispatcher getRequestDispatcher(java.lang.String path)
Returns a request dispatcher object that acts as a wrapper for the resource at the given path. Could be used to forward requests. Always returns null.

Specified by:
getRequestDispatcher in interface javax.servlet.ServletContext

getNamedDispatcher

public javax.servlet.RequestDispatcher getNamedDispatcher(java.lang.String name)
Returns a named dispatcher.

Specified by:
getNamedDispatcher in interface javax.servlet.ServletContext

debug

public void debug(java.lang.String message)
Write a debug message.

Overrides:
debug in class IRCConnectionHandlerAdapter

log

public void log(java.lang.String message)
Write a log message.

Specified by:
log in interface javax.servlet.ServletContext
Overrides:
log in class IRCConnectionHandlerAdapter

log

public void log(java.lang.String message,
                java.lang.Throwable t)
Write a log message.

Specified by:
log in interface javax.servlet.ServletContext

getRealPath

public java.lang.String getRealPath(java.lang.String path)
Get the real (system) path for a given relative path. This returns null as there is no filesystem access in this servlet context.

Specified by:
getRealPath in interface javax.servlet.ServletContext

getServerInfo

public java.lang.String getServerInfo()
Return some general information about the servlet container server.

Specified by:
getServerInfo in interface javax.servlet.ServletContext

getInitParameter

public java.lang.String getInitParameter(java.lang.String name)
Get the named context-wide parameter if it exists or null if it does not.

Specified by:
getInitParameter in interface javax.servlet.ServletContext

getInitParameterNames

public java.util.Enumeration getInitParameterNames()
Specified by:
getInitParameterNames in interface javax.servlet.ServletContext

getAttribute

public java.lang.Object getAttribute(java.lang.String name)
Specified by:
getAttribute in interface javax.servlet.ServletContext

getAttributeNames

public java.util.Enumeration getAttributeNames()
Specified by:
getAttributeNames in interface javax.servlet.ServletContext

setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.Object o)
Specified by:
setAttribute in interface javax.servlet.ServletContext

removeAttribute

public void removeAttribute(java.lang.String name)
Specified by:
removeAttribute in interface javax.servlet.ServletContext

getResourcePaths

public java.util.Set getResourcePaths(java.lang.String path)

getServetContextName

public java.lang.String getServetContextName()

getServlet

public javax.servlet.Servlet getServlet(java.lang.String name)
Deprecated.  

This method does nothing now and will be removed in a future version.

Specified by:
getServlet in interface javax.servlet.ServletContext

getServlets

public java.util.Enumeration getServlets()
Deprecated.  

This method does nothing now and will be removed in a future version.

Specified by:
getServlets in interface javax.servlet.ServletContext

getServletNames

public java.util.Enumeration getServletNames()
Deprecated.  

This method does nothing now and will be removed in a future version.

Specified by:
getServletNames in interface javax.servlet.ServletContext

log

public void log(java.lang.Exception e,
                java.lang.String message)
Deprecated.  

This method calls the log(String, Throwable) version for you.

Specified by:
log in interface javax.servlet.ServletContext

main

public static void main(java.lang.String[] args)