This chapter will help you to configure a development environment so that you can create, develop, test and debug a project faster.
If you have found some more settings that helped you to develop the XINS API faster using Eclipse, send the procedure to [email protected].
The Eclipse version used for this manual is 3.2 and can be found at http://www.eclipse.org/platform.
As described in the install section, if you're using the Ant
distribution included with Eclipse, you may need to copy xercesImpl-2.6.2.jar
to the plugins\org.apache.ant_1.6.5\lib
directory
to avoid putDocumentInCache error messages. If
you still have the error, install Ant and go to Window ->
Preferences -> Ant -> Runtime -> Ant Home... and
choose the Ant directory.
As Eclipse locks the opened files, you choose close them before
calling the create-xxx targets. For example
xins-projects.xml
should be closed before calling
create-api.
If the xins-project.xml is not already created, create it in a new directory with the content specified in the section called “xins-project.xml”.
In Run -> External Tools -> External
Tools, create a new program with the name
xins
, the location set to the
xins\bin\xins.bat
file and the working
directory to the directory containing
xins-projects.xml
. Then you need to add in
the arguments the ${string_prompt}
variable and
add in environment the variable XINS_HOME
with the
value of the XINS directory.
If the API is not created, click on the
create-api
. This target will ask a series
of question in order to create the API including the first
function of the API.
Click on the eclipse
. Enter the name of the API.
The command will create a
xins-eclipse.userlibraries
in the
xins\src\tools\eclipse
directory. Then go to
Window -> Preferences -> Java -> Build Path
-> User Libraries -> Import... -> Browse and
select the xins-eclipse.userlibraries
file.
This step only needs to be done once.
After the eclipse command, depending on the directory location of the api:
If your project is outside your workspace, choose File -> New -> Project... -> Java -> Java Project -> fill the project name -> Create project from existing source and choose the apis\<api name> directory -> .
If your project is in your workspace, choose File -> Import... -> General -> Existing Projects into Workspace -> Next -> choose the apis\<api name> directory -> .
In order to be able to run and debug your web application, you'll need to install Tomcat (http://jakarta.apache.org/tomcat/) and the Tomcat plug-in for Eclipse (http://www.sysdeo.com/eclipse/tomcatplugin).
Configure the Tomcat plug-in in the Preferences:
Set the Tomcat home to the location where you have installed Tomcat
Add, in the JVM settings, the JVM parameter
-Dorg.xins.server.config=c:\java\tomcat\conf\xins.properties
(the xins.properties
could also be in another
directory). For more details about the
xins.properties
, read the section called “The runtime properties”.
Change the Configuration file to apis\<api
name>\tomcat-server.xml
.
Start Tomcat.
You can also use the Jetty plug-in for Eclipse. To install it, go to Help -> Software Updates -> Find and Install... -> Search for new features to install -> Add Update Site. Then enter the name JettyLauncher and the URL http://jettylauncher.sourceforge.net/updates/.
Create an Jetty XML file to link a directory to the
build/webapps/<api>/<api>.war
file.
Go to Run -> Run...
Create a new Jetty Web project
Set a name for the project, set the Jetty home
Click on Use a Jetty configuration file and set the value to the Jetty XML file you've created
Go to the argument tab and add the parameter
-Dorg.xins.server.config=<jetty_home>\etc\xins.properties
.
Now you can run, add breakpoints and debug your web application using the buttons on the toolbar
With Eclipse, by changing the code and saving it you can run your modification without recompiling if the modification is minimal. If you modified a lot of code, you will need to regenerate the war file.
If you have also generated the specific documentation you may
want to use the test forms or the example to test your project. To do
so, create a new External tool named specdocs with the main program
linked to your HTML Browser and the arguments set to
build\specdocs\<api>\index.html
file.
In order to be able to edit the specifications that are in XML,
we also advise that you install a XML plug-in for eclipse such as
XMLBuddy (http://www.xmlbuddy.com/) or
XML Author (http://www.svcdelivery.com/xmlauthor/).
Then in Preferences -> Workbench -> File Associations, add
*.fnc
, *.typ
and
*.rcd
associated with the XML tool.
If you execute the clean
target, you may have
afterwards a window popping up asking you to choose between
build.xml
and build.xml (1)
.
To remove this window go to External Tools... menu and remove the
build.xml (1)
configuration.
The version of NetBeans used for this manual is 5.0 and can be downloaded at http://www.netbeans.org/.
An Ant script for NetBeans 5.0 or higher is provided with XINS.
It requires a correctly set XINS_HOME
environment
variable.
Add the DTD catalog by clicking on the
runtime tab, right click on the DTD
and XML Schema Catalogs item and add the OASIS catalog
located at src\dtd\xinsCatalog.xml
.
Register some extension as XML files in
Tools -> Options -> Advanced Options
-> IDE Configuration -> System -> Object Types ->
XMLObjects -> Extensions and MIME Types
by
adding the items fnc
, typ
,
rcd
and cat
. Check also at
the same time the XML Indentation Engine settings.
From NetBeans 6.5
Tools -> Options -> Miscellaneous
-> Files
Open the project in
demo\xins-project\apis\petstore
.
If the API already exists, execute the
copy-nb-files
target of the
nbbuild.xml
.
If you want to create a new API, execute the
create-api
target. This target will ask a
series of question in order to create the API including the first
function of the API.
Open the project by selecting the directory of the API:
<project dir>\apis\<api
name>
You can now open your function implementation file and write
it's implementation in the Result call(Request
request)
method.
Click on the
button to compile, on the button to run your API, on the button to debug it or on the if you have modified the code with debugging.To profile the API, install NetBeans profiler (http://profiler.netbeans.org/) and execute the profile target.
In NetBeans, the targets can be executed by right-clicking on
the nbbuild.xml
and Run target
or by right-clicking on the project icon or by using the toolbar if
your project is the main project.
In NetBeans you can set conditional breakpoints or exception breakpoints that stop the debugger whenever an exception is thrown.
Targets to deploy your API in Tomcat are provided. You can then use the Netbeans HTTP Monitor with it.
If NetBeans 6 has problems to recognize the
Request
and Result
objects, you can add the option
-J-DCacheClassPath.keepJars=true
in the
Netbeans etc\netbeans.conf
file.