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

CDO Objectivity Simple Example

This example will demonstrate using Objectivity CDO in Eclipse.

Before You Begin

Install Objectivity CDO explained in the Installation Guide

Getting the Example

  1. Download the example here
  2. Import the downloaded zip file into a project by choosing File -> Import -> Existing Project into Workspace
    1. From there you choose the zip file by Selecting "Select archive file"
    2. Import all projects in the zip file.
  3. Now you have the example to run Objectivity CDO for the first time!

Running the Example

  1. Start the Objectivity CDO Server
    1. Expand com.objy.example.company.server
    2. Right Click on CDOObjyServerCompany.launch -> Run As -> CDOObjyServerCompany
  2. Run the Ingest
    1. Expand com.objy.example.company.datagen
    2. Expand src then com.objy.example.company.datagen
    3. Right Click on DataGeneratorCdoClient -> Run As -> Java Application
  3. Looking at the Data
    1. Right Click on CDOObjyCompanyClient.launch in the project, com.objy.example.company.server
    2. Select Run As -> CDOObjyCompanyClient
    3. When the new instance of Eclipse finished loading, open the CDO Client Perspective.
    4. Open a new CDO Session with the following information:
      • Server Description: tcp://localhost:2036
      • Repository Name: companyrepo
    5. To Browse, Right click on Session companyrepo -> Select "Open View"
    6. Expand each folder to see all the data.

How Does it work?

Objectivity CDO Server

The Objectivity CDO server starts using CDOObjyServerCompany.launch. In the configuration, an argument points toward a configuration XML using the following argument: -Dnet4j.config="${resource_loc:/com.objy.example.company.server/rootfiles}". The configuration file uses the convention explained in CDO_Objectivity_Store_ConfigFile to connect to the Objectivity Database.

Data Generation

To create the data in Objectivity CDO, we point to the repository being hosted by our CDO server.

DataGenerator.java:

protected static final String REPOSITORY_NAME = "companyrepo";

DataGeneratorCdoClient.java:

IConnector connector = TCPUtil.getConnector(container, "localhost:2036"); //$NON-NLS-1$

CDOSessionConfiguration configuration = prepareConfiguration(connector);

configuration.setRepositoryName(REPOSITORY_NAME); //$NON-NLS-1$

All other code to query the repository goes by the CDO standard. For more information regarding CDO go here

CDO Explorer

The CDO explorer starts using CDOObjySCompanyClient.launch. It starts an eclipse RCP and loads several plugins to make the companyrepo viewable.

  • com.objy.example.company.model - the model information for the stored information.
  • org.eclipse.emf.cdo.ui.ide - the CDO Explorer IDE plugin to Eclipse.

With these necessary plugins loaded in Eclipse, we point to the repository by pointing to the loaclhost's repository.

In order for the CDO Explorer to see the data stored, the URI of the EMF model and the exported URI must match. This way, the CDO explorer can match the URI from the model to the URI of the model stored inside the repository.

CDOObjyURIModel.png

must match

CDOObjyURIExport.png

Related Pages

CDO Objectivity Store

Back to the top