Thursday, July 30, 2009

Setup eXo JCR development environment

Short intro in preparations to eXo JCR development.

All eXo products development based on Maven2 project management. So, easiest way to start the development with eXo it's to setup right Maven2 project and its dependencies.

eXo Portal (and ECM, DMS, WCM, CS, KS etc) developers can find lot of useful resources on eXo wiki:
All thing from there are actual for eXo JCR development also... but there is easiest way - just setup a right POM.

Prerequisites
  • Java 5 (add JDK executables to the PATH on your system)
  • Maven2 (add Maven2 executables to the PATH on your system, )
  • Eclipse (optional)
Creating project (POM)

We say that our project name is my-jcrapp (use your name instead of this dummy one).

In empty folder run Maven command:
mvn archetype:create -DgroupId=com.mycompany.exojcr -DartifactId=my-jcrapp
This command creates the project folder named my-jcrapp with ready to use files structure. There are pom.xml, src folder with place for application code and tests. Project model (pom.xml) contains dependencies declaration, here is only JUnit now.

eXo JCR dependency

So, you have to add eXo JCR dependency to the POM...

but... eXo JCR jar files don't live on central Maven2 repository, they are on eXoPlatform one.
Add eXo repo to Maven2 local repositories list: or into settings.xml or directly in the your project POM (add repositories element after the dependencies).
<repositories>
<repository>
<id>exo-int</id>
<name>exoplatform.org repository</name>
<url>http://maven2.exoplatform.org/rest/maven2 </url>
<layout>default</layout>
</repository>
</repositories>
Now add the JCR core dependency:
<dependency>
<groupid>org.exoplatform.jcr</groupid>
<artifactid>exo.jcr.component.core</artifactid>
<version>1.11.2</version>
<scope>compile</scope>
</dependency>
If you need JCR Ext features then add this dependency (in fact you need only Ext one, it will points JCR core itself):
<dependency>
<groupid>org.exoplatform.jcr</groupid>
<artifactid>exo.jcr.component.ext</artifactid>
<version>1.11.2</version>
<scope>compile</scope>
</dependency>
And it's ready to build!

Build project

Run given command and wait till eXo JCR with its dependencies will be downloaded to your local Maven2 repo (~25Mb):
mvn clean compile
and be sure you see BUILD SUCCESSFUL at the end of this execution.

If something goes wrong with the build check all step from the begin and proxy.

Successful? Voi-la, you're ready to eXo JCR development!

IDE

To write real code you need any of good Java IDE.
We're using Eclipse, the best one :). But NetBeans or Intellij Idea so good also.
Those short instructions are actual for any IDE, but I assumed that the IDE supports import of existing sources.

The best way it's to load just created my-jcrapp Maven2 project to the IDE.
Maven2 helps great with this task. Create Eclipse project files by the command:
mvn eclipse:eclipse
Then open Eclipse and Import the project as an existing project.


Add local Maven2 repo path variable M2_REPO to Java build classpath:


Now the project is ready to development in Eclipse:


Good luck!

Monday, July 27, 2009

eXo JCR 1.11.2: overview

eXo JCR 1.11.2 is out - What are inside.

This is a new version of our JCR 1.x product line.
It will be a "database" for a next version of eXo Portal.

eXo JBoss JCR project will be based on this release codebase also.

With many features listed below eXo JCR is ready to content-oriented-architecture. Check them here in short or visit eXo JCR wiki for a full list of capabilities.

Try eXo JCR in action via bundled samples - read after the features.

Main features

eXo JCR it’s an implementation of Java Content Repository API (JSR-170). Java Content Repository provides common programmatic interface to stores of hierarchical and unstructured data, content versioning, locking, observation, search (including full-text search), content export/import and many more.

In addition to JSR-170 features we provide Extension Actions API which allow use of programmatic actions triggering on content update or access. Actions can be configured via filters.

Plus you can find set of useful Extensions out of the box:

eXo JCR supports RMI, WebDAV and FTP network access to a repository.

Repository implementation uses database as a persistent storage for a content. We support Oracle, DB2, MySQL, PostgreSQL, MSSQL, Ingres, Derby and HSQLDB backends.

It’s possible to store content using External Value storage. Our implementation comes with several file-system storages. External Value storage API allows develop custom storages e.g. for store data on type or in customer databases.

Additionally we’re supporting Amazon Web Services as a backend:


Samples

To see the JCR in action download eXo JCR Tomcat bundle, extract it in empty folder and run eXo.bat (eXo.sh for Unixes) fron bin folder. Bundle contains full JCR with dependencies - it's ready base for eXo & JCR development.
There are two very simple visual applications: JCR browser and JCR FCKeditor. After the Tomcat started open the url: http://localhost:8080/browser

Sample bundles comes with enabled WebDAV and FTP JCR servers also. So you can surf Repository from external, e.g. via Windows Web-folders or any FTP-client (port 2121).

Open WebDAV view http://localhost:8080/rest/jcr/repository/production/ (for Windows Web-folders open vie InternetExplorer: Ctrl+O, enter the view url and enable "Open as Web-folder").

We provide Samples as EAR also. Deploy procedure described in the readme.txt of the bundle. EAR contains full JCR with dependencies and same samples as Tomcat bundle.

RMI bundle contains RMI Server and sample client binaries, it's useful example to start JCR-RMI coding.

All eXo JCR Samples runs in StandaloneContainer, so it's ready to embedding to another applications or can be used as standalone application (web or via main class).

eXo JCR can be used in PortalContainer also, eXo Portal uses it in that way.


