interface.
Does not support enumerating bean definitions, hence doesn't implement
the
This factory resolves given bean names as JNDI names within the
J2EE application's "java:comp/env/" namespace. It caches the resolved
types for all obtained objects, and optionally also caches shareable
objects (if they are explicitly marked as
shareable resource .
| Method from org.springframework.jndi.support.SimpleJndiBeanFactory Detail: |
public void addShareableResource(String shareableResource) {
this.shareableResources.add(shareableResource);
}
Add the name of a shareable JNDI resource,
which this factory is allowed to cache once obtained. |
public boolean containsBean(String name) {
if (this.singletonObjects.containsKey(name) || this.resourceTypes.containsKey(name)) {
return true;
}
try {
doGetType(name);
return true;
}
catch (NamingException ex) {
return false;
}
}
|
public String[] getAliases(String name) {
return new String[0];
}
|
public Object getBean(String name) throws BeansException {
return getBean(name, (Class) null);
}
|
public Object getBean(String name,
Class requiredType) throws BeansException {
try {
if (isSingleton(name)) {
return doGetSingleton(name, requiredType);
}
else {
return lookup(name, requiredType);
}
}
catch (NameNotFoundException ex) {
throw new NoSuchBeanDefinitionException(name, "not found in JNDI environment");
}
catch (TypeMismatchNamingException ex) {
throw new BeanNotOfRequiredTypeException(name, ex.getRequiredType(), ex.getActualType());
}
catch (NamingException ex) {
throw new BeanDefinitionStoreException("JNDI environment", name, "JNDI lookup failed", ex);
}
}
|
public Object getBean(String name,
Object[] args) throws BeansException {
if (args != null) {
throw new UnsupportedOperationException(
"SimpleJndiBeanFactory does not support explicit bean creation arguments)");
}
return getBean(name);
}
|
public Class getType(String name) throws NoSuchBeanDefinitionException {
try {
return doGetType(name);
}
catch (NameNotFoundException ex) {
throw new NoSuchBeanDefinitionException(name, "not found in JNDI environment");
}
catch (NamingException ex) {
return null;
}
}
|
public boolean isPrototype(String name) throws NoSuchBeanDefinitionException {
return !this.shareableResources.contains(name);
}
|
public boolean isSingleton(String name) throws NoSuchBeanDefinitionException {
return this.shareableResources.contains(name);
}
|
public boolean isTypeMatch(String name,
Class targetType) throws NoSuchBeanDefinitionException {
Class type = getType(name);
return (targetType == null || (type != null && targetType.isAssignableFrom(type)));
}
|
public void setShareableResources(String[] shareableResources) {
this.shareableResources.addAll(Arrays.asList(shareableResources));
}
Set a list of names of shareable JNDI resources,
which this factory is allowed to cache once obtained. |