Chromattic usage in eXo Social

1,130 views

Published on

A presentation made by eXo Platform SEA. We introduce Chromatic usage in eXo Social with several key features. Hope you enjoy it!

Published in: Technology, Education
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,130
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
8
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Chromattic usage in eXo Social

  1. 1. Chromattic how to use Vu Cong Thanh & Le Van Vien Social Team 18/08/2011
  2. 2. Agenda <ul><li>What & why Chromattic? </li></ul><ul><li>Annotation APIs </li></ul><ul><li>APT in Chromattic. </li></ul><ul><li>Config & dependency </li></ul><ul><li>Example </li></ul>
  3. 3. What is Chromattic? <ul><li>Is an object mapper framework that uses Java Content Repository as back end storage. </li></ul><ul><li>Open source under the LGPL license. </li></ul><ul><li>Hosted in Google code: </li></ul><ul><li>http://code.google.com/p/chromattic/ </li></ul>
  4. 4. JCR <ul><li>JCR by nature is not type safe. </li></ul><ul><li>Work with nodes. </li></ul><ul><li>Manage session by myself. </li></ul>
  5. 5. Chromattic <ul><li>Provide a type safe object model for JCR. </li></ul><ul><li>Use Java 5 annotation. </li></ul><ul><li>Integrate at Java compiler level via the Annotation Processor Tool. </li></ul><ul><li>Efficient lazy loading. </li></ul>
  6. 6. Annotation APIs
  7. 7. Annotation APIs <ul><li>Chromattic supports 2 types </li></ul><ul><li>PrimaryType: Mapping between a node type and a java class. </li></ul><ul><li>MixinType: When a class declares a mixin annotation without being bound to a node mapping, this class can be involved in a one to one relationship with the EMBEDDED type. The mixin is added to a node when a one to one relationship of type mixin is created. </li></ul>
  8. 8. Annotation APIs <ul><li>Id: annotates a bean property getter to return the current identifier of the related jcr node </li></ul><ul><li>Path: annotates a bean property getter to return the current path of the related jcr node </li></ul>
  9. 9. Annotation APIs <ul><li>MappedBy: defines the name of the property that is used to maintain one to many relationship with path or reference. </li></ul><ul><li>Name: annotates a bean property to map it against the current name of the related jcr node. </li></ul><ul><li>Property: defines the mapping between the property of a node type and a java bean property of the annotated class. </li></ul>
  10. 10. State Of Chromattic Entity
  11. 11. Annotation APIs <ul><li>Create: define a creator method to create transient instances of a Chromattic entity </li></ul><ul><li>FormattedBy: BaseEncodingObjectFormatter implements ObjectFormatter </li></ul><ul><li>DefaultValue: define the default value of a property </li></ul><ul><li>OneToMany: defines the one side in a one to many relationship </li></ul>
  12. 12. Annotation APIs <ul><li>RelationshipType </li></ul><ul><li>HIERARCHIC: a hierarchic relationship uses the natural parent child relationship to associate nodes. It is valid either for one to one or one to many relationship. </li></ul><ul><li>REFERENCE: a reference relationship uses reference a typed property to associate nodes. It is only valid for one to many relationships. </li></ul><ul><li>PATH: a path relationship uses path a typed property to associate nodes. It is only valid for one to many relationships. </li></ul><ul><li>EMBEDDED </li></ul>
  13. 13. Config & dependency
  14. 14. Config & dependency Config: in file configuration.xml with plugin RepositoryService
  15. 15. Config & dependency Config phase <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.3.1</version> … </plugin>
  16. 16. Config & dependency Config phase <executions> <execution> <id>default-compile</id> <goals> <goal>compile</goal> </goals> <phase>compile</phase> <configuration> <compilerArgument>-proc:none</compilerArgument> </configuration> </execution> </executions>
  17. 17. Config & dependency <ul><li>Config </li></ul><ul><li>Generate implementation when compile </li></ul>
  18. 18. Config & dependency Dependency <dependency> <groupId>org.chromattic</groupId> <artifactId>chromattic.api</artifactId> <version>1.1.0-beta6</version> <scope>provided</scope> </dependency> Annotations, event, format, query
  19. 19. Config & dependency Dependency <dependency> <groupId>org.chromattic</groupId> <artifactId>chromattic.core</artifactId> <version>1.1.0-beta6</version> <scope>provided</scope> </dependency>
  20. 20. Config & dependency Dependency <dependency> <groupId>org.chromattic</groupId> <artifactId>chromattic.metamodel</artifactId> <version>1.1.0-beta6</version> <scope>provided</scope> </dependency>
  21. 21. Config & dependency Dependency <dependency> <groupId>org.chromattic</groupId> <artifactId>chromattic.apt</artifactId> <version>1.1.0-beta6</version> <scope>provided</scope> </dependency>
  22. 22. Config & dependency Dependency <dependency> <groupId>org.chromattic</groupId> <artifactId>chromattic.spi</artifactId> <version>1.1.0-beta6</version> <scope>provided</scope> </dependency>
  23. 23. Config & dependency Dependency <dependency> <groupId>org.chromattic</groupId> <artifactId>chromattic.exo</artifactId> <version>1.1.0-beta6</version> <scope>test</scope> </dependency>
  24. 24. APT in Chromattic
  25. 25. APT in Chromattic <ul><li>ChromatticBuilder </li></ul><ul><li>The builder configures and creates a Chromattic at runtime. </li></ul><ul><ul><li>SESSION_LIFECYCLE_CLASSNAME: The JCR session life cycle class name. </li></ul></ul><ul><ul><li>ROOT_NODE_PATH: The path of the root node. The default value is the path of the JCR workspace root node. </li></ul></ul><ul><ul><li>CREATE_ROOT_NODE: A boolean option that creates the root node designated by the ROOT_NODE_PATH when it does not exist. </li></ul></ul>
  26. 26. APT in Chromattic <ul><li>Chromattic </li></ul><ul><li>The Chromattic object provides the entry point for runtime interactions. </li></ul>
  27. 27. APT in Chromattic <ul><li>ChromatticSession </li></ul><ul><li>The session manages Chromattic objects at runtime, its is obtained from a Chromattic instance. A session is meant to be used by one thread and not shared among threads. </li></ul>
  28. 28. APT in Chromattic <ul><li>ChromatticLifeCycle </li></ul><ul><li>The chromattic life cycle object is a plugin allows to bootstrap a chromattic builder and make it managed either locally or globally. </li></ul><ul><li>Some parameters: </li></ul><ul><ul><li>domain-name: the life cycle domain name. </li></ul></ul><ul><ul><li>workspace-name: the repository workspace name associated with this life cycle. </li></ul></ul><ul><ul><li>entities: list value that contains the list of chromattic entities that will be registered against the builder chromattic builder. </li></ul></ul>
  29. 29. APT in Chromattic Proxy generation based on APT
  30. 30. Example

×