KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > inversoft > verge > mvc > model > repository > RepositoryModelResolver


1 /*
2  * Copyright (c) 2003, Inversoft
3  *
4  * This software is distribuable under the GNU Lesser General Public License.
5  * For more information visit gnu.org.
6  */

7 package com.inversoft.verge.mvc.model.repository;
8
9
10 import java.util.Map JavaDoc;
11
12 import javax.servlet.http.HttpServletRequest JavaDoc;
13
14 import com.inversoft.beans.BeanException;
15 import com.inversoft.verge.mvc.MVCException;
16 import com.inversoft.verge.mvc.MVCRequest;
17 import com.inversoft.verge.mvc.model.ModelResolution;
18 import com.inversoft.verge.mvc.model.ModelResolver;
19 import com.inversoft.verge.repository.RepositoryBean;
20
21
22 /**
23  * <p>
24  * This class is the model resolver for the repository based
25  * model objects.
26  * </p>
27  *
28  * @author Brian Pontarelli
29  * @since 2.0
30  * @version 2.0
31  */

32 public class RepositoryModelResolver implements ModelResolver {
33
34     /**
35      * Constructs a new <code>RepositoryModelResolver</code>
36      */

37     public RepositoryModelResolver() {
38     }
39
40
41     /**
42      * Using the definition, which should contain the repository ID of the model
43      * object, this constructs a RepositoryBean object and returns it. If the
44      * repository ID is invalid or non-existant, this throws an exception.
45      *
46      * @param mvcRequest Used to create/lookup the repository item.
47      * @param definition The first part of this String should be the repository
48      * ID. This uses the RepositoryMetaData to determine the ID
49      * @param extraParams Not used
50      */

51     public ModelResolution resolve(MVCRequest mvcRequest, String JavaDoc definition,
52             Map JavaDoc extraParams)
53     throws MVCException {
54         HttpServletRequest JavaDoc request = mvcRequest.getRequest();
55         RepositoryMetaData md = new RepositoryMetaData(definition);
56         RepositoryBean rb = md.createRepositoryBean(request);
57         
58         try {
59             return new ModelResolution(rb.getInstance(request), md);
60         } catch (BeanException be) {
61             throw new MVCException(be);
62         }
63     }
64 }
65
Popular Tags