https://github.com/bigraph-toolkit-suite/spring-data-cdo
Spring repository support for Connected Data Objects (CDO) - a distributed shared model of Eclipse EMF.
https://github.com/bigraph-toolkit-suite/spring-data-cdo
cdo eclipse eclipse-cdo spring-data spring-data-cdo spring-framework
Last synced: 5 months ago
JSON representation
Spring repository support for Connected Data Objects (CDO) - a distributed shared model of Eclipse EMF.
- Host: GitHub
- URL: https://github.com/bigraph-toolkit-suite/spring-data-cdo
- Owner: bigraph-toolkit-suite
- License: apache-2.0
- Created: 2023-10-30T13:26:06.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2025-08-23T12:13:43.000Z (11 months ago)
- Last Synced: 2026-01-26T20:03:34.166Z (6 months ago)
- Topics: cdo, eclipse, eclipse-cdo, spring-data, spring-data-cdo, spring-framework
- Language: Java
- Homepage:
- Size: 515 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.adoc
- Contributing: CONTRIBUTING.adoc
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.adoc
Awesome Lists containing this project
README
image:https://img.shields.io/badge/License-Apache--2.0-blue.svg[License: Apache 2.0,link=https://opensource.org/licenses/Apache-2.0]
image:https://img.shields.io/maven-central/v/org.bigraphs.springframework.data/spring-data-cdo[Maven Central,link=https://central.sonatype.com/artifact/org.bigraphs.springframework.data/spring-data-cdo]
image::./src/main/asciidoc/images/spring-cdo-logo-white-background.png[width=50%,scalewidth=6cm]
'''
= Spring Data CDO
The primary goal of the https://projects.spring.io/spring-data[Spring Data] project is to make it easier to build Spring-powered applications that use new data access technologies such as non-relational databases, map-reduce frameworks, and cloud based data services.
This module provides infrastructure components to build repository abstractions for stores dealing with the
https://www.eclipse.org/cdo/[*Connected Data Objects (CDO) model repository*] of Eclipse.
*Version Compatability*
|===
|*Spring Data CDO* | *Eclipse Modeling Tools* | *CDO Protocol Version*
|0.8.0 (latest)
|https://www.eclipse.org/downloads/packages/release/2025-12/r/eclipse-modeling-tools[2025-12 (4.38.0)]
|54
|0.7.5
|https://www.eclipse.org/downloads/packages/release/2022-12/r/eclipse-modeling-tools[2022-12 (4.26.0)]
|48
|0.7.2
|https://www.eclipse.org/downloads/packages/release/2022-12/r/eclipse-modeling-tools[2022-12 (4.26.0)]
|48
|0.6.0-SNAPSHOT
|https://www.eclipse.org/downloads/packages/release/2022-12/r/eclipse-modeling-tools[2022-12 (4.26.0)]
|48
|===
== Getting Started
The standard use case of this framework is to store and read native `CDOObject` and standard `EObject`.
To be clear, the framework does not perform a transformation of standard Java POJOs to their Ecore representatives.
Only Java objects of class type `CDOObject` or `EObject` (and in legacy mode) are supported.
Legacy mode: Models that are not converted for CDO support.
See also https://wiki.eclipse.org/CDO/Preparing_EMF_Models[Preparing EMF Models]
Your domain models should be defined using the Eclipse EMF Ecore metamodel as usual, or dynamically at runtime.
Eclipse EMF also supports the generation of an API from Ecore models.
They can also be used afterwards with *Spring Data CDO*.
=== Dependency Configuration (Maven)
Just add the following Maven dependency to your project's `pom.xml`:
[source,xml]
----
org.bigraphs.springframework.data
spring-data-cdo
0.8.0
----
These dependencies are required when you want to start the standalone CDO server that is shipped with this framework:
[source,xml]
----
org.eclipse.platform
org.eclipse.core.runtime
3.34.0
----
=== Usage Examples
The following examples show some possible configuration and usage scenarios.
==== Domain classes
The framework can handle native EMF models:
[source,java]
----
// any auto-generated object of an EMF model or native CDO model
interface Person extends EObject {}
interface Person extends CDOObject {}
----
Non-native EMF domain classes (i.e., classes that don't extend `EObject` or the `CDOObject` interface) should be annotated in the following way to provide necessary details:
[source,java]
----
@CDO(path = "your/repository/resource/path", // CDO resource path
nsUri = "http://www.example.org/personDomainModel", // namespace of the Ecore model
ePackage = PersonDomainModelPackage.class, // the EPackage of the model
ePackageBaseClass = "org.example.ecore.personDomainModel.PersonDomainModelPackage"
)
class PersonWrapper {
// ID is mandatory
@Id
CDOID id;
// Provide here the actual EObject model that the framework can access
// because PersonWrapper does not extend EObject
@EObjectModel(classFor=Person.class)
public Person model; // Person extends from EMF's EObject class
}
----
They effectively work like a wrapper for internal members, which are of class `EObject` or `CDOObject`.
Additionally, an ID must be specified of type `CDOID` using the `@Id` annotation feature of Spring.
==== Spring Configuration
Enable the Spring repository support for CDO repositories:
[source,java]
----
// Spring Configuration Class
@Configuration
@EnableCdoRepositories(basePackageClasses = PersonRepository.class)
//@EnableCdoRepositories(basePackages = "org.example.repository") // Java package to repository interfaces
public class CDOServerConfig {
// ...
}
----
==== Repository Definition
[source,java]
----
package org.example.repository;
@Repository
public interface PersonRepository extends CdoRepository {
// ...
}
----
==== Ecore Package Initialization: Local and Remote
With regard to EMF-related programming, the respective `EPackage` must be registered in the global package registry first (see https://download.eclipse.org/modeling/emf/emf/javadoc/2.9.0/[EPackage.Registry]).
The registry provides a mapping from namespace URIs to `EPackage` instances.
> Though, this framework has some internal mechanism to initialize the EPackage in the registry automatically, it may not always find it.
We advise to initialize the corresponding `EPackage` that is going to be used with this framework by using standard mechanisms of EMF:
[source,java]
----
@BeforeClass
public static void beforeClass() throws Exception {
PersonDomainModelPackageImpl.init();
// Or: EPackage.Registry.INSTANCE.put("http://www.example.org/personDomainModel", PersonDomainModelPackage.eINSTANCE);
// This statement should not fail:
EPackage ePackage = EPackage.Registry.INSTANCE.getEPackage("http://www.example.org/personDomainModel");
Assert.notNull(ePackage, "Model Package couldn't be found in the EPackage Registry.");
}
----
Especially when working with CDO the package should be registered locally and remotely:
[source,java]
----
CdoTemplate template = new CdoTemplate(factory);
CDOPackageRegistry.INSTANCE.put(BookstoreDomainModelPackage.eNS_URI, BookstoreDomainModelPackage.eINSTANCE);
CDOPackageRegistry remoteRegistry = template.getCDOPackageRegistry(); //acquire the remote CDO package registry
EPackage ePackage = remoteRegistry.getEPackage(BookstoreDomainModelPackage.eNS_URI);
if (ePackage == null) {
remoteRegistry.put(BookstoreDomainModelPackage.eNS_URI, BookstoreDomainModelPackage.eINSTANCE);
}
----
=== Events
When required, one can listen to specific events emitted by some repository actions for adding extended behavior.
Events are implemented for Delete, Save and Insert operations, including "after" and "before" notions for fine-grained control.
=== Standalone CDO Server
For testing purposes you can start a standalone CDO server like this:
[source,java]
----
CDOStandaloneServer server = new CDOStandaloneServer("repo1");
CDOStandaloneServer.start(server);
----
=== Working with Eclipse IDEs
This framework includes functionality to launch a standalone CDO server.
Use the Eclipse CDO Explorer, which allows you to easily view and interact with Ecore models hosted on the CDO server.
* Download CDO Explorer or Server via the link:https://www.eclipse.org/downloads/packages/installer[Eclipse Installer].
See table above to see which version of Eclipse to use.
== Development
For information about setting up the development environment, building the project,
and contribution guidelines, please refer to link:DEVELOPMENT.adoc[DEVELOPMENT.adoc].
== License
This library is Open Source software released under the Apache 2.0 license.
```text
Copyright 2023-present Bigraph Toolkit Developers
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
```