Top Banner
The Cernunnos Project Andrew Wills JA-SIG 2007 Summer Conference, Denver Monday June 25th, 2007 © Copyright Unicon, Inc., 2006. This work is the intellectual property of Unicon, Inc. Permission is granted for this material to be shared for non-commercial, educational purposes, provided that this copyright statement appears on the reproduced materials and notice is given that the copying is by permission of Unicon, Inc. To disseminate otherwise or to republish requires written permission from Unicon, Inc.
47

The Cernunnos Project Andrew Wills JA-SIG 2007 Summer Conference, Denver Monday June 25th, 2007 © Copyright Unicon, Inc., 2006. This work is the intellectual.

Dec 26, 2015

Download

Documents

Candace Warner
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: The Cernunnos Project Andrew Wills JA-SIG 2007 Summer Conference, Denver Monday June 25th, 2007 © Copyright Unicon, Inc., 2006. This work is the intellectual.

The Cernunnos Project

Andrew WillsJA-SIG 2007 Summer Conference, Denver

Monday June 25th, 2007

© Copyright Unicon, Inc., 2006. This work is the intellectual property of Unicon, Inc. Permission is granted for this material to be shared for non-commercial, educational purposes, provided that this copyright statement appears on the reproduced materials and notice is given that the copying is by permission of Unicon, Inc. To disseminate otherwise or to republish requires written permission from Unicon, Inc.

Page 2: The Cernunnos Project Andrew Wills JA-SIG 2007 Summer Conference, Denver Monday June 25th, 2007 © Copyright Unicon, Inc., 2006. This work is the intellectual.

1. Introduction

2. Motivation, Goals, & Strategy

3. Using Cernunnos

4. Cernunnos & uPortal

Page 3: The Cernunnos Project Andrew Wills JA-SIG 2007 Summer Conference, Denver Monday June 25th, 2007 © Copyright Unicon, Inc., 2006. This work is the intellectual.

Introducing Cernunnos

• Cernunnos is an open source Java technology for

implementing, instrumenting, and combining valuable

software behavior

• Project Home Page (Google Code): http://

code.google.com/p/cernunnos/

• Community (Google Groups):

http://groups.google.com/group/cernunnos-discussion/

• Presently, there is one contributor (guess who?)

Page 4: The Cernunnos Project Andrew Wills JA-SIG 2007 Summer Conference, Denver Monday June 25th, 2007 © Copyright Unicon, Inc., 2006. This work is the intellectual.

The Cernunnos Platform

• Cernunnos provides a medley of components out-of-the-box (just like Java):

– A contract for Tasks & Phrases (Java API)

– A basic container implementation for running Tasks & Phrases

– An assortment of useful Task & Phrase implementations

– A core syntax for instrumenting these implementations (XML-based)

– Useful tools (e.g. Grammardoc, Command Line Scripts)

Page 5: The Cernunnos Project Andrew Wills JA-SIG 2007 Summer Conference, Denver Monday June 25th, 2007 © Copyright Unicon, Inc., 2006. This work is the intellectual.

But Isn’t That Just Like …

• Cernunnos has some similarities with popular

technologies like Ant, Jelly, Groovy, etc.

• But there are meaningful differences in the details,

some of which are discussed here:

http://code.google.com/p/cernunnos/wiki/Comparison_with_Jelly

• The creator of Cernunnos sees the project not as a

tool written in Java, but as an innovative way to

practice Java

• From that perspective, it appears more similar to

Servlets or Spring than the items above

Page 6: The Cernunnos Project Andrew Wills JA-SIG 2007 Summer Conference, Denver Monday June 25th, 2007 © Copyright Unicon, Inc., 2006. This work is the intellectual.

Motivation, Goals, & Strategy

Page 7: The Cernunnos Project Andrew Wills JA-SIG 2007 Summer Conference, Denver Monday June 25th, 2007 © Copyright Unicon, Inc., 2006. This work is the intellectual.

Notable Quote

“Java’s not worth building in. Nobody uses

Java anymore. It’s this big heavyweight ball

and chain.”

- Steve Jobs

Taken from a recent New York Times interview

about Apple’s new iPhone

http://www.theserverside.com/blogs/thread.tss?thread_id=45781

Page 8: The Cernunnos Project Andrew Wills JA-SIG 2007 Summer Conference, Denver Monday June 25th, 2007 © Copyright Unicon, Inc., 2006. This work is the intellectual.

Goals of Cernunnos

• Cernunnos was created to address software

professional effectiveness

• Professionals who use Cernunnos should be

able to deliver a higher ratio of software value

(outputs) to effort (inputs) compared with

“industry normal” practices

Page 9: The Cernunnos Project Andrew Wills JA-SIG 2007 Summer Conference, Denver Monday June 25th, 2007 © Copyright Unicon, Inc., 2006. This work is the intellectual.

Goals of Cernunnos (Cont.)

Cenunnos is not about:

• Security

• Scalability

• Usability

Cernunnos is about:

• Getting more business

value from your

investment in custom

software

Page 10: The Cernunnos Project Andrew Wills JA-SIG 2007 Summer Conference, Denver Monday June 25th, 2007 © Copyright Unicon, Inc., 2006. This work is the intellectual.

Strategy in a Nutshell

• Mature disciplines are good at creating high-

level solutions from standardized, low-level

components

• But in software we reinvent low-level

behaviors constantly: JDBC calls, file system

I/O, XML parsing, XSL Transformations, etc.

• Cernunnos provides a standard form factor

for behavior, allowing behaviors (old & new)

to be combined in innovative, flexible ways

Page 11: The Cernunnos Project Andrew Wills JA-SIG 2007 Summer Conference, Denver Monday June 25th, 2007 © Copyright Unicon, Inc., 2006. This work is the intellectual.

Short Backstory

Your client is moving to PeopleSoft

Your Assignment:

1. An existing work study app must be changed

to pull data from a new database

2. The work must be done in Java

3. You must do the work

4. The source database isn’t ready, and won’t

be ready before your contract is up

Page 12: The Cernunnos Project Andrew Wills JA-SIG 2007 Summer Conference, Denver Monday June 25th, 2007 © Copyright Unicon, Inc., 2006. This work is the intellectual.

Using Cernunnos

Page 13: The Cernunnos Project Andrew Wills JA-SIG 2007 Summer Conference, Denver Monday June 25th, 2007 © Copyright Unicon, Inc., 2006. This work is the intellectual.

Tasks & Phrases

• In Cernunnos, meaningful work is handled by

Tasks & Phrases

• A Task is a unit of behavior

• A Phrase is an expression that calculates a

value at runtime

<copy-file location="http://www.google.com" to-file="google_home.html"/>

<echo-ln>${valueOf(.)}</echo-ln>

Page 14: The Cernunnos Project Andrew Wills JA-SIG 2007 Summer Conference, Denver Monday June 25th, 2007 © Copyright Unicon, Inc., 2006. This work is the intellectual.

Tasks & Phrases (Cont.)

<!--Examine the contents of all JAR files in the present directory and all subdirectories. Print the name(s) of all entries that match the specifiedpattern.-->

<file-iterator includes="**/*.jar"> <echo-ln>${req(Attributes.LOCATION)}:</echo-ln> <archive-iterator> <if test="${jexl(Attributes.LOCATION.contains('${req($1)}'))}"> <echo-ln prefix="&#009;">${req(Attributes.LOCATION)}</echo-ln> </if> </archive-iterator> <echo-ln/></file-iterator>

> crn find-in-jar.crn DocumentFactory

Page 15: The Cernunnos Project Andrew Wills JA-SIG 2007 Summer Conference, Denver Monday June 25th, 2007 © Copyright Unicon, Inc., 2006. This work is the intellectual.

Tasks & Phrases (Cont.)

• Call standard (out-of-the-box) Tasks & Phrases by

names from a standard grammar file

• Use the <add-grammar> Task to register a custom

grammar file; or

• Refer to Task & Phrase implementations directly (viz.

fully-qualified class name)

<parameter value="${org.jasig.portal.groups.GetMemberKeyPhrase(${singleNode(child/*)})}“/>

