You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by co...@apache.org on 2008/01/21 09:18:00 UTC

[CONF] Apache Tuscany: Tuscany SDO Java - FAQ (page edited)

Tuscany SDO Java - FAQ (TUSCANY) edited by Amita Vadhavkar
      Page: http://cwiki.apache.org/confluence/display/TUSCANY/Tuscany+SDO+Java+-+FAQ
   Changes: http://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=51434&originalVersion=8&revisedVersion=9






Content:
---------------------------------------------------------------------

{section:border=false}
{column:width=15%}
{include: SDO Java Subproject Menu}
{column}
{column:width=85%}
{panel:title=Apache Tuscany SDO Java Frequently Asked Questions|borderStyle=solid|borderColor=#C3CDA1|titleBGColor=#C3CDA1|bgColor=#ECF4D1}

* [Build and Devlopment Questions|#Build and Development Questions]
** [How can I debug into EMF in Eclipse? |#DevA]
** [What is the connection between static XSDHelper calls when definition and load could be using different XSDHelpers for the same instance in the same VM? |#DevB]
** [Is there support for extending generated SDO implementation classes? |#DevC]
** [How do I work with javajet files to modify the SDO generator code? |#DevD]
{panel}

h2. {anchor:Build and Development Questions}

{bgcolor:#C3CDA1}Build and Development Questions
{bgcolor}

h3. {anchor:DevA}

{bgcolor:#C3CDA1}How can I debug into EMF in Eclipse?
{bgcolor}

Download an SDK archive of the appropriate version of eclipse EMF containing EMF and XSD (and Eclipse's SDO 1.0 impl which can be ignored) from http://www.eclipse.org/modeling/emf/downloads/#archives (currently 2.2.3 and likely to remain that way until SDO is not constrained to work with Java 1.4.2).  The archive contains source code for each jar in zip files. Extract this archive onto your file system somewhere. You can associate a jar with a source zip in two ways.  Either ...
# wait until you debug into an EMF class file that doesn't have a source association and then click the "Attach Source ..." button,  or ...
# in the package explorer pane, open up the "Referenced Libraries" part of a projects source hierarchy and right click on one of the referenced libraries.  Select Properties, and click on the Java Source Attachment tab.

Now you have the opportunity to define a variable for eclipse to provide an starting root location in the file system which can be extended in order to locate the source code (this allows for easy transport of eclipse projects between environments, since only the small set of environment variables need to be updated in order to make the project build again in the new environment.)  Define a "New..." variable (mine is EMF_SRC) and make it point to a location above all the source file zips.  The variable's value will be something like C:/Dev/downloads/emf-sdo-xsd-SDK-2.2.3/eclipse/plugins/.  Now create an extension to that variable by clicking on "Extension...".  Select your new variable,  and open up the hierarchy to find the source zip file.  For example 

/EMF_SRC/org.eclipse.emf.source_2.2.3.v200705141058/src/org.eclipse.emf.ecore_2.2.3.v200705141058/src.zip

Be sure to select the zip file,  and not a folder above the file.  Close all the dialogs.  Now your source file attachment is made and you will be able to debug through any file in that jar.  You'll need to make more associations for the other jars by extending the existing EMF_SRC variable for those jars.

h3. {anchor:DevB}

{bgcolor:#C3CDA1}What is the connection between static XSDHelper calls when definition and load could be using different XSDHelpers for the same instance in the same VM?
{bgcolor}
 
*For example:*
{code}
XSDHelper.INSTANCE.define(is, null);
{code}
*and then in another static method xml is loaded*
{code}
XMLDocument xmlDoc = XMLHelper.INSTANCE.load(is);
{code}

{color:#0099cc} *Answer:* The methods you point out are not static methods,  but are executed in the context of the singleton helpers,  and the
metadata generated by the XSDHelper.INSTANCE singleton is stored in the TypeHelper.INSTANCE and accessed from there by the
XMLHelper.INSTANCEsingleton.  Together these singletons form a default set of helpers centred
around a default scope for types.  The recently introduced HelperContext SDO 2.1 API allows you to create new collections of helpers that together define alternative scopes. {color}

h3. {anchor:DevC}

{bgcolor:#C3CDA1}Is there support for extending generated SDO implementation classes?
{bgcolor}

Here is my understanding:
1) I cannot have my own superclass of a generated SDO class since this is already occupied 
2) I cannot (yet) simply subclass a generated SDO class, this may be addressed in TUSCANY-513 
As a consequence I would have to modify the generated  SDO implementation class in order to offer custom formatter and validation logic!? Is there eventually a way to inject code using annotations? Or is it possible to re-generate and prevent override of custom code (merge)?*
{color:#0099cc}*Answer:* The Tuscany SDO generator is currently reusing the code generator 
framework from Eclipse EMF project. If you look at the EMF generator,  you'll see that it's very powerful and customizable. In Tuscany all we've 
done is create a simple command line invocation of the EMF generator, using our own templates, and a few basic options.

One thing we don't support is regen/merge because the EMF merger prereqs the Eclipse JDT, which we didn't want to drag into Tuscany as a 
dependency. If someone is willing to write a standalone merger for Tuscany, we could support regen.
Other things like generating a different base class or adding methods, are supported in EMF but we don't have a way do it in with the Tuscany 
generator yet. If you'd be willing to help get some of this function into Tuscany, I'm sure a lot of people would be interested in it.

The bottom line is that real sophisticated tooling is outside of the scope of the Tuscany project. Another possible direction for this is for some 
Eclipse project to provide a fancy GUI-generator (and possibly other tools) for developing Tuscany SDO applications. It would be nice to see something like that get started.
{color}

h3. {anchor:DevD}

{bgcolor:#C3CDA1}How do I work with javajet files to modify the SDO generator code?
{bgcolor}

{color:#0099cc} *Answer:* You can learn how to set up your Eclipse environment to have javajet function built in using this [tutorial|http://www.eclipse.org/articles/Article-JET/jet_tutorial1.html].
Note that if you install the JET plugin via the Help => Software Updates => Find and Install .. menu of the eclipse IDE then you may see that selecting the "Java Emitter Templates SDK" causes the somewhat cryptic error message that you need the EMF codegen plugin,  but there is no such plugin listed as an additional item to select.  To clear this error and proceed you will need to select the "EMF Extender SDK" option.

Once you have the right eclipse environment you must add a javajet nature to the sdo-tools project, and modify the javajet configuration to match the shape of the sdo-tools project.
{code}
  File => New => Other
  Select "Java Emitter Templates"
  Select "Convert Projects to Jet Projects"
  Select "tuscany-sdo-tools"
  Click "Finish"
{code}
Then in the Package Explorer pane of the Java perspective of Eclipse, right click on the tuscany-sdo-tools project
{code}
  Select "Properties"
  Select "Jet Settings"
  Change the Source Container to "src/main/java"
{code}
Following this,  when you change the code in templates/models/SDOClass.javajet, or templates/models/SDOFactoryClass.javajet, then the corresponding java class will be updated each time that you save the javajet file. 
{color}

{column}
{section}

---------------------------------------------------------------------
CONFLUENCE INFORMATION
This message is automatically generated by Confluence

Unsubscribe or edit your notifications preferences
   http://cwiki.apache.org/confluence/users/viewnotifications.action

If you think it was sent incorrectly contact one of the administrators
   http://cwiki.apache.org/confluence/administrators.action

If you want more information on Confluence, or have a bug to report see
   http://www.atlassian.com/software/confluence



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org