Minos Chadgidakis <[EMAIL PROTECTED]> writes:

> sessionManager has no instance variables.
> Any validating function will need only a session object,and perhaps some other 
> arguments.
>
> So there is no need for multithreading consideration?

That's right... unless there is something that 2 threads could alter
simultaneously then you will be safe.

In general functional programming (programming without side effects)
is multithread safe, it's particularly well suited to validations.


> Then i must assume that the following statements are true.Please correct me...
> Each time a validating function is invoked, what is really invoked
> is a copy of that function.The arguments do not conflict with each
> other.

I don't know what you mean. If you have a single session validator
instance then of course only one copy of the method exists. If you
have multiple instances of the validator then the effect will be like
having multiple methods.

As I said above, if your validator is functional (with no side
effects) then there's no need to worry about thread contention.


> The only case that a copy will not be created, is when the function
> is declared static. There is no need to make these functions static
> or use synchronized.

No... You could do this in a servlet init() method:

  getServletContext().setAttribute("myvalidator", new MySessionValidator());

and this in your filter:

   MySessionValidator v = (MySessionValidator) 
getServletContext().getAttribute("myvalidator");

in which case you'd be using a non-static validator but only one
instance of it.

Making the functions static would be sensible unless the session
validator has state (and it doesn't you say).


Nic

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to