0 Replies Latest reply on Oct 3, 2003 10:03 AM by stefanfreyr

    A couple of questions - Logging and Workers

    stefanfreyr Newbie

      I have a couple of "general" questions that I wasn't able to find a definitive answer to.

      1) I'm curious if there is some standard way of performing Logging in JBoss? I've read the (minimal) chapter on "The JBoss Logging Framework" and it fails to explain how to go about using the logging framework. It does explain to some extent how it is built up but not much more than that. So my question is: How do I log something in an EJB in JBoss? I'd of course want my application specific logging to go to a seperate file(s) and it should be as scalable as possible (for example, what happens if I'm writing to a file and decide to create a JBoss farm?). Any and all explanation on the subject and references to some good reading material would be very well appreciated.

      2) I read in an article that was a part of an IBM serie "EJB Best Practices" - http://www-106.ibm.com/developerworks/java/library/j-ejbcol.html ) how you could use static validation methods in seperate classes to validate data for a session EJB - http://www-106.ibm.com/developerworks/java/library/j-ejb01213.html. Now, this article series also talks about something called the "business delegate pattern" that I assume (I haven't read the whole series yet) is that there is a Java class that actually performs the work that the session bean provides the interface for.
      I've been using classes with static methods to perform the work of session beans (because many of the methods that are in my session beans are doing the same thing). I always ment to go through those things and change them to a "Factory pattern" so that the worker will actually be an instance with instance (not static) methods. What I was thinking when I decided that I should do that was that a static method wouldn't be thread safe when many clients would be accessing the app server and calling various session bean methods that might be using one of the static "delegate" methods. In other words, I'd possibly get more than one calls to the same static method at the same time (originating from one or even more session beans). But when I saw that "static method way" was done for validating data in one of these articles, I had second thoughts. I know that you shouldn't write into a static field in an EJB but you can use a final static field (read only). So my question is: should I avoid using "helper/worker/delegate" classes with static methods? If the answer is yes I pretty much know why... but if the answer is no... then why do they work??? Two things that I'm curious about: a) if the static method is not declared with the synchronized keyword, is there a possibility that two or more beans might be calling the same method at the same time? How exactly would that work (or fail... depending on how you look at it)?

      Any and all information about the above two questions would be very much appreciated.

      Kind regards, Stefan.