com.evasion.common.flex.factory.LocalJNDIResourceLocator Maven / Gradle / Ivy
package com.evasion.common.flex.factory;
import java.text.MessageFormat;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
/**
* Resource locator that locates local resources using JNDI.
*/
public class LocalJNDIResourceLocator implements IResourceLocator {
/**
* @see com.adobe.ac.ejb.IResourceLocator#locate( java.lang.String )
*/
public Object locate(final String name) throws ResourceException {
try {
final Context ctx = new InitialContext();
final Object res = ctx.lookup(name);
return res;
} catch (NamingException e) {
e.printStackTrace();
throw new ResourceException(MessageFormat.format(
"error locating local resource {0}", new Object[]{name}), e);
}
}
}