Spring Framework JndiObjectFactoryBean - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Spring Framework JndiObjectFactoryBean class.

This code example shows how to use the following methods:getObject, setProxyInterface, setJndiName, setResourceRef
This code example shows how to use the following methods:afterPropertiesSet, getObject, setJndiName
	public void resetMailSessionByJNDI(String jndiName) throws IllegalArgumentException, NamingException {
		//always reset session to null, so make "reset" meaningful. This is also a trick, as setSession() doesn't allow null 
		//however, this.setJavaMailProperties(prop) will reset Session to null internally... 
		this.setJavaMailProperties(new Properties());
		 
		JndiObjectFactoryBean factory = new JndiObjectFactoryBean();
		factory.setJndiName(jndiName);
		factory.afterPropertiesSet();
		if(factory.getObject() instanceof Session)
			this.setSession((Session) factory.getObject());
		else 
			throw new IllegalArgumentException("JNDI object is not mail session instance");
	} 
	/** 
	 * mailProperties changed, this method will reload mail session 
	 */ 
	public void resetMailSessionByProperties() { 
		//always reset session to null, so make "reset" meaningful. This is also a trick, as setSession() doesn't allow null 
		//however, this.setJavaMailProperties(prop) will reset Session to null internally... 
		this.setJavaMailProperties(new Properties());
6
CodeRank
This code example shows how to use the following methods:afterPropertiesSet, getJndiName
 * 
 * @author Dapeng.Ni 
 */ 
public class NullableJndiObjectFactoryBean extends  JndiObjectFactoryBean{
	public void afterPropertiesSet() throws IllegalArgumentException, NamingException{
		if(StringUtils.isEmpty(getJndiName())){
			//do nothing 
			return; 
		} 
		super.afterPropertiesSet(); 
	} 
	 
} 
5
CodeRank
See Code Examples for Spring Framework JndiObjectFactoryBean Methods: