Javapolis 2007: AJAX meets JCR

Post on 05-Dec-2014

5.688 views 3 download

description

Javapolis 2007 session. Introducing microjax

Transcript of Javapolis 2007: AJAX meets JCR

Kickstarting the Java Content Repository

AJAX meets JCR

www.javapolis.com

obpqof`qba

R håçï=óçìê=eqji=C=g~î~ëÅêáéíe~îÉ=~=î~ÖìÉ=ÅçåÅÉéí=çÑ=~=“`çåíÉåí=oÉéçëáíçêóÒ

www.javapolis.com

Speaker’s Qualifications

David Nuescheler Chief Technology Officerdavid.nuescheler@day.com

David NueschelerJackrabbit Committer / Memberuncled@apache.org

David NueschelerJSR-170 Spec Leadjsr-170-comments@jcp.org

www.javapolis.com

Overall Presentation Goal

Learn howJCR and Ajax allow for very agile

application development.

www.javapolis.com

Kickstarting JCRAJAX meets JCR

What’s JCR (elevator pitch)

Introducing jax

Weblog in 15 minutessilver

www.javapolis.com

Kickstarting JCRAJAX meets JCR

What’s JCR (elevator pitch)

Introducing jax

Weblog in 15 minutessilver

www.javapolis.com

What’s JCR?