Page 16: The Cernunnos Project Andrew Wills JA-SIG 2007 Summer Conference, Denver Monday June 25th, 2007 © Copyright Unicon, Inc., 2006. This work is the intellectual.

Cernunnos Grammardoc

Page 17: The Cernunnos Project Andrew Wills JA-SIG 2007 Summer Conference, Denver Monday June 25th, 2007 © Copyright Unicon, Inc., 2006. This work is the intellectual.

Installing Cernunnos

Running Cernunnos from the command line:

1. Install the following tools

– Subversion

– Ant

2. Download Cernunnos source

> svn checkout http://cernunnos.googlecode.com/svn/trunk/

3. Compile Cernunnos

> ant build

4. Add the Cernunnos bin/ directory to your path

Page 18: The Cernunnos Project Andrew Wills JA-SIG 2007 Summer Conference, Denver Monday June 25th, 2007 © Copyright Unicon, Inc., 2006. This work is the intellectual.

Embedding Cernunnos

Using Cernunnos in other applications:

1. Add the following JARs to the classpath:

• cernunnos.jar

• commons-jexl-1.1.jar

• dom4j.jar

• jaxen.jar

2. Use the ScriptRunner classScriptRunner runner = new ScriptRunner();

runner.run(location)

Page 19: The Cernunnos Project Andrew Wills JA-SIG 2007 Summer Conference, Denver Monday June 25th, 2007 © Copyright Unicon, Inc., 2006. This work is the intellectual.

Invoking Cernunnos

• You can specify a Cernunnos script using

either a file system path, a URL, or a location

in the classpath

• This is not only true for scripts – you can

reference pretty much any resource pretty

much anywhere in any of these ways

> crn grammardoc.crn

> crn http://cernunnos-discussion.googlegroups.com/web/find-class-in-jar.crn Document

> crn classpath://org.jasig.portal.container.deploy.deploy-portlet-app.crn myApp.war

Page 20: The Cernunnos Project Andrew Wills JA-SIG 2007 Summer Conference, Denver Monday June 25th, 2007 © Copyright Unicon, Inc., 2006. This work is the intellectual.

Cernunnos & uPortal

Page 21: The Cernunnos Project Andrew Wills JA-SIG 2007 Summer Conference, Denver Monday June 25th, 2007 © Copyright Unicon, Inc., 2006. This work is the intellectual.

New or Improved Features

Cernunnos has been used with uPortal in

several ways:

• Execute arbitrary SQL from the console

• Convert a new uPortal 2.5.x to DLM

• Improved “deployPortletApp” target

• Core data Import/Export (XML-based)

Page 22: The Cernunnos Project Andrew Wills JA-SIG 2007 Summer Conference, Denver Monday June 25th, 2007 © Copyright Unicon, Inc., 2006. This work is the intellectual.

Execute Arbitrary SQL

• Cernunnos picks up JDBC connection information

from rdbm.properties (viz. where it lives)

• Invoke with

> crn sql.crn “INSERT INTO up_user…”

<properties location="build/WEB-INF/classes/properties/rdbm.properties"> <sql-connection

driver="${req(jdbcDriver)}" url="${req(jdbcUrl)}" username="${req(jdbcUser)}“password="${req(jdbcPassword)}">

<sql-statement sql="${req($1)}"/> </sql-connection></properties>

Page 23: The Cernunnos Project Andrew Wills JA-SIG 2007 Summer Conference, Denver Monday June 25th, 2007 © Copyright Unicon, Inc., 2006. This work is the intellectual.

Convert to DLM

• Automates the process described on the uPortal wiki:

http://www.ja-sig.org/wiki/display/UPM/DLM+Administration+Guide

• Summary:

1. Set UserLayoutStoreFactory.implementation to RDBMDistributedLayoutStore

2. Set UserLayoutManagerFactory.coreImplementation to DistributedLayoutManager

3. Update the UP_USER_PROFILE table to match the theme and style values for DLM