Main changes of eXo JCR 1.11.2
  • JCR Core Binary Values improved processing: use of input stream with only on-demand spooling of big Binary Values.
  • Asynchronous and Synchronous replication Binary Values processing improved: changes storage for replication use less amount of files
  • Lot of Asynchronous replication improvements: merger, subscriber lifecycle, connection and local storage consistency etc.
  • Synchronous Replication Proxy mode simple configuration. Proxy Replication allows several running servers on the same physical host (useful for development).
  • Support of Values large of 2GiB in External Value Storage.
  • JCR Core Node.gatProperties() bugfix of duplicate Properties returned for unsaved Node when changes occurs in another Session.
  • Lot of minor Backup Service bugs fixed. Asynchronous restore support added.
  • HTTP Backup agent improvements of API.
  • WeBDAV codestyle refactoring and bugfixes of PROPPATCH and DELETE calls
  • Version history Import/Export utility bugfix of Items import.
Find more about eXo JCR on wiki.

Ask about JCR on the Community forum.

Download eXo JCR 1.11.2 from OW2 Forge page.

Sources repository here.


Friday, October 24, 2008

New eXo Platform JCR v.1.10

Today we have released eXo Platform JCR v.1.10.

This is a improvement version of 1.x JCR family
which comming with set of new features.

JCR 1.10 contains such new features as
- JCR based Organization Service
- Amazon SimpleDB
support for Workspace storage
- Repositoy management with ONLINE, READ-ONLY and OFFLINE states
- Content Addressable External Values Storage
- New authentication policy mechanism
- FCKeditor uses REST based access to JCR resources

Main improvements are
- Cache optimization for Items access and modification
- Replication members connection recovery and priority mechanism
- Replication BLOBs processing mechanism
- SessionProvider multithreading usage
- Item Move and Remove operations optimization
- ACL and Permissions logic upgraded

In this release we work on
quality and performance of JCR core.
You will meet better speed of Items Move, Copy, Clone and Remove
operations.
Versioning and Locking operations are faster now too.
Be in touch with eXo JCR performance & QA process here.

We have modernized our Replication service.
The service new features such as Members priority and
Member 'heart-beat' mechanism will help implement more realistic
JCR Cluster.
Replication BLOBs operations were tested again and some issues fixed.
New articles about Replication/Cluster configuration published on eXo wiki.
We have reviewed set of validation aspects according the JSR-170
specification in our JCR core. JCR Path validation more strict now.
Security level and JCR Permissions upgraded using new eXo Core
Security service.

But lets talk about new features of the eXo JCR 1.10.

We start eXo
Organization Service API implementation on JCR storage.
The service actually transparent for other applications having use
Organization Service API, sure as eXoPlatform Portal or ECM.
Only simple component should be configured.
All existing listeners and initializers can be used with the service.

We step on to SaaS path these days :)
eXo JCR storage in Amazon SimpleDB and S3 are beta now.
Yes as the Amazon services.
Today you can setup eXo JCR (Portal, ECM) on SimpleDB (and S3),
put the application on EC2 and you got it.
It's beta now. Beta status mostly thanks to Amazon... the stuff thanks
to Amazon.
But we run it on demo EC2. Ask us if you are interested!

External Values Storage now can be CASasble.
We are supporting Content-Addressable-Storage.
The feature most useful for usecases where same content may be
stored (duplicated) in different locations.
With the Value storage the Value will stored once (one file)
and will be shared between multiple JCR Properties.

So... add Repository state management, new authentication policy,
WebDAV improvements and REST based access to a JCR content.
Would it be tasty for Web2.0, 3.0?

Find more details on JIRA.

Try it! Adopt it!

Ask me ;)

Saturday, July 26, 2008

Manage content with Java Content Repository

Very useful technology for Java developers, and not only

Technology specification

http://jcp.org/en/jsr/detail?id=170

Implementations
Usage

It's similar to a File System we use everyday. But has more features and advantages.

You have to obtain a Repository instance to start. It's implementation specific and simple for most JCRs.

Each Repository presents a list of workspaces. Let us imagine it's drives in file system.

To begin the work with a content you have to login into Repository with selected Workspace.

InitialContext ctx = ...
Repository repository = (Repository)ctx.lookup("myrepo");
// Get a Credentials object
Credentials credentials = new SimpleCredentials("MyName", "MyPassword".toCharArray());
// Get a Session
Session mySession = repository.login(credentials, "MyWorkspace");

After the login you have the Session. So, you have a tool which gives access to a content storage.

Add 'file'

Node myFile = mySession.getRootNode().addNode("my-first-file");

Node it's only object which handles 'file' entity... say handler. Node may contains Property(es). The Property it's a content. String, Integer, Float, Binary, Path etc.

You will use Property to read/write data.

Write
myFile.setProperty("creator_name", "John");
myFile.setProperty("create_date", Calendar.getInstance());
myFile.setProperty("file_content", source.getInputStream());
Read
myFile.getProperty("creator_name").getSTring();
myFile.getProperty("create_date").getDate();
myFile.getProperty("file_content").getStream();

So, not so complicated.

Node can include sub-nodes also. It's only managed by NodeType (like file type, but richer).
myFile.addNode("sub-file");

You may get Node or Property by path, relative from other Node or Property or via Session.

// relative
Node ssFile = myFile.getNode("sub-file/sub-sub-file");
// or by abs path
Node ssFile = (
Node) mySession.getItem("/my-first-file/sub-file/sub-sub-file");

Simple? I hope - yes.

It's a good alternative to a databases in content-oriented applications and makes development process close to a task. A developer should know at least the specification, but it's simple than JDBC anyway.