You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by Norman Maurer <nm...@byteaction.de> on 2006/06/09 22:05:16 UTC

Re: svn commit: r413135 - /james/server/trunk/src/java/org/apache/james/transport/matchers/AbstractNetworkMatcher.java

Hi guys,

i whould like to use setter methods for that in all mailets and matchers
like i did in smtpCommandHandlers (refactoring). Anyone has a problem
with that? If not i go ahead..

bye
Norman

Am Freitag, den 09.06.2006, 19:36 +0000 schrieb norman@apache.org:
> Author: norman
> Date: Fri Jun  9 12:36:39 2006
> New Revision: 413135
> 
> URL: http://svn.apache.org/viewvc?revA3135&view=rev
> Log:
> -Add set methods for ServiceManager and DNSServer
> -Throws MessagingException if the DNSServer was not suplied!
> 
> Modified:
>     james/server/trunk/src/java/org/apache/james/transport/matchers/AbstractNetworkMatcher.java
> 
> Modified: james/server/trunk/src/java/org/apache/james/transport/matchers/AbstractNetworkMatcher.java
> URL: http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/transport/matchers/AbstractNetworkMatcher.java?revA3135&r1A3134&r2A3135&view=diff
> =============================================================================--- james/server/trunk/src/java/org/apache/james/transport/matchers/AbstractNetworkMatcher.java (original)
> +++ james/server/trunk/src/java/org/apache/james/transport/matchers/AbstractNetworkMatcher.java Fri Jun  9 12:36:39 2006
> @@ -17,7 +17,6 @@
> 
>  package org.apache.james.transport.matchers;
> 
> -import org.apache.avalon.framework.service.ServiceException;
>  import org.apache.avalon.framework.service.ServiceManager;
>  import org.apache.james.Constants;
>  import org.apache.james.services.DNSServer;
> @@ -58,18 +57,21 @@
>       * The DNSServer
>       */
>      private DNSServer dnsServer;
> +
> +    /**
> +     * The ServiceManger
> +     */
> +    private ServiceManager compMgr;
> 
>      public void init() throws MessagingException {
> 
> -        ServiceManager compMgr = (ServiceManager)getMailetContext().getAttribute(Constants.AVALON_COMPONENT_MANAGER);
> +        setServiceManager((ServiceManager)getMailetContext().getAttribute(Constants.AVALON_COMPONENT_MANAGER));
> 
>          try {
>              // Instantiate DNSServer
> -            dnsServer = (DNSServer) compMgr.lookup(DNSServer.ROLE);
> -        } catch (ServiceException cnfe) {
> -            log("Failed to retrieve DNSServer" + cnfe.getMessage());
> +            setDNSServer((DNSServer) compMgr.lookup(DNSServer.ROLE));
>          } catch (Exception e) {
> -            log("Failed to retrieve DNSServer:" + e.getMessage());
> +            throw new MessagingException("Failed to retrieve DNSServer:" + e.getMessage());
>          }
> 
>          Collection nets = allowedNetworks();
> @@ -101,5 +103,14 @@
> 
>      protected boolean matchNetwork(String addr) {
>          return authorizedNetworks == null ? false : authorizedNetworks.matchInetNetwork(addr);
> +    }
> +
> +
> +    protected void setDNSServer(DNSServer dnsServer) {
> +        this.dnsServer = dnsServer;
> +    }
> +
> +    protected void setServiceManager(ServiceManager compMgr) {
> +        this.compMgr = compMgr;
>      }
>  }
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
> For additional commands, e-mail: server-dev-help@james.apache.org
> 
> 
> 

Re: svn commit: r413135 - /james/server/trunk/src/java/org/apache/james/transport/matchers/AbstractNetworkMatcher.java

Posted by Stefano Bagnara <ap...@bago.org>.
Norman Maurer wrote:
> Hi guys,
> 
> i whould like to use setter methods for that in all mailets and matchers
> like i did in smtpCommandHandlers (refactoring). Anyone has a problem
> with that? If not i go ahead..
> 
> bye
> Norman

Imho if it helps writing unittests without using Avalon it is a good change.

This is a step we agreed we need to move away from avalon one day: 
http://issues.apache.org/jira/browse/JAMES-494

Stefano


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Re: svn commit: r413135 - /james/server/trunk/src/java/org/apache/james/transport/matchers/AbstractNetworkMatcher.java

Posted by Norman Maurer <nm...@byteaction.de>.
Am Samstag, den 10.06.2006, 14:37 +0200 schrieb Stefano Bagnara:
> Norman Maurer wrote:
> > Hi guys,
> > 
> > i whould like to use setter methods for that in all mailets and matchers
> > like i did in smtpCommandHandlers (refactoring). Anyone has a problem
> > with that? If not i go ahead..
> > 
> > bye
> > Norman
> 
> Imho if it helps writing unittests without using Avalon it is a good change.
> 
> This is a step we agreed we need to move away from avalon one day: 
> http://issues.apache.org/jira/browse/JAMES-494
> 
> Stefano

It not really help in this case.. anyway it looks a bit cleaner ;-)

bye
Norman


RE: svn commit: r413135 -/james/server/trunk/src/java/org/apache/james/transport/matchers/AbstractNetworkMatcher.java

Posted by "Noel J. Bergman" <no...@devtech.com>.
Norman Maurer wrote:

> i whould like to use setter methods for that in all mailets and matchers

Ah, I just asked you about this.  OK, that explains the change we were
discussing.  :-)

> Anyone has a problem with that?

On the one hand, Java isn't Smalltalk, and I have little need to treat it as
such when initializing simple private properties, but it might help eclipse
users, since the tool can inspect, and we can centralize logging,
validation, etc., so sure, why not?  For protected and public properties,
I'm sure that we're all +1 to proper bean properties.

	--- Noel


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org