⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 iofficecomponentproxy.java

📁 一套完整的工商12315的源程序jsp部分在12315里,后台JAVA部分在gs12315src里,没有打包数据库.
💻 JAVA
字号:
/*
 * ComponentProxy.java
 *
 * Created on 2001年7月13日, 下午3:24
 */

package com.gs.db;

import java.lang.reflect.Constructor;

/**
 * Protection proxy for IofficeComponent
 */
public class IofficeComponentProxy implements IofficeComponent {

     private IofficeComponent component;
    private Authorization authorization;
    private IofficePermissions permissions;
   /** Creates new ComponentProxy */
    public IofficeComponentProxy(IofficeComponent component, Authorization
            authorization, IofficePermissions permissions)
    {
        this.component = component;
        this.authorization = authorization;
        this.permissions = permissions;
    }

    public String getName() {
        return component.getName();
    }
    
    /**
     * return the DisplayName  used to  denote the component in GUI or WWWPAGE
 */
    public String getDisplayName() {
        return component.getDisplayName();
    }
    
    /**
     * Set the DisplayName  used to  denote the component in GUI or WWWPAGE
 */
    public void setDisplayName(String dispName) throws UnauthorizedException {
        if (permissions.get(IofficePermissions.SYSTEM_ADMIN)) {
            component.setDisplayName(dispName);
        }
        else {
            throw new UnauthorizedException();
        }
    }
    
    /**
     * return the URL to entry the component services
 */
    public String getEntryURL() {
        return component.getEntryURL();
    }
    
    /**
     * Set the URL to entry the component services
 */
    public void setEntryURL(String url) throws UnauthorizedException {
        if (permissions.get(IofficePermissions.SYSTEM_ADMIN)) {
            component.setEntryURL(url);
        }
        else {
            throw new UnauthorizedException();
        }
    }
    
    /**
     * get the importance of the component
     * @return 0..99 , the larger the more important
 */
    public int getWeight() {
        return component.getWeight();
    }
    
    /**
     * Set the importance of the component
     * @return 0..99 , the larger the more important
 */
    public void setWeight(int weight) throws UnauthorizedException {
        if (permissions.get(IofficePermissions.SYSTEM_ADMIN)) {
            component.setWeight(weight);
        }
        else {
            throw new UnauthorizedException();
        }
    }
    
    /**
     * get which desktop the component belongs to 
     * @return  1: public  2:personal
 */
    public int getDesktop() {
        return component.getDesktop();
    }
    
    /**
     * set which desktop the component belongs to 
     * @return  1: public  2:personal
 */
    public void setDesktop(int desktop) throws UnauthorizedException {
        if (permissions.get(IofficePermissions.SYSTEM_ADMIN)) {
            component.setDesktop(desktop);
        }
        else {
            throw new UnauthorizedException();
        }
    }
    
    /**
     * Tells if the component is active
 */
    public boolean isActive() {
        return component.isActive();
    }
    
    /**
     * Activate or Deactivate the component 
 */
    public void activate(boolean flag) throws UnauthorizedException {
        if (permissions.get(IofficePermissions.SYSTEM_ADMIN)) {
            component.activate(flag);
        }
        else {
            throw new UnauthorizedException();
        }
        
    }
    
    /**
     * return the agent class name 
 */
    public String getAgentClassName() {
        return component.getAgentClassName();
    }
    
    /**
     * set the agent class name
 */
    public void setAgentClassName(String className) throws UnauthorizedException {
        if (permissions.get(IofficePermissions.SYSTEM_ADMIN)) {
            component.setAgentClassName(className);
        }
        else {
            throw new UnauthorizedException();
        }
    }
    
    /**
     * get Agent Instance 
 */
    public Object getAgentInstance() {
        //first we should test if the component has acessbility to this component
        
        Class agentClass=null;
        //for each agent class you should provide simultaneously a Proxy class which has
        //a constructor with parameters ( Authorization, IofficePermissions)
        try {
            agentClass = Class.forName( getAgentClassName() );
        }
        catch ( ClassNotFoundException e )
        {
            return null;
        }
        Class[] paras = new Class[2];
        try {
        paras[0] = Class.forName("com.gs.db.Authorization");
        paras[1] = Class.forName("com.gs.db.IofficePermissions");
        }
        catch ( ClassNotFoundException e ){ return null; }  //ignore
        
        Constructor agentContructor ;
        try {
            agentContructor = agentClass.getConstructor(paras);
        }
        catch ( Exception e )
        {
            System.err.println("Agent class contructor not found"+e);
            return null;
        }
        
        Object paraObjs[]= new Object[2];
        paraObjs[0] =authorization;
        paraObjs[1] =permissions;
        try {
            return (agentContructor.newInstance(paraObjs ));
        }
        catch ( Exception e )
        {
            System.err.println("Agent instantiation"+e);
            return null;
        }
    }
    
    /**
     * Tells if the component is accessbile to all groups by default
     *
     * @return true if is default
     */
    public boolean isDefaultAccessible() {
        return component.isDefaultAccessible();
    }    
    
    /**
     * Tells if the component is accessbile to all groups by default
     *
     * @return true if is default
     */
    public void setDefaultAccessible(boolean flag) throws UnauthorizedException {
        if (permissions.get(IofficePermissions.SYSTEM_ADMIN)) {
            component.setDefaultAccessible(flag);
        }
        else {
            throw new UnauthorizedException();
        }    
    }    
    
}

⌨️ 快捷键说明

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