Page 24: The Cernunnos Project Andrew Wills JA-SIG 2007 Summer Conference, Denver Monday June 25th, 2007 © Copyright Unicon, Inc., 2006. This work is the intellectual.

Convert to DLM (Cont.)

<properties location="build/WEB-INF/classes/properties/rdbm.properties">

<!-- First change portal.properties... --> <string-replace string="${url(properties/portal.properties)}" regex="...UserLayoutStoreFactory.impl=..." replacement="...RDBMDistributedLayoutStore"> <string-replace regex="...UserLayoutManagerFactory.impl=..." replacement="...DistributedLayoutManager"> <write-file file="properties/portal.properties"/> </string-replace> </string-replace>

<!-- Next update the database... --> <sql-connection ...> <sql-statement sql="UPDATE up_user_profile

SET structure_ss_id=4, theme_ss_id=3 WHERE theme_ss_id=11"/>

</sql-connection>

</properties>

Page 25: The Cernunnos Project Andrew Wills JA-SIG 2007 Summer Conference, Denver Monday June 25th, 2007 © Copyright Unicon, Inc., 2006. This work is the intellectual.

New “deployPortletApp” Target

• Current deployPortletApp implementation creates a

new web.xml file using some values from the existing

one, which causes problems

– Hard-coded use of the 2.3 servlet spec (UP-1241)

– //description becomes /web-app/description

• New implementation merely adjusts the web.xml that is

provided

• New implementation also makes it more natural to

invoke this behavior within the web application itself

classpath://org/jasig/portal/container/deploy/deploy-portlet-app.crn

Page 26: The Cernunnos Project Andrew Wills JA-SIG 2007 Summer Conference, Denver Monday June 25th, 2007 © Copyright Unicon, Inc., 2006. This work is the intellectual.

New “deployPortletApp” Target (Cont.)

Summary of deployPortletApp behavior:

1. Extract the specified portlet WAR file to the appropriate location within Tomcat (deploy.home in Ant)

2. Add <servlet> elements for each portlet definition in portlet.xml using XSLT

3. Add <servlet-mapping> elements for each <servlet> element using XSLT

4. Add a <taglib> element for portlet JSP tags

5. Add the portlet.tld file to the webapp in Tomcat

Page 27: The Cernunnos Project Andrew Wills JA-SIG 2007 Summer Conference, Denver Monday June 25th, 2007 © Copyright Unicon, Inc., 2006. This work is the intellectual.

XML Import/Export

• XML Import & Export using Cernunnos was

presented at the uPortal Developers’ Meeting at

Johns Hopkins University in April

• This portion of the session contains updated

material from that meeting

• Much more detailed information -- and a working

prototype -- are available onlinehttp://www.ja-sig.org/wiki/display/UPC/uP2+XML+Import+Export+with+Cernunnos

Page 28: The Cernunnos Project Andrew Wills JA-SIG 2007 Summer Conference, Denver Monday June 25th, 2007 © Copyright Unicon, Inc., 2006. This work is the intellectual.

XML Import/Export (Cont.)

• Although every uPortal release comes with a

working data set, every institution needs to

customize this data extensively to meet their

individual needs

• Editing this data where it lives (i.e. data.xml)

is confusing, tedious, and risky!

• Using uPortal’s UI to edit the data isn’t

reproducible by automated means

Page 29: The Cernunnos Project Andrew Wills JA-SIG 2007 Summer Conference, Denver Monday June 25th, 2007 © Copyright Unicon, Inc., 2006. This work is the intellectual.

XML Import/Export (Cont.)

It would be nice if…

• The data set were more approachable

(readable and editable)

• Entities were described in individual files

instead of a single, monolithic document

• Entities didn’t reference each other using

database IDs, so they could be imported (or

shared) in any order

Page 30: The Cernunnos Project Andrew Wills JA-SIG 2007 Summer Conference, Denver Monday June 25th, 2007 © Copyright Unicon, Inc., 2006. This work is the intellectual.

Example XML Document

<layout username="student" script="classpath://org/jasig/portal/layout/simple/import-

