#OSLC AMESim Adapter
AMESim Concept | GET | POST | PUT | DELETE |
---|---|---|---|---|
Component | X | X | ||
Circuit | X | X | ||
Line | X | X | X | |
Port | X | X | ||
Parameter | X | X | X | |
Global Parameter | X | X | X |
##Instructions to install and run OSLC AMESim Adapter (for AMESim v13, and v14)
Last updated by Axel Reichwein ([email protected]) February 26, 2016
Follow the Instructions to install Eclipse Lyo. The document also contains instructions on how to use a proxy server with Maven and Eclipse.
Follow the Instructions to install edu.gatech.mbsec.subversion.client.
Follow the Instructions to install edu.gatech.mbsec.adapter.subversion.
- Open the Git Repositories View (Window -> Show View -> type “Git Repositories” in the search field)
- Click on the Clone Repository icon
- In the URI field, paste the following URL: https://github.com/ld4mbse/oslc-adapter-amesim.git
- The Host and Repository fields will autofill.
- Click Next, only select the master branch
- Click Next until Finish.
- In the Git repositories view, right-click edu.gatech.mbsec.adapter.amesim and select “Import Projects”. Click Next until Finish
- The 3 projects are in the Eclipse workspace
- In Eclipse, open the Project Explorer view. (Window → Show View → Project Explorer)
- Expand the edu.gatech.mbsec.adapter.amesim.ecore project
- Right click pom.xml -> Run As -> Maven clean
- Right click pom.xml -> Run As -> Maven install
- Expand the edu.gatech.mbsec.adapter.amesim.resources project
- Right click pom.xml -> Run As -> Maven clean
- Right click pom.xml -> Run As -> Maven install
- Expand the edu.gatech.mbsec.adapter.amesim project
- Right click pom.xml -> Run As -> Maven clean
- Right click pom.xml -> Run As -> Maven install
#####Troubleshooting
######Red error mark next to a project
- If there is a red error mark next to any project, select the project. Right-click->Maven->Update Project… and click OK
- Make sure that the Eclipse projects displayed in the project explorer view do not contain any error icons displayed next to the project names as for example displayed below.
- Select the project and open its properties view (Project->right click->Properties). Under the Projects Facet tab, make sure that 1.8 is selected.
- Select the project, right-click -> Properties. Select Java Compiler and select 1.8 in the drop down menu next to the JDK compliance setting as highlighted below.
Specify the port number of the OSLC AMESim adapter service of in the config.properties file under edu.gatech.mbsec.adapter.amesim/configuration. By default, port 8282 will be used. As an example displayed below, the port number is set to 8282.
Optional - only useful if you want to re-generate the OSLC4J-annotated Java classes *Specify the location of AMESim Ecore file in the config.properties file under edu.gatech.mbsec.adapter.amesim/configuration. The location of the AMESim ecore file named amesim.ecore is in the edu.gatech.mbsec.adapter.amesim.ecore project under /model/amesim.ecore. As an example displayed below, the location of the amesim.ecore file is specified to
C:/Users/…/git/oslc4jamesim/edu.gatech.mbsec.adapter.amesim.ecore /model/amesim.ecore
Note: The file path can contain backslashes Warning: Do not put quotes around the file path and add nothing at the end!
The OSLC AMESim adapter currently supports the retrieval of AMESim models
- within a specific local directory on the server
- within a subversion repository
- from individuals files hosted on the same or on different subversion repositories
Specify the location of the folder containing AMESim models which will be considered by the OSLC AMESim adapter in the config.properties file under edu.gatech.mbsec.adapter.amesim/configuration. As an example displayed below, the location of the folder containing AMESim models for the OSLC adapter is specified to
C:/Users/…/git/oslc-adapter-amesim/edu.gatech.mbsec.adapter.amesim/amesimmodels/
Warning: the location of the folder containing AMESim models needs to refer to the amesimmodels folder contained in the edu.gatech.mbsec.adapter.amesim project as in the example above. This lack of flexibility is temporary. It is important that the folder be named amesimmodels and be located directly under the project.
Several example AMESim models are located in the amesimmodels folder in the edu.gatech.mbsec.adapter.amesim project.
Note: The file path can contain backslashes.
Warning: Do not put quotes around the file path!
- Set the value of syncWithSvnRepo to true n the config.properties file under edu.gatech.mbsec.adapter.amesim/configuration
- Specify the Subversion repository URL containing AMESim models which will be considered by the OSLC AMESim adapter in the config.properties file under edu.gatech.mbsec.adapter.amesim/configuration. As an example displayed below, the Subversion repository URL is specified to be
https://mysvnrepos.com/svn/amesimrepository
Warning: Do not put quotes around the file path! 3. Set the time period in seconds at which the adapter will poll the Subversion repository for updates. Example:
delayInSecondsBetweenDataRefresh = none
or
delayInSecondsBetweenDataRefresh = 90
- Specify your Subversion credentials through the svnUserName and svnPassword fields
- Specify the location of the folder containing AMESim models where the Subversion files will be saved locally in config.properties file under edu.gatech.mbsec.adapter.amesim/configuration. As an example displayed below, the location of the folder containing AMESim models for the OSLC adapter is specified to
C:/Users/…/git/oslc-adapter-amesim/edu.gatech.mbsec.adapter.amesim/amesimmodels/
Warning: the location of the folder containing AMESim models needs to refer to the amesimmodels folder contained in the edu.gatech.mbsec.adapter.amesim project as in the example above. This lack of flexibility is temporary. It is important that the folder be named amesimmodels and be located directly under the project.
- Set the value of useIndividualSubversionFiles to true
- Specify the Subversion file URLs representing AMESim models which will be published by the adapter at startup in the subversionfiles.csv file under edu.gatech.mbsec.adapter.amesim/configuration. As an example displayed below, the Subversion file URLs are specified to be
https://koneksys1:18080/svn/repository1/FlatTwin.ame
https://koneksys1:18080/svn/repository1/FlatTwin3.ame
- During adapter runtime, you can change the Subversion files to be published through the web app at http://localhost:8080/oslc4jamesim/services/svnfilepublisher Note: the port number may differ from 8080 if specified differently in thr config.properties file By clicking on Publish, the adapter will retrieve the latest version of the Subversion files and publish them
- Specify your Subversion credentials through the svnUserName and svnPassword fields
- Specify the location of the folder containing AMESim models where the Subversion files will be saved locally in config.properties file under edu.gatech.mbsec.adapter.amesim/configuration. As an example displayed below, the location of the folder containing AMESim models for the OSLC adapter is specified to
C:/Users/…/git/oslc4jamesim/edu.gatech.mbsec.adapter.amesim/localworkingdirs
Note: The contents of this folder will be deleted when the adapter starts in individualSubversionFile mode.
Warning: Do not choose as local Subversion file storage the same folder as the one containing all sample AMESim models, nor the one containing the local AMESim models models without Subversion info.
Make sure that you have already installed AMESim. A Python interpreter is typically installed together with AMESim. You can check if you have already installed Python on your Windows machine by typing ”python -V” in the command prompt window. Launch the command prompt by clicking on Start->All Programs-> Accessories-> Command Prompt. You may have multiple Python interpreters installed on your computer. You can check your active Python interpreter on your Windows machine by typing ”which python” in the command prompt window. It should refer to the Python interpreter provided by AMESim.
Note: if your active Python interpreter is different than the one provided by AMEsim:
- run the python.bat file located in your AMESim installation folder
- set the PATH environment variable such that it first refers to the python distribution of AMESim before any other Pyhton distribution
- set the PYTHONHOME environment variable to point to the python distribution of AMESim
Optional: This step is only necessary if you want to use a specific Tomcat instance instead of the Tomcat instance embedded in Eclipse and downloaded by the Maven Tomcat plugin. This step is only necessary if you want:
- to deploy the AMESim adapter on a specific Tomcat instance (possibly with specific configurations)
- to deploy the AMESim adapter such that it accepts HTTP PUT requests, necessary for updating AMESim parameters
- Download Tomcat 8 by going to this page: https://tomcat.apache.org/download-80.cgi
- Download the zip distribution for your operating system. Note: do not use the windows installer as it doesn’t install all Tomcat scripts.
- Unzip the Tomcat 8 distribution in a folder where your user account has read/write permission. Note: Windows disables direct file access to programs folder for normal users per default.
- Make sure that the /bin folder in your Tomcat installation directory contains the catalina.bat batch file
- Make sure that you have JDK 8 installed on your machine. OSLC Adapters are now currently being build with Java 8 compilers. So Tomcat should also run with Java 8.
- On Windows, verify your installed Java version by typing in the command prompt java –version
- Test that environment variables JAVA_HOME and PATH respectively point to JDK and JDK/bin. Verify this on Windows by typing in the command prompt echo %JAVA_HOME% and echo %PATH%. If necessary set the envornoment variable in the command prompt using the set command (Example: set variable=string). After having set the environment variables, open a new ommand prompt to verify the values of the environment variables.
- Make sure that JAVA_HOME and JRE_HOME both point to the same Java version, for example Java 8.
- Make sure that CATALINA_HOME points to the correct installation directory of your Tomcat distribution.
- Adding Server Runtime Environment in Eclipse
- In Eclipse. Open Window -> Preferences -> Server -> Runtime Environments to create a Tomcat installed runtime.
- Click on Add... to open the New Server Runtime dialog,
- From the drop down menu, select Tomcat 8.0 as shown below. Click Next.
- Enter the Tomcat 8.0 installation directory (not the Apache installation directory!) as highlighted below.
- Click on Finish.
Tomcat by default is not enabled for HTTP PUT command. But, it can easily be configured to support it.
- In your Apache Tomcat 8 installation directory, open /conf/web.xml
- Add the readonly init param to the web.xml file as shown below and save the file
<init-param>
<param-name>readonly</param-name>
<param-value>false</param-value>
</init-param>
Note: If you get the warning shown below while trying to save the file, then copy the web.xml file into another location, modify it, and then replace the original web.xml file by the modified web.xml file.
- By default, the OSLC AMESim adapter service will run on port 8282. Change the port of the oslc4jamesim service only if you need to avoid a conflict with another service already running on port 8282. Skip the next steps if you do not need to change the port.
- In Eclipse, open the Project Explorer view. (Window → Show View → Project Explorer)
- Expand the edu.gatech.mbsec.adapter.amesim project
- Select and open the maven pom.xml file through double-click
- The pom.xml file contains several tabs. By default, the overview tab will be displayed. The various available tabs are displayed at the bottom of the editor window. Click on the pom.xml tab of the pom.xml.
- In the pom.xml tab of the pom.xml file, specify the port of the OSLC AMESim adapter service in the Maven tomcat plugin configuration found at the bottom of the pom.xml tab of the pom.xml file. Enter the port number in the configuration section.
Configuring Tomcat user roles and passwords (only useful for deploying adapter as war on standalone Tomcat)
In the /conf folder of the Tomcat installation directory, add in tomcat-users.xml inside the tag the following user tag
<user username="admin" password="admin" roles="admin-gui,manager-gui,manager-script" />
Note: Manager-script role is necessary to enable Maven deploy
Copying adapter configuration properties (only useful for deploying adapter as war on standalone Tomcat)
- In Eclipse, open the Project Explorer view. (Window → Show View → Project Explorer)
- Expand the edu.gatech.mbsec.adapter.amesim project
- Copy the folder named oslc4jamesim configuration
- Paste the folder in the Tomcat installation directory (Example: C:\Program Files\apache-tomcat-8.0.24-windows-x64\apache-tomcat-8.0.24/oslc4jamesim configuration)
In the maven user/.m2/ (Example: C:\Users\Axel.m2) folder, add in settings.xml the following
<?xml version="1.0" encoding="UTF-8"?>
<settings>
<servers>
<server>
<id>tomcat7</id>
<username>admin</username>
<password>admin</password>
</server>
</servers>
</settings>
Note: you can still use Tomcat 8 with the Tomcat 7 Maven plugin even though it only officially supports Tomcat 7. There is no Tomcat Maven plugin for Tomcat 8 at this point.
Optional - only useful if you want to use this REST client
- For Google Chrome, add the Postman REST client to your browser
- And the Postman launcher
There are several options
- Deploying OSLC AMESim adapter on Tomcat server embedded in Eclipse launched through Maven
- Deploying OSLC AMESim adapter on standalone Tomcat server manually
- Deploying OSLC AMESim adapter on standalone Tomcat server automatically from Eclipse
- Deploying OSLC AMESim adapter on standalone Tomcat server automatically from Eclipse in debug mode
For options except 2) and 3), you need to launch the Tomcat server manually
- Open a command prompt
- Change the directory of the command prompt to the/bin folder of the Tomcat installation directory using the cd command (Example: cd C:\Program Files\apache-tomcat-8.0.24-windows-x64\apache-tomcat-8.0.24\bin)
- Launch Tomcat by running the following command: catalina start
For all options except 1), if you wish to stop the Tomcat server
- Open a command prompt
- Change the directory of the command prompt to the/bin folder of the Tomcat installation directory using the cd command
- Stop Tomcat by running the following command: shutdown –force. Note: It is important to avoid a memory problem by using shutdown –force, else the OSLC AMESim adapter can cause a memory leak
Option #1: Deploying OSLC AMESim adapter on Tomcat server embedded in Eclipse launched through Maven
Select the oslc4jamesim launch configuration (Run -> Run Configurations… and select in the Maven build category the launch configuration named oslc4jamesim-wink tomcat run and click Run. In the console window, several logging related exceptions will appear (SLF4J and log4j). This is not critical.
Warning: If the OSLC AMESim adapter service fails to launch due to a java.net.BindException, a different port for the OSLC AMESim adapter needs to be used since there is a conflict with another service using the same port. By default, the OSLC AMESim adapter uses port 8282. A java.net.BindException means that a different service is already using this port. Go back to Steps #5 and #10 to change the port number.
Note: In order to stop a running oslc4jamesim web application, click Terminate in the Console window, or in the toolbar of the debug perspective.
Note: If you launch the Maven launch configuration (OSLC AMESim adapter) in debug mode, and do not see the Java code when the application hits a breakpoint, then you need to add the Eclipse workspace to the source lookup path. In the Debug view, right click on the running thread (in threads tab), or on the application as shown below and select Edit Source Lookup, and add the workspace. Re-launch the Maven launch configuration and the code should be visible in the editor when the application hits a breakpoint.
- Option 1)
- In Eclipse, open the Project Explorer view. (Window → Show View → Project Explorer)
- Expand the edu.gatech.mbsec.adapter.amesim project
- Open the /target folder
- rename the oslc4jamesim-1.1.0.war file into oslc4jamesim.war
- copy oslc4jamesim.war into the /webapps folder of the of the Tomcat installation directory
- Option 2)
- In your browser go to localhost:8080
- Click on Manager App
- If asked for your credentials, type in admin as user name and password
- In the Deploy section, select the WAR file to upload using the dialog shown below.
Run the Maven launch configuration named oslc4jamesim wink - tomcat deploy
Option #4: Deploying OSLC AMESim adapter on standalone Tomcat server automatically from Eclipse in debug mode
- In the startup.bat script under {TOMCAT_INSTALL_DIR}/bin, add following lines to the beginning as shown below
set JPDA_ADDRESS=8000
set JPDA_TRANSPORT=dt_socket
setlocal
- Open a command prompt to launch the Tomcat server
- Change the directory of the command prompt to the/bin folder of the Tomcat installation directory using the cd command (Example: cd C:\Program Files\apache-tomcat-8.0.24-windows-x64\apache-tomcat-8.0.24\bin)
- Launch Tomcat by running the following command: catalina jpda start
- Set breakpoints in your code if necessary
- First launch the remote java application named remote debugger oslc4jamesim on tomcat by choosing in Eclipse Debug-> Debug Configurations… , and then run the remote java application
- And then run the Maven launch configuration named oslc4jamesim wink - tomcat deploy
- Launch your web browser Google Chrome
- In the URL field, type for test purposes: http://localhost:8282/oslc4jamesim/services/catalog/singleton. This will send a HTTP GET request to retrieve the HTML representation of the AMESim Service Provider Catalog. This will launch a Python script.
- You will then see an HTML page showing you the list of Service Providers. You can browse from the Service Providers (e.g. for FlatTwin) to the Services and ultimately to the OSLC AMESim resources.
- Click on the Postman icon at the top right of the Chrome browser . A new tab will open.
- In the URL field, type for test purposes the URI of a resource published by the AMESim adapter (Example: http://localhost:8282/oslc4jamesim/services/FlatTwin/components/Constant).
- Click on the Headers field to the right of the URL field
- Enter Accept in the Header field and application/rdf+xml in the value field as shown below
- Click Send
- This will send a HTTP GET request to retrieve the RDF/XML representation of the AMESim block.
The edu.gatech.mbsec.adapter.amesim project contains example AMESim models containing different types of AMESim elements. The example models are located in the folder amesimmodels such as FlatTwin
Testing the retrieval of Subversion File Metadata resources in HTML and RDF (only available in "SVN Repository mode" and "Individual SVN files mode")
URL: http://localhost:8282/oslc4jamesim/services/subversionfiles/
Testing the selection of Subversion Files hosted by AMESim adapter in HTML and RDF (only available in "Individual SVN files mode")
URL: http://localhost:8282/oslc4jamesim/services/svnfilepublisher
URL: http://localhost:8282/oslc4jamesim/services/resourceShapes
URL: http://localhost:8282/oslc4jamesim/services/rdfvocabulary