blob: ced6cd221689d37d7fead205c49a443758ed59cd [file] [log] [blame]
---
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
title: Remote Object Persistence Tutorial Client Project
url: /docs/2.0/remote-object-persistence-tutorial-client-project.html
layout: docs_legacy
---
<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>&quot;File &gt; New &gt; Project&quot;</TT>. Select a <TT>&quot;Java Project&quot;</TT> for the project type and click &quot;Next&quot;.</LI>
<LI>Enter <TT>&quot;cayenne-tutorial-client&quot;</TT> for the project name, select &quot;Create separate source and output folders&quot; radio button and click &quot;Next&quot;.</LI>
<LI>On the next (&quot;Java Settings&quot;) screen go to the &quot;Libraries&quot; tab and click &quot;Add External Jar&quot; 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 &quot;lib&quot; 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="/docs/2.0/images/eclipse-client-libs.jpg" style="border: 0px solid black"></SPAN></P>
<UL>
<LI>When done click &quot;Finish&quot; 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>&quot;cayenne-tutorial/src/cayenne.xml&quot;</TT> file (note that the mapping files stay in the server project; client will obtain mapping information from the server).</LI>
<LI>Select an &quot;UntitledDomainMap&quot; DataMap and check &quot;Allow Client Entities&quot;</LI>
<LI>Enter &quot;cayenne.tutorial.client&quot; for the &quot;Client Java Package&quot; and click an &quot;Update..&quot; button next to it to refresh the client package of all entities.</LI>
</UL>
<P><SPAN class="image-wrap" style=""><img src="/docs/2.0/images/client-package.jpg" style="border: 0px solid black"></SPAN></P>
<UL>
<LI>Now select &quot;Tools &gt; Generate Classes&quot; menu.</LI>
<LI>For &quot;Type&quot; select &quot;Client Persistent Objects&quot; (this will use a different generation template).</LI>
<LI>For the output directory select &quot;cayenne-tutorial-client/src&quot; directory of your <B>client</B> Eclipse project.</LI>
<LI>Click &quot;Generate&quot;.</LI>
</UL>
<P><SPAN class="image-wrap" style=""><img src="/docs/2.0/images/client-class-generator.jpg" style="border: 0px solid black"></SPAN></P>
<P>Now go back to Eclipse, right click on &quot;cayenne-tutorial-client&quot; project and select &quot;Refresh&quot; - you should see a pair of classes generated for each mapped entity. Note that you should not modify the classes whose names start with &quot;_&quot; (underscore), as they will be replaced on subsequent generator runs. Instead all custom logic should be placed in their subclasses located in &quot;cayenne.tutorial&quot; 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>