欢迎光临
我们一直在努力

权限组件所缺的文件-JSP教程,资料/其它

建站超值云服务器,限时71元/月

原意是给大家看一下结构,没想大家都那么关心,我现在把所有的代码贴上来,谢谢大家关心.

唉,blog好烦啊,无法直接上传文件要一个一个贴

================resourcelib.java ============

package org.fswan;

import java.util.arraylist;

import java.util.properties;

/**

* 用来存储通用的xml配置文件位置和数据库连接属性.

* 作为org.fswan里所有的包中类的基础配置文件.

*/

public class resourcelib

{

/**

* 驱动的字符串

*/

public static final string driver = "driver";

/**

* 数据库连接字符串

*/

public static final string url = "url";

/**

* 用户

*/

public static final string user = "user";

/**

* 密码

*/

public static final string password = "password";

/**

* 所有的xml配置文件的存储位置,存储的对象为url

*/

private static arraylist resource = new arraylist();

/**

* 存储所有的数据库配置.

* 所有的数据库存储位置格式为:

* 对象为properties对象

* 而properties对象里包含:

* {@link #driver driver},{@link #url url},{@link #user user},{@link #password password},{@link #view view},{@link #type type}六个属性分别对应

* 数据库的驱动,边接字符串,用户名,密码,视图,类型

* 或者

* {@link #jndi jndi},{@link #view view},{@link #type type}

* jndi名,视图,类型

* 类型是以下的一个

* {@link #workflow workflow}

* {@link #brand brand}

* {@link #status status}

* {@link #switch switcher}

* {@link #workunit workunit}

* {@link #user user}

*/

private static arraylist prop = new arraylist();

/**

* 获取所有的xml资源

* @return xml资源泉

*/

public static arraylist getxmlresource()

{

return resource;

}

/**

* 获取所有的数据库连接属性

* @return 数据库链接属性

*/

public static arraylist getconnection()

{

return prop;

}

/**

* 增加xml资源

* @param source xml资源

*/

public static void addresource(string source)

{

synchronized(resource)

{

resource.add(source);

}

}

/**

* 增加数据库链接属性

* @param pro 数据库链接属性

*/

public static void adddataproperty(properties pro)

{

synchronized(prop)

{

prop.add(pro);

}

}

}

==============input.java============

/*

* created on 2003-11-20

*

* create by 方志文

* email:fswan@yeah.net

*/

package org.fswan;

/**

* @author 方志文

*

* 输入数据的接口,作为主类的数据输入式,

* 现可以从xml,httpservletrequest和jspupload获取数据

*

*/

public interface input {

/**

* 获取参数的值,如果无该参数则返回null,如果该参数对应多个值则返回其第一个值

* @param parameter 参数

* @return 值

*/

public string getparameter(string parameter);

/**

* 获取参数的值列表

* @param parameter 参数

* @return 值

*/

public string[] getparametervalues(string parameter);

/**

* 获取参数名的列表

* @return 所有的参数的名

*/

public string[] getparameternames();

/**

* 获取数据源

* @return 数据源

*/

public object getsource();

/**

* 设置参数,如果已存在该参数,则原来的作废

* @param parameter 参数

* @param value 值

*/

public void setparameter(string parameter,string value);

/**

* 设置参数,如果已存在该参数,则把原来的作废

* @param parameter 参数

* @param values 值

*/

public void setparameter(string parameter,string[] values);

/**

* 添加参数,如果已存在该参数,则把该值添加到原值后成数组

* @param parameter 参数

* @param value 值

*/

public void addparameter(string parameter,string value);

/**

* 添加参数(多个值),如果已存在该参数,则把该值添加到原值后成数组

* @param parameter 参数

* @param values 值

*/

public void addparameter(string parameter,string[] values);

}

================manualinput.java ==============

package org.fswan;

public class manualinput extends abstractinput

{

/* (non-javadoc)

* @see org.fswan.input#getsource()

*/

public object getsource()

{

return null;

}

}

===================identity.java==========

package org.fswan;

import org.fswan.workflow.exception.identitymappingerror;

/**

* @author administrator

* 这个接是一个标识,用来唯一标识所有的工作流,状态,切换开关,分枝操作

*/

public interface identity

