Skip to content

Commit

Permalink
fix javadoc errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Wenzel committed Jan 24, 2019
1 parent f97bd60 commit 666f972
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 15 deletions.
26 changes: 21 additions & 5 deletions zkspring-core/src/main/java/org/zkoss/spring/SpringUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {
Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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).<br/>
* <br/>
* e.g. Websocket requests or executions activated from background threads (server push / eventqueues / manual activation).<br>
* <br>
* 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}<br/>
* The listener can be enabled/disabled via the library property 'org.zkoss.spring.init.SecurityContextAwareExecutionListener.enabled'.<br/>
* default attribute name {@link org.springframework.security.web.context.HttpSessionSecurityContextRepository#SPRING_SECURITY_CONTEXT_KEY}<br>
* The listener can be enabled/disabled via the library property 'org.zkoss.spring.init.SecurityContextAwareExecutionListener.enabled'.<br>
* 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
Expand Down Expand Up @@ -51,6 +51,12 @@ public void cleanup(Execution exec, Execution parent, List<Throwable> 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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 666f972

Please sign in to comment.