db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arm...@apache.org
Subject cvs commit: jakarta-ojb/src/java/org/apache/ojb/broker/metadata/auto AutoCreatorDb.java
Date Thu, 28 Nov 2002 22:19:25 GMT
arminw      2002/11/28 14:19:25

  Modified:    src/java/org/apache/ojb/broker/metadata
                        RepositoryXmlHandler.java DescriptorRepository.java
                        ConnectionPoolDescriptor.java
               src/java/org/apache/ojb/broker/metadata/auto
                        AutoCreatorDb.java
  Log:
  DescriptorRepository now hold defaultPBKey,
  make classes compatible
  
  Revision  Changes    Path
  1.21      +94 -99    jakarta-ojb/src/java/org/apache/ojb/broker/metadata/RepositoryXmlHandler.java
  
  Index: RepositoryXmlHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/java/org/apache/ojb/broker/metadata/RepositoryXmlHandler.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- RepositoryXmlHandler.java	21 Nov 2002 22:54:25 -0000	1.20
  +++ RepositoryXmlHandler.java	28 Nov 2002 22:19:25 -0000	1.21
  @@ -72,8 +72,8 @@
    * @version $Id$
    */
   public class RepositoryXmlHandler
  -    extends DefaultHandler
  -    implements RepositoryElements, IsolationLevels
  +        extends DefaultHandler
  +        implements RepositoryElements, IsolationLevels
   {
       private Logger logger;
   
  @@ -115,7 +115,7 @@
           }
           catch (NullPointerException t)
           {
  -            throw new MetadataException("unknown literal: '" + literal + "'",t);
  +            throw new MetadataException("unknown literal: '" + literal + "'", t);
           }
   
       }
  @@ -126,13 +126,13 @@
        */
       public RepositoryXmlHandler(DescriptorRepository dr)
       {
  -    	if (dr != null)
  -    	{
  -        	m_repository = dr;
  -    	}
  +        if (dr != null)
  +        {
  +            m_repository = dr;
  +        }
           else
           {
  -        	m_repository = DescriptorRepository.getDefaultInstance();
  +            m_repository = DescriptorRepository.getDefaultInstance();
           }
           logger = LoggerFactory.getLogger(this.getClass());
       }
  @@ -165,7 +165,7 @@
           {
               switch (getLiteralId(qName))
               {
  -                case MAPPING_REPOSITORY :
  +                case MAPPING_REPOSITORY:
                       {
                           String defIso = atts.getValue(tags.getTagById(ISOLATION_LEVEL));
                           if (defIso != null)
  @@ -180,16 +180,16 @@
                           }
                           else
                           {
  -                        	throw new MetadataException("Repository version does not match.
expected " +
  -                        		DescriptorRepository.getVersion() + " but found: " +
  -                        		version);
  +                            throw new MetadataException("Repository version does not match.
expected " +
  +                                    DescriptorRepository.getVersion() + " but found: "
+
  +                                    version);
                           }
   
                           logger.debug(" > " + tags.getTagById(MAPPING_REPOSITORY));
   
                           break;
                       }
  -                case JDBC_CONNECTION_DESCRIPTOR :
  +                case JDBC_CONNECTION_DESCRIPTOR:
                       {
                           logger.debug("   > " + tags.getTagById(JDBC_CONNECTION_DESCRIPTOR));
                           m_CurrentJCD = new JdbcConnectionDescriptor();
  @@ -253,7 +253,7 @@
   
                           break;
                       }
  -                case CLASS_DESCRIPTOR :
  +                case CLASS_DESCRIPTOR:
                       {
                           logger.debug("  > " + tags.getTagById(CLASS_DESCRIPTOR));
                           m_CurrentCLD = new ClassDescriptor(m_repository);
  @@ -322,7 +322,7 @@
                           }
   
                           // set if extends
  -                         // set row-reader attribute
  +                        // set row-reader attribute
                           String extendsAtt = atts.getValue(tags.getTagById(EXTENDS));
                           logger.debug("     " + tags.getTagById(EXTENDS) + ": " + extendsAtt);
                           if (extendsAtt != null)
  @@ -333,40 +333,40 @@
                           break;
                       }
   
  -                case CLASS_EXTENT :
  +                case CLASS_EXTENT:
                       {
                           String classname = atts.getValue("class-ref");
                           logger.debug("     " + tags.getTagById(CLASS_EXTENT) + ": " + classname);
                           m_CurrentCLD.addExtentClassName(classname);
                           break;
                       }
  -               /* case EXTENDS :
  -                    {
  -                        String classname = atts.getValue("class-ref");
  -                        logger.debug("     " + tags.getTagById(EXTENDS) + ": " + classname);
  -                        m_CurrentCLD.setSuperClass(classname);
  -
  -                        // get key for super class
  -                        String fieldref = atts.getValue("field-id-ref");
  -                         try
  -                        {
  -                            int fieldId;
  -                            fieldId = Integer.parseInt(fieldref);
  -                            logger.debug("     " + tags.getTagById(EXTENDS) + ": " +fieldId);
  -                            m_CurrentCLD.setSuperClassFieldRef(fieldId);
  -                        }
  -                        catch (NumberFormatException rex)
  -                        {
  -                            throw new MetadataException(tags.getTagById(EXTENDS)
  -                                                        + " attribute must be an int. Found:
"
  -                                                        + fieldref,rex);
  -                        }
  +                    /* case EXTENDS :
  +                         {
  +                             String classname = atts.getValue("class-ref");
  +                             logger.debug("     " + tags.getTagById(EXTENDS) + ": " + classname);
  +                             m_CurrentCLD.setSuperClass(classname);
  +
  +                             // get key for super class
  +                             String fieldref = atts.getValue("field-id-ref");
  +                              try
  +                             {
  +                                 int fieldId;
  +                                 fieldId = Integer.parseInt(fieldref);
  +                                 logger.debug("     " + tags.getTagById(EXTENDS) + ": "
+fieldId);
  +                                 m_CurrentCLD.setSuperClassFieldRef(fieldId);
  +                             }
  +                             catch (NumberFormatException rex)
  +                             {
  +                                 throw new MetadataException(tags.getTagById(EXTENDS)
  +                                                             + " attribute must be an int.
Found: "
  +                                                             + fieldref,rex);
  +                             }
   
   
  -                        break;
  -                    }*/
  +                             break;
  +                         }*/
   
  -                case FIELD_DESCRIPTOR :
  +                case FIELD_DESCRIPTOR:
                       {
                           logger.debug("    > " + tags.getTagById(FIELD_DESCRIPTOR));
   
  @@ -398,9 +398,9 @@
                           String nullable = atts.getValue(tags.getTagById(NULLABLE));
                           if (nullable != null)
                           {
  -                        	logger.debug("     " + tags.getTagById(NULLABLE) + ": " + nullable);
  -                        	b = ! (new Boolean(nullable)).booleanValue();
  -                        	m_CurrentFLD.setRequired(b);
  +                            logger.debug("     " + tags.getTagById(NULLABLE) + ": " + nullable);
  +                            b = !(new Boolean(nullable)).booleanValue();
  +                            m_CurrentFLD.setRequired(b);
                           }
   
                           String indexed = atts.getValue(tags.getTagById(INDEXED));
  @@ -461,13 +461,13 @@
   
                           break;
                       }
  -                case REFERENCE_DESCRIPTOR :
  +                case REFERENCE_DESCRIPTOR:
                       {
                           logger.debug("    > " + tags.getTagById(REFERENCE_DESCRIPTOR));
                           m_CurrentORD = new ObjectReferenceDescriptor();
                           m_CurrentCLD.addObjectReferenceDescriptor(m_CurrentORD);
   
  -						// prepare for custom attributes
  +                        // prepare for custom attributes
                           this.m_CurrentAttrContainer = m_CurrentORD;
   
                           // set name attribute
  @@ -478,7 +478,7 @@
                           // set class-ref attribute
                           String classRef = atts.getValue(tags.getTagById(REFERENCED_CLASS));
                           logger.debug("     " + tags.getTagById(REFERENCED_CLASS) + ": "
+ classRef);
  -						m_CurrentORD.setItemClassName(classRef);
  +                        m_CurrentORD.setItemClassName(classRef);
   
                           // set proxy attribute
                           String proxy = atts.getValue(tags.getTagById(PROXY_REFERENCE));
  @@ -513,7 +513,7 @@
                           break;
                       }
   
  -                case FOREIGN_KEY :
  +                case FOREIGN_KEY:
                       {
                           logger.debug("    > " + tags.getTagById(FOREIGN_KEY));
                           String fieldIdRef = atts.getValue(tags.getTagById(FIELD_ID_REF));
  @@ -528,19 +528,19 @@
                           catch (NumberFormatException rex)
                           {
                               throw new MetadataException(tags.getTagById(FIELD_ID_REF)
  -                                                        + " attribute must be an int. Found:
"
  -                                                        + fieldIdRef,rex);
  +                                    + " attribute must be an int. Found: "
  +                                    + fieldIdRef, rex);
                           }
                           break;
                       }
   
  -                case COLLECTION_DESCRIPTOR :
  +                case COLLECTION_DESCRIPTOR:
                       {
                           logger.debug("    > " + tags.getTagById(COLLECTION_DESCRIPTOR));
                           m_CurrentCOD = new CollectionDescriptor();
                           m_CurrentCLD.addCollectionDescriptor(m_CurrentCOD);
   
  -						// prepare for custom attributes
  +                        // prepare for custom attributes
                           this.m_CurrentAttrContainer = m_CurrentCOD;
   
                           // set name attribute
  @@ -552,15 +552,15 @@
                           String collectionClassName = atts.getValue(tags.getTagById(COLLECTION_CLASS));
                           if (collectionClassName != null)
                           {
  -                        	logger.debug("     " + tags.getTagById(COLLECTION_CLASS) + ":
" + collectionClassName);
  - 	                       	m_CurrentCOD.setCollectionClassName(collectionClassName);
  +                            logger.debug("     " + tags.getTagById(COLLECTION_CLASS) +
": " + collectionClassName);
  +                            m_CurrentCOD.setCollectionClassName(collectionClassName);
                           }
                           // set element-class-ref attribute
                           String elementClassRef = atts.getValue(tags.getTagById(ITEMS_CLASS));
                           logger.debug("     " + tags.getTagById(ITEMS_CLASS) + ": " + elementClassRef);
                           if (elementClassRef != null)
                           {
  -                        	m_CurrentCOD.setItemClassName(elementClassRef);
  +                            m_CurrentCOD.setItemClassName(elementClassRef);
                           }
   
                           //set orderby and sort attributes:
  @@ -616,7 +616,7 @@
   
                           break;
                       }
  -                case INVERSE_FK :
  +                case INVERSE_FK:
                       {
                           logger.debug("    > " + tags.getTagById(INVERSE_FK));
                           String fieldIdRef = atts.getValue(tags.getTagById(FIELD_ID_REF));
  @@ -631,13 +631,13 @@
                           catch (NumberFormatException rex)
                           {
                               throw new MetadataException(tags.getTagById(FIELD_ID_REF)
  -                                                        + " attribute must be an int. Found:
"
  -                                                        + fieldIdRef,rex);
  +                                    + " attribute must be an int. Found: "
  +                                    + fieldIdRef, rex);
                           }
                           break;
                       }
   
  -                case FK_POINTING_TO_THIS_CLASS :
  +                case FK_POINTING_TO_THIS_CLASS:
                       {
                           logger.debug("    > " + tags.getTagById(FK_POINTING_TO_THIS_CLASS));
                           String column = atts.getValue("column");
  @@ -646,7 +646,7 @@
                           break;
                       }
   
  -                case FK_POINTING_TO_ITEMS_CLASS :
  +                case FK_POINTING_TO_ITEMS_CLASS:
                       {
                           logger.debug("    > " + tags.getTagById(FK_POINTING_TO_ITEMS_CLASS));
                           String column = atts.getValue("column");
  @@ -654,75 +654,70 @@
                           m_CurrentCOD.addFkToItemClass(column);
                           break;
                       }
  -                case CONNECTION_POOL :
  +                case CONNECTION_POOL:
                       {
                           logger.debug("    > " + tags.getTagById(CONNECTION_POOL));
                           ConnectionPoolDescriptor m_CurrentCPD = m_CurrentJCD.getConnectionPoolDescriptor();
  -                        m_CurrentJCD.setConnectionPoolDescriptor(m_CurrentCPD);
   
                           String maxActive = atts.getValue(tags.getTagById(CON_MAX_ACTIVE));
                           logger.debug("     " + tags.getTagById(CON_MAX_ACTIVE) + ": " +
maxActive);
  -                        if(checkString(maxActive)) m_CurrentCPD.setMaxActive(new Integer(maxActive).intValue());
  +                        if (checkString(maxActive)) m_CurrentCPD.setMaxActive(new Integer(maxActive).intValue());
   
                           String maxIdle = atts.getValue(tags.getTagById(CON_MAX_IDLE));
                           logger.debug("     " + tags.getTagById(CON_MAX_IDLE) + ": " + maxIdle);
  -                        if(checkString(maxIdle)) m_CurrentCPD.setMaxIdle(new Integer(maxIdle).intValue());
  +                        if (checkString(maxIdle)) m_CurrentCPD.setMaxIdle(new Integer(maxIdle).intValue());
   
                           String maxWait = atts.getValue(tags.getTagById(CON_MAX_WAIT));
                           logger.debug("     " + tags.getTagById(CON_MAX_WAIT) + ": " + maxWait);
  -                        if(checkString(maxWait)) m_CurrentCPD.setMaxWait(new Integer(maxWait).intValue());
  +                        if (checkString(maxWait)) m_CurrentCPD.setMaxWait(new Integer(maxWait).intValue());
   
                           String minEvictableIdleTimeMillis = atts.getValue(tags.getTagById(CON_MIN_EVICTABLE_IDLE_TIME_MILLIS));
                           logger.debug("     " + tags.getTagById(CON_MIN_EVICTABLE_IDLE_TIME_MILLIS)
+ ": " + minEvictableIdleTimeMillis);
  -                        if(checkString(minEvictableIdleTimeMillis)) m_CurrentCPD.setMinEvictableIdleTimeMillis(new
Long(minEvictableIdleTimeMillis).longValue());
  +                        if (checkString(minEvictableIdleTimeMillis)) m_CurrentCPD.setMinEvictableIdleTimeMillis(new
Long(minEvictableIdleTimeMillis).longValue());
   
                           String numTestsPerEvictionRun = atts.getValue(tags.getTagById(CON_NUM_TESTS_PER_EVICTION_RUN));
                           logger.debug("     " + tags.getTagById(CON_NUM_TESTS_PER_EVICTION_RUN)
+ ": " + numTestsPerEvictionRun);
  -                        if(checkString(numTestsPerEvictionRun)) m_CurrentCPD.setNumTestsPerEvictionRun(new
Integer(numTestsPerEvictionRun).intValue());
  +                        if (checkString(numTestsPerEvictionRun)) m_CurrentCPD.setNumTestsPerEvictionRun(new
Integer(numTestsPerEvictionRun).intValue());
   
                           String testOnBorrow = atts.getValue(tags.getTagById(CON_TEST_ON_BORROW));
                           logger.debug("     " + tags.getTagById(CON_TEST_ON_BORROW) + ":
" + testOnBorrow);
  -                        if(checkString(testOnBorrow)) m_CurrentCPD.setTestOnBorrow(new
Boolean(testOnBorrow).booleanValue());
  +                        if (checkString(testOnBorrow)) m_CurrentCPD.setTestOnBorrow(new
Boolean(testOnBorrow).booleanValue());
   
                           String testOnReturn = atts.getValue(tags.getTagById(CON_TEST_ON_RETURN));
                           logger.debug("     " + tags.getTagById(CON_TEST_ON_RETURN) + ":
" + testOnReturn);
  -                        if(checkString(testOnReturn)) m_CurrentCPD.setTestOnReturn(new
Boolean(testOnReturn).booleanValue());
  +                        if (checkString(testOnReturn)) m_CurrentCPD.setTestOnReturn(new
Boolean(testOnReturn).booleanValue());
   
                           String testWhileIdle = atts.getValue(tags.getTagById(CON_TEST_WHILE_IDLE));
                           logger.debug("     " + tags.getTagById(CON_TEST_WHILE_IDLE) + ":
" + testWhileIdle);
  -                        if(checkString(testWhileIdle)) m_CurrentCPD.setTestWhileIdle(new
Boolean(testWhileIdle).booleanValue());
  +                        if (checkString(testWhileIdle)) m_CurrentCPD.setTestWhileIdle(new
Boolean(testWhileIdle).booleanValue());
   
                           String timeBetweenEvictionRunsMillis = atts.getValue(tags.getTagById(CON_TIME_BETWEEN_EVICTION_RUNS_MILLIS));
                           logger.debug("     " + tags.getTagById(CON_TIME_BETWEEN_EVICTION_RUNS_MILLIS)
+ ": " + timeBetweenEvictionRunsMillis);
  -                        if(checkString(timeBetweenEvictionRunsMillis)) m_CurrentCPD.setTimeBetweenEvictionRunsMillis(new
Long(timeBetweenEvictionRunsMillis).longValue());
  +                        if (checkString(timeBetweenEvictionRunsMillis)) m_CurrentCPD.setTimeBetweenEvictionRunsMillis(new
Long(timeBetweenEvictionRunsMillis).longValue());
   
                           String whenExhaustedAction = atts.getValue(tags.getTagById(CON_WHEN_EXHAUSTED_ACTION));
                           logger.debug("     " + tags.getTagById(CON_WHEN_EXHAUSTED_ACTION)
+ ": " + whenExhaustedAction);
  -                        if(checkString(whenExhaustedAction)) m_CurrentCPD.setWhenExhaustedAction(new
Byte(whenExhaustedAction).byteValue());
  +                        if (checkString(whenExhaustedAction)) m_CurrentCPD.setWhenExhaustedAction(new
Byte(whenExhaustedAction).byteValue());
   
                           String connectionFactoryStr = atts.getValue(tags.getTagById(CONNECTION_FACTORY));
                           logger.debug("     " + tags.getTagById(CONNECTION_FACTORY) + ":
" + connectionFactoryStr);
  -                        if(checkString(connectionFactoryStr)) m_CurrentCPD.setConnectionFactory(connectionFactoryStr);
  +                        if (checkString(connectionFactoryStr)) m_CurrentCPD.setConnectionFactory(connectionFactoryStr);
                           break;
                       }
  -
  -               case ATTRIBUTE :
  +                case ATTRIBUTE:
                       {
  -                    	//handle custom attributes
  +                        //handle custom attributes
                           String attributeName = atts.getValue(tags.getTagById(ATTRIBUTE_NAME));
                           String attributeValue = atts.getValue(tags.getTagById(ATTRIBUTE_VALUE));
                           logger.debug("    > " + tags.getTagById(ATTRIBUTE));
                           logger.debug("     " + tags.getTagById(ATTRIBUTE_NAME) + ": " +
attributeName);
                           logger.debug("     " + tags.getTagById(ATTRIBUTE_VALUE) + ": "
+ attributeValue);
                           // If we have a container to store this attribute in, then do so.
  -                        if (this.m_CurrentAttrContainer!=null)
  +                        if (this.m_CurrentAttrContainer != null)
                           {
  -                            this.m_CurrentAttrContainer.addAttribute(attributeName,attributeValue);
  +                            this.m_CurrentAttrContainer.addAttribute(attributeName, attributeValue);
                           }
  -
                       }
  -
  -
                   default :
                       {
                           // nop
  @@ -750,83 +745,83 @@
           {
               switch (getLiteralId(qName))
               {
  -                case MAPPING_REPOSITORY :
  +                case MAPPING_REPOSITORY:
                       {
                           logger.debug(" < " + tags.getTagById(MAPPING_REPOSITORY));
                           break;
                       }
  -                case JDBC_CONNECTION_DESCRIPTOR :
  +                case JDBC_CONNECTION_DESCRIPTOR:
                       {
                           logger.debug("   < " + tags.getTagById(JDBC_CONNECTION_DESCRIPTOR));
                           break;
                       }
  -                case CONNECTION_POOL :
  +                case CONNECTION_POOL:
                       {
                           logger.debug("   < " + tags.getTagById(CONNECTION_POOL));
                           break;
                       }
  -                case CLASS_DESCRIPTOR :
  +                case CLASS_DESCRIPTOR:
                       {
                           logger.debug("  < " + tags.getTagById(CLASS_DESCRIPTOR));
                           m_CurrentCLD = null;
                           m_CurrentAttrContainer = null;
                           break;
                       }
  -                case CLASS_EXTENT :
  +                case CLASS_EXTENT:
                       {
                           break;
                       }
  -
  -                case FIELD_DESCRIPTOR :
  +                case FIELD_DESCRIPTOR:
                       {
                           logger.debug("    < " + tags.getTagById(FIELD_DESCRIPTOR));
                           m_CurrentFLD = null;
                           m_CurrentAttrContainer = m_CurrentCLD;
                           break;
                       }
  -                case REFERENCE_DESCRIPTOR :
  +                case REFERENCE_DESCRIPTOR:
                       {
                           logger.debug("    < " + tags.getTagById(REFERENCE_DESCRIPTOR));
                           m_CurrentORD = null;
                           m_CurrentAttrContainer = m_CurrentCLD;
                           break;
                       }
  -                case FOREIGN_KEY :
  +                case FOREIGN_KEY:
                       {
                           logger.debug("    < " + tags.getTagById(FOREIGN_KEY));
                           break;
                       }
  -
  -                case COLLECTION_DESCRIPTOR :
  +                case COLLECTION_DESCRIPTOR:
                       {
                           logger.debug("    < " + tags.getTagById(COLLECTION_DESCRIPTOR));
                           m_CurrentCOD = null;
                           m_CurrentAttrContainer = m_CurrentCLD;
                           break;
                       }
  -
  -                case INVERSE_FK :
  +                case INVERSE_FK:
                       {
                           logger.debug("    < " + tags.getTagById(INVERSE_FK));
                           break;
                       }
  -
  -                case FK_POINTING_TO_THIS_CLASS :
  +                case FK_POINTING_TO_THIS_CLASS:
                       {
                           logger.debug("    < " + tags.getTagById(FK_POINTING_TO_THIS_CLASS));
                           break;
                       }
  -                case FK_POINTING_TO_ITEMS_CLASS :
  +                case FK_POINTING_TO_ITEMS_CLASS:
                       {
                           logger.debug("    < " + tags.getTagById(FK_POINTING_TO_ITEMS_CLASS));
                           break;
                       }
  -                case ATTRIBUTE :
  +                case ATTRIBUTE:
                       {
                           logger.debug("    < " + tags.getTagById(ATTRIBUTE));
                           break;
                       }
  -
  +                case DOCUMENTATION:
  +                    {
  +                        logger.debug("    < " + tags.getTagById(DOCUMENTATION));
  +                        break;
  +                    }
                       // handle failure:
                   default :
                       {
  
  
  
  1.26      +39 -14    jakarta-ojb/src/java/org/apache/ojb/broker/metadata/DescriptorRepository.java
  
  Index: DescriptorRepository.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/java/org/apache/ojb/broker/metadata/DescriptorRepository.java,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- DescriptorRepository.java	18 Nov 2002 13:25:10 -0000	1.25
  +++ DescriptorRepository.java	28 Nov 2002 22:19:25 -0000	1.26
  @@ -102,6 +102,12 @@
        */
       private static PBKey defaultPBKey;
   
  +    static
  +    {
  +        /* @todo better solution for init */
  +        getDefaultInstance();
  +    }
  +
       //*****************************************************
   
       /**
  @@ -186,24 +192,43 @@
           {
               String defaultRepositoryName = ((PersistenceBrokerConfiguration) OjbConfigurator.getInstance()
                       .getConfigurationFor(null)).getRepositoryFilename();
  -            RepositoryPersistor persistor = new RepositoryPersistor();
               String user = null;
               String password = null;
  -            try
  -            {
  -                DescriptorRepository ret = persistor.readFromFile(defaultRepositoryName);
  -                JdbcConnectionDescriptor jcd = ret.getDefaultJdbcConnection();
  -                user = jcd.getUserName();
  -                password = jcd.getPassWord();
  -            }
  -            catch (Exception e)
  -            {
  -                throw new MetadataException("Could not build a default PBKey using repository:
" +
  -                        defaultRepositoryName, e);
  -            }
  +            DescriptorRepository ret = readFromRepository(new PBKey(defaultRepositoryName));
  +            JdbcConnectionDescriptor jcd = ret.getDefaultJdbcConnection();
  +            user = jcd.getUserName();
  +            password = jcd.getPassWord();
               defaultPBKey = new PBKey(defaultRepositoryName, user, password);
           }
           return getInstance(defaultPBKey);
  +    }
  +
  +    public static void setDefaultPBKey(PBKey key)
  +    {
  +        defaultPBKey = key;
  +    }
  +
  +    public static PBKey getDefaultPBKey()
  +    {
  +        return defaultPBKey;
  +    }
  +
  +    public static DescriptorRepository readFromRepository(PBKey pbKey) throws MetadataException
  +    {
  +        DescriptorRepository desRep = null;
  +        RepositoryPersistor persistor = new RepositoryPersistor();
  +        try
  +        {
  +            desRep = persistor.readFromFile(pbKey.getRepositoryFile());
  +            prepareJdbcConnectionDescriptor(pbKey, desRep.getDefaultJdbcConnection());
  +            desRep.setPBKey(pbKey);
  +        }
  +        catch (Exception e)
  +        {
  +            LoggerFactory.getDefaultLogger().error(e);
  +            throw new MetadataException(e);
  +        }
  +        return desRep;
       }
   
       /**
  
  
  
  1.6       +11 -10    jakarta-ojb/src/java/org/apache/ojb/broker/metadata/ConnectionPoolDescriptor.java
  
  Index: ConnectionPoolDescriptor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/java/org/apache/ojb/broker/metadata/ConnectionPoolDescriptor.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ConnectionPoolDescriptor.java	21 Sep 2002 15:49:37 -0000	1.5
  +++ ConnectionPoolDescriptor.java	28 Nov 2002 22:19:25 -0000	1.6
  @@ -55,25 +55,26 @@
    * <http://www.apache.org/>.
    */
   
  -import java.io.Serializable;
  -
   import org.apache.ojb.broker.accesslayer.ConnectionFactoryConfiguration;
   import org.apache.ojb.broker.util.configuration.Configurable;
   import org.apache.ojb.broker.util.configuration.Configuration;
   import org.apache.ojb.broker.util.configuration.ConfigurationException;
   import org.apache.ojb.broker.util.configuration.impl.OjbConfigurator;
   import org.apache.ojb.broker.util.logging.LoggerFactory;
  -import org.apache.ojb.broker.util.pooling.PoolInfo;
  +import org.apache.ojb.broker.util.pooling.PoolConfiguration;
  +
  +import java.io.Serializable;
   
   
   /**
  - * Encapsulates configuration properties for {@link org.apache.ojb.broker.accesslayer.ConnectionFactory}
  - * implementations using {@link org.apache.commons.pool.ObjectPool}.
  + * Encapsulates connection pooling configuration properties managed by
  + * {@link org.apache.ojb.broker.metadata.JdbcConnectionDescriptor}.
  + * Each
    *
    * @author <a href="mailto:armin@codeAuLait.de">Armin Waibel</a>
    * @version $Id$
    */
  -public class ConnectionPoolDescriptor extends PoolInfo implements Configurable, Serializable
  +public class ConnectionPoolDescriptor extends PoolConfiguration implements Configurable,
Serializable
   {
       private Class connectionFactory;
   
  @@ -106,15 +107,15 @@
   
       public void setConnectionFactory(String connectionFactory)
       {
  -        if(connectionFactory == null) return;
  +        if (connectionFactory == null) return;
           try
           {
               this.connectionFactory = Class.forName(connectionFactory);
           }
           catch (ClassNotFoundException e)
           {
  -            LoggerFactory.getDefaultLogger().error("Enlisted ConnectionFactory name "+
  -                    connectionFactory+" could not be found, check repository files and
OJB property file", e);
  +            LoggerFactory.getDefaultLogger().error("Enlisted ConnectionFactory name " +
  +                    connectionFactory + " could not be found, check repository files and
OJB property file", e);
           }
       }
   }
  
  
  
  1.7       +3 -3      jakarta-ojb/src/java/org/apache/ojb/broker/metadata/auto/AutoCreatorDb.java
  
  Index: AutoCreatorDb.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/java/org/apache/ojb/broker/metadata/auto/AutoCreatorDb.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- AutoCreatorDb.java	28 Nov 2002 20:40:09 -0000	1.6
  +++ AutoCreatorDb.java	28 Nov 2002 22:19:25 -0000	1.7
  @@ -17,8 +17,8 @@
   import org.apache.ojb.broker.util.logging.Logger;
   import org.apache.ojb.broker.util.logging.LoggerFactory;
   import org.apache.ojb.broker.accesslayer.ConnectionFactory;
  -import org.apache.ojb.broker.accesslayer.ConnectionFactoryDefaultImpl;
   import org.apache.ojb.broker.accesslayer.LookupException;
  +import org.apache.ojb.broker.accesslayer.ConnectionFactoryNotPooledImpl;
   import org.apache.ojb.broker.metadata.ClassDescriptor;
   import org.apache.ojb.broker.metadata.DescriptorRepository;
   import org.apache.ojb.broker.metadata.FieldDescriptor;
  @@ -52,7 +52,7 @@
   				SQLFactory factory = (SQLFactory) (factory_class.newInstance());
   
   				// get db connection
  -				ConnectionFactory connFactory = new ConnectionFactoryDefaultImpl();
  +				ConnectionFactory connFactory = new ConnectionFactoryNotPooledImpl();
   				Connection conn = connFactory.lookupConnection(jdbcDescriptor);
   
   				// get elements
  
  
  

Mime
View raw message