Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "JCR Management"

(initial project generation)
(Jackrabbit XML Nodetype Editor)
Line 25: Line 25:
 
[[Image:ClassEditor.png]]
 
[[Image:ClassEditor.png]]
 
=== Jackrabbit XML Nodetype Editor ===
 
=== Jackrabbit XML Nodetype Editor ===
This editor saves the content in the XML format that can be used for Jackrabbit node type registration. It is basically the sample model editor of EMF enhanced with the JCRM type mapping semantics. You can use it to create a new XML file for the node type registration in Jackrabbit and you can also read the node types from the repository save it and manipulate it with this editor.
+
This editor saves the content in the XML format that can be used for Jackrabbit node type registration. It completely supports drag 'n drop, copy & paste and undo/redo. The editor is basically the sample model editor of EMF enhanced with the JCRM type mapping semantics. You can use it to create a new XML file for the node type registration in Jackrabbit and you can also read the node types from the repository save it and manipulate it with this editor.
  
 
[[Image:JackrabbitXMLNodetypeEditor.png]]
 
[[Image:JackrabbitXMLNodetypeEditor.png]]

Revision as of 12:18, 20 August 2008

JCR Mangement (JCRM)

JCR Management will provide tooling and a JCR (http://en.wikipedia.org/wiki/Content_repository_API_for_Java) persistence framework for EMF with pluggable JCR implementations.


The Contributions

  • My employer inovex GmbH (http://www.inovex.de) contributes 7 person days where I can work on this project within working hours.
  • Ed Merks:
    • helps as a mentor for questions regarding the Eclipse foundation.
    • implemented a new feature request for EMF that I had (dynamic feature delegation)
    • answers a lot of my questions in the newsgroup
  • The ATL team contributed an initial meta model and transformation that will speed up ATL integration.
  • Nick Boldt created the initial JCR Management (CVS, website, ...) setup at eclipse.org

The Status

JCRM is not production ready at the moment. The current code base consists of prototypes that serve as a basis for concrete discussions about requirements and solutions. The prototypes are tested exclusively with the example library EMF model.

The Architecture

JCRM is based on a mapping between EMF and JCR. One part is responsible to map EMF type elements to JCR node type elements and the other part maps EMF objects to JCR nodes. The main advantage of that architecture is, that many EMF frameworks can now work on JCR node types and nodes. The following JCRM tool prototypes are just examples how this mapping can be used. More ideas JCR tools or Eclipse projects are certainly welcome. They will be logged in the ideas section of this wiki. The most interesting ideas will be provided to the community for priorization and for validation the use cases. After that the JCRM team (at the moment it's just me - Sandro) will work on it.

The Tooling

EMF Class Editor

The class editor is based on the EMF Ecore model. This model is generated from the node types in the repository.

ClassEditor.png

Jackrabbit XML Nodetype Editor

This editor saves the content in the XML format that can be used for Jackrabbit node type registration. It completely supports drag 'n drop, copy & paste and undo/redo. The editor is basically the sample model editor of EMF enhanced with the JCRM type mapping semantics. You can use it to create a new XML file for the node type registration in Jackrabbit and you can also read the node types from the repository save it and manipulate it with this editor.

JackrabbitXMLNodetypeEditor.png

Jackrabbit CND Editor

This text editor validates the content against the Jackrabbit CND format. It also contains minimal code completion. For this editor the XText framework of oAW is used. The JCRM type mapping framework makes it possible to use the JCR node type structure in the grammar for the XText editor. This way the CND file can get generated from the node types in the repository on the fly. At the moment only a small subset of the XText features are used in this editor.

JackrabbitCNDEditor.png

Domain Model Editor

The domain model editor is a sample tool that is generated from EMF. It usually has a XML backend. Just the backend configuration changes it to be an editor of JCR nodes.

Every change in the model immediately changes the underlaying repository. E.g. if you add a "Book" object in that editor node.addNode("NewNode","Book") is called. As soon as you save the editor session.save() is called.

JCRMDomainModelEditor.png

The API

The API uses the classes generated by EMF and the JCRM type mapping. At runtime you can see the JCRM object mapping at work. You can find more detailed descriptions in the comments.

 public static void main(String[] args) {
 	// Create an EMF resource set to hold the resources.
 	ResourceSet resourceSet = new ResourceSetImpl();
 	
 	// Register the appropriate EMF resource factory to handle the file 
       // extension "mydomainmodel"
 	resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put
 	("mydomainmodel", new demo.MyResourceFactory());
 
 	// Register the EMF package to ensure it is available during loading.
 	resourceSet.getPackageRegistry().put
 		(MyDomainModelPackage.eNS_URI, 
 		 MyDomainModelPackage.eINSTANCE);
      
 	try {
               // Create an EMF resource using the registered "mydomainmodel" extension
 		Resource resource = resourceSet.createResource(URI.createURI("http:///My.mydomainmodel"));
 
               // Create a domain object. The constructor is initially generated by EMF to be protected
               // but you can make it public if you want.
 		Library library = MyDomainModelFactory.eINSTANCE.createLibrary();
 
               // In contrast to the JCR specification EMF generally allows to have many root nodes
               // hence the content of the resource is designed to be a list in EMF even though the 
               // JCRM Framework needs only one element in the content.
               // JCRM puts the root object containing the corresponding root node of the repository
               // in the content of the resource where it can get retrieved. "root" is the type
               // of the rootObject that corresponds to the node type of the root node.
 		root rootObject = (root) resource.getContents().get(0);
 
               // As soon as an object is added to it's containing object it also get it's
               // node injected. In this case the library object is added to the "residual
               // definition" feature of the rootObject. That calls addNode() on the
               // node that is contained within the rootObject. The resulting node
               // is then injected in the library object.
 		rootObject.getResidualDefinition_base().add(library);
 		
               // Every domain object contains it's corresponding node and every modification 
               // is delegated to the node. In this case setName...("MyLibraryNameByAPI") actually
               // calls nodeOfTheObject.setProperty("name","MyLibraryNameByAPI")
               // This way the objects don't need to have own copies of the property content.
               // At the moment there is not something like a detached mode where you can
               // modify properties without the object having an injected node.
 		library.setName_1_false("MyLibraryNameByAPI");
 		library.setNodeName("MyLibraryNodeNameByAPI");
 		Book aBook = MyDomainModelFactory.eINSTANCE.createBook();
 		library.getResidualDefinition_Book().add(aBook);
 		Writer aWriter = MyDomainModelFactory.eINSTANCE.createGuideBookWriter();
 		aBook.setAuthor_Writer(aWriter);
 		aWriter.setName_1_false("aGuidBookWritersNameByAPI");
 		aBook.setTitle_1_false("Book-TitleByAPI");
 		aBook.setPages_1_false("200ByAPI");
 
               // that calls session.save() and persists the changes made above.
 		resource.save(System.out, null);
 	}
 	catch (IOException exception) {
 		exception.printStackTrace();
 	}
 }

Tasks

  1. See Bugzilla for an overview of the ToDo's https://bugs.eclipse.org/bugs/buglist.cgi?short_desc_type=allwordssubstr&short_desc=&product=EMFT&component=JCR+Management&long_desc_type=allwordssubstr&long_desc=&order=Importance


Next Milestone

Create a first downloadable presentation of the project to show the potential of Eclipse modeling to the Jackrabbit community.

Ideas

  • Using Cedrics Compare editor inside the JCR Manager
http://www.eclipse.org/modeling/emft/?project=compare#compare

Values

  • simplicity
  • transparency
  • no dependency on JCR implementations

FAQ

  1. What's the relationship between JCR Management and Jackrabbit JCR-OCM?

One part of JCR Management has the same goal as JCR-OCM - exposing node data and operations to domain models - but JCRM uses an MDSD approach based on Eclipse Modeling Framework (EMF). This makes it depending less on reflection and using more generated classes instead. It will delegate as many calls on JCR node data as possible to minimize copying node data to domain model objects. Additionally JCR Management also has many other goals. But find out the details of JCR-OCM and check out the source code and the documentation.

CVS Access

CVS Repository Connection

  • Server: dev.eclipse.org
  • Repository Path: /cvsroot/modeling
  • User: anonymous
  • Password: (leave blank)
  • Connection Type: pserver
  • Checkout As: Empty EMF Project

Modules

  • You can check out the plugins in the org.eclipse.emf/org.eclipse.emf.jcrm/plugins folder as CVS modules

Initial project generation

In the "org.eclipse.emf.jcrm.conversion" plugin in the source folder you find the general build.xml file. Follow these steps to initially build all projects: - Right-Click it and choose "Run As/Ant Build..." - In the "JRE" tab choose "Run in the same JRE as the workspace" - Press "Run"

Back to the top