Tooling Support for Enterprise Development
Total Page:16
File Type:pdf, Size:1020Kb
TOOLING SUPPORT FOR ENTERPRISE DEVELOPMENT RYAN CUPRAK & REZA RAHMAN JAVA EE DEVELOPMENT • Java EE has had a bad reputation: • Too complicated • Long build times • Complicated/expensive tooling • Copious amounts of repetitive code • Expensive application servers • Overkill for most projects • Times have changed since 2000! • Java EE 5 made great strides leveraging new features introduced in Java 5. Java EE 6 pushes us forward. • Excellent tooling support combined with a simplification of features makes Java EE development fast, easy, and clean (maintainable). • It is Java EE – NOT J2EE!!! OBJECTIVE Challenge: Starting a new project is often painful. In this presentation you’ll learn: • How to setup a new Java EE project. • Disconnect between theory and practice. • Tools that you should consider learning/adding. • Best practices for Java EE development from tools side. When is the last time you evaluated your tools? APPLICATION TYPES Types of Java EE applications: • Prototype – verify technology, try different techniques, learn new features. • Throw-away – application which has a short-life space, temporary use. • Internal/external portal – application with a long life expectancy and which will grow over time. • Minimize dependence on tools. • Product – an application which deployed at a more than one customer site. Possibly multiple code branches. • Minimize dependence on tools. Life expectancy drives tooling decisions. PRELIMINARIES Considerations for a Java EE toolbox: • Build system: Ant, Maven, IDE specific? • Container: GlassFish/JBoss/ WebLogic/etc. • Technologies: EJB/JPA/CDI/JSF • IDE: Eclipse, NetBeans, IntelliJ IDEA • Other tools: Unit testing, integration testing, UI testing, etc. IDES • NetBeans • Easy to use Java EE templates. • Includes a pre-configured GlassFish container. • Support for bleeding edge Java EE features. • IntelliJ • Excellent editor support – auto-completion and analysis. • Support for complex project structures. • Support for a myriad of web technologies. • Eclipse • Wide industry adoption. • External Java EE tools from JBoss. • External plugins – large ecosystem. If exploring Java EE, start with NetBeans. ADD-ON TOOLS Beyond the IDE: • JBoss Tools – extends Eclipse’s Java EE capabilities. • JRebel – greatly speeds deployments so that you only swap in the code that changes. http://zeroturnaround.com/ • Arquillian – integration testing – enables EJBs to be tested an in embedded Java EE container (GlassFish/JBoss etc.). http://www.jboss.org/arquillian.html • Liquidbase – “version control” for database schemas – important for applications that are going to grow over time. http://www.liquidbase.org • JMeter – web application stress testing tool (http://jmeter.apache.org). • Hudson/Jenkins – continuous integration (http://hudson-ci.org). • Selenium – functional web UI testing (http://seleniumhq.org). • SOAP UI – testing SOAP/rest web services (http://www.soapui.org). • Monitoring Tools – NAGIOS/HP OpenView/IBM Tivoli/Oracle Enterprise Management Tools • Profiling – NetBeans Profiler/Jprofiler/VisualVM/etc. Impossible to cover everything. BUILD SYSTEMS Ant Maven • Pro: • Pro • Infinitely flexible – write • Standard project layout once. • Dependency management • Integrated support with • Supported by all IDEs most IDEs. • Cons • Cons • Steep learning curve • No defined project • Harder to customize standard • Build cycle-time (lacks • Maintenance headache incremental compilation) • IDE integration. BUILD SYSTEM IDE Hybrid (bad idea): • Pro • Pro • Fast build/deployment • Fast build times • GUI management • Tool independence • Cons • Cons • Not portable • Twice the work • Continuous integration support JAVA EE PACKAGING Traditional EE: XML META-INF ejb-jar.xml EAR (.ear) EJB-JAR (.jar) XML XML application.xml EJB 1 persistence.xml XML EJB 1 beans.xml XML WEB-INF WAR (.war) web.xml lib index.xhtml dependency 1.jar dependency 2.jar SIMPLIFIED JAVA EE PACKAGING Simplified EJB packaging (WAR): WEB-INF classes WAR (.war) EJB 1 XML index.xhtml web.xml EJB 2 XML login.xhtml beans.xml XML faces-config.xml XML persistence.xml Introduced in EJB 3.1 CONFIGURATION FILES beans.xml web.xml ejb-jar.xml application.xml persistence.xml faces-config.xml PACKAGING & CONFIGURATION Tooling challenge – how do you: • Create a new project scratch? • Import an existing project? • Create valid Java EE configuration files? • Edit Java EE configuration files? • Navigate Java EE features effectively? • Manage the evolution of a project and Java EE technology changes? IDES • Leading Java IDEs: • NetBeans 7.2 • IntelliJ IDEA 11 • Eclipse Juno • Is one IDE better than the others? • NO! Each has a unique set of features. • What are the major differences: • Available project templates • Supported containers • Setup/external libraries • Ease of use • Unique features: • NetBeans: Profiling, Hudson integration, CDI, HTML5, JavaFX, etc. • IDEA: Code inspection/completion, SOAP UI, Android, Flash/Flex, SQL/ JavaScript editor, etc. • Eclipse: BIRT, Perspectives, GWT, AspectJ, JBoss Tools, gigantic unique of add-ons. IDES Key features to consider: • Project creation/management (wizards) • Container integration (launching/ deploying/debugging) • Generating/checking configuration files • Generating entities/CRUDs • Embedded libraries • JQL query code completion/ verification • EL code completion (CDI support) • CDI/JSF/JPA validation/error detection IDEA • JetBrains IDEA – two editions: • Community – core Java development (free) • Ultimate – support for enterprise technologies (purchase $199 personal license/$99 academic) • Support for running in application servers. • CDI/JPA coding support etc. • Ultimate edition needed for Java EE development. IDEA IDEA build system support: • Build system options with IDEA: • Maven – supported project type • IDEA specific • IDEA uses its own build system by default. • Drawbacks: • Other developers must use IDEA to compile/package • Cannot integrate into continuous integration services such Hudson, CruiseControl, etc. • Benefits: • Optimized for fast builds and incremental compiling • Tight integration with IDEA – complete management in UI. • Options: • Create an Ant build file: Build | Generate Ant Build… • Create project using Maven • Create a Maven project using mvn idea:idea IDEA • Before creating a project: • Configure the application server you are going to be using. • Create data sources in IDEA for a database. • Supported containers: • Apache Tomcat (4.0-7.0) • WebLogic (7.0-12.1.1) • WebSphere (5.1-8.0) • JBoss (4.2-7.0.2) • GlassFish (2-3) • Resin (3-4) • Jetty (6-8.1) • JSR45 Compatible server • Container can be either local or remote IDEA • Important concepts: • Project – organizational unit that represents a complete solution. It is composed of modules. • Module – discrete unit of functionality with can be compiled/ run/tested independently. (WAR/EJB JAR) • Facets – represents a framework/technology/language used in a module. (CDI/JSF/JPA) • Two project formats: • Directory based: .idea • Configuration settings are stored in separate XML files (compiler.xml, encoding.xml, etc.) • workspace.xml should not be stored in VCS. • File based: • .ipr – project settings to be stored in VCS. • .iws – machine specific settings – do not put in VCS. IDEA • Java EE Projects: • No pre-defined Java EE templates. • Three starting points: • New project from scratch • Create from external model (Maven/Eclipse/Gradle) • Existing sources (ignores build file) • Add facets/frameworks for Java EE features. • Configure artifacts to define Java EE packaging. • Create a Project and a Module. IDEA New Project Wizard Pick Java Configure Configure Configure Module technologies Facets Artifacts Java EE Pertinent • Java • JPA • WAR • Web • Web Application • CDI • EAR • Plugin • Struts • EJB • JAR • J2ME • JSF • GWT • Exploded • Flash • Struts 2 • JRebel • Maven • Application Server • JSF • Grails • EJB • Seam • Griffon • Java EE Application • Struts • Android • Java EE Persistence • etc. • Hibernate • SQL Support IDEA DEMO IDEA Wizard Summary • Wizard creates a single module project. • Project uses the technologies that you selected. • Downloads Java EE dependencies. Important • Additional modules can be created after the project is created. • Don’t select all of the technologies if creating an EAR!! • Wizard does not create a “EAR” project with multiple modules. IDEA What have we accomplished? • Created a new IDEA project from scratch. • Single enterprise web module • Downloaded and configured CDI. • Added facets for CDI, JPA, and EJB. • Deployed the application to GlassFish. Challenges: • Container installation performed separately. • Libraries had to be downloaded separately. • Config files must be created separately. • Required project setup post configuration. NETBEANS • Excellent support for Java EE. • Java EE support is not a separate download (features can be activated). • 3 Java web templates: • Web Application – supports CDI/EJB (simplified project) • Web Application with Existing Sources • Web Free Form Application • 6 Java EE templates: • Enterprise Application • Enterprise Application with Existing Sources • EJB Module • EJB Module with Existing Sources • Enterprise Application Client • Enterprise Application Client with Existing Sources NETBEANS • Full support for Java EE 6 • Integrated IDE support for CDI • Service integration/monitoring: • Database editor • Container integration: • Tomcat • GlassFish • JBoss • WebLogic • JPA support • Web Services (consume/produce) • JSF support • Integration with Hudson