Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /* DelegatingVariableResolver.java
  
  {{IS_NOTE
  	Purpose:
  		
  	Description:
  		
  	History:
  		Thu Jun  1 13:53:53     2006, Created by henrichen
 }}IS_NOTE
 
 Copyright (C) 2006 Potix Corporation. All Rights Reserved.
 
 {{IS_RIGHT
 }}IS_RIGHT
  */
 package org.zkoss.zkplus.spring;
 
 import java.util.List;
 
 import  org.springframework.context.ApplicationContext;
 
 

DelegatingVariableResolver for resolving Spring beans, Spring Security variables and Spring Webflow variables.

It delegates variable resolving to ZK Spring core, ZK Spring Security and ZK Spring FlowResolver if they are on application classpath.

Usage:
<?variable-resolver class="org.zkoss.zkplus.spring.DelegatingVariableResolver"?>

Developers can specify a list of class names separated with comma in a library property called org.zkoss.spring.VariableResolver.class, such they are used as the default variable resolvers.

Applicable to Spring Framework version 2.x or later

Author(s):
henrichen
ashish
 
 	private static final Logger log = LoggerFactory.getLogger(DelegatingVariableResolver.class);

Holds list of variable resolvers for Spring core (3.0RC and later), Spring security(3.0RC and later) and Spring webflow(only for 1.x)
 
 	protected transient List<VariableResolver_variableResolvers = new ArrayList<VariableResolver>();
 
 		final Execution exec = Executions.getCurrent();
 		String classes = null;
 		if (exec != null) {
 			classes = exec.getDesktop()
 				.getPreference("org.zkoss.spring.VariableResolver"null);
 		}
 
 		if (classes == null)
 			classes = Library.getProperty("org.zkoss.spring.VariableResolver.class");
 
 		if (classes != null) {
 			String[] vrClss = classes.split(",");
 			for (int i = 0; i < vrClss.lengthi++) {
 				try {
 					}
 				} catch (Throwable e) {
 					.warn("Ignored: failed to instantiate "+vrClss[i], e);
 				}
 			}
 		} else {
 		}
 	}

Resolves variable name by name. It can resolve a spring bean, spring security authentication and spring web flow variables depending upon ZK Spring libraries in the classpath
 
 	public Object resolveVariable(String name) {
		Object o = null;
			o = resolver.resolveVariable(name);
			if (o != null) {
				return o;
			}
		}
		return o;
	}
	public int hashCode() {
		return Objects.hashCode();
	}
	public boolean equals(Object obj) {
		return this == obj || (obj instanceof DelegatingVariableResolver
	}
	// -- Serializable --//
	private synchronized void writeObject(java.io.ObjectOutputStream sthrows IOException {
		for (Iterator it = .iterator(); it.hasNext();) {
			Object o = it.next();
			if (o instanceof DefaultDelegatingVariableResolver) {
else
		}
	}
	private void readObject(java.io.ObjectInputStream sthrows IOException,
		int size = s.readInt();
		for (int i=0; i<sizei++) {
			Object o = s.readObject();
			if (o instanceof String) {
else
		}
	}

Provides a default variable resolver implementation that resolves spring beans by name. It also declares an implicit variable springContext that resolves to Spring webapp context

Author(s):
ashish
	private static class DefaultDelegatingVariableResolver implements VariableResolver {
		private ApplicationContext _ctx;
		private ApplicationContext getApplicationContext() {
			if ( != null)
				return ;
			 = SpringUtil.getApplicationContext();
			return ;
		}
		public Object resolveVariable(String namethrows XelException {
			if ("springContext".equals(name)) {
			}
			return SpringUtil.getBean(name);
		}
		public int hashCode() {
			return Objects.hashCode(getClass());
		}
		public boolean equals(Object obj) {
			return this == obj || (obj instanceof DefaultDelegatingVariableResolver && getClass() == obj.getClass());
		}
	}
New to GrepCode? Check out our FAQ X