KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jorm > verifier > lib > JormVerifier


1 /**
2  * JORM: an implementation of a generic mapping system for persistent Java
3  * objects. Two mapping are supported: to RDBMS and to binary files.
4  * Copyright (C) 2001-2003 France Telecom R&D - INRIA
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  *
20  * Contact: jorm-team@objectweb.org
21  *
22  */

23
24 package org.objectweb.jorm.verifier.lib;
25
26 import org.objectweb.jorm.metainfo.api.Manager;
27 import org.objectweb.jorm.verifier.api.MappingVerifier;
28 import org.objectweb.jorm.verifier.api.Verifier;
29 import org.objectweb.util.monolog.api.BasicLevel;
30 import org.objectweb.util.monolog.api.Logger;
31 import org.objectweb.util.monolog.api.LoggerFactory;
32 import org.objectweb.jorm.util.api.Loggable;
33
34 import java.util.HashMap JavaDoc;
35 import java.util.Collection JavaDoc;
36
37 public class JormVerifier implements Verifier, Loggable {
38     /**
39      * The meta information manager for managing meta-objects within the
40      * context of a mapper.
41      */

42     private Manager metaInfoManager;
43
44     /**
45      * The project name associated with this verifier.
46      */

47     private String JavaDoc projectName;
48
49     /**
50      * A simple logger to log.
51      */

52     private Logger logger;
53
54     /**
55      * A logger factory to create other loggers if needed.
56      */

57     private LoggerFactory loggerFactory;
58
59     /**
60      * the mapping verifier to use to verify the mapping part of the mapping
61      * information.
62      */

63     private HashMap JavaDoc mappingVerifiers = new HashMap JavaDoc();
64
65     /**
66      * builds a new JormVerifier object.
67      */

68     public JormVerifier() {
69     }
70
71     // IMPLEMENTATION OF METHODS FROM THE Verifier INTERFACE
72

73     /**
74      * Assigns the meta information manager created by the parser module to
75      * the current BlobVerifier object.
76      *
77      * @param mim the meta information manager to use
78      */

79     public void setMetaInfoManager(Manager mim) {
80         metaInfoManager = mim;
81     }
82
83     /**
84      * Assigns a project name to the verifier.
85      * @param name The associated name.
86      */

87     public void setProjectName(String JavaDoc name) {
88         projectName = name;
89     }
90
91     /**
92      * Sets the mapping verifier which verifies the mapping part of the meta
93      * information.
94      * @param mappername the name of the mapper
95      * @param mappingVerifier the Mapping BlobVerifier object
96      */

97     public void addMappingVerifier(String JavaDoc mappername, MappingVerifier mappingVerifier) {
98         mappingVerifiers.put(mappername, mappingVerifier);
99     }
100
101     /**
102      * Verifies the meta information.
103      */

104     public void verify(Collection JavaDoc mos) {
105         if (logger.isLoggable(BasicLevel.DEBUG))
106             logger.log(BasicLevel.DEBUG,
107                        "Start the verification of the meta-information");
108
109         // work
110

111         if (logger.isLoggable(BasicLevel.DEBUG))
112             logger.log(BasicLevel.DEBUG,
113                        "The verification of the meta-information is finished");
114     }
115
116     // IMPLEMENTATION OF METHODS FROM THE Loggable INTERFACE
117

118     public void setLogger(Logger logger) {
119         this.logger = logger;
120     }
121
122     public void setLoggerFactory(LoggerFactory loggerfactory) {
123         this.loggerFactory = loggerfactory;
124     }
125
126     public Logger getLogger() {
127         return logger;
128     }
129
130     public LoggerFactory getLoggerFactory() {
131         return loggerFactory;
132     }
133 }
134
Popular Tags