Technical Paper: Java

Technical Paper: Java

Technical Paper: Java - J2EE Conventions and Guidelines Release 1.0.2 Stephan Janssen The JCS Team Technical Paper: Java - J2EE Conventions and Guidelines: Release 1.0.2 Stephan Janssen The JCS Team Copyright © 1998-2004 JCS Int. NV. (www.jcs.be) Copyright © 1995-1999 Adapted with permission from CODE CONVENTIONS FOR THE JAVATM PROGRAMMING LANGUAGE. Copyright 1995-1999 Sun Microsystems, Inc. All rights reserved. Copyright © 1995-1999 Sun, Sun Microsystems, the Sun logo, Java, J2EE, JavaServer Pages, Enterprise JavaBeans, Java Naming and Directory Interface, EJB, JSP, J2EE, J2SE and the Java Coffee Cup logo are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries. Table of Contents Preface.........................................................................................................................13 Why Read This Document? ...................................................................................... 13 Who Should Read This? .......................................................................................... 13 Conventions Used In This Document ......................................................................... 13 TypographicalConventions ......................................................................................14 Post Your Feedback ................................................................................................14 ExampleApplication ..............................................................................................14 MoreInformation ...................................................................................................14 1.Conventions ..............................................................................................................1 Why Use Conventions? ...........................................................................................1 ConventionRules ...................................................................................................1 Defining.......................................................................................................1 Enforcing .....................................................................................................1 NamingConventions ..............................................................................................2 Introduction ..................................................................................................2 JavaNaming .................................................................................................2 J2EENaming ................................................................................................7 CommentsConventions ...........................................................................................11 JavaComments .............................................................................................11 CodingConventions ...............................................................................................18 Introduction ..................................................................................................18 JavaCoding ..................................................................................................18 J2EECoding .................................................................................................26 Exceptions ............................................................................................................41 ExceptionsDefined ........................................................................................41 When To Use Exceptions ................................................................................. 41 ExceptionTypes ............................................................................................42 ThrowingExceptions ......................................................................................43 CatchingExceptions .......................................................................................43 Cleaning Up After An Exception Using A finally Clause ....................................... 44 ExceptionMatching ........................................................................................45 Exceptions And Error Messages ........................................................................ 46 ExceptionChaining ........................................................................................47 Creating Custom Exceptions ............................................................................47 Exceptions And EJBs ......................................................................................48 2.Guidelines .................................................................................................................51 Introduction ..........................................................................................................51 Project Directory Structure .......................................................................................51 Introduction ..................................................................................................51 Proposed Directory Structure ............................................................................52 BuildTools ...........................................................................................................53 ANT............................................................................................................53 Maven .........................................................................................................65 Logging ...............................................................................................................71 Introduction ..................................................................................................71 Why Use Logging? .........................................................................................71 LoggingExample ...........................................................................................71 LoggingLevels ..............................................................................................73 LocalizedMessages ........................................................................................74 ConfigurationFile ..........................................................................................74 DatabaseIndependency ...........................................................................................75 Introduction ..................................................................................................75 JDBCBasics .................................................................................................75 iv J&J-CCGBP UseOfSQL ..................................................................................................81 Know Your Target Database(s) ......................................................................... 81 Architecture ..................................................................................................82 JMS.....................................................................................................................82 Introduction ..................................................................................................82 Overview Of JMS ..........................................................................................83 JMSExamples ...............................................................................................91 Assertions.............................................................................................................94 Introduction ..................................................................................................94 CodingAssertions ..........................................................................................95 Design By Contract ........................................................................................97 Testing.................................................................................................................99 Automated Regression Testing .........................................................................99 Unit Tests (White Box) ................................................................................... 100 Scenario Tests (Black Box) .............................................................................. 111 Integration of JUnit with development tools ........................................................ 113 Stress Tests (Volume Tests) ..................................................................................... 114 Stress testing with JMeter ................................................................................ 115 JMX ....................................................................................................................116 Introduction ..................................................................................................117 JMXBasics ..................................................................................................117 Why And When To Use JMX ........................................................................... 118 HowToUseJMX ..........................................................................................119 JMXPitfalls ..................................................................................................121 MBeans........................................................................................................122 JAAS...................................................................................................................124

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    302 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us