oracle adf architecture tv - deployment - build options
DESCRIPTION
Slides from Oracle's ADF Architecture TV series covering the Deployment phase of ADF projects, considering your build options for building ADF applications. Like to know more? Check out: - Subscribe to the YouTube channel - http://bit.ly/adftvsub - Deployment Playlist - http://www.youtube.com/playlist?list=PLJz3HAsCPVaTFLxxO8qwwZqk7mpEcXOwG - Read the episode index on the ADF Architecture Square - http://bit.ly/adfarchsquareTRANSCRIPT
1 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
2 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Build Options
ORACLE PRODUCT
LOGO
Real World ADF Design & Architecture Principles
15th Feb 2013 v1.0
3 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Learning Objectives
• At the end of this module you should be able to:
– Describe the process of building ADF applications – Identify your options for building ADF applications – Describe your options for managing dependencies in the build – And understand why continuous integration is an integral part of
any build solution
Image: imagerymajestic/ FreeDigitalPhotos.net
4 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Program Agenda
• Building Source Code • ADF Build Setup
– Pre Build: Deployment Profiles – Build Tools & Options – Dependency Management – Post Build: WLS Deployment Plans & Build Modifications
• Continuous Integration
5 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
The Act of "Building" Software
• The act of building software from source code includes
– Checking out code – Compiling and linking code – Dependency management and build orders – Packaging code into deployable artefacts – Deployment – Running tests – Creating automated documentation and release notes
6 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Presentation Scope
• Deployment is covered in separate slides
7 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
The JDeveloper & ADF "Build" Perspective
• Applications built via JDeveloper and for ADF need to consider
– Building & packaging for the JDeveloper/ADF platform • Creating Oracle proprietary ADF Library JARs, MARs, FARs etc
– Dependency management and build order • Cognizant of ADF architecture, ADF Libraries and master app build orders
– Building & packaging for the Java EE platform • Java EE artefacts such as JARs, WARs & EARs
– Building & packaging for the Oracle WLS platform • WLS deployment descriptors & plans
8 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
JDeveloper Build Setup
• Setting up an ADF build process requires the following:
Configuring JDeveloper deployment profiles
Choosing and configuring tools to build the applica9on
Catering for dependency
management & build order
Configuring WLS deployment plans & post
build modifica9ons
9 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Program Agenda
• Building Source Code • ADF Build Setup
– Pre Build: Deployment Profiles – Build Tools & Options – Dependency Management – Post Build: WLS Deployment Plans & Build Modifications
• Continuous Integration
10 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
JDeveloper Deployment Profiles
• Define & include options for how applications and code are: – Packaged as deployment artifact: JARs, WARs, EARs, ADF Library JARs etc
– Specific deployment platforms: WLS deployment descriptors – And much more depending on the deployment profile type....
• Used by JDeveloper or ojdeploy to build the artifact • Removes grunt work of assembling & generating artifacts yourself
– Do you remember the good ol' days of make files....
• Within JDeveloper you define 1 or more at the application or project level
11 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
JDeveloper Deployment Profiles Types
Applica9on Deployment Profile Types Project Deployment Profile Types
ADF Mobile for Android ADF Mobile for iOS EAR files MAR files
ADF Library JAR file ADF Mobile feature archive Business Components archive file Business Components EJB Session Bean Business Components Service Interface Client JAR files EJB JAR files Extension JAR file JAR file OSGi bundle RAR file Shared Library JAR file Taglib JAR file WAR files
12 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Project Properties – Deployment Profiles
13 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Application Properties – Deployment Profiles
14 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Deployment Profile Types
• Project Deployment Profile Types – WAR Files – ADF Library JAR – Business Component Service Interface
• Application Deployment Profile Types – EAR Files – MAR Files
15 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Deployment Profile Types
• Project Deployment Profile Types – WAR Files – ADF Library JAR – Business Component Service Interface
• Application Deployment Profile Types – EAR Files – MAR Files
• Java EE web archives
– Contains web components. e.g. JSPs, JSFs, HTML, servlets and other resources
– + deployment descriptors (e.g. web.xml)
– Use when you want to create/deploy a Java EE web application to a Java EE server
16 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Deployment Profile Types
• Project Deployment Profile Types – WAR Files – ADF Library JAR – Business Component Service Interface
• Application Deployment Profile Types – EAR Files – MAR Files
• Oracle proprietary Java ADF archive
– Contains reusable ADF components: ADF task flows, declarative components, task flow templates, model projects
– + hidden generated deployment descriptors (e.g. task-flow-registry.xml)
– Some limitations compared to JAR archive such as inability to filter content
– Use when you want other ADF applications to reuse the ADF Library JARed components
17 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Deployment Profile Types
• Project Deployment Profile Types – WAR Files – ADF Library JAR – Business Component Service Interface
• Application Deployment Profile Types – EAR Files – MAR Files
– For publishing ADF BC objects as SDOs
– Generates both client proxy JAR for consumers to use and server JAR
18 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Deployment Profile Types
• Project Deployment Profile Types – WAR Files – ADF Library JAR – Business Component Service Interface
• Application Deployment Profile Types – EAR Files – MAR Files
• Java EE enterprise archives
– For deploying one or more applications or modules to Java EE server
– Contains 1 or more WAR, EJB JAR and client JAR files
– + deployment descriptions (e.g. weblogic-application.xml)
– Includes options for deploying security artifacts to WebLogic Server
19 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Deployment Profile Types
• Project Deployment Profile Types – WAR Files – ADF Library JAR – Business Component Service Interface
• Application Deployment Profile Types – EAR Files – MAR Files
• Metadata archive file
– For deploying seeded customizations or base metadata for MDS repository in application server
20 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 20 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Image: Ambro / FreeDigitalPhotos.net
Consider defining naming standards for the deployment profiles, the
default profile names can be messy.
Don’t leave outdated or unused deployment profiles against the applicaIons and projects, it's hard for the next programmer to know
which one to use.
21 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Program Agenda
• Building Source Code • ADF Build Setup
– Pre Build: Deployment Profiles – Build Tools & Options – Dependency Management – Post Build: WLS Deployment Plans & Build Modifications
• Continuous Integration
22 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Options to Build ADF Artifacts
1. Manually/by hand – Not recommended! 2. Within JDeveloper – Only suitable for development 3. Via ojdeploy
– Via command line – Via Ant script
• Inline or outside JDeveloper including command line or CI engine – Via ojserver – Via Maven (JDev 12c)
4. Via Oracle Developer Cloud Services (and Hudson and ojdeploy)
23 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
ojdeploy
• Compilation and intelligent ADF post compilation processor – Badly named – “builds” not “deploys” – "Headless" JDeveloper version – Called via command line or Apache Ant – Calls the inline build function in JDeveloper – Builds one artifact at a time – Requires file system access to source code – Requires a full-blown JDeveloper install to operate
24 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
ojdeploy Command Line Examples
// Deploying an ADF Library from the Model project ojdeploy -workspace /usr/jdoe/MyApp/MyApp.jws -project Model -profile MyAppAdfLib // Deploying an EAR from the Application workspace ojdeploy -workspace /usr/jdoe/MyApp/MyApp.jws -profile MyAppEar
25 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
ojdeploy • Features
– Validates ADF metadata XML files – Generates ADF specific metadata files
(e.g. task-flow-registry.xml) – Edits detail of connection manager
(connections.xml) – Compiles and generates files for ADF
BC & ADF Security – Creates Oracle deployment artifacts
(e.g. ADF Libraries and MAR files)
• Every check & automation the JDeveloper inline build tool does, ojdeploy does too
My developers don't want to install the full JDeveloper onto
the build server for just the headless ojdeploy. Why should we use ojdeploy at all when we
can call javac instead?
Image: imagerymajestic/ FreeDigitalPhotos.net
26 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
ojdeploy
• Pros – Understands JDeveloper application artifacts – Beyond compilation ensures health of your ADF project – Automagical
• Cons – Requires full check of source code, no version control intelligence – Requires a full JDeveloper install on your build server – Start/stop cycle is slow – Blackbox implementation – No inbuilt dependency management intelligence
27 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 27 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Image: Ambro / FreeDigitalPhotos.net
ojdeploy's features come for free & disk space is cheap.
Follow Oracle's recommendation and use
ojdeploy, not your own home built java build routines
28 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Ant + ojdeploy
• ojdeploy can be embedded in Ant as a native task type – Provided by OJDeployAnt.class Ant TaskDef
• Platform independent Ant script – Though there is a dependency JDeveloper/ojdeploy being pre-installed
• Can be called via: – JDeveloper – Command line Java utilities – CI tools such as Hudson
• Making it a worth while investment to create and reuse
29 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
ojdeploy build.xml Ant Example
<target name="deploy"> <taskdef name="ojdeploy" classname="oracle.jdeveloper.deploy.ant.OJDeployAntTask" uri="oraclelib:OJDeployAntTask" classpath="/vol1/jdeveloper/jdev/lib/ant-jdeveloper.jar"/> <ora:ojdeploy xmlns:ora="oraclelib:OJDeployAntTask" executable="/vol1/jdeveloper/jdev/bin/ojdeploy"> <ora:deploy> <ora:parameter name="workspace" value="/usr/jdoe/MyApp/MyApp.jws"/> <ora:parameter name="project" value="Model"/> <ora:parameter name="profile" value="MyAppAdfLib"/> </ora:deploy> </ora:ojdeploy> </taskdef> </target>
30 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Ant + ojdeploy Limitation & Workaround
• Current as of 11.1.1.6.0 and 11.1.2.3.0 (may change in later releases) – If you want to use the same Ant script for both development PCs and build server – The pregenerated Ant build.properties file will assume JDeveloper (with ojdeploy)
is installed in the same location in both environments • You must standardize JDeveloper installation directories • Cater for disparate operating systems with Unix vs Windows paths
– Workaround: Ant properties are immutable. • Create a wrapping Ant script that loads custom properties • Get that Ant script to call the original Ant build script
31 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
ojserver • Server version of ojdeploy, available as of 11.1.2.X • Called from ojdeploy with switch • Has all pros/cons of ojdeploy • Except only started/stopped once
– ojdeploy start/stop times of multiple workspace can take significant time – ojserver starts once, lightweight ojdeploy passes job, faster for multiple build jobs
• Must have access to the build paths/objects just like ojdeploy, the build objects are not transmitted to ojserver
• Limitation as of 11.1.2.3.0 – ojserver and address flags currently not supported by OJDeployAnt – See workaround: http://bit.ly/NQtcqk
32 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
ojdeploy to ojserver example
// On server ojserver –start // On client ojdeploy -workspace /usr/jdoe/MyApp/MyApp.jws -project ViewController -profile DemoVCProfile -ojserver -address localhost:2010
33 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Maven
• Within JDeveloper 12c Maven will be 1st class citizen • ojdeploy plug in will be provided • ADF applications can be built from ojdeploy
• More information pending 12c's arrival • Also covered in the upcoming dependency management section
34 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Oracle Developer Cloud Services
§ Develop A turnkey development platform securely hosted in the cloud
§ Collaborate Integrated tools to manage and track tasks, builds, and documentation
§ Deploy Automatic deployment to Oracle Java Cloud Service or your local infrastructure
§ Standards-based Git, Hudson, Maven Developer
35 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Cloud or On-Premise
Dev, Test or Production
Deploy
Hudson
Sources
Tasks
Wiki Commit
Track & Monitor
Oracle Developer Cloud Services
Developers Developer Services
Java Cloud Service
36 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Oracle Developer Cloud Services
• Currently supports (Jan 2013) JDev/ADF 11.1.1.6.0 • Must use Git for source control • Modify build.xml/build.properties to work with Cloud environment
– Still uses ojdeploy
• Push local/developer Git repository changes to cloud repository – Or other 3rd party Git repository e.g. GitHub
• Built via Hudson Job 1. Extracts code from Git repository 2. Calls build.xml 3. Creates deployment artefact
37 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Oracle Developer Cloud Services
• More information pending ODCS's arrival
38 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Program Agenda
• Building Source Code • ADF Build Setup
– Pre Build: Deployment Profiles – Build Tools & Options – Dependency Management – Post Build: WLS Deployment Plans & Build Modifications
• Continuous Integration
39 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
"Architecture is actually really simple.
It is dependency management."
Author Unknown http://clojurefun.wordpress.com/
40 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Build Dependency Management
• ADF applications are optionally built with multiple modules – 3rd party libraries such as ADF Runtimes, open source code etc – Your own ADF Libraries and the final EAR (composite) application
• Modules may be dependent on other modules • In order to build the final application the modules
must be built in order of their dependencies – Least dependent first, then building modules
following the chain of dependents – Breaking this order implies the system can't
be built
Image: jscretionz / FreeDigitalPhotos.net
41 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Build Dependency Management
• To build in the correct order dependencies must be configured • JDeveloper projects record the libraries they're dependent on
– But is locked up in the associated/undocumented .jpr file – JDeveloper provides no useful dependency management assistance
• Supplement JDeveloper with a dependency management tool – Manual Apache Ant scripts – Apache Ivy – Apache Maven
42 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Build Dependency Management Tools
• Hardcoded Ant scripts for small projects are okay – Simply wont scale to large projects – scripts become impossible to maintain
• Dependency management tools provide assistance with – Define and track the modules, versions and dependencies – Library repositories
• Allows developers share versioned modules • Through publish/retrieve mechanism
– Define dependencies and transient (indirect) dependencies – Conflict resolution on dependencies
43 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Apache Ivy
• Free extension to Ant from Apache foundation • Purely a dependency management tool • Relatively simple to learn • Relatively flexible to your needs via agility of Apache Ant scripts • Documentation is available and of average quality • Online forums/help participation is okay • Has been used by JDeveloper customers • Still used and updated (as of Nov-2012), but Maven is the Java EE
industry's preference
44 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Apache Ivy Implementation
• Combines with your existing ojdeploy Ant scripts • Central ivysettings.xml file specifies location of Ivy repository
– Local, shared and public repositories including file systems and Maven
• Per module an ivy.xml file specifies details and dependencies • This is "published" to the repository • When building a module
– The repository containing all ivy.xml files is queried – Determines direct dependencies and transient dependencies in build order – Reports this to the Ant build scripts – Ant build scripts can optionally check-out/build/publish modules in orders
45 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Apache Maven
• Free from the Apache Foundation • Defining Maven is difficult: Not just a dependency management tool • Amongst many features
– Builds out your project source and management with – Change log document created directly from source control – Cross referenced sources – Mailing lists – Dependency list – Unit test reports including coverage
46 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Apache Maven
• Optional server install • You must do things the Maven-way or else • You either love it or hate it • Arguably requires additional tooling to work with it
• But is a near Java EE industry defacto standard
47 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Apache Maven & JDeveloper
• JDeveloper 11gR1 has no support for Maven • JDeveloper 11gR2 has limited supported
– But considered incomplete/first step to support • JDeveloper 12c Apache Maven will be a 1st class citizen
– Will include ojdeploy plugin and ojmake plugins
• More information will become available on the 12c release
48 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Program Agenda
• Building Source Code • Considerations of Building ADF Applications
– Pre Build: Deployment Profiles – Build Tools & Options – Dependency Management – Post Build: WLS Deployment Plans & Build Modifications
• Continuous Integration
49 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Post Build Modifications • Upon deployment of the artefacts may be necessary to modify it
– Such as modifying configuration files for different dev/test/prod environments – e.g. these web.xml settings should be set/unset per environment
• 2 options – WLS deployment plans – Ant scripts
<context-param> <param-name>oracle.adf.view.rich.ASSERT_ENABLED</param-name> <param-value>true</param-value> </context-param> <context-param> <param-name>org.apache.myfaces.trinidad.DEBUG_JAVASCRIPT</param-name> <param-value>true</param-value> </context-param>
50 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
WLS Deployment Plans
• Oracle WLS feature only • Created by developers and administrators • Applied during deployment phase • Intercepts and modifies artefact before deployment • Can modify "standard" Java EE configurations file
– web.xml, weblogic.xml, weblogic-application.xml – e.g. Modify a <context-param> in a web.xml file – Has no intelligence/support for ADF or JSF files
51 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Modify web.xml context-param Example
<?xml version = '1.0' encoding = 'ISO-8859-1'?> <web-app xmlns="..." xmlns:xsi="..." xsi:schemaLocation="..." version="2.5"> <context-param> <param-name>oracle.adf.view.rich.versionString.HIDDEN</param-name> <param-value>false</param-value> </context-param> ...
java weblogic.PlanGenerator –all -plan plan.xml Application.ear
We want to change this to "true" at
deployment time
52 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
WLS Deployment Plan Example <?xml version='1.0' encoding='UTF-8'?> <deployment-plan xmlns="..." xmlns:xsi="..." xsi:schemaLocation="..."> <application-name>Application.ear</application-name> <variable-definition> <variable> <name>hide_version</name><value>true</value> </variable> </variable-definition> <module-override> <module-descriptor external="false"> <root-element>web-app</root-element> <uri>WEB-INF/web.xml</uri> <variable-assignment> <name>hide_version</name> <xpath> /web-app/context-param/[param-name="oracle.adf.view.rich.versionString.HIDDEN"]/param-value </xpath> <operation>replace</operation> </variable-assignment> ..
53 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Ant Scripts • Use Ant scripts to explode and modify the end artefact • "Ant-Contrib" Ant extension provides useful task extensions
– New procedural constructs/tasks: if, for, foreach
• "XMLTask" Ant extension allows to read/write XML files • In combination
– Inspect ADF XML files – Loop over number of XML elements – Test conditions – Modify XML elements – e.g. Loop over bc4j.xcfg named configurations searching for a match and modify
the data source to point to a production JNDI
54 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Program Agenda
• Software Builds • ADF Build Setup
– Pre Build: Deployment Profiles – Build Tools & Options – Dependency Management – Post Build: WLS Deployment Plans & Build Modifications
• Continuous Integration
55 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
The Discipline of Continuous Integration • CI dictates software builds are not just limited to building your
application for deployment and use
• Includes: – Regular run sanity checks testing integrity of
your code after check-ins – Run periodic tests – Provide early feedback to developers
• Don't confuse a CI engine with the actual build tool itself. A CI engine is typically a scheduling tool that kicks off the build tool
Image: Phaitoon / FreeDigitalPhotos.net
56 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Hudson • There are plenty of CI engines available • Oracle recommends Hudson • Hudson was inherited by Oracle from Sun • Was donated to the Eclipse Foundation in 2012 • Jenkins was an open source fork of Hudson • Oracle recommends Hudson over Jenkins
– Ongoing support from Oracle – Removed IP concerns over internal code – Used internally by Oracle and Oracle's Developer Cloud Services extensively – Widening supports for ADF applications
57 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
The CI Maturity Model
1. No Build Server 2. Nightly Builds 3. Nightly Builds and Basic Automated Tests 4. Metrics 5. Sophisticated Testing Methodologies 6. Automated Acceptance Tests and More
Automated Deployment 7. Continuous Deployment
58 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Conclusion
• Building your applications isn't a 1 click affair • Consider your
– Deployment profiles and options – Build tools – Post build modifications
• Introduce a process and document it • Plan to introduce tools to assist you with dependency management • Make continuous integration a central mantra of your development
efforts
59 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Further Reading
• Fusion Developer's Guide for Oracle Application Development Framework 11.1.2.3.0 – Section 41 Deploying Fusion Web Applications
• http://bit.ly/adfdevguide11123sect41
• ojdeploy and JDeveloper http://bit.ly/WAtDFh
• ojserver and JDeveloper http://bit.ly/NQtcqk
• Apache Ivy http://ant.apache.org/ivy
• Apache Ivy and JDeveloper http://bit.ly/RdX7JG
• Apache Maven http://maven.apache.org
60 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.