scopepolicyeditor.java

来自「Xfire文件 用于开发web service 的一个开源工具 很好用的」· Java 代码 · 共 66 行

JAVA
66
字号
package org.codehaus.xfire.service.invoker;

import java.beans.PropertyEditorSupport;

/**
 * This class is responsible for converting string to ScopePolicy object.
 * <p>
 * 
 * @author Ben Yu Feb 12, 2006 12:40:31 AM
 */
public class ScopePolicyEditor
    extends PropertyEditorSupport
{
    /**
     * To get the default scope policy when no policy is specified. This
     * implementation uses "application" as default.
     */
    public static ScopePolicy getDefaultScope()
    {
        return ApplicationScopePolicy.instance();
    }

    /**
     * Convert a policy name to ScopePolicy object.
     * 
     * @param policy
     *            the policy name.
     * @return the ScopePolicy object.
     */
    public static ScopePolicy toScopePolicy(String policy)
    {
        if (policy == null)
        {
            return getDefaultScope();
        }
        
        policy = policy.trim();
        
        if (policy.length() == 0)
        {
            return getDefaultScope();
        }
        else if ("application".equals(policy))
        {
            return ApplicationScopePolicy.instance();
        }
        else if ("session".equals(policy))
        {
            return SessionScopePolicy.instance();
        }
        else if ("request".equals(policy))
        {
            return RequestScopePolicy.instance();
        }
        else
        {
            throw new IllegalArgumentException("Scope " + policy + " is invalid.");
        }
    }

    public void setAsText(String text)
    {
        setValue(toScopePolicy(text));
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?