User: oleg    
  Date: 00/10/02 06:58:59

  Modified:    castorjdo/src/main/org/jboss/jdo/castor CastorJDOImpl.java
  Log:
  Better logging; was made Serializable
  
  Revision  Changes    Path
  1.2       +20 -3     
contrib/castorjdo/src/main/org/jboss/jdo/castor/CastorJDOImpl.java
  
  Index: CastorJDOImpl.java
  ===================================================================
  RCS file: 
/products/cvs/ejboss/contrib/castorjdo/src/main/org/jboss/jdo/castor/CastorJDOImpl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- CastorJDOImpl.java        2000/09/13 15:04:04     1.1
  +++ CastorJDOImpl.java        2000/10/02 13:58:58     1.2
  @@ -8,6 +8,7 @@
   package org.jboss.jdo.castor;
   
   import java.io.PrintWriter;
  +import java.io.Serializable;
   //import java.lang.reflect.InvocationHandler;
   //import java.lang.reflect.Proxy;
   import java.lang.reflect.Method;
  @@ -37,6 +38,7 @@
   
   import org.jboss.logging.Log;
   import org.jboss.logging.Logger;
  +import org.jboss.logging.LogWriter;
   import org.jboss.util.ServiceMBeanSupport;
   
   import org.jboss.proxy.Proxy;
  @@ -47,18 +49,22 @@
    *   Castor JDO support
    *
    *   @author Oleg Nitz ([EMAIL PROTECTED])
  - *   @version $Revision: 1.1 $
  + *   @version $Revision: 1.2 $
    */
   public class CastorJDOImpl extends ServiceMBeanSupport 
  -        implements DataObjects, ObjectFactory, Referenceable,
  +        implements DataObjects, ObjectFactory, Referenceable, Serializable,
                      CastorJDOImplMBean, MBeanRegistration, LogInterceptor {
      
       private String _jndiName;
   
       private JDO _jdo = new JDO();
   
  +    private String _dataSourceName;
  +
       private static HashMap instances = new HashMap();
   
  +    private transient PrintWriter writer;
  +
       public CastorJDOImpl() {
           // Instance being used as ObjectFactory
       }
  @@ -76,6 +82,9 @@
               unm = new Unmarshaller(org.exolab.castor.jdo.conf.Database.class);
               database = (org.exolab.castor.jdo.conf.Database) unm.unmarshal(new 
InputSource(dbConf));
               _jdo.setDatabaseName(database.getName());
  +            if (database.getJndi() != null) {
  +                _dataSourceName = database.getJndi().getName();
  +            }
           } catch (Exception ex) {
               log.error("Cannot read " + dbConf + ": " + ex);
           }
  @@ -103,6 +112,7 @@
       public void initService() throws Exception {
           // Bind in JNDI
           bind(new InitialContext(), _jndiName, this);
  +        log.debug("DataObjects factory for " + _dataSourceName + " bound to " + 
_jndiName);
       }
      
       public void stopService() {
  @@ -198,12 +208,19 @@
   
   
       public void message(String message) {
  -        log.warning(message);
  +        log.debug(message);
       }
   
   
       public void exception(Exception except) {
  -        log.warning(except.toString());
  +        log.exception(except);
  +    }
  +
  +    public PrintWriter getPrintWriter() {
  +        if (writer == null) {
  +            writer = new LogWriter(log);
  +        }
  +        return writer;
       }
   }
   
  
  
  

Reply via email to