J2EE Design Patterns
If you don't have SessionFacade pattern implementation,is it possible to have a Business Delegate talking to a Session Bean
Thanks in advance
yes its possible
Similar Messages
-
JavaBean Models, Command Bean and J2EE Design Pattern
Hello,
I have read the available "How To", Using EJBs in Web Dynpro Applications where the author mentions that one should use a Command Bean (according to J2EE Design Patterns) so that one can invoke business methods in a Session Bean from our Web Dynpro Application. Well, although, I have read some available articles in the internet about J2EE design patterns, I still have some questions about command beans and its usage in Web Dynpro applications.
I have developed a WD App which uses EJBs to read data from the DB.
Let's suppose I only have two tables: BOOKS and AUTHORS.
Lets also suppose I have to Entity Beans (one for each table) and a Session Bean with two methods: Book[] getAllBooks() and Author[] getAllAuthors();
I also have a Command Bean which I imported in my WD App.
My questions are:
How should I design my Command Bean?
Can I have only one Command Bean with two methods each calling one of the methods of the Session Bean?
Or instead should I design two Command Beans, one for each call?
In the last case do the methods must be named <b>execute</b> or can I name them whatever I want?
Furthermore, how should I store the data in my command bean? In instance variables?
If so, can I use array of a class representing a record in the database table (for instance, classes Book and Author) or do I have to store the data in a generic collection (such as ArrayList for instance)?
I ask this last question because if I try to store the data in an array when I am importing the Command Bean as a JavaBean model I always get an error.
One last question: Can the Command Bean execute method directly return the data or should I always store the data in an instance variable an then get it using getter methods?
I know this questions are more about J2EE Design Patterns and JavaBeans specification than they are about Web Dynpro but I also have doubts about the rules that the command bean must obey in order to accomplish a successful JavaBean model import in WD.
Some guidance or tips would be highly appreciated.
King RegardsI have the same problem.
Does anyone know the solution?
Thanks
Davide -
Suggest good book for J2EE Design Pattern.
Is there any good book for J2EE Design pattern? I know Head First Design Pattern book, but is focuses oncore java. I want to learn in detail with examples J2EE design pattern.
Please suggest good books.
Thanks in advance.
Rahul.most j2ee patterns are discredited now. they were mostly workarounds for deficiencies in ejb 1 & 2 specs.
"core j2ee patterns" is your best bet, but take it with a grain of salt.
better to learn spring, IMO:
springframework.org
% -
J2EE design patterns vs SAP component model
Hello,
does anyone have documentation or articles which makes a link between the J2EE design patterns and the SAP component model ?
ThanksHi Thierry,
> What do you mean by assembling DC's into another DC ? Do you mean by using child DC's? Also , the J2EE server DC will have to be in a SC.
If you create "Java" DC that DC will not have a deployable result on its own. Typically you create a public part with purpose "compilation" (API) and a public part with purpose "assembly". If you define a dependency from an EAR DC or a J2EE Library DC to that assembly public part then the Jar file contained in that public part will be assembled into your (deployable) .ear file or the J2EE library.
Child DCs are just a means of limiting visibility/scope, similar to ACLs.
As long as you are working with a "track" each and every DC will be part of an SC. You define a track, you add "developed" SCs, you get a "compartment" where you can create DCs. So each DC automatically belongs to an SC. (But not all DC types produce deployable results, EJB Module/Web Module also need to be assembled into an EAR).
> is it typical to have an SC dedicated to utility classes?
Depends on the size of the project/product. I'd start by putting utility classes into some utility package (pure Java). If that gets too large I'd put utility classes sorted by functionality into DCs (Java libraries = jars). If that gets too large its time to think about utility SCs. Otherwise the tradeoff between meta-information and real content might be too much. As the project/product grows the need for refactoring may arise...
Regards,
Marc -
what's the role of the handle in the business delegate pattern sequence diagram
Hi,
If I get it clear, the String version of handle can be used to reconnect the business service. An example can be found there:
www.javapassion.com/j2ee/DesignPatterns.pdf
Hope this helps.
L.P. -
Hi,
I understood the structure of DAO pattern like : The business Object uses Data AccessObject which encapsulates the DataSource. The DAO creates/uses the Transfer Object and the BusinessObject obtains/modifies the Transfer Object.
Can i get the sample code for this pattern and any links for the code.
ThanksHi,
I understood the structure of DAO pattern like : The
business Object uses Data AccessObject which
encapsulates the DataSource. The DAO creates/uses the
Transfer Object and the BusinessObject
obtains/modifies the Transfer Object.
Wrong.
Can i get the sample code for this pattern and any
links for the code.
ThanksYou should be able to take it from there if you understood it that well. Too bad you don't
% -
Recommanded J2EE design pattern
I have a program with the following design:
one WebService
which calls one EJB (Session bean).
The EJB is calling one of 9 STATIC(!) methods (depends on parameter that webservice accept) which can call another static methods etc...
I know this design is bad, and I want your recommended design for this application.
I am getting an outOfMemory exception when i run a loop that calls this webservice for many time.
Is there any design which may help me avoid this outOfMemory exception ?
Again , please refer this:
** one webservice
** one ejb who calls to static methods - depends on parameter that webservice accept.
ThanksHi duffymo, Thanks for attentionHi George, it's my pleasure. Maybe we'll both learn something here.
answers :
1) its a stateless session beanVery good. Any private data members in that SLSB?
2) The out of memory error happens when i am running
the application from 150 clients repeatly as a load
testAre you monitoring memory using a tool like JVMStat from Sun, OptimizeIt, or JProbe? I'd recommend it.
How much memory have you allocated to the JVM? What are the -Xms and -Xmx settings? Have you tuned any other JVM settings for memory and GC?
3) you say : "none of these objects can be GC'd" ,
why is that ?A static object is associated with a class. Once a class is loaded by the JVM it's never unloaded. The static objects will remain in memory for as long as the class does.
4) The stack trace shows an outOfMemory exception and
can happen in any phase, after ~X times.(depends on
free JVM memory).Objects aren't being cleaned up. You're hanging onto references, so the GC can do its job.
5) I can't run a profiler on this machine because of
a technical reasons.You can certainly run JVMStats. It's non-invasive.
6) I indeed saw the perm space growing with systemout
methods
The big question is about the coding,
1) is there anyway to improve this kind of code
writing ? Undoubtedly yes.
2) Will the GC run better if these methods would be
running from a nonstatic source ? should i write
classes for these methods and invoke an object for
each call ? If the methods are all related, differentiated only by a parameter, why have nine objects? Why not one SLSB with nine methods?
3) Should i write 9 SLSB and let the webservice
decide which one to call ? or should i write one SLSB
with 9 methods and let the webservice
decide which method to call ? I'd try the latter.
are the 3 questions above have anything with
memory/GC performance ? I don't know without more info.
% -
Simple J2EE Design patterns for newbies
Hey
I've managed to get a basic understanding of how J2EE web applications are put together. I've done some simple stuff like jsp's posting to servlets to do database inserts for example.
In an effort to get a more well rounded understanding of whats going on I want to write a simple phonebook web app. As my previous adventures in web development have been php pages that mixed php and html. I really want to get away from the bad habits that people say PHP can encourage and get a proper MVC setup going. I'll describe my plan and then all you guys can rip it apart and hopefully in the process I will learn something Smile
In the case of a user wishing to insert a new record. I imagine the process to be the following.
JSP/HTML form that posts to a servlet, the servlet then uses a bean to handle the database interaction and once the bean has finished the jdbc work the servlet forwards the user to another jsp that displays the current contents of the table.
So, for example I will write a bean that has 4 methods. One to read the full contents of the table, one to insert a new record, one to update and finally one to delete.
Depending on what parameters are passed to the servlet via HTTP POST it will call the corresponding javabean method.
Am I on the right track?
ThanksOk well this is what I have come up with so far
Servlet
public void doGet (HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException
out = resp.getWriter();
String action = req.getParameter("action");
String name = req.getParameter("name");
String phone = req.getParameter("phone");
DbWorker db = new phonebook.DbWorker();
if (action.equals("insert")){
db.doInsert(name,phone);
} else if (action.equals("delete")){
db.doDelete(name,phone);
} else {
out.println("you didnt ask me to do anything");
} And the "Bean" it uses to do the database work is below. Note: The term java bean is used all in all the books and online forums I have seen. Whats so strange about its use today (just curious). Anyway the db stuff
public void doInsert(String name, String phone){
String query = "Insert into test(name,email) values(?,?)";
try{
PreparedStatement stmt = con.prepareStatement (query);
stmt.setString(1, name);
stmt.setString(2, phone);
stmt.executeUpdate();
} catch (SQLException e){
public void doDelete(String name, String phone){
String query = "delete from test where name = ? and email = ?";
try{
PreparedStatement stmt = con.prepareStatement (query);
stmt.setString(1, name);
stmt.setString(2, phone);
stmt.executeUpdate();
} catch (SQLException e){
} The code above works without any problems. However I now want to write a method to execute a select statement and I want it to be able to return the results to a jsp that can then iterate through and print out the results. My guess is that i create a method to return the resultsset array that a jsp page picks up by using the standard tag library to go through it and print out the results? -
SERVICE LOCATOR ?? Is it really an interesting Design pattern??
Hi everybody,
i've a problem with the J2EE Design Pattern "Services locator" (it's a singleton).
It is said that by making use of a Service Locator we can :
- hide to the client the complexities of initial context creation, EJB home object lookup,and EJB objectre-creation.
- multiple clients can reuse the Service Locator object to reduce code complexity, provide a single point of control, and improve performance by providing a caching facility.
But i would like to understand at which side should that service locator object reside??!!??
If it is at server side then the clients need well an initial context in order to make a lookup on that object.
Conclusion :
the service locator doesn't hide the complexities of initial context!!
Furthermore the client has to perform a look-up on that service locator object!! The only advantage left is caching facility.
If it is at client side, each client needs his own services locator object
Conclusion :
multiple client don't reuse the same service locator. What's the advantage to be a singleton ???
There is certainly something that i don't understand so help me please!! Thanks.Hi Yves,
But i would like to understand at which side should
that service locator object reside??!!??
If it is at client side, each client needs his own
services locator object
Conclusion :
multiple client don't reuse the same service locator.
What's the advantage to be a singleton ???The service locator resides on the client side and is implemented as
a singleton. Since it is possible that there could be multiple
class loaders/JVMs on the client side, and therefore, multiple
instances of the "singleton" service locator. This is typical
in a distributed environment (e.g. servlets/JSPs in a web-tier
cluster using service locator). Thus service locator is not
a truly "distributed singleton" object. But, the empahsis
is to design the service locator such that it does not hold
any state that needs to be replicated across multiple
instances across different JVMs as mentioned. Thus, there
is no need for multiple clients to use the "same" service locator,
but still the benefits of implementing this pattern is realized.
By making it a singleton, and keeping it from holding state
that needs to be replicated, we realize the benefits of this pattern.
You may also want to visit the J2EE Pattern interest list
and see these relevant discussions :
Topic: Service Locator and passivation
http://archives.java.sun.com/cgi-bin/wa?A2=ind0106&L=j2eepatterns-interest&F=&S=&P=1026
Topic: Caching EJBHome interfaces
http://archives.java.sun.com/cgi-bin/wa?A2=ind0106&L=j2eepatterns-interest&F=&S=&P=9226
Topic: Using Service Locator for Data Source caching
http://archives.java.sun.com/cgi-bin/wa?A1=ind0106&L=j2eepatterns-interest#31
hope this helps,
thanks,
-deepak -
Hi guys,
I want to start learn j2ee design pattern , i browsed net but not got any significant point from where i can start. could anybody suggest me from where should i start .
Thanks in advanceThe Design Patterns Java Companion
Head First Design Patterns
Huston Design Patterns
Overview of Design Patterns
~ -
Greetings, I am attempting to build a JSF application while learning JSR 127 and a few of the J2EE design patterns. The problem that I am having is that I don't plan on using EJB/Spring with my project and many of the tutorials I have been able to find place a focus on the EJB/Spring implementation details which are both overkill for this project. That said, I want to learn the appropriate patterns to build a functional application without catching "pattern fever".
I have a general idea of some of the patterns I need to use to get from the presentation tier to the data tier, such as Business Delegate and Data Transfer Object. However, I'm not sure I understand how to use these in conjunction with the managed beans facility. Do the managed beans contain (as in composition) the Business Delegate objects? Or do I use a DTO to push the data from the managed bean to the Delegate? How much if any logic do I put in the managed beans if I'm using them in this fashion (or are they basically just fields and getter/setters)?
All comments or suggestions are sincerely appreciated,
JonHi,
Have you taken a look at Java BluePrints Solutions Catalog:
https://blueprints.dev.java.net/bpcatalog/
The Solutions Catalog focuses on different topics specifically so that you can pick and choose which articles are most interesting to you.
-Larry -
Hi,
I am new to these forums.
I know that there are 4 types of J2EE Design Patterns.
1. Fundamental
2. Structural
3. Creational
4. Behavioral.
Hope that's correct. Can anyone plz tell me what's the difference between them?
Also, examples for them. ie; Under which category mentioned above, patterns like Singleton,ServiceLocator,Session facade, DAO,DTO etc fall?
Thanks in advance.BigDaddyLoveHandles wrote:
Kumaari wrote:
Please give me some explanation in your words.
Thanks in advance.In software engineering, a design pattern is a general reusable solution to a commonly occurring problem in software design. A design pattern is not a finished design that can be transformed directly into code. It is a description or template for how to solve a problem that can be used in many different situations. Object-oriented design patterns typically show relationships and interactions between classes or objects, without specifying the final application classes or objects that are involved. Algorithms are not thought of as design patterns, since they solve computational problems rather than design problems.
Not all software patterns are design patterns. Design patterns deal specifically with problems at the level of software design. Other kinds of patterns, such as architectural patterns, describe problems and solutions that have alternative scopes.
Better?
Brilliant. Bravo sir, bravo -
Hi friends!
i need j2ee design patterns in a single pdf. But in Blueprints section, the design pattern catalog consists of separate link.is there is any link to download design pattern in single pdf?
Please inform me
regards.,
sekarhttp://www.patterndepot.com/put/8/JavaPatterns.htm
-
A good book on design patterns?
Hi there. Just wondering if anyone could recommend a good book on design patterns, for someone who's relatively experienced at the nuts and bolts of programming in a few languages, but hasn't really considered design patterns before? Someone recommended Gamma et al's, 'Design patterns: elements of reusable object-oriented software' to me, but it is perhaps a little dated now. Any thoughts?
Surprisingly, no one posted the link to the Sun J2EE Pattern blueprints:
http://java.sun.com/blueprints/corej2eepatterns/index.html
I also liked the O'Reilly publication "J2EE Design Patterns"
They are specific to J2EE architecture, but there's a lot of reuse available even if that's not the architecture you're working with.
Brian -
Suggestions regarding corej2ee design patterns
hi all
i wanted to go through the core j2ee design pattern but i don't know which one to refer and what to
so i need suggestions that what to read in a design pattern
and which is the best book or pdf if possible send me the link tooCore J2EE patterns are not what they were. A lot of them would be considered anti-patterns, work arounds for deficiencies in the EJB 1.0 and 2.0 specs that have been addressed in EJB 3.0.
The "Core J2EE Patterns" (Amazon.com search will find it) sounds like what you want.
%
Maybe you are looking for
-
Mail "Home Directory is Full" again
Allan Sampson said on 6th July 2006 "With the Mail.app quit and using the Finder, go to Home > Library > Mail > Envelope Index. Move the Envelope Index file to the Desktop. After doing so, copy the Mail folder and place the copy on the Desktop for ba
-
Can any one help me get rid of a deleted app 4oD that still appears in the Settings list. I deleted it from the home screen and Spotlight search confirms it has gone. It is causing problems because I get notified of updates and I cannot get rid of th
-
Today's Esoterica: What are the Differences between Tint, Tint, and Tint?
There are three controls in Aperture named Tint: - The lower half of the "Temperature and Tint" panel in the White Balance Brick. - The eponymous section in the Enhance Brick - The eponymous Quick Brush, which, when used, creates a Tint Brick. Are th
-
Bought a different phone, now Palm says they can't give me my Memos
I had a Palm Pre until yesterday. I just had too many little pproblems with the Palm Pre, disappointing. I went to my local Sprint store and changed it for a HTC Hero. The Sprint employees were able to transfer my contacts and calendar (because
-
Oracle Forms Personalization - Menu Icon
Hello, hopefully a quick question. Looking at forms personalization and want to add a new menu item. I can achieve this using Forms Personalization no problem. My question is regarding the 'Icon Name' field for the Action Type of Menu. I understand t