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 SequenceDescriptor.java RepositoryElements.java JdbcConnectionDescriptor.java DescriptorRepository.java ConnectionRepository.java ConnectionPoolDescriptor.java FieldDescriptor.java MetadataManager.java ConnectionDescriptorXmlHandler.java RepositoryTags.java RepositoryXmlHandler.java
Date Thu, 09 Jan 2003 16:58:38 GMT
arminw      2003/01/09 08:58:37

  Modified:    src/java/org/apache/ojb/broker/metadata
                        RepositoryElements.java
                        JdbcConnectionDescriptor.java
                        DescriptorRepository.java ConnectionRepository.java
                        ConnectionPoolDescriptor.java FieldDescriptor.java
                        MetadataManager.java
                        ConnectionDescriptorXmlHandler.java
                        RepositoryTags.java RepositoryXmlHandler.java
  Added:       src/java/org/apache/ojb/broker/metadata
                        SequenceDescriptor.java
  Log:
  - move the whole sequence-manager
  properties stuff from the OJB.properties to
  the repository
  - move the 'useAutoCommit' and
  'ignoreAutocommitExceptions' properties from OJB.properties
  to jdbc-connection-descriptor
  
  - remove the 'maxConnectionsInPool'
  property from OJB.properties
  
  - rename DescriptorRepository#getExtentClass
  to #getTopLevelClass, deprecate PB#getExtentClass
  and add PB#getTopLevelClass
  
  Revision  Changes    Path
  1.19      +12 -1     jakarta-ojb/src/java/org/apache/ojb/broker/metadata/RepositoryElements.java
  
  Index: RepositoryElements.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/java/org/apache/ojb/broker/metadata/RepositoryElements.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- RepositoryElements.java	2 Jan 2003 21:27:19 -0000	1.18
  +++ RepositoryElements.java	9 Jan 2003 16:58:35 -0000	1.19
  @@ -79,6 +79,8 @@
       public static final int USER_PASSWD = 11;
       public static final int EAGER_RELEASE = 74;
       public static final int BATCH_MODE = 83;
  +    public static final int USE_AUTOCOMMIT = 90;
  +    public static final int IGNORE_AUTOCOMMIT_EXCEPTION = 91;
       public static final int CLASS_DESCRIPTOR = 12;
       public static final int CLASS_NAME = 13;
       public static final int CLASS_PROXY = 35;
  @@ -119,6 +121,7 @@
       public static final int LENGTH = 52;
       public static final int PRECISION = 53;
       public static final int SCALE = 54;
  +
       public static final int CON_MAX_ACTIVE = 55;
       public static final int CON_MAX_IDLE = 56;
       public static final int CON_MAX_WAIT = 57;
  @@ -129,9 +132,17 @@
       public static final int CON_TEST_WHILE_IDLE = 62;
       public static final int CON_TIME_BETWEEN_EVICTION_RUNS_MILLIS = 63;
       public static final int CON_WHEN_EXHAUSTED_ACTION = 64;
  +    public static final int CON_LOG_ABANDONED = 87;
  +    public static final int CON_REMOVE_ABANDONED = 85;
  +    public static final int CON_REMOVE_ABANDONED_TIMEOUT = 86;
  +
       public static final int CONNECTION_POOL = 65;
       public static final int CONNECTION_FACTORY = 66;
       public static final int VALIDATION_QUERY = 79;
  +    public static final int SEQUENCE_MANAGER = 88;
  +    public static final int SEQUENCE_MANAGER_CLASS = 89;
  +
  +
       public static final int REPOSITORY_VERSION = 67;
       public static final int CLASS_REF = 68;
       public static final int ID = 69;
  @@ -144,5 +155,5 @@
       public static final int ACCEPT_LOCKS = 78;
   
       // maintain a last id to keep track where we are
  -    public static final int _LAST = 85;
  +    public static final int _LAST = 92;
   }
  
  
  
  1.19      +79 -141   jakarta-ojb/src/java/org/apache/ojb/broker/metadata/JdbcConnectionDescriptor.java
  
  Index: JdbcConnectionDescriptor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/java/org/apache/ojb/broker/metadata/JdbcConnectionDescriptor.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- JdbcConnectionDescriptor.java	25 Dec 2002 23:26:57 -0000	1.18
  +++ JdbcConnectionDescriptor.java	9 Jan 2003 16:58:36 -0000	1.19
  @@ -58,6 +58,11 @@
   
   import org.apache.ojb.broker.util.logging.Logger;
   import org.apache.ojb.broker.util.logging.LoggerFactory;
  +import org.apache.ojb.broker.metadata.SequenceDescriptor;
  +import org.apache.ojb.broker.metadata.ConnectionPoolDescriptor;
  +import org.apache.ojb.broker.metadata.XmlCapable;
  +import org.apache.ojb.broker.metadata.RepositoryTags;
  +import org.apache.ojb.broker.PBKey;
   import org.apache.commons.lang.builder.ToStringBuilder;
   import org.apache.commons.lang.builder.ToStringStyle;
   import org.apache.commons.lang.SystemUtils;
  @@ -85,9 +90,16 @@
       private double m_JdbcLevel = 2.0;
       private boolean m_eagerRelease = false;
       private boolean m_batchMode = false;
  -    private boolean m_defaultConnection = false;
  -    private Integer descriptorKey;
  +    private boolean defaultConnection = false;
  +    private int useAutoCommit = 1;
  +    private boolean ignoreAutoCommitExceptions = false;
  +    private PBKey pbKey;
       private ConnectionPoolDescriptor cpd;
  +    private SequenceDescriptor sequenceDescriptor;
  +
  +    public static final int AUTO_COMMIT_IGNORE_STATE = 0;
  +    public static final int AUTO_COMMIT_SET_TRUE_AND_TEMPORARY_FALSE = 1;
  +    public static final int AUTO_COMMIT_SET_FALSE = 2;
   
       /**
        * Constructor declaration
  @@ -110,18 +122,42 @@
        */
       public void setJcdAlias(String jcdAlias)
       {
  -        this.clearDescriptorKey();
  +        this.clearPBKey();
           this.m_jcdAlias = jcdAlias;
       }
   
  +    /**
  +     *
  +     */
       public boolean isDefaultConnection()
       {
  -        return m_defaultConnection;
  +        return defaultConnection;
       }
   
  +    /**
  +     *
  +     */
       public void setDefaultConnection(boolean defaultConnection)
       {
  -        this.m_defaultConnection = defaultConnection;
  +        this.defaultConnection = defaultConnection;
  +    }
  +
  +    /**
  +     * Return the associated <code>SequenceDescriptor</code>
  +     * or <code>null</code> if not set.
  +     */
  +    public SequenceDescriptor getSequenceDescriptor()
  +    {
  +        return sequenceDescriptor;
  +    }
  +
  +    /**
  +     * Set the <code>SequenceDescriptor</code> for this
  +     * connection descriptor.
  +     */
  +    public void setSequenceDescriptor(SequenceDescriptor sequenceDescriptor)
  +    {
  +        this.sequenceDescriptor = sequenceDescriptor;
       }
   
       /**
  @@ -143,21 +179,18 @@
       /**
        * Return a key to identify the connection descriptor.
        */
  -    public Integer getDescriptorKey()
  +    public PBKey getPBKey()
       {
  -        if (descriptorKey == null)
  +        if (pbKey == null)
           {
  -            StringBuffer buf = new StringBuffer(m_jcdAlias);
  -            buf.append(getUserName());
  -            buf.append(getPassWord());
  -            descriptorKey = new Integer(buf.toString().hashCode());
  +            this.pbKey = new PBKey(this.getJcdAlias(), this.getUserName(), this.getPassWord());
           }
  -        return descriptorKey;
  +        return pbKey;
       }
   
  -    private void clearDescriptorKey()
  +    private void clearPBKey()
       {
  -        this.descriptorKey = null;
  +        this.pbKey = null;
       }
   
       /**
  @@ -168,7 +201,7 @@
           ToStringBuilder buf = new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE);
           buf.
           append("jcd-alias", m_jcdAlias).
  -        append("default-connection", m_defaultConnection).
  +        append("default-connection", defaultConnection).
           append("dbms", m_Dbms).
           append("jdbc-level", m_JdbcLevel).
           append("driver", m_Driver).
  @@ -176,13 +209,34 @@
           append("sub-protocol", m_SubProtocol).
           append("db-alias", m_DbAlias).
           append("user", m_UserName).
  -        append("password", m_Password).
  +        append("password", "*****").
           append("eager-release", m_eagerRelease).
           append("ConnectionPoolDescriptor", cpd).
  -        append("batchMode", m_batchMode);
  +        append("batchMode", m_batchMode).
  +        append("sequenceDescriptor", sequenceDescriptor);
           return buf.toString();
       }
   
  +    public int getUseAutoCommit()
  +    {
  +        return useAutoCommit;
  +    }
  +
  +    public void setUseAutoCommit(int useAutoCommit)
  +    {
  +        this.useAutoCommit = useAutoCommit;
  +    }
  +
  +    public boolean isIgnoreAutoCommitExceptions()
  +    {
  +        return ignoreAutoCommitExceptions;
  +    }
  +
  +    public void setIgnoreAutoCommitExceptions(boolean ignoreAutoCommitExceptions)
  +    {
  +        this.ignoreAutoCommitExceptions = ignoreAutoCommitExceptions;
  +    }
  +
       /**
        * Method declaration
        * @return
  @@ -288,7 +342,7 @@
        */
       public void setUserName(String str)
       {
  -        this.clearDescriptorKey();
  +        this.clearPBKey();
           m_UserName = str;
       }
   
  @@ -307,130 +361,11 @@
        */
       public void setPassWord(String str)
       {
  -        this.clearDescriptorKey();
  +        this.clearPBKey();
           m_Password = str;
       }
   
       /**
  -     * Method declaration
  -     * @param def
  -     * @return
  -     */
  -    public String getDbms(JdbcConnectionDescriptor def)
  -    {
  -        if (m_Dbms == null)
  -        {
  -            return def.getDbms();
  -        }
  -        else
  -        {
  -            return m_Dbms;
  -        }
  -    }
  -
  -    /**
  -     * Method declaration
  -     * @param
  -     * @return
  -     */
  -    public String getDriver(JdbcConnectionDescriptor def)
  -    {
  -        if (m_Driver == null)
  -        {
  -            return def.getDriver();
  -        }
  -        else
  -        {
  -            return m_Driver;
  -        }
  -    }
  -
  -    /**
  -     * Method declaration
  -     * @param def
  -     * @return
  -     */
  -    public String getProtocol(JdbcConnectionDescriptor def)
  -    {
  -        if (m_Protocol == null)
  -        {
  -            return def.getProtocol();
  -        }
  -        else
  -        {
  -            return m_Protocol;
  -        }
  -    }
  -
  -    /**
  -     * Method declaration
  -     * @param def
  -     * @return
  -     */
  -    public String getSubProtocol(JdbcConnectionDescriptor def)
  -    {
  -        if (m_SubProtocol == null)
  -        {
  -            return def.getSubProtocol();
  -        }
  -        else
  -        {
  -            return m_SubProtocol;
  -        }
  -    }
  -
  -    /**
  -     * Method declaration
  -     * @param def
  -     * @return
  -     */
  -    public String getDbAlias(JdbcConnectionDescriptor def)
  -    {
  -        if (m_DbAlias == null)
  -        {
  -            return def.getDbAlias();
  -        }
  -        else
  -        {
  -            return m_DbAlias;
  -        }
  -    }
  -
  -    /**
  -     * Method declaration
  -     * @param def
  -     * @return
  -     */
  -    public String getUserName(JdbcConnectionDescriptor def)
  -    {
  -        if (m_UserName == null)
  -        {
  -            return def.getUserName();
  -        }
  -        else
  -        {
  -            return m_UserName;
  -        }
  -    }
  -
  -    /**
  -     * Method declaration
  -     * @param def
  -     * @return
  -     */
  -    public String getPassWord(JdbcConnectionDescriptor def)
  -    {
  -        if (m_Password == null)
  -        {
  -            return def.getPassWord();
  -        }
  -        else
  -        {
  -            return m_Password;
  -        }
  -    }
  -
  -    /**
        * Gets the datasourceName.
        * @return Returns a String
        */
  @@ -507,7 +442,7 @@
   
       public void setBatchMode(boolean flag)
       {
  -        this.clearDescriptorKey();
  +        this.clearPBKey();
       	m_batchMode = flag;
       }
   
  @@ -556,7 +491,10 @@
           	strReturn += "    " + tags.getAttribute(USER_PASSWD, passwd) + eol;
           }
   
  -		strReturn += "  />" + eol;
  +		strReturn += "  >" + eol+eol;
  +        strReturn += this.getConnectionPoolDescriptor().toXML()+eol;
  +        if(this.getSequenceDescriptor() != null) strReturn += this.getSequenceDescriptor().toXML()+eol;
  +        strReturn += "  " + tags.getClosingTagById(JDBC_CONNECTION_DESCRIPTOR) + eol;
   		return strReturn;
       }
   
  
  
  
  1.30      +21 -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.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- DescriptorRepository.java	26 Dec 2002 19:34:45 -0000	1.29
  +++ DescriptorRepository.java	9 Jan 2003 16:58:36 -0000	1.30
  @@ -133,14 +133,15 @@
       }
   
       /**
  -     * returns the Extent to which the class clazz belongs.
  -     * This may be a baseclass,an interface or clazz itself, if no Extent
  -     * is defined.
  -     * throws a PersistenceBrokerException if clazz is not persistence capable,
  +     * Returns the top level (extent) class to which the given class belongs.
  +     * This may be a (abstract) base-class, an interface or the given class
  +     * itself if given class is not defined as an extent in other class
  +     * descriptors.
  +     *
  +     * @throws ClassNotPersistenceCapableException if clazz is not persistence capable,
        * i.e. if clazz is not defined in the DescriptorRepository.
  -     * @param the class to lookup the Extent for
        */
  -    public Class getExtentClass(Class clazz)
  +    public Class getTopLevelClass(Class clazz) throws ClassNotPersistenceCapableException
       {
           // try to find an extent that contains clazz
           Class retval = (Class) m_extentClassTable.get(clazz);
  @@ -155,15 +156,21 @@
                       // Changed to call getExtentClass recursively
                       // old version:
                       // extentClass = cld.getClassOfObject();
  -                    retval = getExtentClass(cld.getClassOfObject());
  +                    retval = getTopLevelClass(cld.getClassOfObject());
  +                    // if such an extent could not be found just return clazz itself.
  +                    if (retval == null)
  +                    {
  +                        retval = clazz;
  +                    }
                   }
  +                else
  +                {
  +                    // check if class is persistence capable
  +                    getDescriptorFor(clazz);
  +                    retval = clazz;
  +                }
  +                m_extentClassTable.put(clazz, retval);
               }
  -            // if such an extent could not be found just return clazz itself.
  -            if (retval == null)
  -            {
  -                retval = clazz;
  -            }
  -            m_extentClassTable.put(clazz, retval);
           }
           return retval;
       }
  
  
  
  1.3       +49 -20    jakarta-ojb/src/java/org/apache/ojb/broker/metadata/ConnectionRepository.java
  
  Index: ConnectionRepository.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/java/org/apache/ojb/broker/metadata/ConnectionRepository.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ConnectionRepository.java	26 Dec 2002 19:34:45 -0000	1.2
  +++ ConnectionRepository.java	9 Jan 2003 16:58:36 -0000	1.3
  @@ -4,6 +4,7 @@
   import org.apache.commons.lang.SystemUtils;
   import org.apache.ojb.broker.util.logging.Logger;
   import org.apache.ojb.broker.util.logging.LoggerFactory;
  +import org.apache.ojb.broker.PBKey;
   
   import java.io.Serializable;
   import java.util.Collection;
  @@ -30,20 +31,49 @@
       }
   
       /**
  -     * Returns a copy of the matching {@link JdbcConnectionDescriptor}.
  +     * Returns the matching {@link JdbcConnectionDescriptor}
  +     * or <code>null</code> if no descriptor could be found.
        */
  -    public JdbcConnectionDescriptor getDescriptor(String jcdAlias)
  +    public JdbcConnectionDescriptor getDescriptor(PBKey pbKey)
       {
  -        JdbcConnectionDescriptor result = (JdbcConnectionDescriptor) jcdMap.get(jcdAlias);
  -        if (result != null)
  +        JdbcConnectionDescriptor result = (JdbcConnectionDescriptor) jcdMap.get(pbKey);
  +        if (result == null)
           {
  -            result = (JdbcConnectionDescriptor) SerializationUtils.clone(result);
  +            result = deepCopyOfFirstFound(pbKey.getAlias());
  +            if(result != null)
  +            {
  +                result.setUserName(pbKey.getUser());
  +                result.setPassWord(pbKey.getPassword());
  +                // this build connection descriptor could not be the default connection
  +                result.setDefaultConnection(false);
  +                addDescriptor(result);
  +            }
  +            else
  +            {
  +                log.info("Could not found " + JdbcConnectionDescriptor.class.getName()
+ " for alias '" + pbKey + "'");
  +            }
           }
  -        else
  +        return result;
  +    }
  +
  +    /**
  +     * Returns a deep copy of the first found connection descriptor
  +     * with the given <code>jcdAlias</code> name or <code>null</code>
  +     * if none found.
  +     */
  +    private JdbcConnectionDescriptor deepCopyOfFirstFound(String jcdAlias)
  +    {
  +        Iterator it = jcdMap.values().iterator();
  +        JdbcConnectionDescriptor jcd;
  +        while (it.hasNext())
           {
  -            log.info("Could not found " + JdbcConnectionDescriptor.class.getName() + "
for alias '" + jcdAlias + "'");
  +            jcd = (JdbcConnectionDescriptor) it.next();
  +            if(jcdAlias.equals(jcdAlias))
  +            {
  +                return (JdbcConnectionDescriptor) SerializationUtils.clone(jcd);
  +            }
           }
  -        return result;
  +        return null;
       }
   
       /**
  @@ -53,12 +83,12 @@
       {
           synchronized (jcdMap)
           {
  -            if (jcdMap.containsKey(jcd.getJcdAlias()))
  +            if (jcdMap.containsKey(jcd.getPBKey()))
               {
  -                throw new MetadataException("Found duplicate jcd-alias '" + jcd.getJcdAlias()
+
  -                        "', remove the old descriptor first, before add anew one with same
jcd-alias. "+jcd);
  +                throw new MetadataException("Found duplicate connection descriptor using
PBKey " +
  +                        jcd.getPBKey() + ", remove the old descriptor first, before add
the new one. "+jcd);
               }
  -            jcdMap.put(jcd.getJcdAlias(), jcd);
  +            jcdMap.put(jcd.getPBKey(), jcd);
               if(log.isDebugEnabled()) log.debug("New descriptor was added: " + jcd);
           }
       }
  @@ -66,19 +96,18 @@
       /**
        * Remove a descriptor.
        * @param validKey  This could be the {@link JdbcConnectionDescriptor}
  -     * itself, or the {@link JdbcConnectionDescriptor#getJcdAlias jcd-alias name}
  -     * as String.
  +     * itself, or the associated {@link JdbcConnectionDescriptor#getPBKey PBKey}.
        */
       public void removeDescriptor(Object validKey)
       {
  -        String jcdMapKey;
  -        if (validKey instanceof String)
  +        PBKey jcdKey;
  +        if (validKey instanceof PBKey)
           {
  -            jcdMapKey = (String) validKey;
  +            jcdKey = (PBKey) validKey;
           }
           else if (validKey instanceof JdbcConnectionDescriptor)
           {
  -            jcdMapKey = ((JdbcConnectionDescriptor) validKey).getJcdAlias();
  +            jcdKey = ((JdbcConnectionDescriptor) validKey).getPBKey();
           }
           else
           {
  @@ -88,7 +117,7 @@
           Object removed = null;
           synchronized (jcdMap)
           {
  -            removed = jcdMap.remove(jcdMapKey);
  +            removed = jcdMap.remove(jcdKey);
           }
           log.info("Remove descriptor: " + removed);
       }
  
  
  
  1.8       +41 -11    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.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ConnectionPoolDescriptor.java	24 Dec 2002 13:14:33 -0000	1.7
  +++ ConnectionPoolDescriptor.java	9 Jan 2003 16:58:36 -0000	1.8
  @@ -55,7 +55,6 @@
    * <http://www.apache.org/>.
    */
   
  -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;
  @@ -63,6 +62,7 @@
   import org.apache.ojb.broker.util.logging.LoggerFactory;
   import org.apache.ojb.broker.util.pooling.PoolConfiguration;
   import org.apache.ojb.broker.util.ClassHelper;
  +import org.apache.commons.lang.SystemUtils;
   
   import java.io.Serializable;
   
  @@ -70,19 +70,21 @@
   /**
    * Encapsulates connection pooling configuration properties managed by
    * {@link org.apache.ojb.broker.metadata.JdbcConnectionDescriptor}.
  - * Each
  + * <br/>
  + * Every new instantiated <code>ConnectionPoolDescriptor</code> was
  + * associated with default connection pool attributes.
    *
    * @author <a href="mailto:armin@codeAuLait.de">Armin Waibel</a>
    * @version $Id$
    */
  -public class ConnectionPoolDescriptor extends PoolConfiguration implements Configurable,
Serializable
  +public class ConnectionPoolDescriptor extends PoolConfiguration implements Serializable,
XmlCapable
   {
       private Class connectionFactory;
   
       public ConnectionPoolDescriptor()
       {
  +        super();
           init();
  -        OjbConfigurator.getInstance().configure(this);
       }
   
       /**
  @@ -93,12 +95,8 @@
           this.setTestOnBorrow(true);
           this.setTestOnReturn(false);
           this.setTestWhileIdle(false);
  -    }
  -
  -    public void configure(Configuration pConfig) throws ConfigurationException
  -    {
  -        ConnectionFactoryConfiguration conFacConf = (ConnectionFactoryConfiguration) pConfig;
  -        this.setMaxActive(conFacConf.getConMaxActive());
  +        this.setLogAbandoned(false);
  +        this.setRemoveAbandoned(false);
       }
   
       public Class getConnectionFactory()
  @@ -110,6 +108,38 @@
       {
           if (connectionFactory == null) throw new MetadataException("Given ConnectionFactory
was null");
           this.connectionFactory = connectionFactory;
  +    }
  +
  +    public String toXML()
  +    {
  +        RepositoryTags tags = RepositoryTags.getInstance();
  +        String eol = SystemUtils.LINE_SEPARATOR;
  +        StringBuffer buf = new StringBuffer();
  +        //opening tag + attributes
  +        buf.append("      " + tags.getOpeningTagNonClosingById(CONNECTION_POOL) + eol);
  +        buf.append("         " + tags.getAttribute(RepositoryElements.CON_MAX_ACTIVE, ""
+ getMaxActive()) + eol);
  +        buf.append("         " + tags.getAttribute(RepositoryElements.CON_MAX_IDLE, ""
+ getMaxIdle()) + eol);
  +        buf.append("         " + tags.getAttribute(RepositoryElements.CON_MAX_WAIT, ""
+ getMaxWait()) + eol);
  +        buf.append("         " + tags.getAttribute(RepositoryElements.CON_MIN_EVICTABLE_IDLE_TIME_MILLIS,
"" +
  +                getMinEvictableIdleTimeMillis()) + eol);
  +        buf.append("         " + tags.getAttribute(RepositoryElements.CON_NUM_TESTS_PER_EVICTION_RUN,
"" +
  +                getNumTestsPerEvictionRun()) + eol);
  +        buf.append("         " + tags.getAttribute(RepositoryElements.CON_TEST_ON_BORROW,
"" + isTestOnBorrow()) + eol);
  +        buf.append("         " + tags.getAttribute(RepositoryElements.CON_TEST_ON_RETURN,
"" + isTestOnReturn()) + eol);
  +        buf.append("         " + tags.getAttribute(RepositoryElements.CON_TEST_WHILE_IDLE,
"" + isTestWhileIdle()) + eol);
  +        buf.append("         " + tags.getAttribute(RepositoryElements.CON_TIME_BETWEEN_EVICTION_RUNS_MILLIS,
"" +
  +                getTimeBetweenEvictionRunsMillis()) + eol);
  +        buf.append("         " + tags.getAttribute(RepositoryElements.CON_WHEN_EXHAUSTED_ACTION,
"" +
  +                getWhenExhaustedAction()) + eol);
  +        buf.append("         " + tags.getAttribute(RepositoryElements.VALIDATION_QUERY,
"" + getValidationQuery()) + eol);
  +
  +        buf.append("         " + tags.getAttribute(RepositoryElements.CON_LOG_ABANDONED,
"" + isLogAbandoned()) + eol);
  +        buf.append("         " + tags.getAttribute(RepositoryElements.CON_REMOVE_ABANDONED,
"" +
  +                isRemoveAbandoned()) + eol);
  +        buf.append("         " + tags.getAttribute(RepositoryElements.CON_REMOVE_ABANDONED_TIMEOUT,
"" +
  +                getRemoveAbandonedTimeout()) + eol);
  +        buf.append("      />" + eol);
  +        return buf.toString();
       }
   }
   
  
  
  
  1.15      +6 -5      jakarta-ojb/src/java/org/apache/ojb/broker/metadata/FieldDescriptor.java
  
  Index: FieldDescriptor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/java/org/apache/ojb/broker/metadata/FieldDescriptor.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- FieldDescriptor.java	24 Dec 2002 13:14:33 -0000	1.14
  +++ FieldDescriptor.java	9 Jan 2003 16:58:36 -0000	1.15
  @@ -55,6 +55,7 @@
    */
   
   import org.apache.commons.lang.builder.ToStringBuilder;
  +import org.apache.commons.lang.SystemUtils;
   import org.apache.ojb.broker.OJBRuntimeException;
   import org.apache.ojb.broker.accesslayer.conversions.FieldConversion;
   import org.apache.ojb.broker.accesslayer.conversions.FieldConversionDefaultImpl;
  @@ -459,14 +460,14 @@
       public String toXML()
       {
           RepositoryTags tags = RepositoryTags.getInstance();
  -        String eol = System.getProperty("line.separator");
  +        String eol = SystemUtils.LINE_SEPARATOR;
   
           //opening tag + attributes
  -        String result = "      " + tags.getOpeningTagNonClosingById(FIELD_DESCRIPTOR) +
" ";
  +        String result = "      " + tags.getOpeningTagNonClosingById(FIELD_DESCRIPTOR) +
" "+eol;
   
  -        // id
  -        String id = new Integer(getColNo()).toString();
  -        result += /*"        " +*/ tags.getAttribute(ID, id) + eol;
  +//        // id
  +//        String id = new Integer(getColNo()).toString();
  +//        result += /*"        " +*/ tags.getAttribute(ID, id) + eol;
   
           // name
           result += "        " + tags.getAttribute(FIELD_NAME, this.getAttributeName()) +
eol;
  
  
  
  1.3       +9 -9      jakarta-ojb/src/java/org/apache/ojb/broker/metadata/MetadataManager.java
  
  Index: MetadataManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/java/org/apache/ojb/broker/metadata/MetadataManager.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- MetadataManager.java	26 Dec 2002 19:34:45 -0000	1.2
  +++ MetadataManager.java	9 Jan 2003 16:58:36 -0000	1.3
  @@ -12,18 +12,18 @@
   import java.io.IOException;
   
   /**
  - * Central class for metadata operations, manages OJB's
  + * Central class for metadata operations - manages all OJB's
    * {@link org.apache.ojb.broker.metadata.DescriptorRepository} and
    * {@link org.apache.ojb.broker.metadata.ConnectionRepository} instances.
    * <br>
  - * Allow a bunch of different repository handling possibilities - allows a transparent
flexible
  - * metadata manipulation at runtime.
  + * Allow a bunch of different repository handling possibilities -
  + * allows a transparent flexible metadata manipulation at runtime.
    * <p>
    * Per default the manager handle one global {@link org.apache.ojb.broker.metadata.DescriptorRepository}
    * for all calling threads, but you could {@link #setEnablePerThreadChanges enable a per
thread}
  - * handling. Then it is possible to set a different
  - * {@link org.apache.ojb.broker.metadata.DescriptorRepository} for each calling thread.
  - * This allows a per thread manipulation of the metadata at runtime.
  + * handling. This enables to set a different
  + * {@link org.apache.ojb.broker.metadata.DescriptorRepository DescriptorRepository} for
each calling thread.
  + * This allows a per thread manipulation of the persistent object metadata at runtime.
    * </p>
    *
    * @author <a href="mailto:armin@codeAuLait.de">Armin Waibel</a>
  @@ -107,7 +107,7 @@
   
       /**
        * Returns explicit the global {@link DescriptorRepository} - use with
  -     * care, because it ignores the {@link #setEnablePerThreadChanges per thread mode}.
  +     * care, because it ignores the {@link #isEnablePerThreadChanges per thread mode}.
        */
       public DescriptorRepository getGlobalRepository()
       {
  @@ -146,7 +146,7 @@
   
       /**
        * Convenience method for
  -     * {@link #setDescriptorRepository setDescriptor(repository, false)}.
  +     * {@link #setDescriptor setDescriptor(repository, false)}.
        */
       public void setPerThreadDescriptor(DescriptorRepository repository)
       {
  
  
  
  1.2       +85 -5     jakarta-ojb/src/java/org/apache/ojb/broker/metadata/ConnectionDescriptorXmlHandler.java
  
  Index: ConnectionDescriptorXmlHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/java/org/apache/ojb/broker/metadata/ConnectionDescriptorXmlHandler.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ConnectionDescriptorXmlHandler.java	24 Dec 2002 13:14:33 -0000	1.1
  +++ ConnectionDescriptorXmlHandler.java	9 Jan 2003 16:58:36 -0000	1.2
  @@ -83,7 +83,7 @@
   
       private ConnectionRepository con_repository;
       private JdbcConnectionDescriptor m_CurrentJCD;
  -//    private String m_CurrentString;
  +    private SequenceDescriptor currentSequenceDescriptor;
       private List conDesList;
   
       /**
  @@ -192,6 +192,8 @@
   
                           // set the datasource attribute
                           String datasource = atts.getValue(tags.getTagById(DATASOURCE_NAME));
  +                        // check for empty String
  +                        if(datasource != null && datasource.trim().equals(""))
datasource = null;
                           if (isDebug) logger.debug("     " + tags.getTagById(DATASOURCE_NAME)
+ ": " + datasource);
                           m_CurrentJCD.setDatasourceName(datasource);
   
  @@ -215,6 +217,18 @@
                           if (isDebug) logger.debug("     " + tags.getTagById(BATCH_MODE)
+ ": " + batchMode);
                           m_CurrentJCD.setBatchMode(Boolean.valueOf(batchMode).booleanValue());
   
  +                        // set useAutoCommit attribute
  +                        String useAutoCommit = atts.getValue(tags.getTagById(USE_AUTOCOMMIT));
  +                        if (isDebug) logger.debug("     " + tags.getTagById(USE_AUTOCOMMIT)
+ ": " + useAutoCommit);
  +                        m_CurrentJCD.setUseAutoCommit(Integer.valueOf(useAutoCommit).intValue());
  +
  +                        // set ignoreAutoCommitExceptions attribute
  +                        String ignoreAutoCommitExceptions = atts.getValue(tags.getTagById(IGNORE_AUTOCOMMIT_EXCEPTION));
  +                        if (isDebug) logger.debug("     " + tags.getTagById(IGNORE_AUTOCOMMIT_EXCEPTION)
+ ": " + ignoreAutoCommitExceptions);
  +                        m_CurrentJCD.setIgnoreAutoCommitExceptions(Boolean.valueOf(ignoreAutoCommitExceptions).booleanValue());
  +
  +
  +
   
                           break;
                       }
  @@ -269,13 +283,64 @@
   
                           String validationQuery = atts.getValue(tags.getTagById(VALIDATION_QUERY));
                           if (isDebug) logger.debug("     " + tags.getTagById(VALIDATION_QUERY)
+ ": " + validationQuery);
  -                        if (checkString(connectionFactoryStr)) m_CurrentCPD.setValidationQuery(validationQuery);
  +                        if (checkString(validationQuery)) m_CurrentCPD.setValidationQuery(validationQuery);
  +
  +                        // abandoned connection properties
  +                        String logAbandoned = atts.getValue(tags.getTagById(CON_LOG_ABANDONED));
  +                        if (isDebug) logger.debug("     " + tags.getTagById(CON_LOG_ABANDONED)
+ ": " + logAbandoned);
  +                        if (checkString(logAbandoned)) m_CurrentCPD.setLogAbandoned(new
Boolean(logAbandoned).booleanValue());
  +
  +                        String removeAbandoned = atts.getValue(tags.getTagById(CON_REMOVE_ABANDONED));
  +                        if (isDebug) logger.debug("     " + tags.getTagById(CON_REMOVE_ABANDONED)
+ ": " + removeAbandoned);
  +                        if (checkString(removeAbandoned)) m_CurrentCPD.setRemoveAbandoned(new
Boolean(removeAbandoned).booleanValue());
  +
  +                        String removeAbandonedTimeout = atts.getValue(tags.getTagById(CON_REMOVE_ABANDONED_TIMEOUT));
  +                        if (isDebug) logger.debug("     " + tags.getTagById(CON_REMOVE_ABANDONED_TIMEOUT)
+ ": " + removeAbandonedTimeout);
  +                        if (checkString(removeAbandonedTimeout)) m_CurrentCPD.setRemoveAbandonedTimeout(new
Integer(removeAbandonedTimeout).intValue());
  +
  +                        break;
  +                    }
  +                case SEQUENCE_MANAGER:
  +                    {
  +                        String className = atts.getValue(tags.getTagById(SEQUENCE_MANAGER_CLASS));
  +                        if(checkString(className))
  +                        {
  +                            this.currentSequenceDescriptor = new SequenceDescriptor(this.m_CurrentJCD);
  +                            this.m_CurrentJCD.setSequenceDescriptor(this.currentSequenceDescriptor);
  +                            if (isDebug) logger.debug("    > " + tags.getTagById(SEQUENCE_MANAGER));
  +                            if (isDebug) logger.debug("     " + tags.getTagById(SEQUENCE_MANAGER_CLASS)
+ ": " + className);
  +                            if (checkString(className)) currentSequenceDescriptor.setSequenceManagerClass(ClassHelper.getClass(className));
  +                        }
  +                        break;
  +                    }
  +                case ATTRIBUTE:
  +                    {
  +                        // If we have a container to store this attribute in, then do so.
  +                        if (this.currentSequenceDescriptor != null)
  +                        {
  +                            //handle custom sequence manager attributes
  +                            String attributeName = atts.getValue(tags.getTagById(ATTRIBUTE_NAME));
  +                            String attributeValue = atts.getValue(tags.getTagById(ATTRIBUTE_VALUE));
  +                            if (checkString(attributeName))
  +                            {
  +                                if (isDebug) logger.debug("    > " + tags.getTagById(ATTRIBUTE));
  +                                if (isDebug) logger.debug("     " + tags.getTagById(ATTRIBUTE_NAME)
+ ": " + attributeName);
  +                                if (isDebug) logger.debug("     " + tags.getTagById(ATTRIBUTE_VALUE)
+ ": " + attributeValue);
  +                                this.currentSequenceDescriptor.addConfigurationProperty(attributeName,
attributeValue);
  +                            }
  +                            else
  +                            {
  +                                logger.info("Found 'null' or 'empty' attribute object for
sequence-manager element."+
  +                                        " attribute-name=" + attributeName + ", attribute-value="
+ attributeValue+
  +                                        " See jdbc-connection-descriptor with jcdAlias
'"+m_CurrentJCD.getJcdAlias()+"'");
  +                            }
  +                        }
   
                           break;
                       }
                   default :
                       {
  -                        // nop
  +                        // noop
                       }
               }
           }
  @@ -288,7 +353,7 @@
   
       private boolean checkString(String str)
       {
  -        return (str != null && !str.equals(""));
  +        return (str != null && !str.trim().equals(""));
       }
   
       /**
  @@ -317,6 +382,7 @@
        */
       public void endElement(String uri, String name, String qName)
       {
  +        boolean isDebug = logger.isDebugEnabled();
           try
           {
               switch (getLiteralId(qName))
  @@ -324,11 +390,25 @@
                   case JDBC_CONNECTION_DESCRIPTOR:
                       {
                           logger.debug("   < " + tags.getTagById(JDBC_CONNECTION_DESCRIPTOR));
  +                        m_CurrentJCD = null;
                           break;
                       }
                   case CONNECTION_POOL:
                       {
                           logger.debug("   < " + tags.getTagById(CONNECTION_POOL));
  +
  +                        break;
  +                    }
  +                case SEQUENCE_MANAGER:
  +                    {
  +                        if (isDebug) logger.debug("    < " + tags.getTagById(SEQUENCE_MANAGER));
  +                        // set to null at the end of the tag!!
  +                        this.currentSequenceDescriptor = null;
  +                        break;
  +                    }
  +                case ATTRIBUTE:
  +                    {
  +                        if (isDebug) logger.debug("    < " + tags.getTagById(ATTRIBUTE));
                           break;
                       }
                   default :
  
  
  
  1.21      +28 -12    jakarta-ojb/src/java/org/apache/ojb/broker/metadata/RepositoryTags.java
  
  Index: RepositoryTags.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/java/org/apache/ojb/broker/metadata/RepositoryTags.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- RepositoryTags.java	2 Jan 2003 21:27:19 -0000	1.20
  +++ RepositoryTags.java	9 Jan 2003 16:58:36 -0000	1.21
  @@ -55,6 +55,8 @@
    */
   
   import org.apache.ojb.broker.util.DoubleHashtable;
  +import org.apache.ojb.broker.util.logging.LoggerFactory;
  +import org.apache.ojb.broker.util.pooling.PoolConfiguration;
   
   /**
    * this class maintains a table mapping the xml-tags used in the
  @@ -108,6 +110,8 @@
           table.put("password", new Integer(USER_PASSWD));
           table.put("eager-release", new Integer(EAGER_RELEASE));
           table.put("batch-mode", new Integer(BATCH_MODE));
  +        table.put("useAutoCommit", new Integer(USE_AUTOCOMMIT));
  +        table.put("ignoreAutoCommitExceptions", new Integer(IGNORE_AUTOCOMMIT_EXCEPTION));
           table.put("class-descriptor", new Integer(CLASS_DESCRIPTOR));
           table.put("class", new Integer(CLASS_NAME));
           table.put("proxy", new Integer(CLASS_PROXY));
  @@ -154,18 +158,23 @@
           table.put("proxy", new Integer(PROXY_REFERENCE));
           table.put("sort", new Integer(SORT));
   
  -        table.put("maxActive", new Integer(CON_MAX_ACTIVE));
  -        table.put("maxIdle", new Integer(CON_MAX_IDLE));
  -        table.put("maxWait", new Integer(CON_MAX_WAIT));
  -        table.put("minEvictableIdleTimeMillis", new Integer(CON_MIN_EVICTABLE_IDLE_TIME_MILLIS));
  -        table.put("numTestsPerEvictionRun", new Integer(CON_NUM_TESTS_PER_EVICTION_RUN));
  -        table.put("testOnBorrow", new Integer(CON_TEST_ON_BORROW));
  -        table.put("testOnReturn", new Integer(CON_TEST_ON_RETURN));
  -        table.put("testWhileIdle", new Integer(CON_TEST_WHILE_IDLE));
  -        table.put("timeBetweenEvictionRunsMillis", new Integer(CON_TIME_BETWEEN_EVICTION_RUNS_MILLIS));
  -        table.put("whenExhaustedAction", new Integer(CON_WHEN_EXHAUSTED_ACTION));
  +        table.put(PoolConfiguration.MAX_ACTIVE, new Integer(CON_MAX_ACTIVE));
  +        table.put(PoolConfiguration.MAX_IDLE, new Integer(CON_MAX_IDLE));
  +        table.put(PoolConfiguration.MAX_WAIT, new Integer(CON_MAX_WAIT));
  +        table.put(PoolConfiguration.MIN_EVICTABLE_IDLE_TIME_MILLIS, new Integer(CON_MIN_EVICTABLE_IDLE_TIME_MILLIS));
  +        table.put(PoolConfiguration.NUM_TESTS_PER_EVICTION_RUN, new Integer(CON_NUM_TESTS_PER_EVICTION_RUN));
  +        table.put(PoolConfiguration.TEST_ON_BORROW, new Integer(CON_TEST_ON_BORROW));
  +        table.put(PoolConfiguration.TEST_ON_RETURN, new Integer(CON_TEST_ON_RETURN));
  +        table.put(PoolConfiguration.TEST_WHILE_IDLE, new Integer(CON_TEST_WHILE_IDLE));
  +        table.put(PoolConfiguration.TIME_BETWEEN_EVICTION_RUNS_MILLIS, new Integer(CON_TIME_BETWEEN_EVICTION_RUNS_MILLIS));
  +        table.put(PoolConfiguration.WHEN_EXHAUSTED_ACTION, new Integer(CON_WHEN_EXHAUSTED_ACTION));
  +        table.put(PoolConfiguration.VALIDATION_QUERY, new Integer(VALIDATION_QUERY));
  +
  +        table.put(PoolConfiguration.LOG_ABANDONED, new Integer(CON_LOG_ABANDONED));
  +        table.put(PoolConfiguration.REMOVE_ABANDONED, new Integer(CON_REMOVE_ABANDONED));
  +        table.put(PoolConfiguration.REMOVE_ABANDONED_TIMEOUT, new Integer(CON_REMOVE_ABANDONED_TIMEOUT));
  +
           table.put("connectionFactory", new Integer(CONNECTION_FACTORY));
  -        table.put("validationQuery", new Integer(VALIDATION_QUERY));
           table.put("connection-pool", new Integer(CONNECTION_POOL));
           table.put("class-ref", new Integer(CLASS_REF));
   		table.put("id", new Integer(ID));
  @@ -177,6 +186,9 @@
   		table.put("documentation", new Integer(DOCUMENTATION));
           table.put("accept-locks", new Integer(ACCEPT_LOCKS));
   
  +        table.put("sequence-manager", new Integer(SEQUENCE_MANAGER));
  +        table.put("className", new Integer(SEQUENCE_MANAGER_CLASS));
  +
           // add new tags here !
       }
   
  @@ -261,7 +273,11 @@
        */
       public int getIdByTag(String tag)
       {
  -        return ((Integer) table.getValueByKey(tag)).intValue();
  +        Integer value = (Integer) table.getValueByKey(tag);
  +        if(value == null)
  +            LoggerFactory.getDefaultLogger().error("** "+
  +                    this.getClass().getName()+": Tag '"+tag+"' is not defined. **");
  +        return value.intValue();
       }
   
   	/**
  
  
  
  1.28      +4 -4      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.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- RepositoryXmlHandler.java	3 Jan 2003 21:39:21 -0000	1.27
  +++ RepositoryXmlHandler.java	9 Jan 2003 16:58:36 -0000	1.28
  @@ -95,7 +95,7 @@
        * Allows not to specify field id
        */
       private int m_lastId;
  -     
  +
       /**
        * All known xml tags are kept in this table.
        * The tags table allows lookup from literal to id
  @@ -328,8 +328,8 @@
                       {
                           if (isDebug) logger.debug("    > " + tags.getTagById(FIELD_DESCRIPTOR));
   
  -                        String strId = atts.getValue("id");
  -			m_lastId = (strId == null ? m_lastId + 1 : Integer.parseInt(strId));
  +                        String strId = atts.getValue(tags.getTagById(ID));
  +                        m_lastId = (strId == null ? m_lastId + 1 : Integer.parseInt(strId));
                           m_CurrentFLD = new FieldDescriptor(m_CurrentCLD, m_lastId);
                           m_CurrentCLD.addFieldDescriptor(m_CurrentFLD);
   
  
  
  
  1.1                  jakarta-ojb/src/java/org/apache/ojb/broker/metadata/SequenceDescriptor.java
  
  Index: SequenceDescriptor.java
  ===================================================================
  package org.apache.ojb.broker.metadata;
  
  import org.apache.ojb.broker.util.logging.Logger;
  import org.apache.ojb.broker.util.logging.LoggerFactory;
  import org.apache.commons.lang.SystemUtils;
  import org.apache.commons.lang.StringUtils;
  import org.apache.commons.lang.builder.ToStringBuilder;
  import org.apache.commons.lang.builder.ToStringStyle;
  
  import java.io.Serializable;
  import java.util.Properties;
  import java.util.Enumeration;
  
  /**
   * Encapsulates sequence manager configuration properties managed by
   * {@link org.apache.ojb.broker.metadata.JdbcConnectionDescriptor}.
   * <br/>
   * All sequence manager implementation specific configuration
   * attributes are represented by key/value pairs in a
   * <code>Properties</code> object and could be reached via
   * {@link #getConfigurationProperties}.
   * <br/>
   * Every new instantiated <code>SequenceDescriptor</code> was associated
   * with the default sequence manager implementation
   * {@link org.apache.ojb.broker.util.sequence.SequenceManagerHighLowImpl}.
   *
   * @author <a href="mailto:armin@codeAuLait.de">Armin Waibel</a>
   * @version $Id: SequenceDescriptor.java,v 1.1 2003/01/09 16:58:36 arminw Exp $
   */
  public class SequenceDescriptor implements Serializable, XmlCapable
  {
      private Logger logger = LoggerFactory.getLogger(SequenceDescriptor.class);
  
      private JdbcConnectionDescriptor jcd;
      private Class sequenceManagerClass;
      private Properties configurationProperties;
  
      public SequenceDescriptor(JdbcConnectionDescriptor jcd)
      {
          this.jcd = jcd;
          this.configurationProperties = new Properties();
      }
  
      public SequenceDescriptor(JdbcConnectionDescriptor jcd, Class sequenceManagerClass)
      {
          this.jcd = jcd;
          this.sequenceManagerClass = sequenceManagerClass;
      }
  
      public JdbcConnectionDescriptor getJdbcConnectionDescriptor()
      {
          return jcd;
      }
  
      public void setJdbcConnectionDescriptor(JdbcConnectionDescriptor jcd)
      {
          this.jcd = jcd;
      }
  
      public Class getSequenceManagerClass()
      {
          return sequenceManagerClass;
      }
  
      public void setSequenceManagerClass(Class sequenceManagerClass)
      {
          this.sequenceManagerClass = sequenceManagerClass;
      }
  
      public void addConfigurationProperty(String key, String value)
      {
          configurationProperties.setProperty(key, value);
      }
  
      public String getConfigurationProperty(String key)
      {
          return configurationProperties.getProperty(key);
      }
  
      public Properties getConfigurationProperties()
      {
          return configurationProperties;
      }
  
      public void setConfigurationProperties(Properties configurationProperties)
      {
          this.configurationProperties = configurationProperties;
      }
  
      public String toString()
      {
          ToStringBuilder buf = new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE);
          buf.append("   sequenceManagerClass", getSequenceManagerClass()).
          append("   Properties", getConfigurationProperties());
          return buf.toString();
      }
  
      public String toXML()
      {
          RepositoryTags tags = RepositoryTags.getInstance();
          String eol = SystemUtils.LINE_SEPARATOR;
          StringBuffer buf = new StringBuffer();
          //opening tag + attributes
          buf.append("      " + tags.getOpeningTagNonClosingById(SEQUENCE_MANAGER) + eol);
          buf.append("         " + tags.getAttribute(SEQUENCE_MANAGER_CLASS, "" + getSequenceManagerClass().getName()));
          buf.append("      >" + eol);
          buf.append("         <!-- "+eol);
          buf.append("         Add sequence manger properties here, using custom attributes"
+ eol);
          buf.append("         e.g. <attribute attribute-name=\"grabSize\" attribute-value=\"20\"/>"
+ eol);
          buf.append("         -->"+eol);
          buf.append(buildAttributes());
          buf.append("      " + tags.getClosingTagById(SEQUENCE_MANAGER)+eol);
  
          return buf.toString();
      }
  
      private String buildAttributes()
      {
          String eol = SystemUtils.LINE_SEPARATOR;
          Properties prop = getConfigurationProperties();
          if(prop == null || prop.isEmpty()) return "";
  
          StringBuffer buf = new StringBuffer();
          Enumeration enum = prop.keys();
          while (enum.hasMoreElements())
          {
              String key = (String) enum.nextElement();
              String value = prop.getProperty(key);
              buf.append("         <attribute attribute-name=\""+key+"\" attribute-value=\""+value+"\"/>"+eol);
          }
          return buf.toString();
      }
  }
  
  
  

Mime
View raw message