J2ee patterns

Hi, anyone can tell me wich j2ee patterns are really necessary to learn, I'm asking so coz there many patterns already implemented in many framework. which of those should I learn for my future applications, thanx...

ramesh_bhojan wrote:
Well, all the design patterns are unique and may have their own advantages.....
However, as a beginner u may concentrate on Singleton pattern(which is actually a creational pattern) and the Factory Pattern.(The Factory Class)...
going forward.... u may learn bout the other design patterns available... as all of them are interesting in some way or other...Singleton has been largely discredited:
http://code.google.com/p/google-singleton-detector/
%

Similar Messages

  • Welcome to this forum on "Core J2EE Patterns" by the Sun Java Center

    Welcome to this forum on Core J2EE Patterns by the Sun Java Center!
    CONTEXT:
    This forum is intended for discussing the patterns from the Sun Java Center J2EE Pattern Catalog and other topics discussed in our book, Core J2EE Patterns.
    We, the authors of the book, welcome you to this forum.
    WHO WE ARE:
    We are Enterprise Java Architects from the Sun Java Center (SJC), which is the Java consulting organization of Sun Microsystems. We are a world-wide group of architects focusing on all consulting related to Java technologies.
    Visit our web-site for more information on SJC:
    http://www.sun.com/service/sunps/jdc/index.html
    BACKGROUND:
    Over the last few years, we at SJC have worked with our customers in architecting, designing, and implementing solutions on the J2EE platform. We have worked on documenting the J2EE patterns for over two years and released the patterns for public review in Beta form via the Java Developer Connection in May, 2001.
    The beta version of the patterns is available online as The Sun Java Center J2EE Pattern Catalog at:
    http://developer.java.sun.com/developer/technicalArticles/J2EE/patterns/
    Subsequent to the release, we received great feedback and comments from hundreds of reviewers. We then worked towards incorporating the feedback into the pattern documentation. One of the common comments was about the lack of code examples in the online documentation. The latest pattern documentation provides many code examples and incorporates all the feedback received so far.
    BOOK INFORMATION:
    Core J2EE Patterns, the book, was released at JavaOne 2001 during June 4-9, and will be available in stores around the end of June 2001.
    The book includes the complete updated Sun Java Center J2EE Pattern Catalog with 15 patterns covering these J2EE technologies: Java Server Pages (JSP), Servlets, Enterprise JavaBeans (EJB), and Java Message Service (JMS). In addition to the J2EE Pattern Catalog, the book also provides other chapters that discuss design considerations,
    bad practices, and J2EE Refactorings. Example code is included for all patterns and strategies.
    If you wish to view the complete table of contents or order the book, please visit one of the following online bookstores:
    Fatbrain.com: http://www1.fatbrain.com/asp/bookinfo/bookinfo.asp?theisbn=0130648841
    Amazon.com: http://www.amazon.com/exec/obidos/ASIN/0130648841
    COMMUNITY:
    The online community for discussing the patterns included in our book Core J2EE Patterns has grown over the past year, since our first presentation at JavaOne 2000. This community is supported by our LISTSERV and is available for public participation at:
    http://archives.java.sun.com/j2eepatterns-interest.html
    You can view the past discussions on this list at the above URL.
    FORUM LOGISTICS:
    John and Dan are on the east coast and Deepak is on the west coast. We will be tuned into the forum and answering the messages periodically between June 19 and June 25, 2001. If you want to discuss the J2EE Patterns after June 25, you are invited to join the aforementioned J2EE Patterns Interest list.
    FORUM DISCLAIMER:
    All responses to questions posed in this News Group are given on an "as is" basis. We believe the solutions or explanations given here are correct, but do not guarantee that responses will be complete, without error and/or work for all platforms and system configurations.
    The forum is now open! Let the discussion begin...
    John Crupi - Chief Java Architect
    Dan Malks - Enterprise Java Architect
    Deepak Alur - Enterprise Java Architect
    ---Authors of Core J2EE Patterns

    Rajakannan,
    There are numerous ways to implement a templating mechanism in support of the composite view pattern, included in the catalog as a presentation-tier pattern.
    The goal is to avoid simply having monolithic views with all the formatting code embedded directly withing the view. If we have common subviews that are shared across several or more views then we end up with a copy-and-paste type of reuse...undesirable. So, modularity is one issue. Another major force when considering the Composite View pattern is that we may want to manage the layout of our pages and the content of our pages separately. We may have some logical regions defined, such as a search panel and main body, and a subview that plugs into those logical regions that map to a physical page (ie: x.jsp and y.jsp). We may then want to vary one independent of the other...ie: we may want to modify the layout of the page w/o changing the content and we may want to vary the content w/o touching the layout.
    There are a number of implementation strategies that can be used to implement the Composite View pattern, ranging from relatively simple to much more sophisticated. We describe each in our book and include source code examples.
    The example in the book that allows for supporting all the issues described above is implemented using the "Custom Tag View Management Strategy" and uses a tag library written by David Geary, that supports the Composite View pattern. The library is also included in David's new book, Adv. JavaServer Pages, Prentice Hall, 2001.
    Again, it's simply one implementation and, as you mention, there are many different ways to implement this strategy.
    Thanks for your question,
    Dan

  • How to design using J2EE pattern?

    I am new to J2EE and I would like some ideas on how I should design the following system in J2EE pattern. I am required to use JSP pages + EJB to implement a very simple online shopping system. And I already created the following classes:
    This is the EJB object interface.
    package assignment;
    import java.rmi.*;
    import javax.ejb.*;
    import java.util.Vector;
    public interface ShoppingSystem extends EJBObject {
         public boolean LoginAsCust(String id,String pwd) throws RemoteException;
         public boolean LoginAsAdmin(String id,String pwd) throws RemoteException;
         public Vector getMusicCategories() throws RemoteException;
         public Vector getCategoryItems(String category) throws RemoteException;
         public MusicRecording getMusicRecording(String id) throws RemoteException;
    }This is the home interface.
    package assignment;
    import java.rmi.*;
    import javax.ejb.*;
    public interface ShoppingSystemHome extends EJBHome {
         public ShoppingSystemHome create() throws RemoteException, CreateException;
    }This is the session bean objects.
    package assignment;
    import java.rmi.*;
    import javax.ejb.*;
    import java.util.Vector;
    public class ShoppingSystemBean implements SessionBean {
         // data item to hold a reference to a passed Session context
         private SessionContext ctx;
         // save the session context
         public void setSessionContext(SessionContext x) { ctx = x;}
         // the various method implementations
         // imposed on us by interface
         public void ejbCreate() {}
         public void ejbActivate() {}
         public void ejbPassivate() {}
         public void ejbRemove() {}
         public boolean LoginAsCust(String id,String pwd) throws RemoteException{
         public boolean LoginAsAdmin(String id,String pwd) throws RemoteException{
         public Vector getMusicCategories() throws RemoteException{
         public Vector getCategoryItems(String category) throws RemoteException{
    public MusicRecording getMusicRecording(String id) throws RemoteException{
    }I will probably need to create a shopping cart class and a database accessor class. What I would like to know is , do I need to divide the shopping cart class into three components: Home interface, EJB object interface, SessionBean object.
    Please give me some ideas on how I can develop this system using EJB. (This is just a school assignment)
    Thanks.

    know is , do I need to divide the shopping cart class
    into three components: Home interface, EJB object
    interface, SessionBean object.Shopping cart is a typical example of a stateful session bean. So you need to write a session bean. And, of course, every session bean consists of three things: remote interface, home interface and bean class.
    Please give me some ideas on how I can develop this
    system using EJB. (This is just a school assignment)In this case you can tell them to fuk off.

  • Core J2EE Patterns - ActionMap XML

    I am reading through Core J2EE Patterns and I'm confused about a coupel fo thing and hoping someone can shed some light for me.
    1. I'm confused on how to actually implement the Map, refered to on page 208, which hold references to handles that represent target resoruces.
    2. In the example micro-architecture in chapter, page 603, references an XML file called HireEmployeeActionMap.xml. I believe this to be the action mapping file, but it's not clear how it is used. More imortant, the class in example 9.4 simply has a coment that I should "Get real commandstring from mapfile usign Action", while being helpful that it is included, is not so helpful if you don't actually know how to go about reading this XML file.
    More to the point, here is my task:
    I have a servlet (existing code from someone else) that I am going to refactor and make more expandable by implementing some of the J2EE patterns I've been reading about. My understanding of the patterns is varied, of course.
    This servlet does one basic thing. It accepts an HTTP transaction from an app that sends it request parameters (liek a form) to perform a specific transaction, of which there are about 12. Each transaction requests a different task to be peformed, of course. Speifically, data lookups in a various enterprise system or placing requests into various system queuss and such.
    Right now this sevlet has a huge if/else block checking for each transaction ID sent in the parameters and then calls a method to handle that transaction (calling delegates, facades, and services in the down path).
    I'd like to refactor this so that I have an CommandMapper that uses an CommandMap to map out each transaction ID to an Command class specific to that transaction. This way, I can write the application controller once and then when new transactions are needed, I simply add the new comand to the CommandMap XML file and add the new Command class (and delegates, facades, ejbs, etc.) and I'm done. No regression testing on the other transactions because there was no core code modified.
    So I went looking for exmaples of how to implement CommandFactory and CommandMap and I'm stumped. I also can't find any good examples of reading an XML file for this purpose. Any help would be greatyl appreciated.

    One more thought: my questions above have nothing to do with the classes and interfaces found in javax.activation. I'm going from the book mentioned above.

  • The "ValueList Handler" pattern in "Core j2ee patterns(2nd ed)"

    In the book "Core j2ee patterns(2nd ed)", it suggests that the "ValueList Handler" pattern can be used when the resultset from database is huge.
    Basically, this is what it will do:
    1) obtain a resultset from database query
    2) cache the full resultset using a valueList
    3) create a subList from the valueList
    4) present the subList to the front end
    To me, caching the full resultset in a valueList is no different from sending the full resultset to the front end. Both of them wasted a lot of resources. I am wondering why anyone would want to do the step(2) above. Why don't we go from (1) to (3) directly since we usually know which subset of the results the users are interested in even before we do the query.

    Hi
    Same problem I also need to clarify. Please some one
    explain in detail which approach give high
    performance.
    BR
    SenakaExactly, I don't understand why that "ValueList Handler" pattern qualified itself as a j2ee pattern since it has so much negative perfomance impacts.
    On a website like Amazon, thousands of queries are performed daily. To cache the full resultset of every query simply wouldn't work.
    I think the most efficient way is to write a disconnected resultset so it won't tie to the database. The disconnected resultset will only contains those data to be display on the front end.
    I would really like to see somthing like the following in the JDBC API.
    ResultSet rs = null; // some resultset
    ResultSetFilter filter = null;  // a filter to filter resultsets
    // obtain a disconnected resultset from java.sql.ResultSet
    DisconnectedResultset drs = DisconnectedResultset.filter(rs, filter);
    // close the original resultset
    rs.close();In the above, anything that meets the condition specified in the filter will be stored in the disconnected resultset. After we created a disconnected resultset, it is safe to close the original resultset to release any database resources.

  • Question of using Struts for the J2EE pattern

    I am now using Struts for the development. I have 3 questions about J2EE
    pattern by the use of Struts:
    1) How can I use Struts to create the Front Controller? In the book
    descibing Front Controller, it is a servlet file which receives the request
    and then dispatches to the appropriate view according to the request.
    However, in using Struts, should I use the same way? However, I found that
    in using Struts, I can call the controller class which subclass
    ActionServlet, all the views forwarded are declared in the
    struts-config.xml. Am I right in this method?
    2) In the project, there is a Front Controller which dispatches the request
    to the appropriate view (jsp file). Of course, I use Struts to do this.
    However, I expect that the user is impossible for going to the view (jsp
    page) directly by typing the address of the jsp file. I hope that the user
    can go to the view through the controller only. How can I do this?
    3) There is a problem by using browser - when a user browses a site, he can
    press the 'back' button to the previous page, and then click the 'forward'
    button also. How can I prevent this by using Struts? I found that in some
    sites, when the user clicks the 'back' button, an error page displays. How
    can I do this? Thanks!
    Many Thanks!
    Stephen

    I'll take a stab at number 2 and number 3.......
    2) You could have the controller object place a "flag" in the request that is dispatched to the JSP. Make the JSP check for that flag to ensure that this request came from the controller object. If the request comes from anywhere other than the controlle object, you can display an error page, or you could redirect them back to the controller. You could also use the HTTPSessionObject to place flags for users and have the JSP check there.
    3) Keep a log of the user's activities in the HTTPSession. Whenever a page is invoked, have it check to see if the user has already been here, and if it is appropriate for the user to be here again.
    Hope this helps!!
    I'm not really a java programmer, I just play one on TV.

  • J2EE pattern

    Hi,
    Is there any newsgroup for J2EE design patterns.
    TIA
    -VSK

    This may interest you:
    http://www.theserverside.com/discussion/index.jsp
    VSK wrote:
    Hi,
    Is there any newsgroup for J2EE design patterns.
    TIA
    -VSK

  • New J2EE Pattern

    Introducing Shine Pattern
    A brief history of Shine
    When we started to do a project we encountered an important problem. Developing a project with amateur developers is very dangerous. Because new developers don't care about some important things, and if the project manager, technical architect or head developer don’t care about those points, the project will fail.
    In 2008 the university manager to assess the student progress situation wants them to develop an enterprise project. Because most of students haven’t enough experiences in implementing software project, we did primary analysis and during implementing project we try to don't help them. Unfortunately output of the project was re-programming the project. This problem kept our mind busy for a long time until we try to create a standard and comprehensive pattern for completing a project. After doing this job we do many enterprise projects with this pattern and the result was 50% saving time of developing and extending the project. So we decided to offer this pattern for developers in SourgeForge website.
    The problems which make the projects to are:
    •     Not to follow a standard architecture
    •     Not to care about naming rules in forms, classes, pages...
    •     Creating useless classes in frameworks such as Struts, Spring and also JSF
    •     Using complexity classes
    •     Implementing logic layer in the UI layer
    •     Plethora of dependency on UI
    •     Gaffes of web designer
    •     Creating meaningless pages
    •     Not to care about security points
    •     Creating complexity in distributed application on the network by using RMI, Corba, JMS
    •     Plethora engaging with frameworks XML adjustments
    Shine's parts
    Shine pattern has been developed for variety of application. This pattern has these parts:
    •     Maplet: a framework for doing web projects which are coincidence with MVC architecture. This framework helps developers to follow a standard pattern for developing a web application. Maplet helps developers to save time of developing and extending.
    •     JShooter: a framework that makes reflects oriented programming an easy job for developers. Meanwhile it helps distributing application on the network.
    •     JConnection: This package helps developers to work with JDBC and Hibernate easier than before.
    •     Util: This package helps developers in these subjects:
    1-     File System
    2-     Runtime
    3-     Compiler
    4-     System Information
    5-     Web Socket
    6-     MD5
    7-     Thread
    8-     Validation
    9-     XML Parsing
    10-     Web uploading
    Suggestion
    Our suggestion is that before producing any new part for your application search our Util package. There are lots of classes in this package that help you in different fields. This package will be developed by java open source developers in every version of Shine.

    thanks for share.i like it . http://www.usedconecrusher.com
    Edited by: 783365 on 2010-7-20 下午6:23

  • J2EE Pattern  ...PLZ

    Hi
    Using IN DAO PATTERN, using Datasource Object should Is it necesary
    to i create Connectionn pool or not in case of EJB.
    with regards
    Karthik

    Using DataSource , Is it necessary to create
    te Connection pool or notIt's not necessary; it depends on whether or not you want pooling and whether or not the DataSource implementation pools its connections or not.

  • BC4J and J2EE Patterns (JNDI Datasource)

    Hallo Everybody,
    My Application reads from connections.xml the jdbc connection settings,
    in order to connect to the oracle database.
    I don't like the fact that I have to force my Customer to edit this File by Hand for the JDBC Settings.
    I would like to use a "JNDI Datasource Name" for example jdbc/MyDatabase that will evaluated
    from the Applicationserver (not from bc4j interal JNDI!!!!)
    In this case, the Customer can define the jdbc Connection Settings in his Applicationserver
    by creating a "Resource-Reference" for a javax.sqlDataSource with the name "jdbc/MyDatabase" .
    ( This is also Possible in Tomcat. )
    This is the usual way to configure jdbc Connections in a managed Enviroment.
    How can I say to the Applicaton Module "please obtain your jdbc-connections over the datasource java/MyDataBase" ???
    Is this in bc4j Framework possible ? ( note: I'm new to bc4j but not to j2ee )
    Thank for any Hint,
    regarts,
    Manolis
    (sorry for my bad english, learned it through compiler error messages ;-) )

    See
    Re: What software do I need to get started with GIS development

  • J2EE pattern for complex database searches

    I am havin trouble finding a method for doing complex searches that I am happy with.
    I have a table of "log entrys" - each "log entry" is composed of an "admin user", "action" and one or two "target" value objects, as well as a Timestamp.
    The problem here is a user, through a JSP form, will want to run searches such as "Get me all logs for user X between time Y and time Z involoing action A".
    What is the best way of encapsulating this between the Web Tier and the EJB tier (obviously, once it's in the EJB Tier, it's time to translate it into SQL in the DAO and send the query off to the database).
    Is it as simple as having a "Search Criteria" class containing many constants (e.g. SEARCH_BY_USER_ID, SEARCH_BY_MIN_TIME) and each instance of search criteria holding a map (e.g. "SEARCH_BY_USER_ID" => "BDTURNE", "SEARCH_BY_MIN_TIME" => "21st August") - or is there a better / neater way of encapsulating this call ?
    All ideas / suggesitons welcomed !
    Cheers,
    Ben Turner

    I think it is good Idea to have some constants like USERID, MINTIME, etc and can dynamically formulate the Query depending on the Data you are getting.

  • 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 Decorating Filter Design Pattern

    I have been reading a little bit about J2EE patterns on Sun's web site
              (URL at bottom). The design pattern called "Decorating Filter" involves
              creating servlets that are always executed before and/or after all
              servlets.These always-executed servlets do things such as request
              logging and security.
              The idea sounds really nice to me. You can do a lot, without putting
              code for logging or security in the servlet that people actually
              requested. So, you could request a servlet, but these other servlets are
              executed before/after it automatically.
              Is there a way to do this in WebLogic? Is this "servlet chaining"?
              Thanks,
              Mike
              

    Mike,
              Checkout 6.1 it has filters implemented as part of servlet2.3 spec.
              http://e-docs.bea.com/wls/docs61///////webapp/filters.html
              Kumar.
              Michael Olivieri wrote:
              > I have been reading a little bit about J2EE patterns on Sun's web site
              > (URL at bottom). The design pattern called "Decorating Filter" involves
              > creating servlets that are always executed before and/or after all
              > servlets.These always-executed servlets do things such as request
              > logging and security.
              >
              > The idea sounds really nice to me. You can do a lot, without putting
              > code for logging or security in the servlet that people actually
              > requested. So, you could request a servlet, but these other servlets are
              > executed before/after it automatically.
              >
              > Is there a way to do this in WebLogic? Is this "servlet chaining"?
              >
              > Thanks,
              > Mike
              

  • Patterns used in J2EE Blueprints

    Does it specify anywhere exactly what patterns are used in the Blueprints and what components/beans/classes map to each pattern ?
    Thanks very much
    P.

    Go to http://developer.java.sun.com/developer/technicalArticles/J2EE/patterns/ and click on J2EE Patterns Catalog for a better explanation of the patterns and how/when to use them. These are based on the book Core J2EE pattrens- Best practices and design strategies. You can download example source code from http://www.phptr.com/corej2eepatterns/

  • Using the BusinessDelegate pattern at lower levels

    I was hoping to elicit some feedback on general J2EE architecture...
    We have an application that we separate into three general tiers: web/client tier, service tier (with 'services' that implement business logic) and a data tier (with 'controllers' which basically implement CRUD (create, read, update, delete) for a single domain object or table). We have this thing called a 'manager' that straddles the service and data tier which also implements CRUD, but at a more coarse grained level. Managers allow us to work with big objects that are actually a composition of small objects.
    Our services and managers are almost always implemented as session beans (stateless) so the client tier uses a "Business Delegate" as per Sun's J2EE patterns to hide the implementation details of those services and managers. So a given call in the system would look like:
    Struts action class -> business delegate -> manager or service -> controller -> entity bean
    Managers and services, when they need to work with persistent data then use controllers to get at that data. Most controllers are currently session beans (stateless), but we are starting to add controllers that implement the DAO pattern.
    I'd like to hide the implementation details of those controllers from the managers and services that use them, though. I hate seeing code in managers/services where we use ServiceLocator to look up a home interface, create the EJB controller and then do method calls.
    My question is whether it's possible and appropriate to use a BusinessDelegate between two session beans such as our 'managers' and 'controllers'. Doing so would make a given call in the system would look like:
    Struts action class -> business delegate -> manager or service -> business delegate -> controller -> entity bean (if used). Would you loose the transaction between manager and controllers (managers always use Required for each method and controllers use Supports - as well, controllers only ever expose a local interface).
    Thanks for any advise/opinions you might have.
    Donald

    In your framework, does each delegate become a single
    InvocationHandler instance
    Yes, exactly.
    with (for instance) a
    constructor that does the EJB lookup and an invoke()
    method?
    EJB lookup is being done by a ServiceLocator.
    Do you have ServiceLocator return the proxy object (I
    know that traditionally ServiceLocators merely return
    EJB home interfaces,
    My does the same. But it's used by EJBDelegateFactory, which creates EJBDelegates.
    EJBDelegates implement InvocationHandler and support InvocationDecorators.
    but I have used them to return
    POJO implementations of interfaces so it becomes a
    kind of implementation factory).
    Nice idea. I have POJOLocator for that.
    Do you have your Proxy object implement the EJB
    interface, rather than creating a new one.
    Yes. The only drawback is that client code needs to catch EJB specific and remote exceptions.
    However it's not a big problem, because there is a decorator which catches all EJB exceptions and throws BusinessDelegateException with a user-friendly error message inside. This means that EJB interfaces need to declare BusinessDelegateException in throws clauses, but it doesnt cause any problems.
    So client code is something like:
    try {
          foo.invokeSomeMethod();
    }  catch (BusinessDelegateException  ex)
         displayErrorMessage(ex.getMsg);
    }   catch  (Exception ex)
          //   can be empty
    I have
    been thinking about creating a new one and then seeing
    if I can change xdoclet's templates to have the EJB
    interface extend this interface.
    I have used this idea, too. I think it's even called a pattern. You can make EJB bean to implement this interface and then you have compile time checking of EJB compliance.
    I remember I had problems with that when some CORBA client stub generator got confused.
    Thanks for any little advise you can provide.
    Maybe I will even put my framework as OS in WEB. If my client will allow me to do it.
    best regards,
    Maris Orbidans

Maybe you are looking for