📄 componentmanagerproxy.java
字号:
/*
* ComponentManagerProxy.java
*
* Created on 2001年7月13日, 下午1:53
*/
package com.gs.db;
import java.util.*;
/**
*Protection proxy for the ComponentManager interface. It restricts access of certain
* methods to those that have the proper permissions to manage component
* registration
* @ComponentManager
*/
public class ComponentManagerProxy implements ComponentManager {
private ComponentManager manager;
private Authorization authorization;
private IofficePermissions permissions;
/** Creates new ComponentManagerProxy */
public ComponentManagerProxy(ComponentManager manager, Authorization
authorization, IofficePermissions permissions)
{
this.manager = manager;
this.authorization = authorization;
this.permissions = permissions;
}
/**
* Register a new component into IOffice System
* @param componentName the name of the component, must be unique
* @param componentAgentClassName the name of the component agent class
* @param entryURL the URL used to entry the component services
* @param weight the importance of the component
*
* @throw UnauthorizedException if not authorized to do so,
* @ throw ComponentRegistrationException if registration fails
*/
public IofficeComponent registerComponent(String componentName,String componentAgentClassName,
String entryURL, String displayName, int weight, int desktop )
throws UnauthorizedException,ComponentRegistrationException
{
IofficeComponent cp = null;
if (permissions.get(IofficePermissions.SYSTEM_ADMIN)) {
cp = manager.registerComponent( componentName, componentAgentClassName, entryURL,displayName, weight,desktop);
}
else {
throw new UnauthorizedException();
}
return new IofficeComponentProxy( cp,authorization, permissions);
}
/*
* Delete a new component off Inter-Office System
* @param componentName the name of the component, must be unique
* might throw UnauthorizedException if not authorized to do so,
* might throw ComponentNotFoundException if name not found
public void unregisterComponent(String componentName)
throws UnauthorizedException, ComponentNotFoundException
{
if (permissions.get(IofficePermissions.SYSTEM_ADMIN)) {
manager.unregisterComponent( componentName);
}
else {
throw new UnauthorizedException();
}
}
*/
/**
* Get a IofficeComponent object by the component name
* <i>ComponentNotFoundException</i> will be thrown if the
* name is invalid.
* @param componentName the name of the component
*/
public IofficeComponent getComponent(String componentName) throws ComponentNotFoundException{
IofficeComponent cp = manager.getComponent( componentName);
return new IofficeComponentProxy( cp, authorization , permissions);
}
/**
* Return the total number of components registered
*/
public int getComponentCount()
{
return manager.getComponentCount();
}
/**
* Return an Iterator, de facto,a ComponentIterator(Proxy) object,
* by which you can get each component
*/
public Iterator getComponents()
{
Iterator iterator = manager.getComponents();
return new ComponentIteratorProxy( iterator, authorization, permissions);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -