This gets the mapping.xml and database.xml creates a jdo and binds it to the the jndi tree. All you would need to do for the war case is just place your xml files in the web-inf/classes directory.

Hope this helps



package vanderbilt.ed.utils;

import java.util.Hashtable;
import javax.naming.Context;
import javax.naming.InitialContext;
import org.exolab.castor.jdo.JDO;
import org.exolab.castor.util.Logger;
import vanderbilt.ed.utils.EDWhiteboardLog;
import weblogic.common.T3ServicesDef;
import weblogic.common.T3StartupDef;

public class ConfigureJDO implements T3StartupDef
{
public String _wlTransactionManager = "weblogic.transaction.TransactionManager";
public String _databaseType = "oracle";
public String _jndiName = "ConfigureJDO";
public String _databaseConfigFile;
public String _jndiProvider;
public T3ServicesDef _services;
public String _loggingKey = "ConfigureJDO.startup()";
public InitialContext _context;
public JDO _jdo;
public Logger _logger;
public ConfigureJDO()
{
}

public void setServices(T3ServicesDef services)
{
_services = services;
}

public String startup(String name, Hashtable args) throws Exception
{
_loggingKey = "ConfigureJDO.startup()";

if (!(args != null && args.containsKey("databaseConfigFile")
&& args.containsKey("databaseType")))
{
EDWhiteboardLog.info("ConfigureJDO: invalid parameters");
return null;
}
_jndiProvider = (String)args.get("jndiProvider");
_databaseConfigFile = (String)args.get("databaseConfigFile");
_databaseType = (String)args.get("databaseType");
EDWhiteboardLog.info("ConfigurJDO:jndiProvider = " + _jndiProvider);
EDWhiteboardLog.info("databaseConfigFile = " + _databaseConfigFile);
EDWhiteboardLog.info("databaseType = " + _databaseType);



Hashtable ht = new Hashtable();
ht.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
ht.put(Context.PROVIDER_URL, _jndiProvider);
_context = new InitialContext(ht);


//file:/C:/bea/wlserver6.1/config/edisdomain/serverclasses/database
Pool.xml>
EDWhiteboardLog.info("Location of databasePool.xml "
+ (String)getClass().getResource(_databaseConfigFile).toString());
// PrintWriter writer = new Logger(System.out).setPrefix(jndiName);
ClassLoader klassLoader = this.getClass().getClassLoader();

_jdo = new JDO();
_logger = new Logger( System.out ).setPrefix( "castor" );
_jdo.setLogWriter(_logger);
// jdo.setLogWriter(writer);
_jdo.setDatabaseName(_databaseType);

_jdo.setConfiguration(getClass().getResource(_databaseConfigFile).t
oString());
_jdo.setTransactionManager(_wlTransactionManager);
_jdo.setClassLoader(klassLoader);

// register JDO in JNDI
EDWhiteboardLog.info("Binding JDO to JNDI: " + _jndiName);
try
{
EDWhiteboardLog.info("JDO Reference: " + _jdo);
_context.rebind(_jndiName, _jdo.getReference());
}
catch (Exception e)
{
EDWhiteboardLog.error("ConfigureJDO :", e);
}
return "JDO created and bound to jndi";
}
}






--On Tuesday, December 17, 2002 7:08 PM -0500 Tim Holloway <[EMAIL PROTECTED]> wrote:

Sorry, I'm afraid I'm simply too dense to get something that works
from hints and fragments. I posted what I did and what happened -
or didn't - not too long ago, but nobody told me what I did wrong.

  Tim

On 2002-12-17  16:43 "Lanaghan, Kevin M" wrote:
You can use a mapping from a war.  Just put the mapping files in
the classpath and retrieve it the way you would a properties file


--On Tuesday, December 17, 2002 2:10 PM -0500 Tim Holloway
<[EMAIL PROTECTED]> wrote:

> Personally, I was stopped dead in the water because there was
> no easy way to use a mapping from a WAR. I admit to some
> personal self-interest here, but that really DOES seem to me
> to be a critical need if you want Castor to be seen as a
> productive tool for webapp development. I solved my particular
> problem quickly by switching to Zeus, but there's a whole raft
> of webapp problems that Zeus isn't a good fit for that Castor
> would be.
>
>   Tim
>
> On 2002-12-17  10:46 "Colwell, David" wrote:
>> The testing/development was done using the latest version of
>> Castor, v0.9.4.1.  The problems I mention are recognized at
>> least by other members of this mailing list but remain
>> unsolved. I too would like to hear response to the issues
>> raised as we plan to continue with Castor on our current
>> project.  Are others successfully using Castor in an n-tier
>> environment with a complex data model?  Have they experienced
>> the same issues and what are their solutions?
>>
>> Thanks,
>> Dave
>>
>> -----Original Message-----
>> From: tek1 [mailto:[EMAIL PROTECTED]]
>> Sent: Tuesday, December 17, 2002 9:21 AM
>> To: [EMAIL PROTECTED]
>> Subject: Re: [castor-dev] Here a an interesting article on
>> castor
>>
>>
>> what version of castor was used by the person who wrote the
>> article?
>>
>> have the problems that he mentioned by solved in the most
>> current version  of castor?
>>
>> pr-wise, it would be good if someone very experienced with
>> castor wrote a  response or follow-up on the article to answer
>> some of the questions raised  by the article.
>>
>> thank you.
>>
>>
>>  > O/R Mapping with Castor JDO in the Real World
>>  >
>>  > http://www.spiderlogic.com/modules.php?name=News&file=arti
>>  > cle &sid=16
>>
>> -----------------------------------------------------------
>> If you wish to unsubscribe from this mailing, send mail to
>> [EMAIL PROTECTED] with a subject of:
>> 	unsubscribe castor-dev
>>
>> -----------------------------------------------------------
>> If you wish to unsubscribe from this mailing, send mail to
>> [EMAIL PROTECTED] with a subject of:
>> 	unsubscribe castor-dev
>>
> --
> "The cost benefit outweighs the fact that customer satisfaction
> levels may dip."
>
>    Brian Huff, Datamonitor PLC
>
> -----------------------------------------------------------
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
> 	unsubscribe castor-dev
>



---------------------------------------
Lanaghan, Kevin M
Vanderbilt University
Email: [EMAIL PROTECTED]

-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
	unsubscribe castor-dev

--
"The cost benefit outweighs the fact that customer satisfaction
levels may dip."

   Brian Huff, Datamonitor PLC

-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
	unsubscribe castor-dev



---------------------------------------
Lanaghan, Kevin M
Vanderbilt University
Email: [EMAIL PROTECTED]

----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev

Reply via email to