`çåíÉåí=oÉéçëáíçêó=Ñçê=g~î~qj=íÉÅÜåçäçÖó=^mfpéÉÅJiÉ~ÇWa~ó=pçÑíï~êÉpí~íìëW=cáå~ä=oÉäÉ~ëÉ=NTJàìåJOMMR

gpoJNTM

bñéÉêí=dêçìéW

www.javapolis.com

bñéÉêí=dêçìéW

gpoJNTM gpoJOUP

`çåíÉåí=oÉéçëáíçêó=Ñçê=g~î~qj=íÉÅÜåçäçÖó=^mf=îOKMpéÉÅJiÉ~ÇWa~ó=pçÑíï~êÉpí~íìëW=mìÄäáÅ=oÉîáÉï=`äçëÉÇ=ëÉéJOMMT

What’s JCR?

www.javapolis.com

What’s JCR?

“The API should be a standard, implementation independent, way to access content bi-directionally on a granular level to a content repository.” ?

Best of both worlds.data base filesystem

content repository

read

write

hier-archiesstreams

locking accesscontrol

integrity structure

tx query

un-structured“full-text” sort

orderversion

ingobser-vation

multi-value

www.javapolis.com

- Reality Check -

Task: Write a JSP snippet that lists “documents” in a “folder”.”

What’s JCR?

www.javapolis.com

- Reality Check -

Task: Write a JSP snippet that lists “documents” in a “folder”.”

What’s JCR?<%childCount = node.getContentCount();for(int i=0;i<childCount;i++) { IContent child = node.getContent(i); Property title = child.getPropertyByName("Title"); %><%= title.getValue() %><br/><%}%>

<%LAPI_DOCUMENTS documents

= new LAPI_DOCUMENTS(session);

LLValue childTable = new LLValue();

documents.ListObjects(volumeID, folderID,

null, null, LAPI_DOCUMENTS.PERM_SEE, chi

ldTable);

Enumeration children = childTable.enumerateValue

s();

while(children.hasMoreElements()) {

LLValue child = (LLValue)e.nextElement()

;

String title = child.toString("Name");

%><%= title %><br/><%

}%>

<%fndocs = new IFnObjSetDualProxy( fnfolder.getContents(idmFolderContent.idmFolderContentDocument));

int numDocs = fndocs.getCount();for (int i = 1; i <= numDocs; i++) {

IFnDocumentDual fndoc = new IFnDocumentDualProxy(fndocs.getItem(new Integer(i)));

IFnPropertiesDual propset = fndoc.getProperties();

IFnPropertyDual idmTitleProp = propset.getItem("Title");

String title = idmTitleProp.getValue();

%><%= title %><br/><% if (comCleanup) { cleaner.release(fndoc); }}%>

<%IDocuments documents =

new IDocumentsProxy(binder.getDocuments());

documents.cache();

int documentCount = documents.getCount();

for (int i = 0; i<documentCount; i++) {

document = new IDocumentProxy(docume

nts.getItemByIndex(i));

String title = document.getTitle()

%><%= title %><br/><%

}%>

<%PageIterator children = page.getPages();while (children.hasNext()) { Page child = children.nextPage(); Container toplevel = child.getContent(); Atom title = toplevel.getAtom("Title"); %><%= title %><br /><%}%>

+800

<<<<%NodeIterator children = node.getNodes();while (children.hasNext()) { Node child = children.nextNode(); Property title = child.getProperty("Title"); %><%= title %><br /><%}%>

JCR API

www.javapolis.com

- Functional Elevator Pitch -What’s JCR?

level 1

level 2

read, export, query

write, import, accesscontrol

sql locking obser-vation tx versioning

optional

www.javapolis.com

JSR-283 Public Review Ballot

approved

final release:

expected m

id

2008

Java Standardization

www.javapolis.com

Java Standardization

www.javapolis.com

Known compliant Repositories

Apache Jackrabbit Oracle XML DBExo

ECMS PlatformMicrosoft

Sharepoint OpenText Livelink

Day CRX IBM FileNet P8 Xythos Repository Alfresco ECM Vignette V7

Interwoven Repository IBM CM EMC Documentum

How many

RDBMS vendors

do you need?+hundreds of TCKsregistered

* *

*

*

* using third party connector

*

www.javapolis.com

Sourcemix Sourcemix

Percussion Rhythmix Lutece

Portal

QuickWCM WCMS

Jahia Framework

Hippo CMS

InfoQ Online CommunityNuxeo ECM

Sakai E-learning

TYPO3 v5.0 WCMGX WebManager

Exo ECMS Platform

Liferay Enterprise Portal

Artifactory Maven Proxy

IBM FileNet WebSiteManagerApache James

medic-2-medic mapofmedicine

Day Communiqué WCMS

Apache Tapestry

Day Communique Collab

QSLabs ComplianceApache

Cocoon

Alfresco ECMSApache Sling

Mindquarry Collaboration

Day Communique DAMmagnolia WCMS

JBoss Portal

Some known JCR Applications

Sun OpenPortal Interface 21

Spring Framework

Fast Enterprise SearchOracle PortalBEA Portal

www.javapolis.com

JCR - Weatherforcast-5°

2008 2009-8°

2010-12°

www.javapolis.com

Kickstarting JCRAJAX meets JCR

What’s JCR (elevator pitch)

Introducing jax

Weblog in 15 minutessilver

www.javapolis.com

Kickstarting JCRAJAX meets JCR

What’s JCR (elevator pitch)

Introducing jax

Weblog in 15 minutessilver

www.javapolis.com

Introducing jax

Apache Sling

microsling

microjax jax

JCR backed ReST-devkit(OSGI, OCM , ...)subtract osgisubtract ocm

contains

www.javapolis.com

JCR

functionally broad

well designedlong term

strategicheavy duty16 tons

stable & durable

Introducing jax

www.javapolis.com

JCR

me

short-sighted...easily confused

developer hat

hacklazy

“i want to build webapps” the o

ther

side

functionally broad

well designedlong term

strategicheavy duty16 tons

stable & durable

Introducing jax

www.javapolis.com

JCR

me (david)

developer hat

very simple projection: fits the bill

µjax

silver

Introducing jax

I2

3

Browser

J2EE WebServer

browser & ujax.jsreading: json & resource GET’swriting: form-POSTs & GETs

MicrojaxServlet.javatranslating requests to JCR calls

JCR CompliantContent Repository

I

2

3very simple js API to read content, Forms to write content

handles all the heavy lifting, particularly security16 tons

Introducing jax

www.javapolis.com

Introducing jax

“Data First!”JCR supports “structure first” aswell. (but that’s missing point)

DEMO

www.javapolis.com

Getting ready...

download and installtest & mount as a drive

www.javapolis.com

simple write example

write me!http://localhost:7402/apps/firs

tsteps/1_write.html

<html>

<head><title>u

jax: simple wr

ite example</t

itle>

</head><body>

<form action="

/content/first

steps" method=

"POST">

<!-- title -->

<h2>Title</h2>

<input type="t

ext" name="Tit

le" />

<!-- descripti

on -->

<h2>Descriptio

n</h2>

<textarea rows

="5" name="Des

cription">

</te

xtarea>

<!-- color -->

<h2>Color</h2>

<select name="

Color">

<option value=

"red">red

<option value=

"green">green

</select>

</form>

</body>

</html>

www.javapolis.com

simple read example

read me!http://localhost:7402/apps/firststeps/2_read.html

<html>

<head><title>u

jax: simple re

ad example</ti

tle>

</head>

<body>

<script src

="/ujax/ujax.j

s"></script

<script>

var node=uj

ax.getContent(

"/content/firs

tsteps");

var div='<d

iv style="back

ground-color:'

+node.Color+'"

>';

document.wr

ite(div);

</script>

<h2><script>

document.write

(node.Title);

</script></h2>

<p><script>

document.write

(node.Descript

ion);

</script></p>

</div>

</body>

</html>

www.javapolis.com

add newhttp://localhost:7402/apps/firststeps/3_addnew.html

add new entry

<html>

<head><title>u

jax: add new e

ntry example</

title>

</head><body>

<form action="

/content/first

steps/entries/

*"

method="PO

ST" >

<h2>Title</h2>

<input type="t

ext" name="Tit

le" />

<h2>Descriptio

n</h2>

<textarea rows

="5" name="Des

cription"></te

xtarea>

<h2>Color</h2>

<select name="

Color">

<option value=

"red">red

<option value=

"green">green

</select>

<p><input type

="submit"></p>

</form>

</body>

</html>

www.javapolis.com

list entries

list entrieshttp://localhost:7402/apps/firststeps/4_list.html

<html>

<head><title>u

jax: list entr

ies example</t

itle>

[...]

<script>

var entries=uj

ax.getContent(

"/content/firs

tsteps/entries

", 2);

</script>

<div>

<script>

for (var a i

n entries) {

var entry=ent

ries[a];

document.

write('<div st

yle="backgroun

d-color:'+entr

y.Color+'">');

document.

write('<h2>'+e

ntry.Title+'</

h3>');

document.

write(entry.De

scription);

if(entry.

Image) {

[...]

}

document.

write('</div>'

);

document.

write('<a href

="4_list.html"

onclick=

”ujax.removeCo

ntent(\'/mydat

a/entries/\'+a

+'\'">

remove</

a>');

}

</script>

<a href="3_add

new.html">add

new</a>

</div>

</body>

</html>

www.javapolis.com

Kickstarting JCRAJAX meets JCR

What’s JCR (elevator pitch)

Introducing jax

Weblog in 15 minutessilver

www.javapolis.com

Kickstarting JCRAJAX meets JCR

What’s JCR (elevator pitch)

Introducing jax

Weblog in 15 minutessilver

www.javapolis.com

Weblog in 15 minutes- goals -

-seen before?...a bunch of forms & a datamodel.

-something (almost) useable

www.javapolis.com

Weblog in 15 minutes- goals -

Confession

I am not a Blogger.

www.javapolis.com

I am not a Blogger.

Weblog in 15 minutes- goals -

Confession

stefano mazzocchi’s

“linotype”

www.javapolis.com

Transform “Stefano’s Linotype” into a jax and JCR backed Blog.

Weblog in 15 minutes- goals -

»»NO TOOLS!

(well texteditor &

browser ;) )...but an audience full of buddy coders

DEMO

www.javapolis.com

If you remember only 2 thing.

dev.day.com Download CRX and play with ujax. keep an eye on “apache sling”2

I

seriously!

Q&AView JavaPolis talks @ www.parleys.com

Thank you for your attention