|
|
|
Re: Calling Java Code from QVTO 1.0.1 [message #479798 is a reply to message #479698] |
Wed, 12 August 2009 14:31 |
Sergey Boyko Messages: 171 Registered: July 2009 |
Senior Member |
|
|
This is a multi-part message in MIME format.
--------------040006040804040103080806
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit
Hi mary ,
You are using quite old version of QVTo. I advise you to switch on
recent 2.0.0 version (see
http://www.eclipse.org/modeling/m2m/downloads/index.php?proj ect=qvtoml).
It has many improvements over 1.0.1 also in area of black-box supporting.
Some replies in-line, below.
Regards,
Sergey
mary wrote:
>> 3. Created an extention point in the plugin.xml file for
>> "org.eclipse.m2m.qvt.oml.ocl.emf.libraries" .and the metamodel set to
>> UML Here is a copy of the plugin.xml file:
>> =============================
>> <?xml version="1.0" encoding="UTF-8"?>
>> <?eclipse version="3.4"?>
>> <plugin>
>> <extension point="org.eclipse.m2m.qvt.oml.ocl.emf.libraries">
>> <library class="CheckOCLConstraint.getJP"
>> id="CheckOCLConstraint.getJP">
>> <inMetamodel uri="http://www.eclipse.org/uml2/2.1.0/UML"/> </library>
>> </extension>
>> </plugin>
>> =============================
>> However in the file it gives an error [unknown extension point
>> "org.eclipse.m2m.qvt.oml.ocl.emf.libraries"]. But i tried to ignore
>> the error and export the plugin anyway.
>
>
> For the extention point i solved the error.. instead of
> having["org.eclipse.m2m.qvt.oml.ocl.emf.libraries"] I put
> [org.eclipse.m2m.qvt.oml.ocl.libraries] and the error is gone.
> However, still I cant access the library from qvt transformation..The
> error is still [can not find imported module]
It was mistake in earlier post. You're right, ext.point should be
"org.eclipse.m2m.qvt.oml.ocl.libraries".
Looking at posted library's registration in plugin.xml
<library class="CheckOCLConstraint.getJP" id="CheckOCLConstraint.getJP">
I can figure out that library class is named 'getJP' and it's located in
java package 'CheckOCLConstraint'. I think it's not true :)
You should specify fully qualified java class for 'class=' property.
I've attached java library sample (taken from
'org.eclipse.m2m.tests.qvt.oml' plug-in).
In plugin.xml it's registered as follows:
<extension point="org.eclipse.m2m.qvt.oml.ocl.libraries">
<library
class="org.eclipse.m2m.tests.qvt.oml.TestBlackboxLibrary"
id="TestBlackboxLibrary">
<inMetamodel uri="http://www.eclipse.org/emf/2002/Ecore"/>
<outMetamodel uri="http://www.eclipse.org/emf/2002/Ecore"/>
</library>
</extension>
Given it deployed the following script can test it:
import TestBlackboxLibrary;
modeltype ecore uses "http://www.eclipse.org/emf/2002/Ecore";
transformation testOldLib();
main() {
var v := object EClass{}.oclAnyMyOperation();
}
>
> I 've looked in the web and tried a lot of examples. Like the
> SampleLibrary example but yet it didn't work too..
> I don't know what am I missing!! Any help Plz?
>
> Thanks..
>
--------------040006040804040103080806
Content-Type: text/plain;
name="TestBlackboxLibrary.java"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="TestBlackboxLibrary.java"
/*********************************************************** ********************
* Copyright (c) 2008 Borland Software Corporation
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Borland Software Corporation - initial API and implementation
************************************************************ *******************/
package org.eclipse.m2m.tests.qvt.oml;
import java.util.Collections;
import java.util.Set;
import org.eclipse.emf.ecore.ENamedElement;
public class TestBlackboxLibrary {
public Set<ENamedElement> asRenamedSetSingleton(Object self, String newName) {
if(self instanceof ENamedElement) {
ENamedElement namedElement = (ENamedElement) self;
namedElement.setName(newName);
return Collections.singleton(namedElement);
}
return Collections.emptySet();
}
public final Set<Object> oclAnyMyOperation(Object self) {
return Collections.singleton(self);
}
/**
* Metainfo for the native methods should be accessible throu the static
* methods of inner class <code>Metainfo</code> with the same signature
* ant <code>String[]</code> return type. Returned array should contains
* string representation of OCL classifiers:
*
* array[0] - Context classifier
* array[n] - Classifier corresponds to the n-th operation parameter
* array[n+1] - Return type classifier
*/
public static class Metainfo {
private static final String[] RENAMED_SET_SINGLETON = new String[] {
"oclstdlib::OclVoid", // Void context -> module owned (context-less) operation
// imported library module is the implicit source object of the call
"oclstdlib::OclAny", // your argument1
"oclstdlib::String", // your argument2
"Set(ecore::ENamedElement)" // return type
};
private static final String[] OCLANY_MYOPERATION = new String[] {
"oclstdlib::OclAny",
"Set(oclstdlib::OclAny)"
};
public static final String[] asRenamedSetSingleton(Object arg, String newName) {
return RENAMED_SET_SINGLETON;
}
public static final String[] oclAnyMyOperation(Object arg) {
return OCLANY_MYOPERATION;
}
}
}
--------------040006040804040103080806--
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03390 seconds