cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vgritse...@apache.org
Subject svn commit: r154170 - in cocoon/trunk: ./ src/blocks/ojb/ src/blocks/ojb/WEB-INF/xconf/ src/blocks/ojb/conf/ src/blocks/ojb/java/org/apache/cocoon/ojb/broker/components/ src/blocks/ojb/java/org/apache/cocoon/ojb/components/ src/blocks/ojb/java/org/apache/cocoon/ojb/jdo/components/ src/blocks/ojb/java/org/apache/cocoon/ojb/odmg/components/
Date Thu, 17 Feb 2005 17:13:56 GMT
Author: vgritsenko
Date: Thu Feb 17 09:13:51 2005
New Revision: 154170

URL: http://svn.apache.org/viewcvs?view=rev&rev=154170
Log:
merge changes:
separate ojb connection factory config out of ojb access components (pb/jdo/odmg).
cleanup code.
integrate ojb logging with cocoon logging.

Added:
    cocoon/trunk/src/blocks/ojb/conf/OJB-logging.properties   (props changed)
      - copied unchanged from r154169, cocoon/branches/BRANCH_2_1_X/src/blocks/ojb/conf/OJB-logging.properties
    cocoon/trunk/src/blocks/ojb/java/org/apache/cocoon/ojb/components/ConnectionFactoryImpl.java
  (props changed)
      - copied unchanged from r154169, cocoon/branches/BRANCH_2_1_X/src/blocks/ojb/java/org/apache/cocoon/ojb/components/ConnectionFactoryImpl.java
    cocoon/trunk/src/blocks/ojb/java/org/apache/cocoon/ojb/components/LoggerImpl.java   (props
changed)
      - copied unchanged from r154169, cocoon/branches/BRANCH_2_1_X/src/blocks/ojb/java/org/apache/cocoon/ojb/components/LoggerImpl.java
Removed:
    cocoon/trunk/src/blocks/ojb/java/org/apache/cocoon/ojb/components/AbstractOjbImpl.java
    cocoon/trunk/src/blocks/ojb/java/org/apache/cocoon/ojb/components/ConnectionFactoryAvalonDataSource.java
Modified:
    cocoon/trunk/src/blocks/ojb/WEB-INF/xconf/cocoon-ojb.xconf
    cocoon/trunk/src/blocks/ojb/build.xml
    cocoon/trunk/src/blocks/ojb/conf/OJB.properties
    cocoon/trunk/src/blocks/ojb/java/org/apache/cocoon/ojb/broker/components/PBFactory.java
    cocoon/trunk/src/blocks/ojb/java/org/apache/cocoon/ojb/broker/components/PBFactoryImpl.java
    cocoon/trunk/src/blocks/ojb/java/org/apache/cocoon/ojb/jdo/components/JdoPMF.java
    cocoon/trunk/src/blocks/ojb/java/org/apache/cocoon/ojb/jdo/components/JdoPMFImpl.java
    cocoon/trunk/src/blocks/ojb/java/org/apache/cocoon/ojb/odmg/components/OdmgImplementation.java
    cocoon/trunk/src/blocks/ojb/java/org/apache/cocoon/ojb/odmg/components/OdmgImplementationImpl.java
    cocoon/trunk/status.xml

Modified: cocoon/trunk/src/blocks/ojb/WEB-INF/xconf/cocoon-ojb.xconf
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/blocks/ojb/WEB-INF/xconf/cocoon-ojb.xconf?view=diff&r1=154169&r2=154170
==============================================================================
--- cocoon/trunk/src/blocks/ojb/WEB-INF/xconf/cocoon-ojb.xconf (original)
+++ cocoon/trunk/src/blocks/ojb/WEB-INF/xconf/cocoon-ojb.xconf Thu Feb 17 09:13:51 2005
@@ -23,14 +23,21 @@
   <!-- Include roles -->
   <include src="resource://org/apache/cocoon/ojb/ojb.roles"/>
 
