Skip to main content
Jump to: navigation, search

Difference between revisions of "Lyo/creating OSLC4J project"

< Lyo
m (cleanup and force the TOC)
Line 1: Line 1:
 +
__FORCETOC__
 +
 
= General Setup for OSLC4J development =
 
= General Setup for OSLC4J development =
 +
 
You first need to setup an Eclipse environment for general OSLC4J development:
 
You first need to setup an Eclipse environment for general OSLC4J development:
 +
 
# Unless already installed, you need to first install the JDK 8 (see the [[Lyo/prereqs|prerequisites]]).
 
# Unless already installed, you need to first install the JDK 8 (see the [[Lyo/prereqs|prerequisites]]).
 
# Install your preferred Eclipse distribution. Which distribution to use?
 
# Install your preferred Eclipse distribution. Which distribution to use?
 
#* [https://www.eclipse.org/downloads/packages/eclipse-ide-java-ee-developers/lunasr2 Eclipse IDE for Java EE Developers] seems to cover the necessary [[Lyo/prereqs|prerequisites for Building Lyo Projects]].
 
#* [https://www.eclipse.org/downloads/packages/eclipse-ide-java-ee-developers/lunasr2 Eclipse IDE for Java EE Developers] seems to cover the necessary [[Lyo/prereqs|prerequisites for Building Lyo Projects]].
#* [https://www.eclipse.org/downloads/packages/eclipse-ide-java-developers/lunasr2 Eclipse IDE for Java Developers] can be used, together with the following 2 additional plugins:  
+
#* [https://www.eclipse.org/downloads/packages/eclipse-ide-java-developers/lunasr2 Eclipse IDE for Java Developers] can be used, together with the following 2 additional plugins:
 
#** ''Eclipse Java EE Developer Tools''
 
#** ''Eclipse Java EE Developer Tools''
 
#** ''Eclipse Java Web Developer Tools''
 
#** ''Eclipse Java Web Developer Tools''
Line 11: Line 15:
 
## Select '''''Java-->Installed JREs'''''
 
## Select '''''Java-->Installed JREs'''''
 
## Click '''''Add...'''''
 
## Click '''''Add...'''''
## In the new window that appears,  
+
## In the new window that appears,
### choose '''''Standard VM''''' as JRE Type  
+
### choose '''''Standard VM''''' as JRE Type
### click '''''Next'''''.  
+
### click '''''Next'''''.
 
### As '''''JRE home''''' choose the installation dir of your JDK
 
### As '''''JRE home''''' choose the installation dir of your JDK
 
### click '''''Finish'''''.
 
### click '''''Finish'''''.
 
## Back to the preferences screen
 
## Back to the preferences screen
### select the old JRE  
+
### select the old JRE
 
### click '''''Remove'''''
 
### click '''''Remove'''''
### check the newly added JDK and  
+
### check the newly added JDK and
 
### click '''''OK'''''.
 
### click '''''OK'''''.
  
 
= Sample Project =
 
= Sample Project =
  
As a complement when following the instructions below, this [[Media:OSLC4JSampleAdaptor.zip | sample OSLC4J project]] contains a basic but complete Eclipse project that can be used as a starting point and/or a reference.  
+
As a complement when following the instructions below, this [[Media:OSLC4JSampleAdaptor.zip | sample OSLC4J project]] contains a basic but complete Eclipse project that can be used as a starting point and/or a reference.
 +
 
 +
The project is configured with the following values:
  
The project is configured with the following values:
 
 
  '''ProjectName''': ''SampleAdaptor''
 
  '''ProjectName''': ''SampleAdaptor''
 
  '''PackageName''': ''your.basepackage.name''
 
  '''PackageName''': ''your.basepackage.name''
  
# If you desire to change the project configuration, search and replace in the files below each of the above keywords with the specific values for your project
+
If you desire to change the project configuration, search and replace in the files below each of the above keywords with the specific values for your project
#* .project  
+
 
#* pom.xml
+
* <code>.project</code>
#* adaptorModel/my.adaptorInterface
+
* <code>pom.xml</code>
#* src/main/webapp/WEB-INF/web.xml
+
* <code>adaptorModel/my.adaptorInterface</code>
#* src/test/resources/launches/Launch SampleAdaptor.launch
+
* <code>src/main/webapp/WEB-INF/web.xml</code>
# If you get the error "Project configuration is not up-to-date with pom.xml", simply right click on the eclipse project and select '''Maven-->Update Project...'''.
+
* <code>src/test/resources/launches/Launch SampleAdaptor.launch</code>
 +
 
 +
