I don't know how many arguments the method you are overriding with
onLogin takes, but the function you define should take one more
argument then the method you are overiding, the first argument being
an explicit reference to an instance

On Tue, Mar 10, 2009 at 12:16 PM, rb <[email protected]> wrote:
>
> HI Chris,
>
> thanks for your response, and I'll update the code as you suggest.
> However, I actually have problems even when the -onLogin function is
> empty, returns nil, or returns FtpletResult/DEFAULT. It seems it
> causes trouble once it's defined.
>
> I'll post an update tomorrow
>
> Raphaël
>
> On Mar 10, 6:50 pm, chris <[email protected]> wrote:
>> I can see one possible difference, depending on how you are loading
>> the code into the ftp server.
>>
>> In your clojure example you are accessing the logger through a top-
>> level define.  I believe this will run *during the file loading
>> process* as static code.
>>
>> In your working java example, you aren't accessing the logger until
>> the actual onLogin function is called.
>>
>> If the logger is in an odd state (like null) or god forbid the runtime
>> sets up the logger just before it calls into your function then you
>> may get different results.  I would recommend calling the getlogger
>> call in the function perhaps; change the 'def logger' to 'defn logger
>> []' and work out the resulting details.  This would make the clojure
>> example a little closer to your java example and at least eliminate
>> one possible problem.
>>
>> Chris
>>
>> On Mar 10, 7:35 am, rb <[email protected]> wrote:
>>
>> > Hi,
>>
>> > I'm experimenting withhttp://mina.apache.org/ftpserver
>> > I have written a small java class that gets used by the ftp server,
>> > and am trying to transpose it to clojure, but unsuccessfully until
>> > now....
>>
>> > The class generated with clojure is detected and used by the server,
>> > but the code of the method implemented is not run, and even worse, the
>> > ftp server isn't functional anymore (though I don't see any exception
>> > raised).
>>
>> > Does anyone have an idea about what I'm doing wrong?
>>
>> > Thanks
>>
>> > Raphaël
>>
>> > Here's the java code:
>>
>> > package com.raphinou;
>>
>> > import java.io.IOException;
>> > import org.apache.ftpserver.*;
>> > import org.apache.ftpserver.ftplet.*;
>>
>> > public class Ftplet extends DefaultFtplet {
>> >     public FtpletResult onLogin(FtpSession session, FtpRequest
>> > request)
>> >             throws FtpException, IOException {
>> >         java.util.logging.Logger logger=
>> > java.util.logging.Logger.getLogger("com.raphinou");
>> >         logger.addHandler( new java.util.logging.FileHandler("/tmp/
>> > ftp.log"));
>> >         logger.severe("Logging in!!");
>> >         return FtpletResult.DEFAULT;
>> >     }
>>
>> > }
>>
>> > and here's the clojure code:
>>
>> >  (ns com.raphinou.ftplet
>> >   (:gen-class :name com.raphinou.Ftplet
>> >    :extends org.apache.ftpserver.ftplet.DefaultFtplet)
>> >   (:import [org.apache.ftpserver.ftplet DefaultFtpReply
>> > FtpletResult]))
>>
>> > (def logger (java.util.logging.Logger/getLogger "com.raphinou"))
>> > (.addHandler logger (java.util.logging.FileHandler. "/tmp/ftp.log"))
>>
>> > (defn -onLogin [session request]
>> >   (.severe logger "Logging in, clj")
>> >   FtpletResult/DEFAULT)
> >
>



-- 
And what is good, Phaedrus,
And what is not good—
Need we ask anyone to tell us these things?

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to