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

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.

  • How can i view and apply new custom patterns without going to preset manager? i had this facility but have now lost it

    how can i view and apply new custom patterns without going to preset manager? i had this facility but have now lost it.  i design patterns but am fairly new to photoshop. i used to be able to click on the drop down menu in patterns in the 'fill' box but cannot now do this.  have i inadvertently clicked on something to turn this facility off?  i now have to go to 'preset manager' and manually move my new design to the first box and click 'done' so that i can use it.

    Which version of photoshop are you using?
    After you define a custom pattern it should be added to the bottom of whatever patterns are already loaded.
    For example, if you define a custom pattern and then go to Edit>Fill>Pattern, the newly defined pattern should have been added to the existing loaded patterns.

  • Availability of new J2EE 1.4 SDK

    I am pleased to announce availability of new J2EE 1.4 SDK. You can download this today from http://java.sun.com/j2ee/1.4/download.html
    J2EE SDK now includes App Server Platform Edition 8.2 (SJSAS PE 8.2) delivering a rich application deployment environment that is highly available and scalable. It dramatically lowers total cost of ownership proven by the latest SPECjAppServer2004 benchmarks on Sun T2000 CoolThread Server ($86/JOPS for application tier running on SJSAS PE 8.2, Solaris 10, and MySQL5.) The new release greatly improves Web Services performance by a factor of 2 to 4 through the inclusion of FastInfoset and support for latest technologies such as AJAX clients and Java database, based on the Apache Derby to decrease the development cycle time of Web 2.0 interactive applications and maximize developer productivity.
    The Sun Java System Application Server PE 8.2 is fully integrated with NetBeans 5 by providing an out of the box environment for development, deployment and debugging of Web and enterprise applications and extends its advocacy for open source by supporting RedHat Linux 4, MySQL 5 and Apache Derby.
    Below are highlights of Sun Java System Application Server Platform Edition 8.2
    * J2EE 1.4 compatible
    * Outstanding developer experience with NetBeans 5 and improved deployment speed, runtime footprint and server start up time. NetBeans 5.0 includes App Server 8.2 as a default J2EE runtime.
    * Superior throughput performance and better scalability supporting multi core/ multi threaded architecture.
    * Fast Infoset support improves webservices performance multiple folds.
    * App Server 8.2 bundles deployment ready Derby database making it possible to develop and deploy end to end J2EE application.
    * App Server 8.2 adds support for Red Hat 4 and My SQL 5.
    * In built JMS resource adapter makes connectivity with backend systems even more easier. Application Server 8.2 adds out of box connectivity for IBM MQ Series and Sun's MQ Server.
    * Enhanced J2EE 1.4 blueprints including demonstration of using Web 2.0 technologies like AJAX with App Server 8.2
    * JavaServer Faces Support: Developers can quickly build web applications by: assembling reusable UI components in a page; connecting these components to a data source; and wiring client-generated events to server-side event handlers.
    * Improved Administration Console:
    App Server 8.x admin console adds new look and feel with capabilities like JNDI namespace browser, JDBC Connection Validation, Deployment Descriptor Viewer, Error log viewer and improved monitoring.
    * Web Services Security: Container message security mechanisms implementing message-level authentication (e.g. XML digital signature and encryption) of SOAP web services invocations using the X509 and username/password profiles of the OASIS WS-Security standard.
    * JavaServer Pages Standard Tag Library 1.1 Support: the library encapsulates core functionality common to many JSP applications.
    * Bundled J2SE 5.0_06
    Sun Java System Application Server Platform Edition is free for development and deployment. Sun support is offered at an additional cost.
    Useful Links and pointers:
    - Download bits from http://java.sun.com/j2ee/1.4/download.html
    - SPECjAppServer2004 benchmark results demonstrating Sun's price/performance strengths. http://www.spec.org/jAppServer2004/results/res2005q4/jAppServer2004-20051109-00023.html
    - Stay connected with open source development of Application Server 9 on Project Glassfish via The Acquarium
    http://java.sun.com/javaee/glassfish/
    http://blogs.sun.com/roller/page/theaquarium
    - Migrate to Sun Java System Application Server 8.2 today !
    http://java.sun.com/j2ee/tools/migration/index.html
    Fast Infoset whitepaper
    http://www.sun.com/software/whitepapers/javaenterprisesystem/web_services_performance.pdf
    More Information at http://java.sun.com/javaee
    Thanks,
    - Pratik
    Product Line Manager
    Application Platform Products
    Sun Microsystems Inc.

    I couldn't get SAS8 to install using JRE 5. I have, however, succeeded in getting an application client to run with the latest JDK. If the client and server JRE differ, you've got to assign a serialVersionUID to any custom classes that will be passed back and forth.

  • Cannot use new fill pattern scripts for Photoshop CC 2014.2

    I have installed Photoshop CC 2014.2 (2014.2.0 Release), but am unable to get the new Fill pattern scripts to work or even show up in the UI. Namely, I am referring to the Flame, Picture Frame, and Tree scripted patterns described here: https://www.adobe.com/technology/projects/DecoScriptedPatternsInPhotoshop.html
    This is what my Fill dialog looks like:
    I have confirmed that the corresponding presets exist in the Photoshop CC 2014 > Presets > Deco folder:
    I have tried resetting Photoshop's preferences; and while everything was reset, the missing presets still failed to appear.

    If you are talking about CC 2014 and not CC, have you updated to
    Adobe Photoshop Version: 2014.2.1 20141014.r.257 2014/10/14:23:59:59 CL 987299  x64?
    (First line of File > System Info)
    Gene

  • IAB Studio is a new J2EE based Rich Internet Application builder

    Here I would like to introduce a new J2EE based solution for the development of Rich Internet Allications.
    We are pleased to announce a new release of IAB Studio 3.1. This innovative development solution for Rich Internet Application Development is now available for free download from our web site www.worcsnet.com > Products > Downloads.
    Please check out a demo application at www.iabstudio.com to see the power of IAB Studio for yourself. This application was created in just 5 days. Yet it delivers rich functionality and user friendly user interface.
    ****** no HTML, no page refreshes, no Applets, no ActiveX, no Plug-ins, no server side development******
    IAB Studio is a breakthrough alternative to the leading mainstream of web development tools or frameworks, such as .NET, Struts, or Flash. It allows for getting rid of server side development, which normally cannot produce a decent functional GUI. In IAB Studio, a developer builds internet applications using client side controls (also known as widgets), which are extremely powerful and can handle data and functionality associated with them. IAB Studio widget collection includes treeview controls, tab controls, data management and reporting controls, data presentation control (grid), report controls, combo box, toolbars, menus, media controls and many more.
    ****** Create a functional Graphical User Interfaces in no time ******
    IAB Studio is the first tool ever, which allows a web developer to forget about spending tremendous amounts of time developing any GUI and concentrate on the business logic, the same way as in Visual Basic or any other desktop RAD tool. In fact, it is equally easy to use. It comes with a powerful in-browser IDE, which contains Team Organizer, Project Organizer, Data Entry Automation Wizards, Instant Messenger, Visual Page Designer, Visual Workflow Designer, Data Management and Visual Report Designer.
    ****** Does not require learning new programming languages ******
    To use IAB Studio, a developer does not have to learn any new language. Basic knowledge of Java and JavaScript is enough to start developing complex applications right away.
    ****** It is FREE ******
    IAB Studio is completely free for non-commercial use.
    ****** Most Powerful in-Brower Development Environment******
    IAB Studio is compatible with the major operating systems (Windows/Unix) and a wide range of RDBMS such as Oracle, MS SQL Server, Sybase or SAP DB. No other tools except a Web browser are required to use IAB Studio.
    ****** Data Entry Automation ******
    IAB Studio allows one to automate tedious tasks as data entry. Instead of HTML forms and all the hassles related to handling them, IAB Studio provides data entry wizards, updateable grid controls and data manipulation, and reporting controls. These controls provide you with the ability easily and quickly build functional data entry pages with error validations, automatic SQL generation, and more. It requires zero coding as well. Wizards make the most of work for you; there are no XML descriptors involved. This saves a lot of development time.
    ****** Benefits ******
    Applications developed in IAB Studio have superior performance, minimized network traffic, and an optimized data exchange mechanism between client and server. Minimum or ZERO coding is required in most cases to create Rich Internet Applications of any complexity with IAB Studio. Using IAB Studio, developers or even business analysts can create powerful Internet applications in days, with only a Web browser installed on the computer anywhere in the world. The bottom line is - it is easy to develop rich functionality in IAB Studio, and it takes up to 80% less efforts compared to the leading web development tools and frameworks.
    ****** IAB Studio Client Side Widgets ******
    IAB Studio offers a rich set of client side widgets that truly redefine the capabilities of a regular Web application. IAB Studio widgets are JavaScript graphical user interface objects backed by the Java MVC framework on the server side. IAB Studio does not use any Applets or ActiveX controls. WorcsNet technology offers the thinnest client possible, outstanding performance and rich functionality. Internet Applications created with IAB Studio perform better than applications created with the leading development technologies. IAB Studio supports both Internet Explorer and Netscape Navigator.
    ****** Remote Development ******
    IAB applications do not require deployment. A typical IAB application runs as part of the IAB Studio framework; this allows modification of the application on the fly. A team of developers can work on the same project remotely, simultaneously and in real time. The browser based Page Editors allow for development of IAB pages on the client machine and save the work in the server repository. It greatly simplifies the development and deployment processes.
    ****** Robust Security ******
    IAB Studio�s robust security allows the administrator to manage and authorize access to any areas of the application depending on the role of a user.
    Read more about IAB Studio at www.worcsnet.com.
    Check out a demo application at www.iabstudio.com to see the power of IAB Studio for yourself.

    Struts is a server side framework, which has poor means for creating web pages that can provide rich user interface.
    The main reason is that in order to refresh page data, it needs to refresh the whole page. It means that if for example you have two tab pages and you want to switch from one to another, you will refresh the current page, and everything you entered on this page will be lost. So in order to retrieve it when you go back to the first page, you will have to send it to the server in the first place, store itsomewhere and prepare a page when you go back to it. Another problem is that while you are on the second page, you cannot really access data from the first page - because it's not there.
    IAB Studio, on the other hand, is very different. It allows to create pages, which consists of client side controls and not HTML. Client side controls can handle data, assosiated with them. For example, in the abovementioned example, when you click on the second tab page, it will not go to the server. Instead, it will cache this page in memory and handle it accordingly. It also allows to get data from the first page, even if you are on the second page. And so on.
    IAB Studio has over 40 such controls, including reporting control (this one has a functional report designer), grids, treeview, tab controls, various lists,
    message boxes, schedulers, workflows and more.
    Another important difference is that Struts is just a framework, and you have to handle a lot of XML descriptors, whereas IAB Studio is a full-blown IDE, which requires only browser to run.
    Read more about IAB Studio at www.worcsnet.com, or you can download a free version and try it out for yourself.

  • 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/
    %

  • 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.

  • How to add a new j2ee server to PI system?

    how to add a new j2ee server for our PI product system?
    Is it to execute 'install dialog instance ' steps?
    Thanks

    Hello
    I have moved this thread to the Netweaver Administrator forum (this is not a PI technical issue). You have a better chance of getting a quality answer to your query in the Netweaver Administrator forum.
    Take the notes below into consideration after you have added the java node.
    1) #734931   Using a J2EE cluster in the XI 3.0/7.0 environment
    2) #1079478  Using a J2EE Cluster in the PI 7.10 environment
    Can anyone assist with how to add a java node?
    Regards
    Mark Smyth
    XI/PI Moderator

  • 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.

  • ANN: New Design Pattern (DAO)

    Hello,
    Thanks for your overwhelming response to our previous sample applications demonstrating various [url http://www.oracle.com/technology/sample_code/tech/java/j2ee/designpattern/index.html]design patterns.
    Continuing with the series, this month we have showcased the [url http://www.oracle.com/technology/sample_code/tech/java/j2ee/designpattern/dataaccesstier/index.html]Data Access Object (DAO) Design Pattern which is considered as a best practice for applications accessesing the database or the underlying persistence layer from the business tier.
    The DAO implements the access mechanism required to work with the data source. The data source could be a persistent store like an RDBMS, an external service like a B2B exchange, a repository like an LDAP database, or an XML Repository. Using the scenario of web based News Application, this sample application demonstrates the effective use of this pattern.
    [url http://www.oracle.com/technology/sample_code/tech/java/j2ee/designpattern/dataaccesstier/index.html]Download the sample application to learn more about this pattern.
    More Sample Applications are available at [url http://www.oracle.com/technology/sample_code/index.html]
    http://www.oracle.com/technology/sample_code/index.html
    Thanks,
    Rajat
    OTN Team

    Hi
    This is because you are not using the latest jdbc driver version. Either use the latest ojdbc14.jar downloadable from the location given in the readme(Oracle Database 10g (10.1.0.2.0) drivers),
    Or simply comment this part in the code.
    Also you may just replace the close method call with ods=null;
    Hope this helps
    Shrinivas

  • New to patterns

    Hi,
    I am completely new to design patterns and J2EE so any help would be useful.
    I have a basic web page with an embedded flash movie which communicates with a single servlet.
    The servlet is basically a big if...else statement on the request params from the flash. Each if...else calling an appropriate method, doing some work and returning something to the flash movie.
    I have been asked by a customer if this the server side servlet would/could be extendable, I want to redesign the whole approach to use a design pattern (is this the right thing to do?), but I don't know really where to start or even if this is the right thing to do. Any help ideas?
    I have started reading J2EE Design Patterns by William Crawford, Jonathan Kaplan (is this a good book?) and am thinking of something along the MVC lines with all the work done in a JavaBean, the customer will want to be able to add to the if...else in the controller servlet, preferably by some sort of extension without changing my code, how would something like this work? Is there a better pattern for what I'm trying to do?
    Any help will be much appreciated.
    Thanks in advance.
    Phil Maskell

    It is unclear how your customer would want to extend the servlet.
    When you say redesign, do you also mean removing the Flash component? Flash conflicts a little with the J2EE model.
    Checkout http://jakarta.apache.org/struts/ to learn how to build extensible Java web applications.
    Some things to keep in mind:
    Using a MVC pattern, the servlet would act as the Controller, which should delegate to helper classes that carry out actions. In Struts, the org.apache.struts.action.ActionServlet reads the request URL and delegates to the appropriate Action class. Highly extendable by adding and/or revising action classes.
    The View layer would consist of your Flash application if you keep it in the new design. otherwise the View is implemented with JSP pages.
    The Model layer is where your business logic resides. You would use a Business Delegate to interact with the Controller objects. If you keep using Flash, then it seems like your Model or business logic would be mixed in with the View Layer. It really depends on what type of business requirements the application is attempting to realize. Here is the area of conflict with J2EE model.
    Christian

  • New(?) pattern looking for a good home

    Hi everyone, this is my second post to sun forums about this, I initially asked people for help with the decorator and strategy pattern on the general Java Programming forum not being aware that there was a specific section for design pattern related questions. Since then I refined my solution somewhat and was wondering if anyone here would take a look. Sorry about the length of my post, I know it's best to keep it brief but in this case it just seemed that a fully functional example was more important than keeping it short.
    So what I'd like to ask is whether any of you have seen this pattern before and if so, then what is it called. I'm also looking for some fresh eyes on this, this example I wrote seems to work but there are a lot of subtleties to the problem so any help figuring out if I went wrong anywhere is greatly appreciated. Please do tell me if you think this is an insane approach to the problem -- in short, might this pattern have a chance at finding a good home or should it be put down?
    The intent of the pattern I am giving below is to modify behavior of an object at runtime through composition. In effect, it is like strategy pattern, except that the effect is achieved by wrapping, and wrapping can be done multiple times so the effect is cumulative. Wrapper class is a subclass of the class whose instance is being wrapped, and the change of behavior is accomplished by overriding methods in the wrapper class. After wrapping, the object "mutates" and starts to behave as if it was an instance of the wrapper class.
    Here's the example:
    public class Test {
         public static void main(String[] args) {
              double[] data = { 1, 1, 1, 1 };
              ModifiableChannel ch1 = new ModifiableChannel();
              ch1.fill(data);
              // ch2 shifts ch1 down by 1
              ModifiableChannel ch2 = new DownShiftedChannel(ch1, 1);
              // ch3A shifts ch2 down by 1
              ModifiableChannel ch3A = new DownShiftedChannel(ch2, 1);
              // ch3B shifts ch2 up by 1, tests independence from ch3A
              ModifiableChannel ch3B = new UpShiftedChannel(ch2, 1);
              // ch4 shifts ch3A up by 1, data now looks same as ch2
              ModifiableChannel ch4 = new UpShiftedChannel(ch3A, 1);
              // print channels:
              System.out.println("ch1:");
              printChannel(ch1);
              System.out.println("ch2:");
              printChannel(ch2);
              System.out.println("ch3A:");
              printChannel(ch3A);
              System.out.println("ch3B:");
              printChannel(ch3B);
              System.out.println("ch4:");
              printChannel(ch4);
         public static void printChannel(Channel channel) {
              for(int i = 0; i < channel.size(); i++) {
                   System.out.println(channel.get(i) + "");
              // Note how channel's getAverage() method "sees"
              // the changes that each wrapper imposes on top
              // of the original object.
              System.out.println("avg=" + channel.getAverage());
    * A Channel is a simple container for data that can
    * find its average. Think audio channel or any other
    * kind of sampled data.
    public interface Channel {
         public void fill(double[] data);
         public double get(int i);
         public double getAverage();
         public int size();
    public class DefaultChannel implements Channel {
         private double[] data;
         public void fill(double[] data) {
              this.data = new double[data.length];
              for(int i = 0; i < data.length; i++)
                   this.data[i] = data;
         public double get(int i) {
              if(i < 0 || i >= data.length)
                   throw new IndexOutOfBoundsException("Incorrect index.");
              return data[i];
         public double getAverage() {
              if(data.length == 0) return 0;
              double average = this.get(0);
              for(int i = 1; i < data.length; i++) {
                   average = average * i / (i + 1) + this.get(i) / (i + 1);
              return average;
         public int size() {
              return data.length;
    public class ModifiableChannel extends DefaultChannel {
         protected ChannelModifier modifier;
         public void fill(double[] data) {
              if (modifier != null) {
                   modifier.fill(data);
              } else {
                   super.fill(data);
         public void _fill(double[] data) {
              super.fill(data);
         public double get(int i) {
              if(modifier != null)
                   return modifier.get(i);
              else
                   return super.get(i);
         public double _get(int i) {
              return super.get(i);
         public double getAverage() {
              if (modifier != null) {
                   return modifier.getAverage();
              } else {
                   return super.getAverage();
         public double _getAverage() {
              return super.getAverage();
    public class ChannelModifier extends ModifiableChannel {
         protected ModifiableChannel delegate;
         protected ModifiableChannel root;
         protected ChannelModifier tmpModifier;
         protected boolean doSwap = true;
         private void pre() {
              if(doSwap) { // we only want to swap out modifiers once when the
                   // top call in the chain is made, after that we want to
                   // proceed without it and finally restore doSwap to original
                   // state once ChannelModifier is reached.
                   tmpModifier = root.modifier;
                   root.modifier = this;
                   if(delegate instanceof ChannelModifier)
                        ((ChannelModifier)delegate).doSwap = false;
         private void post() {
              if (doSwap) {
                   root.modifier = tmpModifier;
              } else {
                   if(delegate instanceof ChannelModifier)
                             ((ChannelModifier)delegate).doSwap = true;
         public ChannelModifier(ModifiableChannel delegate) {
              if(delegate instanceof ChannelModifier)
                   this.root = ((ChannelModifier)delegate).root;
              else
                   this.root = delegate;
              this.delegate = delegate;
         public void fill(double[] data) {
              pre();
              if(delegate instanceof ChannelModifier)
                   delegate.fill(data);
              else
                   delegate._fill(data);
              post();
         public double get(int i) {
              pre();
              double result;
              if(delegate instanceof ChannelModifier)
                   result = delegate.get(i);
              else
                   result = delegate._get(i);
              post();
              return result;
         public double getAverage() {
              pre();
              double result;
              if(delegate instanceof ChannelModifier)
                   result = delegate.getAverage();
              else
                   result = delegate._getAverage();
              post();
              return result;
         public int size() {
              //for simplicity no support for modifying size()
              return delegate.size();
    public class DownShiftedChannel extends ChannelModifier {
         private double shift;
         public DownShiftedChannel(ModifiableChannel channel, final double shift) {
              super(channel);
              this.shift = shift;
         @Override
         public double get(int i) {
              return super.get(i) - shift;
    public class UpShiftedChannel extends ChannelModifier {
         private double shift;
         public UpShiftedChannel(ModifiableChannel channel, final double shift) {
              super(channel);
              this.shift = shift;
         @Override
         public double get(int i) {
              return super.get(i) + shift;
    Output:ch1:
    1.0
    1.0
    1.0
    1.0
    avg=1.0
    ch2:
    0.0
    0.0
    0.0
    0.0
    avg=0.0
    ch3A:
    -1.0
    -1.0
    -1.0
    -1.0
    avg=-1.0
    ch3B:
    1.0
    1.0
    1.0
    1.0
    avg=1.0
    ch4:
    0.0
    0.0
    0.0
    0.0
    avg=0.0

    jduprez wrote:
    Hello,
    unless you sell your design better, I deem it is an inferior derivation of the Adapter pattern.
    In the Adapter pattern, the adaptee doesn't have to be designed to support adaptation, and the instance doesn't even know at runtime whether it is adapted.
    Your design makes the "modifiable" class aware of the modification, and it needs to be explicitly designed to be modifiable (in particular this constrains the implementation hierarchy). Overall DesignPattern are meant to provide flexibility, your version offers less flexibility than Adapter, as it poses more constraint on the modifiable class.
    Another sign of this inflexibility is your instanceof checks.
    On an unrelated note, I intensely dislike your naming choice of fill() vs _fill()+, I prefer more explicit names (I cannot provide you one as I didn't understand the purpose of this dual method, which a good name would have avoided, by the way).
    That being said, I haven't followed your original problem, so I am not aware of the constraints that led you to this design.
    Best regards,
    J.
    Edited by: jduprez on Mar 22, 2010 10:56 PMThank you for your input, I will try to explain my design better. First of all, as I understand it the Adapter pattern is meant to translate one interface into another. This is not at all what I am trying to do here, I am trying to keep the same interface but modify behavior of objects through composition. I started thinking about how to do this when I was trying to apply the Decorator pattern to filter some data. The way I would do that in my example here is to write an AbstractChannelDecorator that delegates all methods to the Channel it wraps:
    public abstract class AbstractChannelDecorator implements Channel {
            protected Channel delegate;
    ...// code ommitted
         public double getAverage() {
              return delegate.getAverage();
    ...// code ommitted
    }and then to filter the data I would extend it with concrete classes and override the appropriate methods like so:
    public class DownShiftedChannel extends AbstractChannelDecorator {
         ...// code ommitted
         public double get(int i) {
              return super.get(i) - shift;
           ...// code ommitted
    }(I am just shifting the data here to simplify the examples but a more realistic example would be something like a moving average filter to smooth the data).
    Unfortunately this doesn't get me what I want, because getAverage() method doesn't use the filtered data unless I override it in the concrete decorator, but that means I will have to re-implement the whole algorithm. So that's pretty much my motivation for this, how do I use what on the surface looks like a Decorator pattern, but in reality works more like inheritance?
    Now as to the other points of critique you mentioned:
    I understand your dislike for such method names, I'm sorry about that, I had to come up with some way for the ChannelModifier to call ModifiableChannel's super's method equivalents. I needed some way to have the innermost wrapped object to initiate a call to the topmost ChannelModifier, but only do it once -- that was one way to do it. I suppose I could have done it with a flag and another if/else statement in each of the methods, or if you prefer, the naming convention could have been fill() and super_fill(), get() and super_get(), I didn't really think that it was that important. Anyway, those methods are not meant to be used by any other class except ChannelModifier so I probably should have made them protected.
    The instanceof checks are necessary because at some point ChannelModifier instance runs into a delegate that isn't a ChannelModifier and I have to somehow detect that, because otherwise instead of calling get() I'd call get() which in ModifiableChannel would take me back up to the topmost wrapper and start the whole call chain again, so we'd be in infinite recursion. But calling get() allows me to prevent that and go straight to the original method of the innermost wrapped object.
    I completely agree with you that the example I presented has limited flexibility in supporting multiple implementations. If I had two different Channel implementations I would need two ModifiableChannel classes, two ChannelModifiers, and two sets of concrete implementations -- obviously that's not good. Not to worry though, I found a way around that. Here's what I came up with, it's a modification of my original example with DefaultChannel replaced by ChannelImplementation1,2:
    public class ChannelImplementation1 implements Channel { ... }
    public class ChannelImplementation2 implements Channel { ... }
    // this interface allows implementations to be interchangeable in ChannelModifier
    public interface ModifiableChannel {
         public double super_get(int i);
         public double super_getAverage();
         public void setModifier(ChannelModifier modifier);
         public ChannelModifier getModifier();
    public class ModifiableChannelImplementation1
              extends ChannelImplementation1
              implements ModifiableChannel {
         ... // see DefaultChannel in my original example
    public class ModifiableChannelImplementation2
              extends ChannelImplementation1
              implements ModifiableChannel { ...}
    // ChannelModifier is a Channel, but more importantly, it takes a Channel,
    // not any specific implementation of it, so in effect the user has complete
    // flexibility as to what implementation to use.
    public class ChannelModifier implements Channel {
         protected Channel delegate;
         protected Channel root;
         protected ChannelModifier tmpModifier;
         protected boolean doSwap = true;
         public ChannelModifier(Channel delegate) {
              if(delegate instanceof ChannelModifier)
                   this.root = ((ChannelModifier)delegate).root;
              else
                   this.root = delegate;
              this.delegate = delegate;
         private void pre() {
              if(doSwap) {
                   if(root instanceof ModifiableChannel) {
                        ModifiableChannel root = (ModifiableChannel)this.root;
                        tmpModifier = root.getModifier();
                        root.setModifier(this);
                   if(delegate instanceof ChannelModifier)
                        ((ChannelModifier)delegate).doSwap = false;
         private void post() {
              if (doSwap) {
                   if(root instanceof ModifiableChannel) {
                        ModifiableChannel root = (ModifiableChannel)this.root;
                        root.setModifier(tmpModifier);
              } else {
                   if(delegate instanceof ChannelModifier)
                             ((ChannelModifier)delegate).doSwap = true;
         public void fill(double[] data) {
              delegate.fill(data);
         public double get(int i) {
              pre();
              double result;
              if(delegate instanceof ModifiableChannel)
    // I've changed the naming convention from _get() to super_get(), I think that may help show the intent of the call
                   result = ((ModifiableChannel)delegate).super_get(i);
              else
                   result = delegate.get(i);               
              post();
              return result;
         public double getAverage() {
              pre();
              double result;
              if(delegate instanceof ModifiableChannel)
                   result = ((ModifiableChannel)delegate).super_getAverage();
              else
                   result = delegate.getAverage();
              post();
              return result;
         public int size() {
              return delegate.size();
    public class UpShiftedChannel extends ChannelModifier { ...}
    public class DownShiftedChannel extends ChannelModifier { ... }

Maybe you are looking for

  • Error while loading data into ODS

    Hi we have BI for NW04S and CRM4.0. While loading data for a CRM ODS , I have received a error message which I never seen before. Yesterdaya data load was smooth and I only see issue while loading data today The error message in the monitor is as fol

  • Can I install software on a bootable sd card?

    I am a professional photographer who often uses my MacBook Pro on location to review, edit, caption and upload images. In the event of a hard drive crash, I would like to make a bootable SD card, and have found very good instructions on how to do thi

  • How do you get professional quality digital photos????

    You open a magazine or look online and you'll see celebrity pictures that look crystal clear. How does a consumer get this quality?? Is it the camera?? I plan on buying a new camera soon, a Canon with a Digic II processor, but I want my pictures to l

  • Filename question

    i am designing a Student class which implements the Student interface, the Student interface is: * A simple interface to allow access to student * properties from a class data file. public interface Student { //some methods which i named Student.java

  • Introscope Agent Settings

    Hi folks, Quick question this one probably. Can anyone tell me where this screenshot was taken from in Solution Manager please?  I've looked and looked and just cannot find it. Hopefully someone may recognise it?? Thanks