directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ole Ersoy <ole.er...@gmail.com>
Subject [Configuration] Generating the Configuration Beans With EMF
Date Thu, 06 Mar 2008 21:25:02 GMT
Hey Guys,

I generated the beans and wrote a little tutorial / trace of how I did it.  However before
we get really deep into it, maybe someone would care to test out these steps to make sure
they work elsewhere.  The end result will be a maven project containing the intefaces and
implementation of all the configuration beans.  The trace below will just get longer, and
I personally like information in little chunck, so I'll start sharing early.

Here's the trace:

Note that this step is necessary to generate the server.xml schema:

------------------------------------------------------------------

svn checkout http://svn.apache.org/repos/asf/directory/apacheds/trunk-with-dependencies
cd trunk-with-dependencies
mvn install

------------------------------------------------------------------

The remaining steps are necessary to generate the Configuration Implementation 
from the schema:

mvn archetype:create -DartifactId=emf.configuration -DgroupId=org.apache.directory
cd emf.configuration
mvn eclipse:eclipse

import project into eclipse:
File > Import ...

Configure the Maven Compiler:
=================================================================
  <build>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <source>1.5</source>
          <target>1.5</target>
        </configuration>
      </plugin>
    </plugins>
  </build>
=================================================================
  

Add the EMF Maven Repository to the POM
=================================================================
<repositories>
        <repository>
                <id>emf-maven-mirror</id>
                <url>
                        http://mirrors.cat.pdx.edu/eclipse/tools/emf/maven2/
                </url>
        </repository>
</repositories>
=================================================================


Add the EMF Dependencies to the POM (Note that not all of these
are necessary, but I need to experiment more to find out which
ones can be pruned):
=================================================================
		<dependency>
			<groupId>org.eclipse.emf</groupId>
			<artifactId>ant</artifactId>
			<version>2.3.0</version>
		</dependency>

		<dependency>
			<groupId>org.eclipse.emf</groupId>
			<artifactId>codegen</artifactId>
			<version>2.3.0</version>
		</dependency>

		<dependency>
			<groupId>org.eclipse.emf</groupId>
			<artifactId>codegen-ecore</artifactId>
			<version>2.3.0</version>
		</dependency>

		<dependency>
			<groupId>org.eclipse.emf</groupId>
			<artifactId>codegen-ecore-ui</artifactId>
			<version>2.3.0</version>
		</dependency>

		<dependency>
			<groupId>org.eclipse.emf</groupId>
			<artifactId>codegen-ui</artifactId>
			<version>2.3.0</version>
		</dependency>

		<dependency>
			<groupId>org.eclipse.emf</groupId>
			<artifactId>common</artifactId>
			<version>2.3.0</version>
		</dependency>

		<dependency>
			<groupId>org.eclipse.emf</groupId>
			<artifactId>commonj-sdo</artifactId>
			<version>2.3.0</version>
		</dependency>

		<dependency>
			<groupId>org.eclipse.emf</groupId>
			<artifactId>common-ui</artifactId>
			<version>2.3.0</version>
		</dependency>

		<dependency>
			<groupId>org.eclipse.emf</groupId>
			<artifactId>converter</artifactId>
			<version>2.3.0</version>
		</dependency>

		<dependency>
			<groupId>org.eclipse.emf</groupId>
			<artifactId>ecore</artifactId>
			<version>2.3.0</version>
		</dependency>

		<dependency>
			<groupId>org.eclipse.emf</groupId>
			<artifactId>ecore-change</artifactId>
			<version>2.3.0</version>
		</dependency>

		<dependency>
			<groupId>org.eclipse.emf</groupId>
			<artifactId>ecore-change-edit</artifactId>
			<version>2.3.0</version>
		</dependency>

		<dependency>
			<groupId>org.eclipse.emf</groupId>
			<artifactId>ecore-edit</artifactId>
			<version>2.3.0</version>
		</dependency>

		<dependency>
			<groupId>org.eclipse.emf</groupId>
			<artifactId>ecore-sdo</artifactId>
			<version>2.3.0</version>
		</dependency>

		<dependency>
			<groupId>org.eclipse.emf</groupId>
			<artifactId>ecore-sdo-edit</artifactId>
			<version>2.3.0</version>
		</dependency>

		<dependency>
			<groupId>org.eclipse.emf</groupId>
			<artifactId>ecore-xmi</artifactId>
			<version>2.3.0</version>
		</dependency>

		<dependency>
			<groupId>org.eclipse.emf</groupId>
			<artifactId>edit</artifactId>
			<version>2.3.0</version>
		</dependency>

		<dependency>
			<groupId>org.eclipse.emf</groupId>
			<artifactId>edit-ui</artifactId>
			<version>2.3.0</version>
		</dependency>

		<dependency>
			<groupId>org.eclipse.emf</groupId>
			<artifactId>emf</artifactId>
			<version>2.3.0</version>
		</dependency>

		<dependency>
			<groupId>org.eclipse.emf</groupId>
			<artifactId>exporter</artifactId>
			<version>2.3.0</version>
		</dependency>

		<dependency>
			<groupId>org.eclipse.emf</groupId>
			<artifactId>importer</artifactId>
			<version>2.3.0</version>
		</dependency>

		<dependency>
			<groupId>org.eclipse.emf</groupId>
			<artifactId>importer-ecore</artifactId>
			<version>2.3.0</version>
		</dependency>

		<dependency>
			<groupId>org.eclipse.emf</groupId>
			<artifactId>importer-java</artifactId>
			<version>2.3.0</version>
		</dependency>

		<dependency>
			<groupId>org.eclipse.emf</groupId>
			<artifactId>importer-rose</artifactId>
			<version>2.3.0</version>
		</dependency>

		<dependency>
			<groupId>org.eclipse.emf</groupId>
			<artifactId>mapping</artifactId>
			<version>2.3.0</version>
		</dependency>

		<dependency>
			<groupId>org.eclipse.emf</groupId>
			<artifactId>mapping-ecore2ecore</artifactId>
			<version>2.3.0</version>
		</dependency>

		<dependency>
			<groupId>org.eclipse.emf</groupId>
			<artifactId>mapping-ecore2ecore-editor</artifactId>
			<version>2.3.0</version>
		</dependency>

		<dependency>
			<groupId>org.eclipse.emf</groupId>
			<artifactId>mapping-ecore2xml</artifactId>
			<version>2.3.0</version>
		</dependency>

		<dependency>
			<groupId>org.eclipse.emf</groupId>
			<artifactId>mapping-ecore2xml-ui</artifactId>
			<version>2.3.0</version>
		</dependency>

		<dependency>
			<groupId>org.eclipse.emf</groupId>
			<artifactId>mapping-ui</artifactId>
			<version>2.3.0</version>
		</dependency>

		<dependency>
			<groupId>org.eclipse.emf</groupId>
			<artifactId>mapping-xsd2ecore</artifactId>
			<version>2.3.0</version>
		</dependency>

		<dependency>
			<groupId>org.eclipse.emf</groupId>
			<artifactId>mapping-xsd2ecore-editor</artifactId>
			<version>2.3.0</version>
		</dependency>

		<dependency>
			<groupId>org.eclipse.xsd</groupId>
			<artifactId>ecore-exporter</artifactId>
			<version>2.3.0</version>
		</dependency>

		<dependency>
			<groupId>org.eclipse.xsd</groupId>
			<artifactId>ecore-importer</artifactId>
			<version>2.3.0</version>
		</dependency>

		<dependency>
			<groupId>org.eclipse.xsd</groupId>
			<artifactId>edit</artifactId>
			<version>2.3.0</version>
		</dependency>

		<dependency>
			<groupId>org.eclipse.xsd</groupId>
			<artifactId>xsd</artifactId>
			<version>2.3.0</version>
		</dependency>