layout.crn"> <root name="Root folder" immutable="N" unremovable="Y"> <header name="Header folder" immutable="Y" unremovable="Y"> <channel fname="header"/> <channel fname="portal/login/general"/> </header> <tab name="Main Student Tab" immutable="N" unremovable="N"> <column name="Column 2" immutable="N" unremovable="N"> <channel fname="salon.com"/> </column> <column name="Column 1" immutable="N" unremovable="N"> <channel fname="minesweeper"/> <channel fname="word-of-the-day"/> <channel fname="number-guessing-game"/> </column> </tab> <footer name="Footer folder" immutable="N" unremovable="N"> <channel fname="footer"/> </footer> </root></layout>

Page 31: The Cernunnos Project Andrew Wills JA-SIG 2007 Summer Conference, Denver Monday June 25th, 2007 © Copyright Unicon, Inc., 2006. This work is the intellectual.

Using the Prototype

• A Cernunnos-based import/export tool is available that handles the following data:

– Users

– Groups

– Channels

– Group Memberships

– Permissions

– Layouts

• The prototype tool is attached as a ZIP to the wiki page about this technology

• To use it, extract the contents into the root of a uPortal 2.5 (or later) distribution

Page 32: The Cernunnos Project Andrew Wills JA-SIG 2007 Summer Conference, Denver Monday June 25th, 2007 © Copyright Unicon, Inc., 2006. This work is the intellectual.

Using the Prototype (Cont.)

• Invoke it from the command line using Ant

> ant –f import-export.xml export –Ddir={dir} –Dtype={type} [–Dsysid={sysid}]

> ant –f import-export.xml import [-Ddir={dir}] [-Dpattern={pattern}]

dir = a file system directory

type = all | layout | all-layouts | channel | all-channels | all-permissions | all-memberships | group | all-groups

sysid = user_name | fname |group_name

pattern = a regex expression

Page 34: The Cernunnos Project Andrew Wills JA-SIG 2007 Summer Conference, Denver Monday June 25th, 2007 © Copyright Unicon, Inc., 2006. This work is the intellectual.

** REMOVED **

Page 35: The Cernunnos Project Andrew Wills JA-SIG 2007 Summer Conference, Denver Monday June 25th, 2007 © Copyright Unicon, Inc., 2006. This work is the intellectual.

Custom Software is Expensive

• Developing new software using "industry

standard" technologies and practices is very

effort intensive

• Qualified professionals ("knowledge workers")

are expensive

• And don’t forget…

– Software project failure rates are daunting

– So are time-to-market considerations

Page 36: The Cernunnos Project Andrew Wills JA-SIG 2007 Summer Conference, Denver Monday June 25th, 2007 © Copyright Unicon, Inc., 2006. This work is the intellectual.

Whose Problem Is It?

• If you're not thinking about these issues every day, you really should... your employers are

• Offshoring is a popular practice, and growing in use

• Many valuable software projects are never undertaken

• There is a high threshold of expected business value that a proposed software project must meet

Page 37: The Cernunnos Project Andrew Wills JA-SIG 2007 Summer Conference, Denver Monday June 25th, 2007 © Copyright Unicon, Inc., 2006. This work is the intellectual.

Choosing Project Scope

One common approach to planning the scope of a

software project and its iterations:

1. Create a list of proposed features

2. Assign each feature a number for Business Value

3. Assign each feature a number for Effort

4. Sort the list by the ratio of Business Value to Effort

5. Plan to implement the features with the best ratio first

6. Stop when the incremental value no longer justifies the

effort

Page 38: The Cernunnos Project Andrew Wills JA-SIG 2007 Summer Conference, Denver Monday June 25th, 2007 © Copyright Unicon, Inc., 2006. This work is the intellectual.

Choosing Project Scope (Cont.)

Feature BV/LOE LOE BV

A 1.33 3 4

B 1.25 4 5

C 1.20 5 6

D 0.78 9 7

E 0.75 8 6

F 0.71 7 5

G 0.67 6 4

H 0.57 14 8

I 0.54 13 7

J 0.50 12 6

K 0.45 11 5

L 0.45 20 9

M 0.42 19 8

N 0.40 10 4

