You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Tim W Wilson <tw...@us.ibm.com> on 2002/02/22 20:34:12 UTC
Struts vs. Java Faces (aka JSR 127)
Is there any opinion in the Structs development community about whether or
not the Java Faces work
from sun obviates the need for struts? JSR 127 spends a lot of time on tag
libraries but it apparently will
also tackle the page flow control issue as well.
Cheers
Tim W Wilson
Eclipse WSED Architecture & Development
internet: tww@us.ibm.com
(919) 254-0029 (TL 444-0029)
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Profiler
Posted by Dmitri Valdin <va...@freenet.de>.
Hello,
there are several profiling and monitoring tools which help you to find
bottlenecks in your application. I would like to propose yet another
pretty simple tool which does not intend to compete with professional ones.
The idea is very simple. All functions used in application are devided into
several big categories: SERVLET, ACTION, JSP, WEB, EJB, DAO.
ActionServlet class of Struts is modified to define SERVLET and JSP
categories (log4j can be used for this purpose) and add >>> and <<<
log messages for each request. Here I have subclass the ActionServlet:
private static Category s_oProf = null;
private static Category s_oProfJSP = null;
protected void process(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
String sURI = request.getRequestURI();
if (s_oProf.isInfoEnabled()) {
NDC.push(Long.toString(System.currentTimeMillis()));
s_oProf.info(">>> " + sURI);
}
try {
super.process(request, response);
} finally {
if (s_oProf.isInfoEnabled()) {
s_oProf.info("<<< " + sURI);
NDC.pop();
}
}
}
Pushing of timestamp in NDC helps you to differentiate between requests.
It works fine if web and ejb container is the same process.
Similar procedure for JSP pages:
protected void processActionForward(ActionForward forward,
ActionMapping mapping,
ActionForm formInstance,
HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
if (forward == null)
return;
boolean bJsp = forward.getPath().endsWith(".jsp");
if (s_oProfJSP.isInfoEnabled() && bJsp) {
s_oProfJSP.info(">>> " + forward.getPath());
}
try {
super.processActionForward(forward, mapping, formInstance,
request, response);
} finally {
if (s_oProfJSP.isInfoEnabled() && bJsp) {
s_oProfJSP.info("<<< " + forward.getPath());
}
}
}
Action class is also modified to include
if (s_oProf.isInfoEnabled()) {
s_oProf.info(">>> " + this.getClass().getName());
}
at the beginning of execute() method with corresponding
try {
.....
} finally {
if (s_oProf.isInfoEnabled()) {
s_oProf.info("<<< " + this.getClass().getName());
}
}
This we can cover all servlet requests and requests for JSP pages.
All other functions can be proceeded with the help of AspectJ
without of touching of source code. Example of such file is attached to this
mail.
Now we need to configure log4j:
og4j.category.STARTUP=INFO, MONITOR
log4j.additivity.STARTUP=false
log4j.category.SERVLET=INFO, MONITOR
log4j.additivity.SERVLET=false
log4j.category.ACTION=INFO, MONITOR
log4j.additivity.ACTION=false
log4j.category.JSP=INFO, MONITOR
log4j.additivity.JSP=false
log4j.category.WEB=INFO, MONITOR
log4j.additivity.WEB=false
log4j.category.EJB=INFO, MONITOR
log4j.additivity.EJB=false
# Configuration of MONITOR appender
log4j.appender.MONITOR=org.apache.log4j.RollingFileAppender
log4j.appender.MONITOR.File=${log.dir}/monitor.log
log4j.appender.MONITOR.MaxFileSize=5MB
log4j.appender.MONITOR.MaxBackupIndex=10
log4j.appender.MONITOR.layout=org.apache.log4j.PatternLayout
log4j.appender.MONITOR.layout.ConversionPattern=%-10r %-10c <%1x> - %m\n
and start logging in ActionServlet.init()
PropertyConfigurator.configure(sConfigPath);
// Get "profiler" category
s_oProf = Category.getCategory("SERVLET");
s_oProfJSP = Category.getCategory("JSP");
s_oProfStartup = Category.getCategory("STARTUP");
// Start profiling
if (s_oProfStartup.isInfoEnabled()) {
SimpleDateFormat formatter = new SimpleDateFormat("dd.MM.yyyy
'at' H:mm:ss");
NDC.push("*************");
s_oProfStartup.info("Monitoring started on " +
formatter.format(new Date()));
NDC.pop();
}
Now we can start the application and after some time have a look at monitor
files.
I have attached a sample monitor.log file and a profiler for watching the
results.
The profiler can be started with
java -jar profiler.jar
You should open the monitor file and you will see a tree with all requests.
You can walk through tree items and locate the chewing pigs.
Dmitri Valdin
Re: Struts vs. Java Faces (aka JSR 127)
Posted by Martin Cooper <ma...@tumbleweed.com>.
Try this link:
http://www.mail-archive.com/struts-dev@jakarta.apache.org/msg04372.html
--
Martin Cooper
----- Original Message -----
From: "Tim W Wilson" <tw...@us.ibm.com>
To: <st...@jakarta.apache.org>
Sent: Friday, February 22, 2002 11:34 AM
Subject: Struts vs. Java Faces (aka JSR 127)
> Is there any opinion in the Structs development community about whether or
> not the Java Faces work
> from sun obviates the need for struts? JSR 127 spends a lot of time on
tag
> libraries but it apparently will
> also tackle the page flow control issue as well.
>
> Cheers
>
> Tim W Wilson
> Eclipse WSED Architecture & Development
> internet: tww@us.ibm.com
> (919) 254-0029 (TL 444-0029)
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts vs. Java Faces (aka JSR 127)
Posted by "Craig R. McClanahan" <cr...@apache.org>.
On Fri, 22 Feb 2002, Tim W Wilson wrote:
> Date: Fri, 22 Feb 2002 14:34:12 -0500
> From: Tim W Wilson <tw...@us.ibm.com>
> Reply-To: Struts Developers List <st...@jakarta.apache.org>
> To: struts-dev@jakarta.apache.org
> Subject: Struts vs. Java Faces (aka JSR 127)
>
> Is there any opinion in the Structs development community about whether or
> not the Java Faces work
> from sun obviates the need for struts? JSR 127 spends a lot of time on tag
> libraries but it apparently will
> also tackle the page flow control issue as well.
>
I'm on the expert group for JavaServer Faces (JSR-127), and am very
familiar with the internal design discussions going on around this issue
(where does a UI components library leave off and an application framework
start?). How Faces is going to deal with it is not yet clear -- but, no
matter what happens, I strongly believe that there is a need for higher
level application control flows (such as what Actions do for you in a way
that is basically independent of the UI technology you select) even with
whatever Faces ends up with.
That being said, I would not be at all surprised to see Faces be the
preferred UI implementation technology (as opposed to the Struts tag
libraries) once it is standardized and available. I'm committed to make
sure that this is very conveniently accomplished with Struts.
> Cheers
>
> Tim W Wilson
> Eclipse WSED Architecture & Development
> internet: tww@us.ibm.com
> (919) 254-0029 (TL 444-0029)
>
>
Craig McClanahan
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>