Nope, I have no recommendation - I have used neither the Apache one, nor the JBoss.  
We currently use WebSphere, so we get theirs.  But I have played around quite a lot 
with mock objects and how to create a mock JNDI context.  You can do so like this w/o 
having to use any 3rd party libraries:

try
{
        // initialize a mock context factory with the NamingManager
        Hashtable jndiEnv = new Hashtable();
        jndiEnv.put(Context.INITIAL_CONTEXT_FACTORY, 
MockJndiContextFactory.class.getName());
        jndiEnv.put(Context.PROVIDER_URL, MockJndiContextFactory.URL);
        MockJndiContextFactory jndiFactory = new MockJndiContextFactory(jndiEnv);
                        
        NamingManager.setInitialContextFactoryBuilder(
                new MockInitialContextFactoryBuilder(jndiFactory)
        );
                        
        // initialize a mock datasource in the context
        InitialContext ctx = new InitialContext(jndiEnv);
        MockDataSource ds = new MockDataSource();
        ctx.bind("jdbc/" + MockDataSource.JNDI_NAME, ds);
        _mockDataSource = ds;
}
catch (NamingException e)
{
..
}

Do this in a static initializer of some class, or as a singleton or something else 
that you can guarantee to only ever call once.  The point being that if a subsequent 
call to NamingManager.setInitialContextFactoryBuilder() is made at runtime it will 
throw an exception.

All you have to supply is the mock implementations of InitialContextFactory (in my 
case MockJndiContextFactory) and InitialContextFactoryBuilder (in my case 
MockInitialContextFactoryBuilder) and DataSource (in my case MockDataSource).  I have 
posted the implementations I use in unit tests earlier on the Castor wiki, but there 
is nothing preventing you from using them in production - just be sure you implement 
all the methods you think will be required.  The wiki page is here:
http://brainopolis.dnsalias.com/castorwiki/Wiki.jsp?page=CastorMockObjects

jeff

>>> [EMAIL PROTECTED] 10/8/2004 1:50:48 PM >>>
Jeff,

I see what you mean but being familiar only with LDAP JNDI I search
around for an implementation of InitialContext and found the following.
Do you have any suggestions on which one to use?

org.apache.naming.java.javaURLContextFactory

I found a general approche to initializing one.

Properties env = new Properties( );
env.put(Context.INITIAL_CONTEXT_FACTORY,
"org.jnp.interfaces.NamingContextFactory");
env.put(Context.PROVIDER_URL, "jnp://hostname:1099");
env.put(Context.URL_PKG_PREFIXES,
"org.jboss.naming:org.jnp.interfaces");
InitialContext jndiContext = new InitialContext(env);

Should I go with javax.naming.spi.ObjectFactory?

Thanks,
Phil

Jeff Bonevich a �crit :
> 
> Use DataSource.  Configure datasource in your application, not in
> Castor.  And it is not so difficult to set up a simple JNDI context,
> even a mock one, to provide the DataSource to Castor.
> 
> jeff
> 
> >>> [EMAIL PROTECTED] 10/8/2004 8:50:45 AM >>>
> 
> Hi all,
> 
> I would like to encrypt the jdbc configuration in database.xml
> 
> <param name="user" value="QDDdsicy96KSHks1" />
> <param name="password" value="q4q64F6G4LF4" />
> 
> My solution concists of doing just that. Parsing and decrypting and
> modifying the xml and streaming it to an ImputSource for use in the
> Castor JDO API.
> 
> JDO.loadConfiguration(org.xml.sax.InputSource)
> 
> Any other ideas?
> 
> Sincerely,
> 
> Philip Mark Donaghy
> 
> -----------------------------------------------------------
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
>         unsubscribe castor-user
> 
> -----------------------------------------------------------
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
>         unsubscribe castor-user

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

Reply via email to