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/ejb/org/apache/ojb/ejb BeanConstants.java ArticleManagerODMGBean.java ArticleManagerPBBean.java ODMGBaseBeanImpl.java ODMGSessionBean.java PBBaseBeanImpl.java PBSessionBean.java PersonArticleManagerODMGBean.java PersonArticleManagerPBBean.java PersonManagerODMGBean.java PersonManagerPBBean.java
Date Thu, 26 Dec 2002 19:36:06 GMT
arminw      2002/12/26 11:36:06

  Modified:    src/ejb/org/apache/ojb/ejb ArticleManagerODMGBean.java
                        ArticleManagerPBBean.java ODMGBaseBeanImpl.java
                        ODMGSessionBean.java PBBaseBeanImpl.java
                        PBSessionBean.java
                        PersonArticleManagerODMGBean.java
                        PersonArticleManagerPBBean.java
                        PersonManagerODMGBean.java PersonManagerPBBean.java
  Added:       src/ejb/org/apache/ojb/ejb BeanConstants.java
  Log:
  adapt EJB examples
  
  Revision  Changes    Path
  1.3       +3 -3      jakarta-ojb/src/ejb/org/apache/ojb/ejb/ArticleManagerODMGBean.java
  
  Index: ArticleManagerODMGBean.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/ejb/org/apache/ojb/ejb/ArticleManagerODMGBean.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ArticleManagerODMGBean.java	10 Oct 2002 08:56:30 -0000	1.2
  +++ ArticleManagerODMGBean.java	26 Dec 2002 19:36:06 -0000	1.3
  @@ -90,9 +90,9 @@
    * 		type="Required"
    *
    * @ejb:env-entry
  - * 		name="ojb.repository"
  + * 		name="ojb.jcdAlias"
    * 		type="java.lang.String"
  - * 		value="repository.xml"
  + * 		value="default"
    *
    *
    * @author <a href="mailto:armin@codeAuLait.de">Armin Waibel</a>
  
  
  
  1.3       +3 -3      jakarta-ojb/src/ejb/org/apache/ojb/ejb/ArticleManagerPBBean.java
  
  Index: ArticleManagerPBBean.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/ejb/org/apache/ojb/ejb/ArticleManagerPBBean.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ArticleManagerPBBean.java	10 Oct 2002 08:56:30 -0000	1.2
  +++ ArticleManagerPBBean.java	26 Dec 2002 19:36:06 -0000	1.3
  @@ -90,9 +90,9 @@
    * 		type="Required"
    *
    * @ejb:env-entry
  - * 		name="ojb.repository"
  + * 		name="ojb.jcdAlias"
    * 		type="java.lang.String"
  - * 		value="repository.xml"
  + * 		value="default"
    *
    *
    * @author <a href="mailto:armin@codeAuLait.de">Armin Waibel</a>
  
  
  
  1.3       +14 -17    jakarta-ojb/src/ejb/org/apache/ojb/ejb/ODMGBaseBeanImpl.java
  
  Index: ODMGBaseBeanImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/ejb/org/apache/ojb/ejb/ODMGBaseBeanImpl.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ODMGBaseBeanImpl.java	10 Oct 2002 08:56:30 -0000	1.2
  +++ ODMGBaseBeanImpl.java	26 Dec 2002 19:36:06 -0000	1.3
  @@ -101,10 +101,7 @@
   {
       private Logger log = LoggerFactory.getLogger(ODMGBaseBeanImpl.class);
   
  -    private static final String DEFAULT_REPOSITORY = "repository.xml";
  -    private static final String REPOSITORY_LOOKUP = "java:comp/env/ojb.repository";
  -    private static final String ODMG_FACTORY_LOOKUP = "java:/ojb/defaultODMG";
  -    private String ojbRepository;
  +    private String jcdAlias;
       private Implementation odmg;
   
       /**
  @@ -230,9 +227,9 @@
           /*Lookup if a environment entry in Deployment Descriptor exists
           e.g.
           <env-entry>
  -            <env-entry-name>ojb.repository</env-entry-name>
  +            <env-entry-name>ojb.jdbcAlias</env-entry-name>
               <env-entry-type>java.lang.String</env-entry-type>
  -            <env-entry-value>repository.xml</env-entry-value>
  +            <env-entry-value>default</env-entry-value>
           </env-entry>
           */
           Context context = null;
  @@ -248,27 +245,27 @@
           }
           try
           {
  -            ojbRepository = (String) context.lookup(REPOSITORY_LOOKUP);
  -            if(log.isDebugEnabled()) log.debug("Found enviroment entry: "+ojbRepository);
  +            jcdAlias = (String) context.lookup(BeanConstants.ENV_ENTRY_JCD_ALIAS_LOOKUP);
  +            if(log.isDebugEnabled()) log.debug("Found enviroment entry: "+jcdAlias);
           }
           catch (NamingException e)
           {
  -            log.error("ctx.lookup("+REPOSITORY_LOOKUP+") failed", e);
  +            log.error("ctx.lookup("+BeanConstants.ENV_ENTRY_JCD_ALIAS_LOOKUP+") failed",
e);
           }
  -        if (ojbRepository == null || ojbRepository.equals(""))
  +        if (jcdAlias == null || jcdAlias.equals(""))
           {
  -            ojbRepository = DEFAULT_REPOSITORY;
  +            jcdAlias = BeanConstants.JCD_ALIAS;
           }
  -        log.info("Use OJB repository file: " + ojbRepository);
  +        log.info("Use OJB jcdAlias name: " + jcdAlias);
   
           ODMGFactory factory = null;
           try
           {
  -            factory = (ODMGFactory) context.lookup(ODMG_FACTORY_LOOKUP);
  +            factory = (ODMGFactory) context.lookup(BeanConstants.ODMG_FACTORY_LOOKUP);
           }
           catch (NamingException e)
           {
  -            log.error("ctx.lookup("+ODMG_FACTORY_LOOKUP+") failed", e);
  +            log.error("ctx.lookup("+BeanConstants.ODMG_FACTORY_LOOKUP+") failed", e);
               throw new OJBRuntimeException("Could not lookup ODMG factory instance", e);
           }
           odmg = factory.getInstance();
  @@ -279,8 +276,8 @@
           try
           {
               if(log.isDebugEnabled()) log.debug("open new database " +
  -                    db + " using repository " + ojbRepository);
  -            db.open(ojbRepository, Database.OPEN_READ_WRITE);
  +                    db + " using jcdAlias name " + jcdAlias);
  +            db.open(jcdAlias, Database.OPEN_READ_WRITE);
           }
           catch (ODMGException e)
           {
  
  
  
  1.7       +21 -20    jakarta-ojb/src/ejb/org/apache/ojb/ejb/ODMGSessionBean.java
  
  Index: ODMGSessionBean.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/ejb/org/apache/ojb/ejb/ODMGSessionBean.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- ODMGSessionBean.java	9 Oct 2002 00:13:58 -0000	1.6
  +++ ODMGSessionBean.java	26 Dec 2002 19:36:06 -0000	1.7
  @@ -82,6 +82,12 @@
   
   /**
    * This is an session bean implementation using odmg implementation.
  + * <br/>
  + * For more structured implementations take a look at
  + * <br/>
  + * {@link org.apache.ojb.ejb.SessionBeanImpl}<br/>
  + * {@link org.apache.ojb.ejb.ODMGBaseBeanImpl}<br/>
  + * {@link org.apache.ojb.ejb.PBBaseBeanImpl}
    * <p>
    * <b>How to use ODMG</b> <br>
    * In every bean method you must start with one of following operations: <br>
  @@ -109,11 +115,6 @@
    * </ol>
    * </p>
    *
  - * <br>
  - * For more structured implementations take a look at
  - * {@link org.apache.ojb.ejb.SessionBeanImpl},
  - * {@link org.apache.ojb.ejb.ODMGBaseBeanImpl},
  - * {@link org.apache.ojb.ejb.PBBaseBeanImpl}
    *
    * @ejb:bean
    * 			type="Stateless"
  @@ -137,9 +138,9 @@
    * 		type="Required"
    *
    * @ejb:env-entry
  - * 		name="ojb.repository"
  + * 		name="ojb.jcdAlias"
    * 		type="java.lang.String"
  - * 		value="repository.xml"
  + * 		value="default"
    *
    * @author <a href="mailto:armin@codeAuLait.de">Armin Waibel</a>
    * @version $Id$
  @@ -148,7 +149,7 @@
   {
       private Logger log = LoggerFactory.getLogger(ODMGSessionBean.class);
       private SessionContext ctx;
  -    private String ojbRepository;
  +    private String jcdAlias;
       private Implementation odmg;
       private Database db;
   
  @@ -164,8 +165,8 @@
           db = odmg.newDatabase();
           try
           {
  -            log.info("open new database " + db + " using repository " + ojbRepository);
  -            db.open(ojbRepository, Database.OPEN_READ_WRITE);
  +            log.info("open new database " + db + " using jcdAlias name " + jcdAlias);
  +            db.open(jcdAlias, Database.OPEN_READ_WRITE);
           }
           catch (ODMGException e)
           {
  @@ -180,30 +181,30 @@
           /*Lookup if a environment entry in Deployment Descriptor exists
   		e.g.
   		<env-entry>
  -      		<env-entry-name>ojb.repository</env-entry-name>
  +      		<env-entry-name>ojb.jcdAlias</env-entry-name>
         		<env-entry-type>java.lang.String</env-entry-type>
  -      		<env-entry-value>repository.xml</env-entry-value>
  +      		<env-entry-value>default</env-entry-value>
       	</env-entry>
   		*/
           try
           {
               Context context = new InitialContext();
  -            ojbRepository = (String) context.lookup("java:comp/env/ojb.repository");
  +            jcdAlias = (String) context.lookup(BeanConstants.ENV_ENTRY_JCD_ALIAS_LOOKUP);
   
  -            ODMGFactory factory = (ODMGFactory) context.lookup("java:/ojb/defaultODMG");
  +            ODMGFactory factory = (ODMGFactory) context.lookup(BeanConstants.ODMG_FACTORY_LOOKUP);
               odmg = factory.getInstance();
               log.info("Found odmg factory: " + factory + " and get Implementation instance:
" + odmg);
           }
           catch (NamingException e)
           {
  -            log.error("Lookup for ojb repository failed", e);
  +            log.error("Lookup for ojb jcdAlias name or ODMGFactory failed", e);
           }
  -        if (ojbRepository == null || ojbRepository.equals(""))
  +        if (jcdAlias == null || jcdAlias.equals(""))
           {
  -            log.info("No enviroment entry was found, use default repository");
  -            ojbRepository = "repository.xml";
  +            log.info("No enviroment entry for jcdAlias name was found, use default");
  +            jcdAlias = BeanConstants.JCD_ALIAS;
           }
  -        log.info("Use OJB repository file: " + ojbRepository);
  +        log.info("Use jcdAlias name: " + jcdAlias);
       }
   
   
  
  
  
  1.2       +10 -14    jakarta-ojb/src/ejb/org/apache/ojb/ejb/PBBaseBeanImpl.java
  
  Index: PBBaseBeanImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/ejb/org/apache/ojb/ejb/PBBaseBeanImpl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PBBaseBeanImpl.java	9 Oct 2002 00:13:58 -0000	1.1
  +++ PBBaseBeanImpl.java	26 Dec 2002 19:36:06 -0000	1.2
  @@ -97,9 +97,6 @@
   {
       private Logger log = LoggerFactory.getLogger(PBBaseBeanImpl.class);
   
  -    private static final String DEFAULT_REPOSITORY = "repository.xml";
  -    private static final String REPOSITORY_LOOKUP = "java:comp/env/ojb.repository";
  -    private static final String PB_FACTORY_LOOKUP = PBFactoryIF.PBFACTORY_JNDI_NAME;
       private PBKey pbKey;
       private PersistenceBrokerFactoryIF pbf;
   
  @@ -132,33 +129,32 @@
               /*Lookup if a environment entry in Deployment Descriptor exists
               e.g.
               <env-entry>
  -                <env-entry-name>ojb.repository</env-entry-name>
  +                <env-entry-name>ojb.jcdAlias</env-entry-name>
                   <env-entry-type>java.lang.String</env-entry-type>
  -                <env-entry-value>repository.xml</env-entry-value>
  +                <env-entry-value>default</env-entry-value>
               </env-entry>
               */
               context = new InitialContext();
  -            ojbRepository = (String) context.lookup(REPOSITORY_LOOKUP);
  +            ojbRepository = (String) context.lookup(BeanConstants.ENV_ENTRY_JCD_ALIAS_LOOKUP);
           }
           catch (NamingException e)
           {
  -            log.error("Lookup for ojb repository failed", e);
  +            log.error("Lookup for ojb jcdAlias name failed", e);
           }
  -        // no repository found in environment, use default one
  +        // no jcdAlias name found in environment, use default one
           if (ojbRepository == null || ojbRepository.equals(""))
           {
  -            log.info("No enviroment entry was found, use default repository");
  -            ojbRepository = DEFAULT_REPOSITORY;
  +            log.info("No enviroment entry for jcdAlias was found, use default");
  +            ojbRepository = BeanConstants.JCD_ALIAS;
           }
  -        if(log.isDebugEnabled()) log.debug("Use OJB repository file: "+ojbRepository);
  +        if(log.isDebugEnabled()) log.debug("Use OJB jcdAlias: "+ojbRepository);
           pbKey = new PBKey(ojbRepository);
   
  -
           // Lookup the PBF implementation
           try
           {
               context = new InitialContext();
  -            pbf = ((PBFactoryIF) context.lookup(PB_FACTORY_LOOKUP)).getInstance();
  +            pbf = ((PBFactoryIF) context.lookup(BeanConstants.PB_FACTORY_LOOKUP)).getInstance();
           }
           catch (NamingException e)
           {
  
  
  
  1.5       +16 -16    jakarta-ojb/src/ejb/org/apache/ojb/ejb/PBSessionBean.java
  
  Index: PBSessionBean.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/ejb/org/apache/ojb/ejb/PBSessionBean.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- PBSessionBean.java	9 Oct 2002 00:13:58 -0000	1.4
  +++ PBSessionBean.java	26 Dec 2002 19:36:06 -0000	1.5
  @@ -81,10 +81,10 @@
   /**
    * This is an session bean implementation using PB-api.
    * <br>
  - * For more structured implementations take a look at
  - * {@link org.apache.ojb.ejb.SessionBeanImpl},
  - * {@link org.apache.ojb.ejb.ODMGBaseBeanImpl},
  - * {@link org.apache.ojb.ejb.PBBaseBeanImpl}
  + * For more structured implementations take a look at<br/>
  + * {@link org.apache.ojb.ejb.SessionBeanImpl}<br/>
  + * {@link org.apache.ojb.ejb.ODMGBaseBeanImpl}<br/>
  + * {@link org.apache.ojb.ejb.PBBaseBeanImpl}<br/>
    *
    * @ejb:bean
    * 			type="Stateless"
  @@ -108,9 +108,9 @@
    * 		type="Required"
    *
    * @ejb:env-entry
  - * 		name="ojb.repository"
  + * 		name="ojb.jcdAlias"
    * 		type="java.lang.String"
  - * 		value="repository.xml"
  + * 		value="default"
    *
    *
    * @author <a href="mailto:armin@codeAuLait.de">Armin Waibel</a>
  @@ -142,25 +142,25 @@
       {
           log.info("ojbPrepare was called");
           Context context = null;
  -		// Lookup if a environment entry for repository exists
  -        String ojbRepository = null;
  +		// Lookup if a environment entry for jcdAlias name exists
  +        String jcdAlias = null;
           try
           {
               context = new InitialContext();
  -            ojbRepository = (String) context.lookup("java:comp/env/ojb.repository");
  +            jcdAlias = (String) context.lookup("java:comp/env/ojb.jcdAlias");
           }
           catch (NamingException e)
           {
               log.error("Lookup for ojb repository failed", e);
           }
  -        // no repository found in environment, use default one
  -        if (ojbRepository == null || ojbRepository.equals(""))
  +        // no jcdAlias found in environment, use default one
  +        if (jcdAlias == null || jcdAlias.equals(""))
   		{
  -			log.info("No enviroment entry was found, use default repository");
  -            ojbRepository = "repository.xml";
  +			log.info("No enviroment entry was found, use 'default' as jcdAlias name");
  +            jcdAlias = BeanConstants.JCD_ALIAS;
   		}
  -        log.info("Use OJB repository file: "+ojbRepository);
  -        pbKey = new PBKey(ojbRepository);
  +        log.info("Use OJB jcdAlias name: "+jcdAlias);
  +        pbKey = new PBKey(jcdAlias);
   
   
           // Lookup the PBF implementation
  
  
  
  1.3       +2 -6      jakarta-ojb/src/ejb/org/apache/ojb/ejb/PersonArticleManagerODMGBean.java
  
  Index: PersonArticleManagerODMGBean.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/ejb/org/apache/ojb/ejb/PersonArticleManagerODMGBean.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- PersonArticleManagerODMGBean.java	10 Oct 2002 08:56:30 -0000	1.2
  +++ PersonArticleManagerODMGBean.java	26 Dec 2002 19:36:06 -0000	1.3
  @@ -104,15 +104,11 @@
    *      view-type="local"
    *      ref-name="ejb/ojb/odmg/ArticleManager"
    *
  - * @ejb:env-entry
  - * 		name="ojb.repository"
  - * 		type="java.lang.String"
  - * 		value="repository.xml"
    *
    * @author <a href="mailto:armin@codeAuLait.de">Armin Waibel</a>
    * @version $Id$
    */
  -public class PersonArticleManagerODMGBean extends ODMGBaseBeanImpl implements SessionBean
  +public class PersonArticleManagerODMGBean extends SessionBeanImpl implements SessionBean
   {
       private static final String PERSON_MANAGER_EJB_REF_NAME="java:comp/env/ejb/ojb/odmg/PersonManager";
       private static final String ARTICLE_MANAGER_EJB_REF_NAME="java:comp/env/ejb/ojb/odmg/ArticleManager";
  
  
  
  1.3       +1 -5      jakarta-ojb/src/ejb/org/apache/ojb/ejb/PersonArticleManagerPBBean.java
  
  Index: PersonArticleManagerPBBean.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/ejb/org/apache/ojb/ejb/PersonArticleManagerPBBean.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- PersonArticleManagerPBBean.java	10 Oct 2002 08:56:30 -0000	1.2
  +++ PersonArticleManagerPBBean.java	26 Dec 2002 19:36:06 -0000	1.3
  @@ -104,10 +104,6 @@
    *      view-type="local"
    *      ref-name="ejb/ojb/broker/ArticleManager"
    *
  - * @ejb:env-entry
  - * 		name="ojb.repository"
  - * 		type="java.lang.String"
  - * 		value="repository.xml"
    *
    * @author <a href="mailto:armin@codeAuLait.de">Armin Waibel</a>
    * @version $Id$
  
  
  
  1.2       +3 -3      jakarta-ojb/src/ejb/org/apache/ojb/ejb/PersonManagerODMGBean.java
  
  Index: PersonManagerODMGBean.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/ejb/org/apache/ojb/ejb/PersonManagerODMGBean.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PersonManagerODMGBean.java	9 Oct 2002 11:45:52 -0000	1.1
  +++ PersonManagerODMGBean.java	26 Dec 2002 19:36:06 -0000	1.2
  @@ -89,9 +89,9 @@
    * 		type="Required"
    *
    * @ejb:env-entry
  - * 		name="ojb.repository"
  + * 		name="ojb.jcdAlias"
    * 		type="java.lang.String"
  - * 		value="repository.xml"
  + * 		value="default"
    *
    *
    * @author <a href="mailto:armin@codeAuLait.de">Armin Waibel</a>
  
  
  
  1.2       +3 -3      jakarta-ojb/src/ejb/org/apache/ojb/ejb/PersonManagerPBBean.java
  
  Index: PersonManagerPBBean.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/ejb/org/apache/ojb/ejb/PersonManagerPBBean.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PersonManagerPBBean.java	9 Oct 2002 00:13:58 -0000	1.1
  +++ PersonManagerPBBean.java	26 Dec 2002 19:36:06 -0000	1.2
  @@ -90,9 +90,9 @@
    * 		type="Required"
    *
    * @ejb:env-entry
  - * 		name="ojb.repository"
  + * 		name="ojb.jcdAlias"
    * 		type="java.lang.String"
  - * 		value="repository.xml"
  + * 		value="default"
    *
    *
    * @author <a href="mailto:armin@codeAuLait.de">Armin Waibel</a>
  
  
  
  1.1                  jakarta-ojb/src/ejb/org/apache/ojb/ejb/BeanConstants.java
  
  Index: BeanConstants.java
  ===================================================================
  package org.apache.ojb.ejb;
  
  import org.apache.ojb.broker.ta.PBFactoryIF;
  
  /**
   * Here we collect all common constants used within the sample beans.
   *
   * @author <a href="mailto:armin@codeAuLait.de">Armin Waibel</a>
   * @version $Id: BeanConstants.java,v 1.1 2002/12/26 19:36:06 arminw Exp $
   */
  public class BeanConstants
  {
      public static final String JCD_ALIAS = "default";
      public static final String ENV_ENTRY_JCD_ALIAS_LOOKUP = "java:comp/env/ojb.jcdAlias";
      public static final String ODMG_FACTORY_LOOKUP = "java:/ojb/defaultODMG";
      public static final String PB_FACTORY_LOOKUP = PBFactoryIF.PBFACTORY_JNDI_NAME;
  }
  
  
  

Mime
View raw message