Wiki source code of Java Client - Model-Defined FetchSpecifications
                  Version 1.1 by David Avendasora on 2008/01/14 15:44
              
      Hide last authors
| author | version | line-number | content | 
|---|---|---|---|
|                              | 
      1.1 | 1 | Client code: | 
| 2 | |||
| 3 | private static final EODistributedObjectStore dos = (EODistributedObjectStore)(EOEditingContext.defaultParentObjectStore()); | ||
| 4 | |||
| 5 | / | ||
| 6 | |||
| 7 | * Invokes the remote method on session to get a named fetch specification. Needed because | ||
| 8 | * the whole eoaccess package is excluded from the client side frameworks. | ||
| 9 | ** | ||
| 10 | @param spec Fetch specification name. | ||
| 11 | @param entity Name of the entity for which the fetch specification is for. | ||
| 12 | @return The fetch specification, or null if it is not in the model, or an error occured | ||
| 13 | **/ | ||
| 14 | public static EOFetchSpecification getFetchSpecification( | ||
| 15 | String spec, | ||
| 16 | String entity){ | ||
| 17 | |||
| 18 | ~/~/invoke! | ||
| 19 | return (EOFetchSpecification) dos.invokeStatelessRemoteMethodWithKeyPath( | ||
| 20 | "session", | ||
| 21 | "clientSideRequestGetFetchSpecification", | ||
| 22 | new Class[[]]{{String.class, String.class}}{{/String.class, String.class}}, | ||
| 23 | new String[[]]{{spec, entity}}{{/spec, entity}}); | ||
| 24 | } | ||
| 25 | |||
| 26 | Server code, in the Session class: | ||
| 27 | |||
| 28 | / | ||
| 29 | |||
| 30 | * Loads and returns an <tt>EOFetchSpecification</tt> objects for the given | ||
| 31 | * specification and entity name. | ||
| 32 | ** | ||
| 33 | @param spec Name of the specification | ||
| 34 | @param entity Name of the entitiy | ||
| 35 | @return A fetch specification, or <tt>null</tt> if it is not found, or an | ||
| 36 | error occurs | ||
| 37 | **/ | ||
| 38 | public EOFetchSpecification getFetchSpecification(String spec, String entity){ | ||
| 39 | try{ | ||
| 40 | return EOFetchSpecification.fetchSpecificationNamed(spec, entity); | ||
| 41 | }catch(Exception ex){ | ||
| 42 | return null; | ||
| 43 | } | ||
| 44 | } | ||
| 45 | |||
| 46 | (courtesy Florijan Stamenkovic) |