Hello, every one. I'm an chinese, my english not good enough to express my
concepts fluently. say sorry first.
I would like to start an new idea project in which jsf ,page flow and work
flow are integrated seamlessly . it will use pageflow(or dialog) as the
user form interfaces for every human activity. Shale clay also acts as an
very important role to supply html template capabilities for form
designing.Developers can directly bind variables(/beans) of different
scopes to jsf component, such as workflow scope(long running, shall be
persistent), pageflow scope(may be only lived in session),and other
conventional scope(request, session, application).
Because its goal aim as an enterprise application, the performance should
be considered first.I had read some core code of myfaces and shale clay for
finding potential performance defects. so fortunately or my poor skill,
only some design look like performance defects.
the core thing of JSF processing can be understood as concentrating at
managing and consuming component tree(creating, iterating). while using JSF
in actual scenarios, component tree may grow larger and larger. so, too
many components would influence cpu consuming, and cause reponse speed
downward.
In every JSF lifecycle phase, walk through the whole component tree
depth-firstly every time in myfaces implement. if we have 500
components(children components already counted) in a page,we will iterate
every component 6 times at least (restoreveiw, applyrequest, validate,
updatemodel, invokeapplication, render), and all count is 500 * 6.
Apparently, in applyrequest and validate, updatemodel, invokeapplication
phases, if we directly mapping and find corresponded component to the
request ratherthan using children list and iterating all, we can execute
more quickly. Isn't it right ?
About shale clay, I find a improvable implement point. when clay parsing an
raw html template, it will divide every content between "<" and ">" and
make them as node tree, and then use builder pattern to transform them into
ComponentBean tree, and then transform into JSF Component tree again.But it
might well generate too many Verbatim HtmlOutputText components. for
example, to string "<li>a<br>b<br>c<br>d<br></li>", clay will eventually
generate ten HtmlOutputText component for it even thought it shall be only
one HtmlOutputText component. So, if we use large html template,it probably
create thousands of components , and cause serious performance problem, and
be enlarged largely because current JSF impl will iterate all components
over and over again. so , why do not we merge adjacent Verbatim components
to one ?
The other worry is about
"org.apache.shale.clay.config.beans.ConfigDefinitionsWatchdogFilter". this
filter will work in every request. so, if we have one hundred html or xml
templates, in every request there are also 100 dirty check for those files.
if we use URL obj to access files time property,i think it may be an
expensive and no-worthy operation. why do not we place watch dog dirty
checking work in an independent daemon thread and intervally check, i.e.
check every 1 minute?Of course, if we can use hotswap object when dirty
checking to assure thread safe, it would be more perfect.
the following code demo an hotswap design for file change monitoring. the
only limitation is that shall use getMap() first and once.
map idMap = getMap(), and latter use idMap variable through an request
thread. you can use weaked referenced variable and threadlocal to improve
the following demo further.
in clay, watchdog maybe hotswapable I think.
regards
aftermath
====================================================================
public class SecurIDUserAuthMechanism
implements UserAuthenticationMechanisms, FileChangeListener{
private static SecurIDUserAuthMechanism instance = new
SecurIDUserAuthMechanism();
private Map usr_mchnsm_map = new HashMap();
private Map usr_mchnsm_map_old = new HashMap();
private SecurIDUserAuthMechanism() {
}
public static SecurIDUserAuthMechanism getInstance() {
return instance;
}
public void fileChanged (File file){
load(file);
}
synchronized public boolean load(InputStream input) {
try {
Map temp = new HashMap();
BufferedReader reader = new BufferedReader(new
InputStreamReader(input,
"GB2312"));
String line;
while((line=reader.readLine())!=null) {
if (line.trim().length() > 0)
temp.put(line.trim(), "DYNAPASSWORD");
}
setMap(temp);
return true;
}
catch (Exception ex) {
return false;
}
}
synchronized public boolean load(File file) {
boolean success = false;
try {
FileInputStream in = new FileInputStream(file);
success = load(in);
}
catch (Exception ex) {
}
return success;
}
private synchronized Map getMap() {
return usr_mchnsm_map;
}
private synchronized void setMap(Map map) {
usr_mchnsm_map_old = usr_mchnsm_map;
usr_mchnsm_map = map;
}
public boolean isHasMechanism(Principal user, String mechanismName){
Map map = getMap();
if (map.containsKey(user.getName())) {
return true;
}
else
return false;
}
public boolean isHasMechanism(Principal user, SecurityLevel level){
return isHasMechanism(user, level.getSecurityLevelName());
}
public boolean isHasMechanism(String user, String mechanismName){
Map map = getMap();
if (map.containsKey(user)) {
return true;
}
else
return false;
}
public boolean isHasMechanism(String user, SecurityLevel level){
return isHasMechanism(user, level.getSecurityLevelName());
}
}
_________________________________________________________________
与联机的朋友进行交流,请使用 MSN Messenger: http://messenger.msn.com/cn
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]