O 0.39 18 7

P 0.35 17 6

Q 0.31 16 5

R 0.27 15 4

S 0.23 22 5

T 0.19 21 4

Page 39: The Cernunnos Project Andrew Wills JA-SIG 2007 Summer Conference, Denver Monday June 25th, 2007 © Copyright Unicon, Inc., 2006. This work is the intellectual.

Relationship Between Business Value & Effort

0.00

0.20

0.40

0.60

0.80

1.00

1.20

1.40

A B C D E F G H I J K L M N O P Q R S T

Proposed Features

BV/LOE

Choosing Project Scope (Cont.)

Page 40: The Cernunnos Project Andrew Wills JA-SIG 2007 Summer Conference, Denver Monday June 25th, 2007 © Copyright Unicon, Inc., 2006. This work is the intellectual.

It Doesn’t Have to Be This Way

• Among human endeavors, software is

exceedingly young

• Software industry technologies and practices

are at an early evolutionary stage

• Innovations that unlock tremendous gains in

effectiveness are out there to be invented

Page 41: The Cernunnos Project Andrew Wills JA-SIG 2007 Summer Conference, Denver Monday June 25th, 2007 © Copyright Unicon, Inc., 2006. This work is the intellectual.

Relationship Between Business Value & Effort

0.00

0.20

0.40

0.60

0.80

1.00

1.20

1.40

A B C D E F G H I J K L M N O P Q R S T

Proposed Features

BV/LOE

Choosing Project Scope (Revisited)

Page 42: The Cernunnos Project Andrew Wills JA-SIG 2007 Summer Conference, Denver Monday June 25th, 2007 © Copyright Unicon, Inc., 2006. This work is the intellectual.

Goal of This Session

Page 43: The Cernunnos Project Andrew Wills JA-SIG 2007 Summer Conference, Denver Monday June 25th, 2007 © Copyright Unicon, Inc., 2006. This work is the intellectual.

Buzzword Compliance

• Cernunnos leverages forward thinking both

from within the software industry and

elsewhere

– Composite Pattern

– Transparent Enclosure/Decorator Pattern

– Behavior Injection

– Intelligent Defaults

– Form Follows Function

– Platform Independence

Page 44: The Cernunnos Project Andrew Wills JA-SIG 2007 Summer Conference, Denver Monday June 25th, 2007 © Copyright Unicon, Inc., 2006. This work is the intellectual.

Solution

• Storing the data in XML is great because

tools like Subversion can manage it smoothly

• But the XML format used by data.xml is

unapproachable to human beings

• It would be better to store this data in a

collection of smaller XML documents with

domain-specific schemas

Page 45: The Cernunnos Project Andrew Wills JA-SIG 2007 Summer Conference, Denver Monday June 25th, 2007 © Copyright Unicon, Inc., 2006. This work is the intellectual.

Solution (Cont.)

• These documents can be more succinct and

manageable by conveying information

structurally that data.xml must convey

explicitly (e.g parent-child relationships, entity

types)

• Also these documents can avoid referencing

database IDs, allowing entities to be imported

and exported ad hoc – even from one portal

database to another!

Page 46: The Cernunnos Project Andrew Wills JA-SIG 2007 Summer Conference, Denver Monday June 25th, 2007 © Copyright Unicon, Inc., 2006. This work is the intellectual.

Data in uPortal

• Information in the portal database represents the following classes of entities:

– Minor Items (version info., sequences, etc.)

– Users

– Groups

– Channels

– Group Memberships

– Permissions

– Layouts

• Items that appear lower on this list often depend on items that appear higher (viz. foreign keys)

Page 47: The Cernunnos Project Andrew Wills JA-SIG 2007 Summer Conference, Denver Monday June 25th, 2007 © Copyright Unicon, Inc., 2006. This work is the intellectual.

Status of the Prototype

• Work on the prototype started with Layouts (DLM) and proceeded “backwards”

• The prototype currently includes both import and export through Groups Users

• Which leaves:

– Minor Items

– Users

• It works in uPortal 2.5.3 (AFAIK)

• It hasn’t been tried in any other version