{

/**

* 工作流的标识

*/

public static final int workflow = 0;

/**

* 分枝操作的标识

*/

public static final int brand = 1;

/**

* 状态的标识

*/

public static final int status =2;

/**

* 切换开关的标识

*/

public static final int switch = 3;

/**

* 用户的标识

*/

public static final int user = 4;

/**

* 工作单元

*/

public static final int workunit = 5;

/**

* 角色

*/

public static final int role = 6;

/**

* 群组

*/

public static final int group = 7;

public static final int viewclass = 255;

public static final string xmlworkflow = "xmlworkflow";

public static final string xmlbrand = "xmlbrand";

public static final string xmlswitcher = "xmlswitcher";

public static final string xmlstatus = "xmlstatus";

public static final string xmlworkunit = "xmlworkunit";

public static final string dbworkflow = "dbworkflow";

public static final string dbbrand = "dbbrand";

public static final string dbswitcher = "dbswitcher";

public static final string dbstatus = "dbstatus";

public static final string dbworkunit = "dbworkunit";

public static final string xmluser = "xmluser";

public static final string xmlgroup = "xmlgroup";

public static final string xmlrole = "xmlrole";

/**

* 获取标识的类型

* 是以下常量中的一个

* {@link #workflow workflow}

* {@link #brand brand}

* {@link #status status}

* {@link #switch switch}

* {@link #user user}

* @return 标识的类型

*/

public int getidtype();

/**

* 获取标识的名称

* @return 标识的名称

*/

public string getidname();

/**

* 返回该identity的子类型,该子类型是给newinstance使用的

* @return 子类型

*/

public string getsubtype();

/**

* 通过id生成实例

* @return 实例

* @throws identitymappingerror 找不到生器异常

*/

public object newinstance() throws identitymappingerror;

}

=============identityimpl.java===============

package org.fswan;

import java.text.simpledateformat;

import java.util.date;

import java.util.hashtable;

import org.fswan.workflow.exception.identitymaphadexist;

import org.fswan.workflow.exception.identitymappingerror;

/**

* 唯一标识符类.

* 由唯一标识符可以调用相应的类来生成相对应的接口生成相对应的实例

* 不同种类标识符生成相对应的实例的类在{@link map}中进行映射定义.

* 可调用静态方法register进行注册.

*/

public class identityimpl implements identity

