db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arm...@apache.org
Subject cvs commit: db-ojb/xdocs deployment.xml
Date Fri, 21 Mar 2003 19:51:29 GMT
arminw      2003/03/21 11:51:29

  Modified:    xdocs    deployment.xml
  Log:
  update doc, add instructions
  for weblogic
  
  Revision  Changes    Path
  1.18      +247 -2    db-ojb/xdocs/deployment.xml
  
  Index: deployment.xml
  ===================================================================
  RCS file: /home/cvs/db-ojb/xdocs/deployment.xml,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- deployment.xml	19 Mar 2003 01:09:22 -0000	1.17
  +++ deployment.xml	21 Mar 2003 19:51:29 -0000	1.18
  @@ -33,6 +33,7 @@
           <ul>
               <li><a href="#31">Instructions for JBoss</a></li>
               <li><a href="#32">Build the OJB sample session beans</a></li>
  +            <li><a href="#33">Instructions for Weblogic</a></li>
           </ul>
       </li>
   </ul>
  @@ -366,18 +367,34 @@
   
   
   <p>
  +<a name="jboss-ojb.properties"/>
   <b>6. Adapt OJB.properties file</b>
   <br/>
   Your OJB.properties file need the following settings:
   <source><![CDATA[
  +...
   ConnectionFactoryClass=
   org.apache.ojb.broker.accesslayer.ConnectionFactoryManagedImpl
   
  +...
   OJBTxManagerClass=org.apache.ojb.odmg.JTATxManager
   
  +...
   JTATransactionManagerClass=
   org.apache.ojb.otm.transaction.factory.JBossTransactionManagerFactory
   ]]></source>
  +Using the PB-api it is recommended to use
  +<br/><code>ObjectCacheClass=org.apache.ojb.broker.cache.ObjectCachePerBrokerImpl</code>
  +<br/>or
  +<br/><code>ObjectCacheClass=org.apache.ojb.broker.cache.ObjectCacheEmptyImpl</code>.
  +<br/>
  +When using the ODMG-api and the application server is not clustered it's also possible
  +to use all other implementations. The JCS based <code>ObjectCache</code> implementations
  +should also be able to work in distributed environments
  +(see <a href="http://jakarta.apache.org/turbine/jcs/">JCS docs</a>).
  +</p>
  +<p>
  +
   </p>
   
   
  @@ -415,6 +432,21 @@
   <code>false</code> should be ok.
   </p>
   
  +
  +<p>
  +<b>7b. How to deploy ojb test hsqldb database to jboss</b>
  +<br/>
  +After creating the database with
  +<code>bin\build.bat prepare-testdb</code> or <code>bin/build.sh prepare-testdb</code>.
  +<br/>
  +Take the generated <code>OJB.script</code> file from <code>.../target/test</code>
  +and rename the file to <code>default.script</code>.
  +Replace the jboss default.script file in
  +<code>...\jboss-3.x.y\server\default\db\hypersonic</code>
  +with this file.
  +</p>
  +
  +
   <p>
   <b>8a. Inside your EJB's you can get a handle on the ODMG like this:</b>
   <source><![CDATA[
  @@ -440,8 +472,8 @@
   </p>
   <p>
   <b>
  -This solution is not re-deployable. If someone knows the reason or find a
  -solution that makes OJB re-deployable in jboss, please let me know.
  +This solution should be re-deployable in jboss.
  +If you will get any problems, please let me know.
   </b>
   </p>
   </subsection>
  @@ -484,6 +516,219 @@
   <br/>
   To run the ejb-example test cases use the
   <code>org.apache.ojb.ejb.AllTests</code> class.
  +</p>
  +
  +<p>
  +<b>How to run client org.apache.ojb.ejb.AllTests</b>
  +<br/>
  +Numerous jars are required for the client. One possibility is to
  +modify <code>build.bat</code>/<code>build.sh</code> to set this
up properly
  +and called it e.g. <code>.\runEJBClient.bat</code>.
  +A sample srict could look like this:
  +<source>
  +@echo off
  +REM Please let JAVA_HOME point to your JDK base directory
  +if "%JAVA_HOME%" == "" set JAVA_HOME=C:\j2sdk1.4.1
  +set JAVA=%JAVA_HOME%\bin\java
  +set JBOSS_HOME=D:\jboss-3.0.6
  +set cp=
  +for %%i in (%JBOSS_HOME%\client\*.jar) do call bin\cp.bat %%i
  +for %%i in (dist\*.jar) do call bin\cp.bat %%i
  +for %%i in (lib\*.jar) do call bin\cp.bat %%i
  +"%JAVA%" -classpath "%CP%" org.apache.ojb.ejb.AllTests
  +</source>
  +</p>
  +</subsection>
  +
  +
  +
  +<subsection name="Instructions for Weblogic" anchor="33">
  +<br/>
  +<font size="-1">(Thanks Christophe Lombart and Lucy Zhao)</font>
  +<p>
  +<ul>
  +<li>
  +Add the OJB jar files and depedencies into the Weblogic classpath
  +</li>
  +<li>
  +Compile the following classes (see at the <a href="#pb.factory">end of this section</a>)
and add
  +them to the weblogic classpath. This allows to access the PB-api via
  +JNDI lookup.
  +</li>
  +<li>
  +Register via the weblogic console the startup class
  +(see <code>OjbPbStartup</code> class below).
  +The JNDI name and the OJB.properties file path can be specified as
  +parameters in this startup class.
  +<br/>
  +<br/>
  +To use the ODMG-api you have to write a similar startup class.
  +This shouldn't be too complicated.
  +Take a look in <code>org.apache.ojb.jboss</code> package
  +(dir <code>src/connector/main</code>). Here you could find the jboss mbeans.
  +All you have to do is bound a similar class to JNDI in weblogic.
  +<br/>
  +Implement <code>ODMGJ2EEFactory</code> Interface in your class bound this class
  +to JNDI (in the ejb-examples the beans try to lookup the <code>Implementation</code>
  +instance via <code>"java:/ojb/defaultODMG"</code>).
  +Your ODMGFactory class should implement this method
  +<source>
  +public Implementation getInstance()
  +{
  +    return OJBJ2EE_2.getInstance();
  +}
  +</source>
  +</li>
  +<li>
  +As usual create the connection pool and the datasource.
  +</li>
  +<li>
  +Prepare the OJB.properties file. Should be similar to
  +<a href="#jboss-ojb.properties">jboss</a>. Expect the
  +following entry:
  +<source>
  +...
  +# Weblogic Transaction Manager Factory
  +JTATransactionManagerClass=
  +org.apache.ojb.odmg.transaction.WeblogicTransactionManagerFactory
  +</source>
  +</li>
  +<li>
  +Modify the connection information in the repository.xml  (specify the
  +datasource name):
  +<source><![CDATA[
  +<jdbc-connection-descriptor
  +    jcd-alias="default"
  +    default-connection="true"
  +       platform="Hsqldb"
  +       jdbc-level="2.0"
  +       jndi-datasource-name="datasource_demodb"
  +    eager-release="false"
  +    batch-mode="false"
  +    useAutoCommit="0"
  +    ignoreAutoCommitExceptions="false"
  +>
  +
  +    <sequence-manager
  +        className=
  +"org.apache.ojb.broker.util.sequence.SequenceManagerNextValImpl">
  +      <attribute attribute-name="grabSize" attribute-value="20"/>
  +    </sequence-manager>
  +
  +</jdbc-connection-descriptor>
  +]]></source>
  +</li>
  +</ul>
  +</p>
  +<p>
  +Write a session bean similar to thoses provided for the JBOSS samples.
  +It is also possible to use the ejb-example beans doing minor modifications
  +when the JNDI lookup was done.
  +</p>
  +<p>
  +Write an OJB startup class:
  +<a name="pb.factory"/>
  +<source>
  +package org.apache.ojb.weblogic;
  +
  +import javax.naming.*;
  +
  +import org.apache.ojb.broker.ta.PersistenceBrokerFactoryFactory;
  +import org.apache.ojb.broker.ta.PersistenceBrokerFactoryIF;
  +
  +import weblogic.common.T3ServicesDef;
  +import weblogic.common.T3StartupDef;
  +import java.util.Hashtable;
  +
  +/**
  + * This startup class created and binds an instance of a
  + * PersistenceBrokerFactoryIF into JNDI.
  + */
  +public class OjbPbStartup
  +    implements T3StartupDef, OjbPbFactory, Serializable
  +{
  +    private String defaultPropsFile =
  +        "org/apache/ojb/weblogic/OJB.properties";
  +    private T3ServicesDef services;
  +
  +    public void setServices (T3ServicesDef services)
  +    {
  +        this.services = services;
  +    }
  +
  +    public PersistenceBrokerFactoryIF getInstance()
  +    {
  +        return PersistenceBrokerFactoryFactory.instance();
  +    }
  +
  +    public String startup (String name, Hashtable args)
  +        throws Exception
  +    {
  +
  +        try
  +        {
  +            String jndiName = (String)args.get ("jndiname");
  +            if (jndiName == null || jndiName.length () == 0)
  +                jndiName = OjbPbFactory.DEFAULT_JNDI_NAME;
  +
  +            String propsFile = (String)args.get ("propsfile");
  +            if (propsFile == null || propsFile.length () == 0)
  +            {
  +                System.setProperty("OJB.properties", defaultPropsFile  );
  +            }
  +            else
  +            {
  +                System.setProperty("OJB.properties", propsFile  );
  +            }
  +
  +            InitialContext ctx = new InitialContext ();
  +            bind (ctx, jndiName, this);
  +
  +            // return a message for logging
  +            return "Bound OJB PersistenceBrokerFactoryIF to " + jndiName;
  +        }
  +        catch (Exception e)
  +        {
  +            e.printStackTrace();
  +            // return a message for logging
  +            return
  +            "Startup Class error: impossible to bind OJB PB factory";
  +        }
  +    }
  +
  +    private void bind(Context ctx, String name, Object val)
  +            throws NamingException
  +    {
  +        Name n;
  +        for (n = ctx.getNameParser("").parse(name);
  +            n.size() > 1; n = n.getSuffix(1))
  +        {
  +            String ctxName = n.get(0);
  +            try
  +            {
  +                ctx = (Context) ctx.lookup(ctxName);
  +            }
  +            catch (NameNotFoundException namenotfoundexception)
  +            {
  +                ctx = ctx.createSubcontext(ctxName);
  +            }
  +        }
  +        ctx.bind(n.get(0), val);
  +    }
  +}
  +</source>
  +The used OjbPbFactory interface:
  +<source>
  +package org.apache.ojb.weblogic;
  +
  +import org.apache.ojb.broker.ta.PersistenceBrokerFactoryIF;
  +
  +public interface OjbPbFactory
  +{
  +    public static String DEFAULT_JNDI_NAME = "PBFactory";
  +    public PersistenceBrokerFactoryIF getInstance();
  +}
  +</source>
   </p>
   </subsection>
   
  
  
  

Mime
View raw message