-  <!-- ODMG Implementation Interface 
-  <ojb-odmg logger="core.ojb-odmg"/ -->
-  <!-- PersistenceBroker Interface -->
-  <ojb-pb logger="core.ojb-pb"/>
-  
-  <!-- Persistent Manager Factory for JDO -->
-  <!-- uncomment in order to set the logger to a category other than core.startup
-  <ojb-jdo class="org.apache.cocoon.ojb.jdo.components.JdoPMFImpl" logger="core.ojb-jdo"/>
-  -->
+  <!-- OJB Logger -->
+  <component role="org.apache.cocoon.ojb.components.Logger"
+             class="org.apache.cocoon.ojb.components.LoggerImpl"
+             logger="ojb"/>
+
+  <!-- OJB Connection Factory -->
+  <component role="org.apache.cocoon.ojb.components.ConnectionFactory"
+             class="org.apache.cocoon.ojb.components.ConnectionFactoryImpl"
+             logger="core.ojb"/>
+
+  <!-- OJB PersistenceBroker Interface -->
+  <ojb-pb logger="core.ojb.pb"/>
+  <!-- OJB Persistent Manager Factory for JDO -->
+  <ojb-jdo class="org.apache.cocoon.ojb.jdo.components.JdoPMFImpl" logger="core.ojb.jdo"/>
+  <!-- OJB ODMG Implementation Interface -->
+  <ojb-odmg logger="core.ojb.odmg"/>
 
 </components>

Modified: cocoon/trunk/src/blocks/ojb/build.xml
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/blocks/ojb/build.xml?view=diff&r1=154169&r2=154170
==============================================================================
--- cocoon/trunk/src/blocks/ojb/build.xml (original)
+++ cocoon/trunk/src/blocks/ojb/build.xml Thu Feb 17 09:13:51 2005
@@ -42,6 +42,7 @@
     <copy file="${block.dir}/conf/repository_internal.xml" tofile="${build.webapp.classes}/repository_internal.xml"/>
     <copy file="${block.dir}/conf/repository_user.xml" tofile="${build.webapp.classes}/repository_user.xml"/>
     <copy file="${block.dir}/conf/OJB.properties" tofile="${build.webapp.classes}/OJB.properties"/>
+    <copy file="${block.dir}/conf/OJB-logging.properties" tofile="${build.webapp.classes}/OJB-logging.properties"/>
   </target>
 
   <!-- unfortunately this build.xml is called before the samples are compiled,

Copied: cocoon/trunk/src/blocks/ojb/conf/OJB-logging.properties (from r154169, cocoon/branches/BRANCH_2_1_X/src/blocks/ojb/conf/OJB-logging.properties)
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/blocks/ojb/conf/OJB-logging.properties?view=diff&rev=154170&p1=cocoon/branches/BRANCH_2_1_X/src/blocks/ojb/conf/OJB-logging.properties&r1=154169&p2=cocoon/trunk/src/blocks/ojb/conf/OJB-logging.properties&r2=154170
==============================================================================
    (empty)

Propchange: cocoon/trunk/src/blocks/ojb/conf/OJB-logging.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/trunk/src/blocks/ojb/conf/OJB-logging.properties
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: cocoon/trunk/src/blocks/ojb/conf/OJB.properties
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/blocks/ojb/conf/OJB.properties?view=diff&r1=154169&r2=154170
==============================================================================
--- cocoon/trunk/src/blocks/ojb/conf/OJB.properties (original)
+++ cocoon/trunk/src/blocks/ojb/conf/OJB.properties Thu Feb 17 09:13:51 2005
@@ -109,7 +109,7 @@
 # JDBC Connections. Current version ships four implementations:
 #
 # 1. ConnectionFactoryAvalonDatasource
-#    Uses a Cocoon configured DataSource specified with the jcd-alias attribute value in

+#    Uses a Cocoon configured DataSource specified with the jcd-alias attribute value in
 #    a jdbc-connection-descriptor element in the repository.xml file.
 # 2. ConnectionFactoryNotPooledImpl
 #    No pooling, no playing around.
@@ -133,7 +133,7 @@
 # take a look at the repository.dtd, there was a possibility to override
 # this default connection factory entry in each JDBCConnectionDescriptor.
 #
