You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What steps will reproduce the problem?
1. Create converter which returns a javax.naming.Reference populated with the
correct class and factory class (implementing ObjectFactory).
2. Retrieve Reference
What is the expected output? What do you see instead?
a. expected result: a class built by the factory class using the ObjectFactory
interface
b. actual result: just the Reference object
What version of the product are you using? On what operating system?
11.4.1 on Linux
Please provide any additional information below.
if I use the standard Java RefFSContextFactory as JNDI provider, this
works well:
1. Create Reference
2. bind()
3. lookup() returns specific object, here WSMQConnectionFactory
Also, the Glassfish custom resource are implemented that way.
In summary, I see two issues here:
1. References should be returned as actual objects
2. simple-jndi should provide a default converter for the Reference object:
public class SimpleJndiObjectFactoryConverter implements Converter {
private static final String OBJECT_FACTORY_NAME = "objectFactoryName";
/* (non-Javadoc)
* @see org.osjava.sj.loader.convert.Converter#convert(java.util.Properties, java.lang.String)
*/
public Object convert( final Properties properties, final String type ) {
final String factoryName = ( String ) properties.get( OBJECT_FACTORY_NAME );
final Reference ref = new Reference( type, factoryName, null );
for ( final Entry <Object, Object> entry : properties.entrySet() ) {
final String key = (String) entry.getKey();
if ( OBJECT_FACTORY_NAME.equals( key ) ) {
continue;
}
ref.add( new StringRefAddr( key, (String) entry.getValue() ) );
}
return ref;
}
}
Thanks, Jörg
Original issue reported on code.google.com by jfaram...@gmail.com on 25 May 2012 at 12:30
The text was updated successfully, but these errors were encountered:
Instead of "return ref" I would use:
try {
final Class<?> factoryClass = Class.forName( factoryName );
final ObjectFactory of = (ObjectFactory) factoryClass.newInstance();
return of.getObjectInstance( ref, null, null, null );
} catch ( Exception e ) {
return null;
}
The Issue (1) is solved here. But IMHO this should work in general.
And: Is "Class.forName()" correct here? Should we use the thread-context
classloader instead?
Cheers, Jörg
Original comment by jfaram...@gmail.com on 25 May 2012 at 2:59
Original issue reported on code.google.com by
jfaram...@gmail.com
on 25 May 2012 at 12:30The text was updated successfully, but these errors were encountered: