performance tuning for JSF [closed] - java

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
Can any one list out the tips to tune JSF WebApp # its best.

JSF RichFace
Never put logic into your getters.
They are called multiple times and
should only return something already
populated by another method. For
example if you are chaining drop-downs
together use an a4j:support tag on the
first one with an action attribute
that loads the data which is then
retrieved when you reRender the second
one.
Use the ajaxSingle="true" unless
you actually want to send the whole
form back to the server.
Don't use a
rich component if you only need a
normal one. For example don't use
rich:dataTable unless you are making
use of some of the features that it
has over and above h:dataTable.
Consider using immediate=true
attributes on elements where you do
not need validation Avoid displaying
large tables to user.
Use pagination
Do not over complicate EL expressions,
code them in Java in backing bean
JSF BestPractices
Performance Tuning

Moving to Stateless JSF would offer a great performance boost. Now it's possible to use JSF entirely stateless. See this blog & this issue. A payoff is that you can't create views dynamically (e.g. by binding, JSTL tags, etc), nor manipulate it after creation.
A Stateless JSF operation mode
would be incredibly useful for high-load applications and
architectures:
http://industrieit.com/blog/2011/11/stateless-jsf-high-performance-zero-per-request-memory-overhead/#comment-4
This has previously been suggested by Jacob:
http://weblogs.java.net/blog/jhook/archive/2006/01/experiment_goin.html
This would help JSF ditch the stigma of "slow and memory hog," and
help keep up with current tech trends (stateless architectures.)

Related

which database for java to store data in memory? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
I'm looking for a database which would allow me to store most of the objects in the memory. Basically I want to store in the memory everything except some rarely used data (history of changes, etc).
I'm looking for:
simple API for java, preferably non-ORM
ACID is not required (well, D is)
some support for queries, but nothing fancy
The idea is to operate on a model in memory, store any "command" mutating the model in the database, periodically synchronize model to database (like prevayler does)
Which database matches my needs? (I'll use postgres or H2 if there isn't anything simpler).
You need one of object databases: http://en.wikipedia.org/wiki/Comparison_of_object_database_management_systems
You should use Terracotta. It is usually used for caching, but its exactly what you are asking for, except that it's "querying" abilities are sparse.
Update:
The previous link was to their "enterprise" edition, but they have the open source project Ehcache which fits your needs, and their enterprise product is based on.

What method to use to make a Servlet thread-safe? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I am trying to make a servlet thread-safe with sessions. I have read up on different techniques such as a synchronized block, AtomicReference or ConcurrentHashMap. What are the trade-offs for each technique, if any?
The first aim for a servlet is to achieve thread safety by virtue of no shared state. Any shared state will fail to be that when the servlet is deployed into a load-balancing cluster. So if your shared state is not of a cache flavor, meaning it can always be rebuilt from a durable store, you shouldn't have it in the first place.
But, apart from these concerns, you cannot get a one-size-fits-all answer without giving any details on the problem you are trying to solve with shared state. All the techniques you mention have merit, that's why they are still around with us after 15 years of experience with Java.
A servlet should not have state, i.e. instance or static variables that are affected by its request processing methods anyway (additionally its request processing methods should not affect the state of any shared objects). There is only one servlet instance per servlet container and each request is processed using a new Thread that runs the appropriate Servlet method (more commonly doGet() or doPost()).
However, the servlet API provides all the functionality required to store data with respect to a specific user session in a thread-safe manner out of the box. For instance, you could get the session by HttpServletRequest#getSession() and use its setAttribute() method to store objects in the specific session and getAttribute() to get them back on another request of the same session.
Hope this helps.
First of all, servlets should be stateless, which is good for the scalability of application. Actucally, Session Object based on Servlet API is highly extendable, you can write your own HttpSession implementation to make the Session access thread-safe.
IMHO, you should provide some more details of your scenario, because in those data structures you mentioned above, the last two seems have nothing to do with the thread-safe access of Session.

Is velocity templates good for evaluating conditions? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I am thinking about externalizing some conditions instead of implementing them in java so that I can easily change them later as needed.
For example, I need to check if certain keys exist in a given map and if the values of certain keys in a map equal to something.
I was thinking about using spring's expression language, but since we are already using velocity templates, I thought maybe it is a good candidate.
Any idea? Thanks.
You can easily use the #if/#else, #foreach and other condition functionality of velocity to do business logic as part of the velocity template rendering.
However I usually try to separate business logic from rendering in velocity for a number of reasons:
Complexity: The Velocity template can become hard to read, especially
if the target output itself requires complex resulting layout. If you
add additional business logic to the mix, it quickly becomes
impossible to read for anybody else (or for yourself after a few
months of not looking at it constantly)
Testability: It's harder to test Velocity templates, there's
better support for unit/integration testing of Java code
Functionality: Velocity is not a full programming language by
design, so you will miss some things sooner or later and a macro
simply is not a function, e.g. variables by default have global
scope, ... You are bound to run into some of these if you make
your templates big and complex.

Where can I find tasks for using patterns [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
There are a lot books/online resources about using patterns. But I didn't find any tasks for using it. But for good understanding of patterns it's need practice. Maybe someone faced with some resources where there are tasks for using patterns.
For example. Mediator pattern:1)write chat application where...
Thanks in advance.
UPDATE:
I found:
http://www.cs.sjsu.edu/~pearce/modules/labs/patterns/
How to study design patterns?
I'll give you five, with easy and/or moderate difficulty:
Singleton
easy: single database access class for the entire application.
Factory
easy: English-to-another-language translator. I need to be able to add and then access a new language translator with minimal code changes.
Observer
easy: Central data structure that has several copies within the application that need to be updated automatically when a change to the main DS occurs.
moderate: Make this work over a network with cooperating processes updating a central data structure.
Memento
easy: A simple game with the ability to save/load.
Decorator
easy: A simple persistence class with read/write ability. I want to be able to dynamically switch between XML or database persistence.
I know only of one such resource, and it is not formulated as you have specified, but maybe it'll help a bit: In the last chapters of the Head First Design Patterns book, the MVC pattern is explained as a compound pattern, involving several others : Composite, Strategy, Adapter etc.
It is explained with the help of a small application. You could look up the chapter and build the described to practice.
Ever use an iterator? Pattern. My guess is you use a lot of patterns without even really realizing you're using them. Created a buffered reader out of a file reader? Decorator; pattern. Don't set out trying to use patterns--let the problem discover them. They're everywhere, that's why they're patterns.
Things like facades, decorators, iterators, factories, etc. crop up in every single domain. Pick anything you're interested in writing, and discover the patterns already present. Refactor mercilessly--patterns.

Best strategy to multiple CRUD with jsf [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
on my company we are developing a ERP-like app using java and jsf, so far the design team has identified about 20 entities,each with diferent properties, usually we'll be building 20 pages of CRUD , is there any better way to do this?, we are using hibernate as db access, so we came up with the idea of a single DAO for this part of the system, have you faced a similiar situation? what are your thoughts on it?
You really should look into Seam. It has a feature called Seam-Gen that will reverse engineer your entire application CRUD pages from the database. You can edit the Seam-Gen templates (which are based on Freemarker) to customise the pages that will be generated to your liking.
I use the Eclipse plugin Azzurri Clay to model my database and generate the DDL. I then run Seam-Gen and in a few seconds you have a running application. It's a very handy combination.
You might consider codegenerating those 20 screens, much like scaffolding in Ruby does. As far as DAO is concerned, you might pull CUD operations to some generic IBusinessObjectDao, leaving specific R operations (querying by various parameters) to concrete DAO implementations.
I know its late, but I think my little framework would fit this situation perfectly. Check out http://code.google.com/p/happyfacescrud/ . It has search out of box, custom components that recognize datatype of entity, lazy datamodel, and flexibility that code generators can not offer. Here is little sample how page with lazy datatable and search would look like:
<hf:searchPanel columns="4" backingBean="#{accountBean}">
<hf:searchField label="#{messages['account.accountNumber']}" field="accountNumber" />
<hf:searchField label="#{messages['account.active']}" field="active" isMessage="true" />
<hf:searchEntityField label="#{messages['account.customer']}" field="customer" childField="name" popup="true" />
<hf:searchField label="#{messages['account.openingDate']}" field="openingDate" rangeSearch="false" />
</hf:searchPanel>
<hf:dataList label="#{messages['account.search.results']}" backingBean="#{accountBean}">
<hf:column label="#{messages['account.accountNumber']}" field="accountNumber" />
<hf:column label="#{messages['account.active']}" field="active" isMessage="true" />
<hf:column label="#{messages['account.customer']}" field="customer" childField="name" entityView="/pages/customerEdit.xhtml" popupFields="email,phone,address" />
<hf:column label="#{messages['account.openingDate']}" field="openingDate" isDate="true" />
<hf:actionsColumn />
</hf:dataList>

Categories

Resources