diff --git a/zkspring-core/src/main/java/org/zkoss/spring/SpringUtil.java b/zkspring-core/src/main/java/org/zkoss/spring/SpringUtil.java
index c668981..aeed31e 100644
--- a/zkspring-core/src/main/java/org/zkoss/spring/SpringUtil.java
+++ b/zkspring-core/src/main/java/org/zkoss/spring/SpringUtil.java
@@ -18,6 +18,7 @@
import javax.servlet.ServletContext;
+import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanNotOfRequiredTypeException;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.context.ApplicationContext;
@@ -34,21 +35,30 @@
*/
public class SpringUtil {
/**
- * Get the spring application context.
+ * Get the current spring application context.
+ *
+ * @return the current application context
+ * @throws UiException when not in an active zk execution
*/
public static ApplicationContext getApplicationContext() {
+
Execution exec = Executions.getCurrent();
if (exec == null) {
throw new UiException("SpringUtil can be called only under ZK environment!");
}
-
+
return WebApplicationContextUtils.getRequiredWebApplicationContext(
exec.getDesktop().getWebApp().getServletContext());
}
-
+
/**
* Get the spring bean by the specified name.
- */
+ *
+ * @param name the bean name
+ * @return the bean found in the current spring application context or null if no bean was found under the name
+ *
+ * @see BeanFactory#getBean(java.lang.String)
+ */
public static Object getBean(String name) {
Object o = null;
try {
@@ -63,7 +73,13 @@ public static Object getBean(String name) {
/**
* Get the spring bean by the specified name and class.
- */
+ *
+ * @param name the bean name
+ * @param cls the bean class
+ * @return the bean found in the current spring application context or null if no bean was found under the name
+ *
+ * @see BeanFactory#getBean(java.lang.String, java.lang.Class)
+ */
public static Object getBean(String name, Class cls) {
Object o = null;
try {
diff --git a/zkspring-core/src/main/java/org/zkoss/spring/init/CoreVariableResolver.java b/zkspring-core/src/main/java/org/zkoss/spring/init/CoreVariableResolver.java
index 7cff499..371513a 100644
--- a/zkspring-core/src/main/java/org/zkoss/spring/init/CoreVariableResolver.java
+++ b/zkspring-core/src/main/java/org/zkoss/spring/init/CoreVariableResolver.java
@@ -30,6 +30,8 @@ public class CoreVariableResolver implements VariableResolver, Serializable {
/**
* Get the spring application context.
+ *
+ * @return the current application context
*/
protected ApplicationContext getApplicationContext() {
if (_ctx != null)
@@ -41,7 +43,10 @@ protected ApplicationContext getApplicationContext() {
/**
* Get the spring bean by the specified name.
- */
+ *
+ * @param name the spring bean name
+ * @return the bean found by that name or null
+ */
public Object resolveVariable(String name) {
if ("springContext".equals(name)) {
diff --git a/zkspring-core/src/main/java/org/zkoss/spring/init/CoreWebAppInit.java b/zkspring-core/src/main/java/org/zkoss/spring/init/CoreWebAppInit.java
index 0d018af..c48893d 100644
--- a/zkspring-core/src/main/java/org/zkoss/spring/init/CoreWebAppInit.java
+++ b/zkspring-core/src/main/java/org/zkoss/spring/init/CoreWebAppInit.java
@@ -23,9 +23,9 @@
import org.zkoss.zk.ui.WebApp;
/**
- * Register spring core related variable resolver..
- * @author henrichen
- * @see metainfo/zk/config.xml
+ * Register spring core related variable resolver, configured in "zkspring-core.jar:metainfo/zk/config.xml".
+ * @author henrichen, Robert
+ *
* @since 3.0
*/
public class CoreWebAppInit implements org.zkoss.zk.ui.util.WebAppInit {
diff --git a/zkspring-security/src/main/java/org/zkoss/spring/init/SecurityContextAwareExecutionListener.java b/zkspring-security/src/main/java/org/zkoss/spring/init/SecurityContextAwareExecutionListener.java
index 4075592..6536009 100644
--- a/zkspring-security/src/main/java/org/zkoss/spring/init/SecurityContextAwareExecutionListener.java
+++ b/zkspring-security/src/main/java/org/zkoss/spring/init/SecurityContextAwareExecutionListener.java
@@ -12,11 +12,11 @@
/**
* ZK Listener to fill/cleanup Springs {@link SecurityContextHolder} for executions outside Spring's security filter chain.
- * e.g. Websocket requests or executions activated from background threads (server push / eventqueues / manual activation).
- *
+ * e.g. Websocket requests or executions activated from background threads (server push / eventqueues / manual activation).
+ *
* This implementation will retrieve the current {@link SecurityContext} stored in the Http Session using Spring's
- * default attribute name {@link org.springframework.security.web.context.HttpSessionSecurityContextRepository#SPRING_SECURITY_CONTEXT_KEY}
- * The listener can be enabled/disabled via the library property 'org.zkoss.spring.init.SecurityContextAwareExecutionListener.enabled'.
+ * default attribute name {@link org.springframework.security.web.context.HttpSessionSecurityContextRepository#SPRING_SECURITY_CONTEXT_KEY}
+ * The listener can be enabled/disabled via the library property 'org.zkoss.spring.init.SecurityContextAwareExecutionListener.enabled'.
* After disabling a custom implementation can be provided e.g. by overriding the {@link #loadSecurityContext(Execution)} method.
* @author Robert
* @see org.zkoss.zk.ui.util.ExecutionInit
@@ -51,6 +51,12 @@ public void cleanup(Execution exec, Execution parent, List errs) thro
}
}
+ /**
+ * Retrieve the current {@link SecurityContext} from the session associated with the given execution
+ *
+ * @param execution the current execution
+ * @return a SecurityContext or null
+ */
protected SecurityContext loadSecurityContext(Execution execution) {
return (SecurityContext) execution.getSession().getAttribute(SPRING_SECURITY_CONTEXT_KEY);
}
diff --git a/zkspring-security/src/main/java/org/zkoss/spring/init/SecurityWebAppInit.java b/zkspring-security/src/main/java/org/zkoss/spring/init/SecurityWebAppInit.java
index a77b288..0f9e72b 100644
--- a/zkspring-security/src/main/java/org/zkoss/spring/init/SecurityWebAppInit.java
+++ b/zkspring-security/src/main/java/org/zkoss/spring/init/SecurityWebAppInit.java
@@ -24,10 +24,11 @@
import org.zkoss.zk.ui.util.Configuration;
/**
- * Adds ZK Spring Security listeners and register security related variable resolver.
+ * Adds ZK Spring Security listeners and register security related variable resolver ("zkspring-security.jar:metainfo/zk/config.xml")
* @author henrichen, Robert
- * @see metainfo/zk/config.xml
* @since 3.0
+ *
+ * @see SecurityContextAwareExecutionListener
*/
public class SecurityWebAppInit implements org.zkoss.zk.ui.util.WebAppInit {
private static String RESOLVER_CLASS = CoreWebAppInit.RESOLVER_CLASS;
diff --git a/zkspring-security/src/main/java/org/zkoss/spring/security/SecurityUtil.java b/zkspring-security/src/main/java/org/zkoss/spring/security/SecurityUtil.java
index 9d1042f..2061318 100644
--- a/zkspring-security/src/main/java/org/zkoss/spring/security/SecurityUtil.java
+++ b/zkspring-security/src/main/java/org/zkoss/spring/security/SecurityUtil.java
@@ -182,6 +182,8 @@ public static boolean isAnyGranted(String authorities) {
/**
* Return the current Authentication object.
+ *
+ * @return the current {@link Authentication} object retrieved from {@link SecurityContextHolder} or null
*/
public static Authentication getAuthentication() {
if ((SecurityContextHolder.getContext() != null)