|
|
|
|
|
|
|
|
|
Re: Import MyDslStandaloneSetup does not resolve [message #1837010 is a reply to message #1836697] |
Wed, 20 January 2021 23:45   |
Andrej Liebert Messages: 18 Registered: January 2021 |
Junior Member |
|
|
Sorry for the long time without response.
In the meantime I did a bit of research and got more into EMF and Xtext.
You are right, the dsl name is TDLan2 (TDLan2StandaloneSetup).
so far I came up with a bit of code.
MANIFEST.MF:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Load
Bundle-SymbolicName: org.etsi.example.load
Bundle-Version: 1.0.0.qualifier
Automatic-Module-Name: org.etsi.example.load
Require-Bundle: org.eclipse.emf.ecore,
org.etsi.mts.tdl.model,
org.etsi.mts.tdl.TPLan2,
org.etsi.mts.tdl.TDLan2,
org.eclipse.emf.mwe.utils,
org.eclipse.ocl.xtext.essentialocl
Bundle-RequiredExecutionEnvironment: JavaSE-11
I use a basic Test Descrition in TDLan2 format that can be opened with the Sample Ecore Model Editor, resulting in a tree-like structure with
the following URI: "platform:/resource/org.etsi.example.load/model/example.tdlan2". The code describes the interaction between a client and server (just for illustration purpose).
Package Example {
Type STRING;
Gate Type HTTP accepts STRING;
Component Type EndPoint having {
gate http of type HTTP;
}
Test Configuration BasicClientServer {
create SUT server of type EndPoint;
create Tester client of type EndPoint;
connect server.http to client.http;
}
Test Description TD1 uses configuration BasicClientServer {
client.http sends "GET /store" to server.http;
server.http sends "200 OK" to client.http;
}
Test Description TD2 uses configuration BasicClientServer {
client.http sends "GET /users" to server.http;
server.http sends "200 OK" to client.http;
}
}
Java Code:
package org.etsi.example.load.run;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.xtext.resource.XtextResource;
import org.eclipse.xtext.resource.XtextResourceSet;
import org.etsi.mts.tdl.TDLan2StandaloneSetup;
import com.google.inject.Injector;
public class exe {
public static void main(String [] args) {
//from the Xtext Wiki FAQ
new org.eclipse.emf.mwe.utils.StandaloneSetup().setPlatformUri("../");
//adapted for the specific Xtext-based language implementation
Injector injector = new TDLan2StandaloneSetup().createInjectorAndDoEMFRegistration();
XtextResourceSet resourceSet = injector.getInstance(XtextResourceSet.class);
resourceSet.addLoadOption(XtextResource.OPTION_RESOLVE_ALL, Boolean.TRUE);
//adapted for the filename declared above (relative to working directory)
Resource resource = resourceSet.getResource(URI.createURI("platform:/resource/org.etsi.example.load/model/example.tdlan2"), true);
Console:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
at org.eclipse.emf.mwe.utils.StandaloneSetup.<init>(StandaloneSetup.java:107)
at org.etsi.example.load.run.exe.main(exe.java:25)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 2 more
(StandaloneSetup.java:107)
at org.etsi.example.load.run.exe.main(exe.java:25) references new org.eclipse.emf.mwe.utils.StandaloneSetup().setPlatformUri("../"); .
Here I do not know, if the workspace root is correctly set with this argument. As written in https://wiki.eclipse.org/Xtext/FAQ it should be.
[Updated on: Wed, 20 January 2021 23:52] Report message to a moderator
|
|
|
|
|
Re: Import MyDslStandaloneSetup does not resolve [message #1837022 is a reply to message #1837017] |
Thu, 21 January 2021 07:55   |
Andrej Liebert Messages: 18 Registered: January 2021 |
Junior Member |
|
|
I added the deps and it worked. to make it runnable I added the following lines:
//+1 added package initialisation as indicated in the wiki for predefined models
tdlPackage.eINSTANCE.eClass();
//+2 added OCL initialisation as it is used in the TDL implementation
EssentialOCLStandaloneSetup.doSetup();
The package is must be initialised and needs to addressed at the start.
Furthermore, I ran into OCL problems that caused " resolution of uriFragment '|0' failed." - errors
Finally I want to access the (TDL)-packages and other elements in the TDL model by trying to store the first package of the list into a TDL Object.
//adapted to root / top-level element type - Package (TDL Package, not Java Package!)
Package p = (Package) resource.getContents().get(0);
System.out.println("Package: "+p.getName()); //a first sign of life!
Exception in thread "main" java.lang.ClassCastException: class org.etsi.mts.tdl.impl.PackageImpl cannot be cast to class java.lang.Package (org.etsi.mts.tdl.impl.PackageImpl is in unnamed module of loader 'app'; java.lang.Package is in module java.base of loader 'bootstrap')
at org.etsi.example.load.run.exe.main(exe.java:36)
[Updated on: Thu, 21 January 2021 07:56] Report message to a moderator
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02946 seconds