{

private string name;

private int type;

private string subtype;

/**

* 从id到类的映射表

*/

private static hashtable map = new hashtable();

public identityimpl(int type,string subtype,string name)

{

this.type = type;

this.subtype=subtype;

this.name = name;

}

public identityimpl genidentity(int type)

{

simpledateformat f = new simpledateformat("yyyymmddhhmmsssss");

string name = f.format(new date());

return new identityimpl(type,"",name);

}

/* (non-javadoc)

* @see org.fswan.identity#getidname()

*/

public string getidname()

{

return name;

}

/* (non-javadoc)

* @see org.fswan.identity#getidtype()

*/

public int getidtype()

{

return type;

}

public string getsubtype()

{

return subtype;

}

public string tostring()

{

return "["+type+":"+name+"]";

}

public boolean equals(object obj)

{

if(obj instanceof identity)

{

return this.getidtype()==((identity)obj).getidtype()

&& getidname().equals(((identity)obj).getidname());

}

return false;

}

/**

* 查找相应对的对象

* @return 实例化后的对象

* @throws identitymappingerror 映射实现不了,

* 可能是因为注册的类不存在或者无法实例化该类,或该类不是implementidentity

*/

public object newinstance() throws identitymappingerror

{

try

{

if(map.get(subtype)==null)return null;

implementidentity ids = (implementidentity)class.forname(map.get(subtype).tostring()).newinstance();

return ids.newinstance(this);

} catch (instantiationexception e)

{

e.printstacktrace();

} catch (illegalaccessexception e)

{

e.printstacktrace();

} catch (classnotfoundexception e)

{

e.printstacktrace();

}

throw new identitymappingerror();

}

/**

* 注册标识种类到生成实例类的映射

* @param type 类型

* @param obj 相对应的类名

* @throws identitymaphadexist 异常,(该类型已注册)

*/

public static void register(string subtype,string obj) throws identitymaphadexist

{

if(map.containskey(subtype)) throw new identitymaphadexist(subtype);

map.put(subtype,obj);

}

static

{

try

{

identityimpl.register(identity.dbbrand,"org.fswan.workflow.dbwrokflow");

} catch (identitymaphadexist e)

{

e.printstacktrace();

}

try

{

identityimpl.register(identity.dbstatus,"org.fswan.workflow.dbstatus");

} catch (identitymaphadexist e)

{

e.printstacktrace();

}

try

{

identityimpl.register(identity.dbswitcher,"org.fswan.workflow.dbswitcher");

} catch (identitymaphadexist e)

{

e.printstacktrace();

}

try

{

identityimpl.register(identity.dbworkflow,"org.fswan.workflow.dbwrokflow");

} catch (identitymaphadexist e)

{

e.printstacktrace();

}

try

{

identityimpl.register(identity.dbworkunit,"org.fswan.workflow.dbworkunit");

} catch (identitymaphadexist e)

{

e.printstacktrace();

}

try

{

identityimpl.register(identity.xmlbrand,"org.fswan.workflow.xmlbrand");

} catch (identitymaphadexist e)

{

e.printstacktrace();

}

try

{

identityimpl.register(identity.xmlgroup,"org.fswan.permission.xmlgroup");

} catch (identitymaphadexist e)

{

e.printstacktrace();

}

try

{

identityimpl.register(identity.xmlrole,"org.fswan.permission.xmlrole");

} catch (identitymaphadexist e)

{

e.printstacktrace();

}

try

{

identityimpl.register(identity.xmlstatus,"org.fswan.workflow.xmlstatus");

} catch (identitymaphadexist e)

{

e.printstacktrace();

}

try

{

identityimpl.register(identity.xmlswitcher,"org.fswan.workflow.xmlswitcher");

} catch (identitymaphadexist e)

{

e.printstacktrace();

}

try

{

identityimpl.register(identity.xmluser,"org.fswan.permission.xmluser");

} catch (identitymaphadexist e)

{

e.printstacktrace();

}

try

{

identityimpl.register(identity.xmlworkflow,"org.fswan.workflow.xmlworkflow");

} catch (identitymaphadexist e)

{

e.printstacktrace();

}

try

{

identityimpl.register(identity.xmlworkunit,"org.fswan.workflow.xmlworkunit");

} catch (identitymaphadexist e)

{

e.printstacktrace();

}

}

}

==================implementidentity.java=============

package org.fswan;

/**

* @author swan

* 通过id实例化相应的对象.

* 当用户自己实现user,role,group,brand等对象时,通过id来查找相对应的对象,

* 在类identityimpl对象中根据注册各种identity类型对应的instanceidentity对象

* 来实例化对象.

* 注意:该接口的子类的构造方法一定是public且不带任何参数.

*/

public interface implementidentity

{

/**

* 实例化id相对对应的对象.

* @param identity 要实例化的对象的id

* @return 对象

*/

public object newinstance(identity identity);

}

===========cantfoundidexception.java-==============

package org.fswan.workflow.exception;

import org.fswan.identity;

/**

* @author administrator

*

* to change the template for this generated type comment go to

* window>preferences>java>code generation>code and comments

*/

public class cantfoundidexception extends exception

{

public cantfoundidexception(identity id)

{

super("cant found id:["+id.getidtype()+":"+id.getidname()+"]");

}

}

==================identitymaphadexist.java============

package org.fswan.workflow.exception;

/**

* @author swan

*

* to change the template for this generated type comment go to

* window>preferences>java>code generation>code and comments

*/

public class identitymaphadexist extends exception

{

public identitymaphadexist(string subtype)

{

super("mapping had exist:"+subtype);

}

}

==================identitymappingerror.java============

package org.fswan.workflow.exception;

/**

* @author swan

*

* to change the template for this generated type comment go to

* window>preferences>java>code generation>code and comments

*/

public class identitymappingerror extends exception

{

public identitymappingerror()

{

super("the mapping class is not instanceidentity.");

}

}

=================typecastexception.java ============

package org.fswan.workflow.exception;

import org.fswan.db.field;

/**

* 类型转换异常,当从字符串转成特定类型出错时抛出

*/

public class typecastexception extends exception

{

/**

* 构造函数

* @param field 字段

* @param str 字符串值

*/

public typecastexception(field field,string str)

{

super(str+" cast to "+field + " error");

}

}

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 权限组件所缺的文件-JSP教程,资料/其它
分享到: 更多 (0)

相关推荐

  • 暂无文章