Weitere ähnliche Inhalte Ähnlich wie What's New In Apache Lenya 1.4 (20) Kürzlich hochgeladen (20) What's New In Apache Lenya 1.45. Modularization
Module
Module
Editor X ...
Resource Type A
Integration Code
Foo Service API
Module
Module
Alternative ...
Foo Impl
Default Foo Impl
API
Core
Impl
5 7. Directory
Structure
mymodule/
config/ configuration files
module.xml module descriptor
cocoon-xconf/ patches for cocoon.xconf
services.xconf
sitemap/ patches for main Lenya sitemap
transformers.xconf
usecases/
myusecase.jx usecase view
resources/
images/ image files
css/ CSS files
schemas/ XML schemas (RNG, XSD, ...)
samples/ Samples (in case of resource type modules)
java/
src/ Java source files
test/ Java test classes
lib/ Java libraries
xslt/ XSLT stylesheets
sitemap.xmap main module sitemap
7 9. Module
API
Stable
org.project.foo.*
Foo Service API
Module
org.project.foo.impl.*
Default Foo Impl
org.project.foo.util.*
org.otherproject.*
Subject
to
Change
<module>
...
<export package=quot;org.project.fooquot;/>
...
</module>
9 10. Module
Dependencies
Foo <module>
<id>org.project.modules.foo</id>
<export package=quot;org.project.fooquot;/>
</module>
Bar <module>
<id>com.company.modules.bar</id>
<depends module=quot;org.project.modules.fooquot;/>
</module>
package com.company.bar;
import org.project.foo.*;
import org.project.foo.impl.*;
class SomeService { ...
10 12. Next
Steps
• Requirements
• Easy
installation
• Hot-deploying
modules
• Versioning
of
modules
• Approaches
• Maven
• OSGi
12 16.
<<interface>> LinkResolver Link
MODE_DEFAULT_LANGUAGE getUri() : String
MODE_FAIL getPubId() : String
getArea() : String
resolve(sourceDocument, uri) : LinkTarget
getUuid() : String
getFallbackMode() : int
getLanguage() : String
setFallbackMode(int)
<<interface>> LinkManager LinkTarget
getLinksFrom(sourceDocument) : Link[] exists() : boolean
getReferencingDocuments(targetDoc) : Document[] getDocument() : document
isRevisionSpecified() : boolean
getRevisionNumber() : int
ContentLinkManager
UuidToUrlRewriter
<<interface>> OutgoingLinkRewriter
LinkRewriter
IncomingLinkRewriter
matches(url) : boolean
rewrite(url) : String
UrlToUuidRewriter
16 20. Content
Handling
Layers
Modules
CollectionWrapper AddNewsMessage
Lenya Core
Publication
Area SiteStructure
Document Link SiteNode
Repository
Session Node History
MetaData
20 21.
<<interface>> <<interface>> MetaDataOwner
Session
commit()
rollback()
<<interface>> ContentHolder
exists() : boolean
*
getContentLength() : long
<<interface>> getInputStream() : InputStream
RepositoryItem getlastModified() : long
getMimeType() : String
getSourceURI() : String
<<interface>> Node
checkin(), checkout() SourceNode
lock(), unlock()
exists() : boolean
delete()
getChildren() : Collection JCRSourceNode
getHistory() : History
21 22. <<interface>> SiteStructure
<<interface>>
getNodes() : SiteNode[]
Publication
getNode(path) : SiteNode
getAreaNames() : String[] getByUuid(uuid, language) : Link
getArea(String) : Area contains(path) : boolean
contains(path, language) : boolean
containsByUuid(uuid, language) : booelan
* add(path) : SiteNode
add(path, Document) : Link
<<interface>> Area
getDocuments() : Document[]
*
getDocument(uuid, language) : Document <<interface>> SiteNode
contains(uuid, language) : boolean
getUuid() : String
getSite() : SiteStructure
getChildren() : SiteNode[]
hasLink(language) : boolean
getLink(language) : Link
* isVisible() : boolean
<<interface>> setVisible(boolean)
Document
*
getUUID() : String
<<interface>> Link
getLanguages() : String[]
getTranslation(String) : Document getLanguage() : String
getRepositoryNode() : Node getLabel() : String
0..1
getInputStream() : InputStream setLabel(String)
getOutputStream() : OutputStream getDocument() : Document
22 23.
<<interface>> Collection
getDocuments() : Document[]
add(Document)
remove(Document)
clear()
contains(Document) : boolean
CollectionWrapper
<<interface>> checkin(), checkout()
Document lock(), unlock()
exists() : boolean
getInputStream()
delete()
<<interface>> Usecase
getOutputStream()
getChildren() : Collection
getHistory() : History execute()
NewsWrapper AddNewsMessage
addNewsMessage(NewsMessage) execute()
23 24. Next
Steps
• Queryable
meta
data
String xPath = “*[@media:width > 100]“;
Query query = new XPathQuery(xPath);
Document[] docs = area.getDocuments(query);
24 25. Code
Example
public void addNewsDocument(String newsPath, String uuid, String language) {
Session session = RepositoryUtil.getSession(this.manager, this.request);
DocumentFactory factory
= DocumentUtil.getDocumentFactory(this.manager, this.request);
String webappUrl = ServletHelper.getWebappUrl(this.request);
URLInformation info = new URLInformation(webappUrl);
Publication pub = factory.getPublication(info.getPublicationId());
Area authoring = pub.getArea(„authoring“);
Document[] docs = authoring.getDocuments();
Document messageDoc = authoring.getDocument(uuid, language);
SiteStructure site = authoring.getSite();
SiteNode node = site.getNode(newsPath);
String[] languages = node.getLanguages();
Link link = node.getLink(language);
Document newsDoc = link.getDocument();
NewsWrapper newsWrapper = new NewsWrapper(newsDoc, getLogger());
wrapper.add(0, messageDoc);
}
25 27.
<<interface>> <<interface>> MetaDataRegistry
MetaDataOwner
getElementSet(namespaceUri) : ElementSet
getMetaData(namespaceUri) : MetaData getNamespaceUris() : String[]
getMetaDataNamespaceUris() : String[] register(namespaceUri, elementSet)
isRegistered(namespaceUri) : boolean
*
*
<<interface>>
<<interface>> ElementSet
MetaData
getNamespaceUri() : String
getAvailableKeys()
getElements() : Element[]
addValue(key, value)
getElement(name) : element
setValue(key, value)
containsElement(name) : boolean
getValues(key)
*
<<interface>> Element
ONCOPY_COPY
ONCOPY_DELETE
ONCOPY_IGNORE
getName() : String
isEditable() : String
isMultiple() : String
getActionOnCopy() : int
27 28. Meta-Data
Code
Example
<meta-data>
...
<component-instance
name=quot;http://apache.org/lenya/metadata/media/1.0quot;
class=quot;org.apache.lenya.cms.metadata.ConfigurableElementSetquot;>
<element name=quot;filenamequot; multiple=quot;falsequot;/>
<element name=quot;widthquot; multiple=quot;falsequot;/>
<element name=quot;heightquot; multiple=quot;falsequot;/>
</component-instance>
...
</meta-data>
String mediaNamespace = quot;http://apache.org/lenya/metadata/media/1.0quot;;
MetaData metaData = document.getMetaData(mediaNamespace);
String width = metaData.getFirstValue(quot;widthquot;);
28 30. Chemistry
Math
Science
Physics
Biology
University
English
French
Spanish
Languages
Italian
30 31. Overriding
Resources
@import ...
University
XSLT A XSLT B main.css head.css
Science
XSLT A XSLT B' main.css head.css
Physics
XSLT A XSLT B'' main.css head.css
<xsl:import>
31 32. Templating
API
<<interface>> <<interface>>
Instantiator PublicationTemplateManager
instantiate(templatePub, id, name) visit(publication, publicationVisitor)
visit(publication, path, sourceVisitor)
<<interface>> <<interface>> <<interface>>
SourceVisitor VisitingSourceResolver PublicationVisitor
visit(resolver, sourceUri) getSource() : Source visit(publication)
ExistingSourceResolver
AllExistingSourceResolver
getUris() : String[] ExistingAncestorSourceResolver
32 35. Usecases
• User
interaction
• Typically
form-based
• Edit
and
manage
content
• Interact
with
other
applications
(newsletter)
• Functionality
for
website
visitors
(contact
form)
• ...
• Triggered
using
a
request
parameter
(lenya.usecase)
• Full
screen
or
document-based
35 36.
continuation
Form Form
! !
Template Template
View
Sitemap + Flowscript
Controller
!
Usecase Handler
vali-
dation
Documents, ... Documents, ...
Model
36 37. Declaring
a
Usecase
<component-instance name=quot;site.createquot;
class=quot;o.a.lenya.cms.site.usecases.CreateDocumentquot;>
<view template=quot;modules/.../usecases/site/create.jxquot;>
<parameter name=“...“ value=“...“/>
</view>
<parameter name=“...“ value=“...“/>
<parameter name=“...“ value=“...“/>
<transaction policy=“pessimistic“/>
<exit usecase=“...“>
<parameter name=“...“ value=“...“/>
</exit>
</component-instance>
37 38. Example
Usecase:
<<interface>>
Usecase
Contact
Form
initParameters()
checkPreconditions()
advance()
checkExecutionConditions()
execute()
<<interface>>
checkPostconditions()
UserManager
getUser(userId) : User
AbstractUsecase
<<interface>>
Notifier
notify(recipients, sender, message)
ContactForm
MailNotifier SmsNotifier InboxNotifier
38 40.
<<interface>> <<interface>> RepositoryEvent
Notifier RepositoryListener
getDescriptor() : Object
notify(message) eventFired(RepositoryEvent)
Object
AbstractNotifier NotificationListener
notify(message)
NotificationEventDescriptor
notify(user, translatedMessage)
translateMessage(locale, message)
getMessage() : Message
Message
getSender() : Identifiable
EmailNotifier
getSubject() : String
getSubjectParameters() : String[]
InboxNotifier
getBody() : String
getBodyParameters() : String[]
getTime() : Date
40 41. Creating
a
Message
User recipient = userManager.getUser(userId);
Identifiable[] recipients = { recipient };
String subject = quot;publish-notificationquot;;
String[] subjectParams = {};
String body = quot;document-was-publishedquot;
String[] bodyParams = {
DublinCoreHelper.getTitle(document) };
Message message = new Message(subject,
subjectParams,
body,
bodyParams,
sender,
recipients);
41 42. Sending
Notification
Messages
a)
Directly
• Immediate
notification
NotificationUtil.notify(this.manager, message);
b)
Via
repository
observation
• Notification
when
(if)
session
is
committed
NotificationEventDescriptor descriptor
= new NotificationEventDescriptor(message);
RepositoryEvent event = RepositoryEventFactory
.createEvent(this.manager, authoringDocument,
getLogger(), descriptor);
getSession().enqueueEvent(event);
42 43. Inbox
API
<<interface>>
InboxManager
getInbox(User) : Inbox
<<interface>>
Inbox
getMessages() : InboxMessage[]
getMessage(id) : InboxMessage
add(message)
remove(message)
*
Message
<<interface>>
InboxMessage getSender() : Identifiable
getSubject() : String
getId() : String
getSubjectParameters() : String[]
getMessage() : Message
getBody() : String
isMarkedAsRead() : boolean
getBodyParameters() : String[]
markAsRead(boolean)
getTime() : Date
43