-ConnectionFactoryClass=org.apache.cocoon.ojb.components.ConnectionFactoryAvalonDataSource
+ConnectionFactoryClass=org.apache.cocoon.ojb.components.ConnectionFactoryImpl
 #ConnectionFactoryClass=org.apache.ojb.broker.accesslayer.ConnectionFactoryPooledImpl
 #ConnectionFactoryClass=org.apache.ojb.broker.accesslayer.ConnectionFactoryNotPooledImpl
 #ConnectionFactoryClass=org.apache.ojb.broker.accesslayer.ConnectionFactoryManagedImpl

Modified: cocoon/trunk/src/blocks/ojb/java/org/apache/cocoon/ojb/broker/components/PBFactory.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/blocks/ojb/java/org/apache/cocoon/ojb/broker/components/PBFactory.java?view=diff&r1=154169&r2=154170
==============================================================================
--- cocoon/trunk/src/blocks/ojb/java/org/apache/cocoon/ojb/broker/components/PBFactory.java
(original)
+++ cocoon/trunk/src/blocks/ojb/java/org/apache/cocoon/ojb/broker/components/PBFactory.java
Thu Feb 17 09:13:51 2005
@@ -15,6 +15,7 @@
  */
 package org.apache.cocoon.ojb.broker.components;
 
+
 import org.apache.ojb.broker.PBFactoryException;
 import org.apache.ojb.broker.PBKey;
 import org.apache.ojb.broker.PersistenceBroker;

Modified: cocoon/trunk/src/blocks/ojb/java/org/apache/cocoon/ojb/broker/components/PBFactoryImpl.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/blocks/ojb/java/org/apache/cocoon/ojb/broker/components/PBFactoryImpl.java?view=diff&r1=154169&r2=154170
==============================================================================
--- cocoon/trunk/src/blocks/ojb/java/org/apache/cocoon/ojb/broker/components/PBFactoryImpl.java
(original)
+++ cocoon/trunk/src/blocks/ojb/java/org/apache/cocoon/ojb/broker/components/PBFactoryImpl.java
Thu Feb 17 09:13:51 2005
@@ -15,8 +15,9 @@
  */
 package org.apache.cocoon.ojb.broker.components;
 
+import org.apache.avalon.framework.logger.AbstractLogEnabled;
 import org.apache.avalon.framework.thread.ThreadSafe;
-import org.apache.cocoon.ojb.components.AbstractOjbImpl;
+
 import org.apache.ojb.broker.PBFactoryException;
 import org.apache.ojb.broker.PBKey;
 import org.apache.ojb.broker.PersistenceBroker;
@@ -28,25 +29,8 @@
  * @author <a href="mailto:antonio@apache.org">Antonio Gallardo</a>
  * @version CVS $Id$
 */
