pgoldstein    2002/09/24 15:23:04

  Modified:    src/java/org/apache/james/smtpserver SMTPServer.java
               src/java/org/apache/james/pop3server POP3Server.java
               src/java/org/apache/james/nntpserver NNTPServer.java
  Log:
  Fixed XML "enabled" attribute to be a kosher boolean attributes.
  Made enabled volatile to ensure visibility to all threads
  Documented the enabled variable.
  
  
  Revision  Changes    Path
  1.12      +9 -5      
jakarta-james/src/java/org/apache/james/smtpserver/SMTPServer.java
  
  Index: SMTPServer.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-james/src/java/org/apache/james/smtpserver/SMTPServer.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- SMTPServer.java   24 Sep 2002 15:33:48 -0000      1.11
  +++ SMTPServer.java   24 Sep 2002 22:23:03 -0000      1.12
  @@ -38,7 +38,12 @@
        * The mailet context - we access it here to set the hello name for the Mailet 
API
        */
       MailetContext mailetcontext;
  -    private boolean enabled = true;
  +
  +    /**
  +     * Whether this service is enabled
  +     */
  +    private volatile boolean enabled = true;
  +
       protected ConnectionHandlerFactory createFactory() {
           return new DefaultHandlerFactory(SMTPHandler.class);
       }
  @@ -62,10 +67,9 @@
        * @throws ConfigurationException if an error occurs
        */
       public void configure(final Configuration configuration) throws 
ConfigurationException {
  -        m_port = configuration.getChild("port").getValueAsInteger(25);
  -        if (configuration.getAttribute("enabled").equalsIgnoreCase("false")) {
  -            enabled = false;
  -        } else {
  +        enabled = configuration.getAttributeAsBoolean("enabled", true);
  +        if (enabled) {
  +            m_port = configuration.getChild("port").getValueAsInteger(25);
               try {
                   final String bindAddress = 
configuration.getChild("bind").getValue(null);
                   if (null != bindAddress) {
  
  
  
  1.10      +10 -4     
jakarta-james/src/java/org/apache/james/pop3server/POP3Server.java
  
  Index: POP3Server.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-james/src/java/org/apache/james/pop3server/POP3Server.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- POP3Server.java   24 Sep 2002 15:33:48 -0000      1.9
  +++ POP3Server.java   24 Sep 2002 22:23:03 -0000      1.10
  @@ -24,7 +24,12 @@
    * @author  <a href="mailto:[EMAIL PROTECTED]";>Danny Angus</a>
    */
   public class POP3Server extends AbstractService implements Component {
  -    private boolean enabled = true;
  +
  +    /**
  +     * Whether this service is enabled
  +     */
  +    private volatile boolean enabled = true;
  +
       /**
        * Creates a subclass specific handler factory for use by the superclass.
        *
  @@ -40,9 +45,8 @@
        * @throws ConfigurationException if an error occurs
        */
       public void configure(final Configuration configuration) throws 
ConfigurationException {
  -        if (configuration.getAttribute("enabled").equalsIgnoreCase("false")) {
  -            enabled = false;
  -        } else {
  +        enabled = configuration.getAttributeAsBoolean("enabled", true);
  +        if (enabled) {
               m_port = configuration.getChild("port").getValueAsInteger(25);
               try {
                   final String bindAddress = 
configuration.getChild("bind").getValue(null);
  @@ -59,6 +63,7 @@
               super.configure(configuration.getChild("handler"));
           }
       }
  +
       /**
        * Initialize the component. Initialization includes
        * allocating any resources required throughout the
  @@ -86,6 +91,7 @@
               System.out.println("POP3 Server Disabled");
           }
       }
  +
       /**
        * The dispose operation is called at the end of a components lifecycle.
        * Instances of this class use this method to release and destroy any
  
  
  
  1.10      +8 -4      
jakarta-james/src/java/org/apache/james/nntpserver/NNTPServer.java
  
  Index: NNTPServer.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-james/src/java/org/apache/james/nntpserver/NNTPServer.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- NNTPServer.java   24 Sep 2002 15:33:49 -0000      1.9
  +++ NNTPServer.java   24 Sep 2002 22:23:04 -0000      1.10
  @@ -21,7 +21,12 @@
    * @author  <a href="mailto:[EMAIL PROTECTED]";>Danny Angus</a>
    */
   public class NNTPServer extends AbstractService implements Component {
  -    private boolean enabled = true;
  +
  +    /**
  +     * Whether this service is enabled
  +     */
  +    private volatile boolean enabled = true;
  +
       protected ConnectionHandlerFactory createFactory() {
           return new DefaultHandlerFactory(NNTPHandler.class);
       }
  @@ -32,9 +37,8 @@
        * @throws ConfigurationException if an error occurs
        */
       public void configure(final Configuration configuration) throws 
ConfigurationException {
  -        if (configuration.getAttribute("enabled").equalsIgnoreCase("false")) {
  -            enabled = false;
  -        } else {
  +        enabled = configuration.getAttributeAsBoolean("enabled", true);
  +        if (enabled) {
               m_port = configuration.getChild("port").getValueAsInteger(119);
               try {
                   String bindAddress = configuration.getChild("bind").getValue(null);
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to