| Title: Remote Object Persistence Tutorial Client Project |
| |
| |
| |
| <H3><A name="RemoteObjectPersistenceTutorialClientProject-CreateaClientProject"></A>Create a Client Project</H3> |
| |
| <P><EM>Creation of a new Eclipse project has been discussed in some details <A href="tutorial-setup.html" title="Tutorial Setup">here</A>, so we will omit the screenshots for the common parts.</EM></P> |
| |
| <UL> |
| <LI>In Eclipse go to <TT>"File > New > Project"</TT>. Select a <TT>"Java Project"</TT> for the project type and click "Next".</LI> |
| <LI>Enter <TT>"cayenne-tutorial-client"</TT> for the project name, select "Create separate source and output folders" radio button and click "Next".</LI> |
| <LI>On the next ("Java Settings") screen go to the "Libraries" tab and click "Add External Jar" button on the right to add the following .jar files needed by the client: |
| <UL> |
| <LI><TT>cayenne-client-nodeps.jar</TT>, located in the "lib" directory of the Cayenne installation.</LI> |
| <LI><TT>hessian.jar</TT>, version 3.0.13, that can be downloaded from <A href="http://www.caucho.com/hessian/" class="external-link" rel="nofollow">here</A>.</LI> |
| <LI><TT>commons-logging.jar</TT>, version 1.0.4 or newer, that can be downloaded from <A href="http://jakarta.apache.org/commons/logging/" class="external-link" rel="nofollow">here</A>.</LI> |
| <LI><TT>commons-lang.jar</TT>, version 2.1 or newer, that can be downloaded from <A href="http://jakarta.apache.org/commons/lang/" class="external-link" rel="nofollow">here</A>.</LI> |
| <LI><TT>commons-collections.jar</TT>, version 3.1 or newer, that can be downloaded from <A href="http://jakarta.apache.org/commons/collections/" class="external-link" rel="nofollow">here</A>:</LI> |
| </UL> |
| </LI> |
| </UL> |
| |
| |
| <P><SPAN class="image-wrap" style=""><IMG src="remote-object-persistence-tutorial-client-project.data/eclipse-client-libs.jpg" style="border: 0px solid black"></SPAN></P> |
| |
| <UL> |
| <LI>When done click "Finish" and the new project should appear in Eclipse.</LI> |
| </UL> |
| |
| |
| <H3><A name="RemoteObjectPersistenceTutorialClientProject-ClientClassGeneration"></A>Client Class Generation</H3> |
| |
| <P>Client classes are a lightweight version of server-side DataObjects. They are generated using a separate template. Let's lace them in a new client project.</P> |
| |
| <UL> |
| <LI><A href="running-cayennemodeler.html" title="Running CayenneModeler">Start CayenneModeler</A> and open <TT>"cayenne-tutorial/src/cayenne.xml"</TT> file (note that the mapping files stay in the server project; client will obtain mapping information from the server).</LI> |
| <LI>Select an "UntitledDomainMap" DataMap and check "Allow Client Entities"</LI> |
| <LI>Enter "cayenne.tutorial.client" for the "Client Java Package" and click an "Update.." button next to it to refresh the client package of all entities.</LI> |
| </UL> |
| |
| |
| <P><SPAN class="image-wrap" style=""><IMG src="remote-object-persistence-tutorial-client-project.data/client-package.jpg" style="border: 0px solid black"></SPAN></P> |
| |
| <UL> |
| <LI>Now select "Tools > Generate Classes" menu.</LI> |
| <LI>For "Type" select "Client Persistent Objects" (this will use a different generation template).</LI> |
| <LI>For the output directory select "cayenne-tutorial-client/src" directory of your <B>client</B> Eclipse project.</LI> |
| <LI>Click "Generate".</LI> |
| </UL> |
| |
| |
| <P><SPAN class="image-wrap" style=""><IMG src="remote-object-persistence-tutorial-client-project.data/client-class-generator.jpg" style="border: 0px solid black"></SPAN></P> |
| |
| <P>Now go back to Eclipse, right click on "cayenne-tutorial-client" project and select "Refresh" - you should see a pair of classes generated for each mapped entity. Note that you should not modify the classes whose names start with "_" (underscore), as they will be replaced on subsequent generator runs. Instead all custom logic should be placed in their subclasses located in "cayenne.tutorial" package - those will never be overwritten by the class generator.</P> |
| |
| <HR> |
| <P><B>Next Step: <A href="remote-object-persistence-tutorial-webservice.html" title="Remote Object Persistence Tutorial WebService">Remote Object Persistence Tutorial WebService</A></B></P> |
| <HR> |