-public class PBFactoryImpl
-        extends AbstractOjbImpl
-        implements PBFactory, ThreadSafe {
-
-    /* (non-Javadoc)
-     * @see org.apache.avalon.framework.activity.Disposable#dispose()
-     */
-    public void dispose() {
-        super.dispose();
-        getLogger().debug("Disposed");
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.avalon.framework.activity.Initializable#initialize()
-     */
-    public void initialize() throws Exception {
-        super.initialize();
-        getLogger().debug("Started");
-    }
+public class PBFactoryImpl extends AbstractLogEnabled
+                           implements PBFactory, ThreadSafe {
 
     /* (non-Javadoc)
      * @see org.apache.cocoon.ojb.broker.components.PBFactory#defaultPersistenceBroker()

Copied: cocoon/trunk/src/blocks/ojb/java/org/apache/cocoon/ojb/components/ConnectionFactoryImpl.java
(from r154169, cocoon/branches/BRANCH_2_1_X/src/blocks/ojb/java/org/apache/cocoon/ojb/components/ConnectionFactoryImpl.java)
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/blocks/ojb/java/org/apache/cocoon/ojb/components/ConnectionFactoryImpl.java?view=diff&rev=154170&p1=cocoon/branches/BRANCH_2_1_X/src/blocks/ojb/java/org/apache/cocoon/ojb/components/ConnectionFactoryImpl.java&r1=154169&p2=cocoon/trunk/src/blocks/ojb/java/org/apache/cocoon/ojb/components/ConnectionFactoryImpl.java&r2=154170
==============================================================================
    (empty)

Propchange: cocoon/trunk/src/blocks/ojb/java/org/apache/cocoon/ojb/components/ConnectionFactoryImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/trunk/src/blocks/ojb/java/org/apache/cocoon/ojb/components/ConnectionFactoryImpl.java
------------------------------------------------------------------------------
    svn:keywords = Id

Copied: cocoon/trunk/src/blocks/ojb/java/org/apache/cocoon/ojb/components/LoggerImpl.java
(from r154169, cocoon/branches/BRANCH_2_1_X/src/blocks/ojb/java/org/apache/cocoon/ojb/components/LoggerImpl.java)
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/blocks/ojb/java/org/apache/cocoon/ojb/components/LoggerImpl.java?view=diff&rev=154170&p1=cocoon/branches/BRANCH_2_1_X/src/blocks/ojb/java/org/apache/cocoon/ojb/components/LoggerImpl.java&r1=154169&p2=cocoon/trunk/src/blocks/ojb/java/org/apache/cocoon/ojb/components/LoggerImpl.java&r2=154170
==============================================================================
    (empty)

Propchange: cocoon/trunk/src/blocks/ojb/java/org/apache/cocoon/ojb/components/LoggerImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/trunk/src/blocks/ojb/java/org/apache/cocoon/ojb/components/LoggerImpl.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: cocoon/trunk/src/blocks/ojb/java/org/apache/cocoon/ojb/jdo/components/JdoPMF.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/blocks/ojb/java/org/apache/cocoon/ojb/jdo/components/JdoPMF.java?view=diff&r1=154169&r2=154170
==============================================================================
--- cocoon/trunk/src/blocks/ojb/java/org/apache/cocoon/ojb/jdo/components/JdoPMF.java (original)
+++ cocoon/trunk/src/blocks/ojb/java/org/apache/cocoon/ojb/jdo/components/JdoPMF.java Thu
Feb 17 09:13:51 2005
@@ -1,12 +1,12 @@
 /*
  * Copyright 1999-2004 The Apache Software Foundation.
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -15,21 +15,23 @@
  */
 package org.apache.cocoon.ojb.jdo.components;
 
+import org.apache.avalon.framework.component.Component;
+
 import javax.jdo.PersistenceManager;
 
 /**
- *  Interface of the JDO Persistent Manager Factory.
+ * Interface of the JDO Persistent Manager Factory.
  * It is used to get the Persistence Manager to interact with JDO using OJB
  *
  * @author <a href="mailto:antonio@apache.org">Antonio Gallardo</a>
  * @version CVS $Id$
 */
 public interface JdoPMF {
-    
+
     String ROLE = JdoPMF.class.getName();
-	
+
     /**
-    * get a Persitence Manager.
-	*/
+     * Get a Persitence Manager.
+     */
     PersistenceManager getPersistenceManager();
 }

Modified: cocoon/trunk/src/blocks/ojb/java/org/apache/cocoon/ojb/jdo/components/JdoPMFImpl.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/blocks/ojb/java/org/apache/cocoon/ojb/jdo/components/JdoPMFImpl.java?view=diff&r1=154169&r2=154170
==============================================================================
--- cocoon/trunk/src/blocks/ojb/java/org/apache/cocoon/ojb/jdo/components/JdoPMFImpl.java
(original)
+++ cocoon/trunk/src/blocks/ojb/java/org/apache/cocoon/ojb/jdo/components/JdoPMFImpl.java
Thu Feb 17 09:13:51 2005
@@ -1,12 +1,12 @@
 /*
  * Copyright 1999-2004 The Apache Software Foundation.
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -15,57 +15,37 @@
  */
 package org.apache.cocoon.ojb.jdo.components;
 
-import javax.jdo.PersistenceManager;
-import javax.jdo.PersistenceManagerFactory;
-
+import org.apache.avalon.framework.activity.Initializable;
+import org.apache.avalon.framework.logger.AbstractLogEnabled;
 import org.apache.avalon.framework.thread.ThreadSafe;
-import org.apache.cocoon.ojb.components.AbstractOjbImpl;
+
 import org.apache.ojb.jdori.sql.OjbStorePMF;
 
+import javax.jdo.PersistenceManager;
+import javax.jdo.PersistenceManagerFactory;
+
 /**
 * Implementation of the JdoPMF. Create one PMF and store it for future use
  *
  * @author <a href="mailto:antonio@apache.org">Antonio Gallardo</a>
- * @version CVS $Id: JdoPMFImpl.java,v 1.6 2004/06/25 14:49:56 cziegeler Exp $
+ * @version CVS $Id$
 */
-public class JdoPMFImpl 
-    extends AbstractOjbImpl 
-    implements JdoPMF, ThreadSafe {
+public class JdoPMFImpl extends AbstractLogEnabled
+                        implements JdoPMF, ThreadSafe, Initializable {
     
-	protected PersistenceManagerFactory factory;
+    protected PersistenceManagerFactory factory;
 	
     /* (non-Javadoc)
-     * @see org.apache.avalon.framework.activity.Disposable#dispose()
+     * @see org.apache.cocoon.ojb.jdori.components.JdoPMF#getPersistenceManager()
      */
-    public void dispose() {
-        super.dispose();
-		if (this.getLogger().isDebugEnabled()) {
-			this.getLogger().debug("OJB-JDO: Disposed OK!");
-        }
+    public PersistenceManager getPersistenceManager() {
+        return this.factory.getPersistenceManager();
     }
 
-	/* (non-Javadoc)
-	 * @see org.apache.cocoon.ojb.jdori.components.JdoPMF#getPersistenceManager()
-	 */
-	public PersistenceManager getPersistenceManager() {
-		return factory.getPersistenceManager();
-	}
-    
-	/* (non-Javadoc)
-	 * @see org.apache.avalon.framework.activity.Initializable#initialize()
-	 */
-	public void initialize() throws Exception {
-        super.initialize();
-		try	{
-			// Create the factory
-			factory = new OjbStorePMF();
-			if (this.getLogger().isDebugEnabled()) {
-                this.getLogger().debug("OJB-JDO: Started OK!");
-            }
-		} catch (Throwable t){
-			if (this.getLogger().isFatalErrorEnabled()) {
-				this.getLogger().fatalError("OJB-JDO: Started failed: Cannot create a Persistence Manager
Factory.",t);
-			}
-		}
-	}
+    /* (non-Javadoc)
+     * @see org.apache.avalon.framework.activity.Initializable#initialize()
+     */
+    public void initialize() throws Exception {
+        this.factory = new OjbStorePMF();
+    }
 }

Modified: cocoon/trunk/src/blocks/ojb/java/org/apache/cocoon/ojb/odmg/components/OdmgImplementation.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/blocks/ojb/java/org/apache/cocoon/ojb/odmg/components/OdmgImplementation.java?view=diff&r1=154169&r2=154170
==============================================================================
--- cocoon/trunk/src/blocks/ojb/java/org/apache/cocoon/ojb/odmg/components/OdmgImplementation.java
(original)
+++ cocoon/trunk/src/blocks/ojb/java/org/apache/cocoon/ojb/odmg/components/OdmgImplementation.java
Thu Feb 17 09:13:51 2005
@@ -1,12 +1,12 @@
 /*
  * Copyright 1999-2002,2004 The Apache Software Foundation.
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -15,10 +15,10 @@
  */
 package org.apache.cocoon.ojb.odmg.components;
 
+
 import org.odmg.Implementation;
 import org.odmg.ODMGException;
 
-
 /**
  * Interface of the ODMG Implementation. It is used to get the Implementation Object to interact
with ODMG using OJB
  *
@@ -38,7 +38,7 @@
      * @throws ODMGException DOCUMENT ME!
      */
     Implementation getInstance()
-        throws ODMGException;
+    throws ODMGException;
 
     /**
      * Get a ODMG Instance with a specific connection definition.
@@ -50,7 +50,7 @@
      * @throws ODMGException DOCUMENT ME!
      */
     Implementation getInstance(String connection)
-        throws ODMGException;
+    throws ODMGException;
 
     /**
      * Get a ODMG Instance with a specific connection definition and a Database operation
mode.
@@ -63,7 +63,7 @@
      * @throws ODMGException DOCUMENT ME!
      */
     Implementation getInstance(String connection, int mode)
-        throws ODMGException;
+    throws ODMGException;
 
     /**
      * Get a ODMG Instance with a default connection definition and a Database operation
mode.
@@ -75,5 +75,5 @@
      * @throws ODMGException DOCUMENT ME!
      */
     Implementation getInstance(int mode)
-        throws ODMGException;
+    throws ODMGException;
 }

Modified: cocoon/trunk/src/blocks/ojb/java/org/apache/cocoon/ojb/odmg/components/OdmgImplementationImpl.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/blocks/ojb/java/org/apache/cocoon/ojb/odmg/components/OdmgImplementationImpl.java?view=diff&r1=154169&r2=154170
==============================================================================
--- cocoon/trunk/src/blocks/ojb/java/org/apache/cocoon/ojb/odmg/components/OdmgImplementationImpl.java
(original)
+++ cocoon/trunk/src/blocks/ojb/java/org/apache/cocoon/ojb/odmg/components/OdmgImplementationImpl.java
Thu Feb 17 09:13:51 2005
@@ -1,12 +1,12 @@
 /*
  * Copyright 1999-2002,2004 The Apache Software Foundation.
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -15,89 +15,69 @@
  */
 package org.apache.cocoon.ojb.odmg.components;
 
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.Set;
-
+import org.apache.avalon.framework.activity.Disposable;
+import org.apache.avalon.framework.activity.Initializable;
+import org.apache.avalon.framework.logger.AbstractLogEnabled;
 import org.apache.avalon.framework.thread.ThreadSafe;
-import org.apache.cocoon.ojb.components.AbstractOjbImpl;
+
 import org.apache.ojb.odmg.OJB;
 import org.odmg.Database;
 import org.odmg.Implementation;
 import org.odmg.ODMGException;
 
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.Set;
 
 /**
  * Implementation of the OdmgImplementation. Create a ODMG Implementation and store it for
future use
  *
  * @author <a href="mailto:giacomo@apache.org">Giacomo Pati</a>
- * @version CVS $Id: OdmgImplementationImpl.java,v 1.4 2004/06/25 14:49:56 cziegeler Exp
$
+ * @version CVS $Id$
  */
-public class OdmgImplementationImpl
-    extends AbstractOjbImpl
-    implements OdmgImplementation, ThreadSafe {
+public class OdmgImplementationImpl extends AbstractLogEnabled
+                                    implements OdmgImplementation, ThreadSafe, Initializable,
Disposable {
 
     private final static String DEFAULT_CONNECTION ="default";
     private final static int DEFAULT_MODE = Database.OPEN_READ_WRITE;
     private Implementation odmg;
-    
+
     private Hashtable databases = new Hashtable();
-    
-    /*  (non-Javadoc)
+
+    /* (non-Javadoc)
      * @see org.apache.avalon.framework.activity.Disposable#dispose()
      */
     public void dispose() {
-        super.dispose();
-        synchronized(this.databases) {
-            final Set keys = this.databases.keySet();
-            for( Iterator i = keys.iterator(); i.hasNext(); )
-            {
-                final Database db = (Database)i.next();
-                try
-                {
-                    db.close();
-                }
-                catch( final ODMGException e) {
-                    getLogger().error( "OJB-ODMG: Cannot close Database", e);
-                }
-                i.remove();
+        final Set keys = this.databases.keySet();
+        for (Iterator i = keys.iterator(); i.hasNext();) {
+            final Database db = (Database) i.next();
+            try {
+                db.close();
+            } catch (ODMGException e) {
+                getLogger().error("OJB-ODMG: Cannot close Database", e);
             }
-        }
-        if (this.getLogger().isDebugEnabled()) {
-            this.getLogger().debug("OJB-ODMG: Disposed OK!");
+            i.remove();
         }
     }
 
     /* (non-Javadoc)
      * @see org.apache.avalon.framework.activity.Initializable#initialize()
      */
-    public void initialize()
-        throws Exception {
-        super.initialize();
-        try {
-            // Get the Implementation
-            this.odmg = OJB.getInstance();
-            
-            if (this.getLogger().isDebugEnabled()) {
-                this.getLogger().debug("OJB-ODMG: Started OK!");
-            }
-        } catch (Throwable t) {
-            if (this.getLogger().isFatalErrorEnabled()) {
-                this.getLogger().fatalError("OJB-ODMG: Started failed: Cannot get an ODMG
Implementation.", t);
-            }
-        }
+    public void initialize() throws Exception {
+        // Get the Implementation
+        this.odmg = OJB.getInstance();
     }
 
     /* (non-Javadoc)
      * @see org.apache.cocoon.ojb.odmg.components.Odmg#getInstance()
      */
     public Implementation getInstance() throws ODMGException {
-        Database db = (Database)this.databases.get( DEFAULT_CONNECTION );
-        if (null == db ) {
+        Database db = (Database) this.databases.get(DEFAULT_CONNECTION);
+        if (null == db) {
             db = this.odmg.newDatabase();
             db.open(DEFAULT_CONNECTION, DEFAULT_MODE);
             synchronized (this.databases) {
-                this.databases.put( DEFAULT_CONNECTION + DEFAULT_MODE, db );
+                this.databases.put(DEFAULT_CONNECTION + DEFAULT_MODE, db);
             }
         }
         return this.odmg;
@@ -107,12 +87,12 @@
      * @see org.apache.cocoon.ojb.odmg.components.Odmg#getInstance(java.lang.String, int)
      */
     public Implementation getInstance(String connection, int mode) throws ODMGException {
-        Database db = (Database)this.databases.get( connection + mode);
-        if (null == db ) {
+        Database db = (Database) this.databases.get(connection + mode);
+        if (null == db) {
             db = this.odmg.newDatabase();
             db.open(connection, mode);
             synchronized (this.databases) {
-                this.databases.put( connection + mode, db );
+                this.databases.put(connection + mode, db);
             }
         }
         return this.odmg;
@@ -122,26 +102,27 @@
      * @see org.apache.cocoon.ojb.odmg.components.Odmg#getInstance(java.lang.String)
      */
     public Implementation getInstance(String connection) throws ODMGException {
-        Database db = (Database)this.databases.get( connection + DEFAULT_MODE);
-        if (null == db ) {
+        Database db = (Database) this.databases.get(connection + DEFAULT_MODE);
+        if (null == db) {
             db = this.odmg.newDatabase();
             db.open(connection, DEFAULT_MODE);
             synchronized (this.databases) {
-                this.databases.put( connection + DEFAULT_MODE, db );
+                this.databases.put(connection + DEFAULT_MODE, db);
             }
         }
         return this.odmg;
     }
+
     /* (non-Javadoc)
      * @see org.apache.cocoon.ojb.odmg.components.OdmgImplementation#getInstance(int)
      */
-    public Implementation getInstance( int mode ) throws ODMGException  {
-        Database db = (Database)this.databases.get( DEFAULT_CONNECTION+ mode);
-        if (null == db ) {
+    public Implementation getInstance(int mode) throws ODMGException {
+        Database db = (Database) this.databases.get(DEFAULT_CONNECTION + mode);
+        if (null == db) {
             db = this.odmg.newDatabase();
             db.open(DEFAULT_CONNECTION, mode);
             synchronized (this.databases) {
-                this.databases.put( DEFAULT_CONNECTION+ mode, db );
+                this.databases.put(DEFAULT_CONNECTION + mode, db);
             }
         }
         return this.odmg;

Modified: cocoon/trunk/status.xml
URL: http://svn.apache.org/viewcvs/cocoon/trunk/status.xml?view=diff&r1=154169&r2=154170
==============================================================================
--- cocoon/trunk/status.xml (original)
+++ cocoon/trunk/status.xml Thu Feb 17 09:13:51 2005
@@ -479,6 +479,9 @@
    </action>
  </release>
  <release version="2.1.7" date="TBD">
+   <action dev="VG" type="update">
+     OJB Block: Integrated OJB logging with Cocoon logging.
+   </action>
    <action dev="CZ" type="update">
      Add a deprecation logger that gives hint about used deprecated stuff.
    </action>



Mime
View raw message