If you get the error "Project configuration is not up-to-date with pom.xml", simply right click on the eclipse project and select '''Maven-->Update Project...'''.
  
 
= Setup an OSLC4J project =
 
= Setup an OSLC4J project =
Line 43: Line 50:
 
The steps below guide you through the necessary steps of creating an Eclipse project with the necessary configurations to develop any OSLC4J adaptor.
 
The steps below guide you through the necessary steps of creating an Eclipse project with the necessary configurations to develop any OSLC4J adaptor.
  
In the instructions below, we assume an eclipse project named ''SampleAdaptor'', where the java classes are managed under the base package named ''your.basepackage.name''.
+
In the instructions below, we assume an eclipse project named ''SampleAdaptor'', where the java classes are managed under the base package named <code>your.basepackage.name</code>.
  
# Create a JAVA EE Web Application
+
; Create a JAVA EE Web Application
## '''File-->New-->Project...'''
+
:- '''File-->New-->Project...'''
## Select ''Web/Dynamic Web Project''
+
:- Select ''Web/Dynamic Web Project''
## As project name, specify ''SampleAdaptor''
+
:- As project name, specify ''SampleAdaptor''
## On the final step of the wizard, check the '''Generate web.xml...''' option
+
:- On the final step of the wizard, check the '''Generate web.xml...''' option
## Select '''Finish'''
+
:- Select '''Finish'''
# Convert project to Maven
+
; Convert project to Maven
## Right click on the project, and select '''Configure --> Convert to Maven Project'''
+
:- Right click on the project, and select '''Configure --> Convert to Maven Project'''
## In the window that appears, select ''war'' under '''Packaging'''
+
:- In the window that appears, select ''war'' under '''Packaging'''
# Configure the project
+
; Configure the project
## Create a folder '''test''' at the root of the project
+
:- Create a folder '''test''' at the root of the project
## Create the sub-folders '''launches''' & '''resources''' under the new folder '''test'''
+
:- Create the sub-folders '''launches''' & '''resources''' under the new folder '''test'''
## Copy the 3 configuration files from the [[Media:OSLC4JCodeGeneratorconfigurationFileTemplates.zip | Configuration File Templates]] into the corresponding folders:
+
:- Copy the 3 configuration files from the [[Media:OSLC4JCodeGeneratorconfigurationFileTemplates.zip | Configuration File Templates]] into the corresponding folders:
### ''/SampleAdaptor/pom.xml''
+
::- ''/SampleAdaptor/pom.xml''
### ''/SampleAdaptor/src/main/webapp/WEB-INF/web.xml''
+
::- ''/SampleAdaptor/src/main/webapp/WEB-INF/web.xml''
### ''/SampleAdaptor/src/main/webapp/WEB-INF/jetty.xml''
+
::- ''/SampleAdaptor/src/main/webapp/WEB-INF/jetty.xml''
### If necessary, refresh your Eclipse workspace by right clicking on ''SampleAdaptor -> Refresh''
+
::- If necessary, refresh your Eclipse workspace by right clicking on ''SampleAdaptor -> Refresh''
## If you choose a different name for your project and/or java package, search and replace these values in the project files as instructed under the [[Lyo/creating_OSLC4J_project#Sample_Project | Sample Project]] above.
+
:- If you choose a different name for your project and/or java package, search and replace these values in the project files as instructed under the [[Lyo/creating_OSLC4J_project#Sample_Project | Sample Project]] above.
# Activate Project Facet JAX-RS
+
; Activate Project Facet JAX-RS
## Right click the project & Select '''properties'''
+
:- Right click the project & Select '''properties'''
## Select the '''Project Facets''' window
+
:- Select the '''Project Facets''' window
## Select '''JAX-RS (REST Web Services)'''
+
:- Select '''JAX-RS (REST Web Services)'''
## Click '''OK''' to commit the changes.
+
:- Click '''OK''' to commit the changes.
## Right click again on the project & Select '''properties'''
+
:- Right click again on the project & Select '''properties'''
## select the new '''JAX-RS''' sub-window under '''Project Facets'''
+
:- select the new '''JAX-RS''' sub-window under '''Project Facets'''
## Set '''Type:''' to ''Disable Library Configuration''
+
:- Set '''Type:''' to ''Disable Library Configuration''
## Enter '''JAX-RS servlet class name''': ''org.apache.wink.server.internal.servlet.RestServlet''
+
:- Enter '''JAX-RS servlet class name''': ''org.apache.wink.server.internal.servlet.RestServlet''
## Under '''URL mapping patterns''':
+
:- Under '''URL mapping patterns''':
### Remove the existing pattern
+
::- Remove the existing pattern
### Add a new pattern ''/services/*''
+
::- Add a new pattern ''/services/*''
##* '''Note:''' the above two steps (8 and 9) are no longer available in the Eclipse Mars 4.5 Java EE dialog for the JAX-RS facet. The web.xml file can, of course, be manually edited to make the indicated changes.
+
: '''Note:''' the above two steps (editing the JAX-RS servlet class name and the URL mapping patterns) are no longer available in the Eclipse Mars 4.5 Java EE dialog for the JAX-RS facet. The web.xml file can, of course, be manually edited to make the indicated changes.
## Click '''OK''' to commit the changes.
+
:- Click '''OK''' to commit the changes.
# Further project configuration
+
; Further project configuration
## right click the project & select '''Properties'''
+
:- right click the project & select '''Properties'''
## select '''Deployment Assembly'''
+
:- select '''Deployment Assembly'''
## '''Add...'''
+
:- '''Add...'''
## In the new window that appears
+
:- In the new window that appears
### select '''Java Build Path Entries'''
+
::- select '''Java Build Path Entries'''
### click '''Next >'''
+
::- click '''Next >'''
### select '''Maven Dependencies'''
+
::- select '''Maven Dependencies'''
### click '''Finish'''
+
::- click '''Finish'''
### click '''Apply'''
+
::- click '''Apply'''
### click '''OK'''
+
::- click '''OK'''
# Create a new Run configuration
+
; Create a new Run configuration
## Select the menu '''Run-->Run Configurations...'''
+
:- Select the menu '''Run-->Run Configurations...'''
## Select '''Maven Build'''
+
:- Select '''Maven Build'''
## Create a new Configuration (Right click on '''Maven Build -> New''')
+
:- Create a new Configuration (Right click on '''Maven Build -> New''')
## Enter a '''name''' for the new configuration (such as ''"Launch SampleAdaptor"'')
+
:- Enter a '''name''' for the new configuration (such as ''"Launch SampleAdaptor"'')
## Set the '''Base directory''' to ''${workspace_loc:/SampleAdaptor}''
+
:- Set the '''Base directory''' to ''${workspace_loc:/SampleAdaptor}''
## Set '''Goal''' as ''jetty:run-exploded''
+
:- Set '''Goal''' as ''jetty:run-exploded''
## Switch to tab '''JRE'''
+
:- Switch to tab '''JRE'''
### Set '''Runtime JRE''' to ''Workspace default JRE...''
+
::- Set '''Runtime JRE''' to ''Workspace default JRE...''
## Switch to tab '''Source'''
+
:- Switch to tab '''Source'''
### Click '''Add...'''
+
::- Click '''Add...'''
### In the new window, select '''Project''' and click '''OK'''
+
::- In the new window, select '''Project''' and click '''OK'''
#### Check the ''SampleAdaptor'' project
+
:::- Check the ''SampleAdaptor'' project
#### Check the '''add required projects of selected projects''' option
+
:::- Check the '''add required projects of selected projects''' option
#### Click '''OK'''
+
:::- Click '''OK'''
## Switch to Tab '''Common'''
+
:- Switch to Tab '''Common'''
### Select '''Shared file'''
+
::- Select '''Shared file'''
### Click '''Browse...'''
+
::- Click '''Browse...'''
### In the window that appears, select the recently created folder ''test/launches'' under the ''SampleAdaptor'' project
+
::- In the window that appears, select the recently created folder ''test/launches'' under the ''SampleAdaptor'' project
### click '''OK'''
+
::- click '''OK'''
## Click '''Apply'''
+
:- Click '''Apply'''
## Clock '''Close'''
+
:- Clock '''Close'''

Revision as of 19:39, 13 April 2017


General Setup for OSLC4J development

You first need to setup an Eclipse environment for general OSLC4J development:

  1. Unless already installed, you need to first install the JDK 8 (see the prerequisites).
  2. Install your preferred Eclipse distribution. Which distribution to use?
  3. Once Eclipse is installed, you need to make sure the JAVA_HOME environment variable is set to the installed JDK (instead of the default JRE).
    1. Select Window-->Preferences
    2. Select Java-->Installed JREs
    3. Click Add...
    4. In the new window that appears,
      1. choose Standard VM as JRE Type
      2. click Next.
      3. As JRE home choose the installation dir of your JDK
      4. click Finish.
    5. Back to the preferences screen
      1. select the old JRE
      2. click Remove
      3. check the newly added JDK and
      4. click OK.

Sample Project

As a complement when following the instructions below, this sample OSLC4J project contains a basic but complete Eclipse project that can be used as a starting point and/or a reference.

The project is configured with the following values:

ProjectName: SampleAdaptor
PackageName: your.basepackage.name

If you desire to change the project configuration, search and replace in the files below each of the above keywords with the specific values for your project

  • .project
  • pom.xml
  • adaptorModel/my.adaptorInterface
  • src/main/webapp/WEB-INF/web.xml
  • src/test/resources/launches/Launch SampleAdaptor.launch

If you get the error "Project configuration is not up-to-date with pom.xml", simply right click on the eclipse project and select Maven-->Update Project....

Setup an OSLC4J project

Note: This information is based on the tutorial from The MBAT Tutorial on Implementing OSLC Consumers and Providers with OSLC4J - By Stefan Paschke ViF.

The steps below guide you through the necessary steps of creating an Eclipse project with the necessary configurations to develop any OSLC4J adaptor.

In the instructions below, we assume an eclipse project named SampleAdaptor, where the java classes are managed under the base package named your.basepackage.name.

Create a JAVA EE Web Application
- File-->New-->Project...
- Select Web/Dynamic Web Project
- As project name, specify SampleAdaptor
- On the final step of the wizard, check the Generate web.xml... option
- Select Finish
Convert project to Maven
- Right click on the project, and select Configure --> Convert to Maven Project
- In the window that appears, select war under Packaging
Configure the project
- Create a folder test at the root of the project
- Create the sub-folders launches & resources under the new folder test
- Copy the 3 configuration files from the Configuration File Templates into the corresponding folders:
- /SampleAdaptor/pom.xml
- /SampleAdaptor/src/main/webapp/WEB-INF/web.xml
- /SampleAdaptor/src/main/webapp/WEB-INF/jetty.xml
- If necessary, refresh your Eclipse workspace by right clicking on SampleAdaptor -> Refresh
- If you choose a different name for your project and/or java package, search and replace these values in the project files as instructed under the Sample Project above.
Activate Project Facet JAX-RS
- Right click the project & Select properties
- Select the Project Facets window
- Select JAX-RS (REST Web Services)
- Click OK to commit the changes.
- Right click again on the project & Select properties
- select the new JAX-RS sub-window under Project Facets
- Set Type: to Disable Library Configuration
- Enter JAX-RS servlet class name: org.apache.wink.server.internal.servlet.RestServlet
- Under URL mapping patterns:
- Remove the existing pattern
- Add a new pattern /services/*
Note: the above two steps (editing the JAX-RS servlet class name and the URL mapping patterns) are no longer available in the Eclipse Mars 4.5 Java EE dialog for the JAX-RS facet. The web.xml file can, of course, be manually edited to make the indicated changes.
- Click OK to commit the changes.
Further project configuration
- right click the project & select Properties
- select Deployment Assembly
- Add...
- In the new window that appears
- select Java Build Path Entries
- click Next >
- select Maven Dependencies
- click Finish
- click Apply
- click OK
Create a new Run configuration
- Select the menu Run-->Run Configurations...
- Select Maven Build
- Create a new Configuration (Right click on Maven Build -> New)
- Enter a name for the new configuration (such as "Launch SampleAdaptor")
- Set the Base directory to ${workspace_loc:/SampleAdaptor}
- Set Goal as jetty:run-exploded
- Switch to tab JRE
- Set Runtime JRE to Workspace default JRE...
- Switch to tab Source
- Click Add...
- In the new window, select Project and click OK
- Check the SampleAdaptor project
- Check the add required projects of selected projects option
- Click OK
- Switch to Tab Common
- Select Shared file
- Click Browse...
- In the window that appears, select the recently created folder test/launches under the SampleAdaptor project
- click OK
- Click Apply
- Clock Close

Back to the top