=================================================================

Run mvn eclipse:eclipse again to update the project's dependencies


Create a model directory under the root project directory:
mkdir emf.configuration/model

Place the server.xml schema generated during the build in the model directory.
It's located here:

trunk-with-dependencies/apacheds/apacheds-xbean-spring/target/xbean/apacheds-xbean-spring.xsd



Now for this next step make sure you have EMF installed in the Eclipse workbench.

Then do:

File > New > Other > Eclipse Modeling Framework > EMF Model

Now in the EMF Model Dialog select the emf.configuration/model directory

Name the model configuration.genmodel (This is the model that we will use to generate the
beans)

Next

Select XML Schema For the Model Importer

Next

Select the apacheds-xbean-spring.xsd file as the source file for the model

Finish

RESULT
=================================================================
The files:
emf.configuration/model/_1.ecore
emf.configuration/model/configuration.genmodel

Are now created.
=================================================================

Double click on configuration.genmodel

This opens it in the genmodel editor that's part of emf.

We need to make a change to the genmodel so the code gets 
generated into src/main/java, instead of the root of the
project directory.

Double click on the root element in the genmodel editor 
such that the properties dialog opens up.

In the properties dialog, go down to the model section and 
expand it.  See the property called "model directory" that 
is set to "/emf.configuration/src".  Change it to:

"/emf.configuration/src/main/java"

Now right click on the Configuration node (Top level) in the 
genmodel editor and select "Generate Model Code".

This will generate interfaces and interface implementations for 
all the elements in the original schema.

Have a look in 

org.apache.config_1
and
org.apache.config_1.impl

The interfaces are in the first.

The implementation in the second.

Notice that intefaces have the Schema element name,
and the impleentation has the "Impl" postfix.

Notice that the _1 is used as prefixes
in the names of java files and in the package 
naming.  EMF Source this from the original schema.

We should update this so that it's set to a more sensible value.

Have a look at the classes and intefaces.  Do these look 
OK?

If there are errors in the project, run mvn eclipse:eclipse and refresh and that should take
care of it.

That's the implementation.  Now we just need to create an instance of the root container (The
container for all of the beans), serialize it, and we have an instance of server.xml.

I'll start on that next, as well as showing how to read it, etc.

Cheers,
- Ole



Mime
View raw message