01: /**********************************************************************************
02: * $URL: https://source.sakaiproject.org/svn/metaobj/tags/sakai_2-4-1/metaobj-util/tool-lib/src/java/org/sakaiproject/metaobj/utils/mvc/impl/beans/AdditionalHibernateMappings.java $
03: * $Id: AdditionalHibernateMappings.java 14230 2006-09-05 18:02:51Z chmaurer@iupui.edu $
04: ***********************************************************************************
05: *
06: * Copyright (c) 2004, 2005, 2006 The Sakai Foundation.
07: *
08: * Licensed under the Educational Community License, Version 1.0 (the "License");
09: * you may not use this file except in compliance with the License.
10: * You may obtain a copy of the License at
11: *
12: * http://www.opensource.org/licenses/ecl1.php
13: *
14: * Unless required by applicable law or agreed to in writing, software
15: * distributed under the License is distributed on an "AS IS" BASIS,
16: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17: * See the License for the specific language governing permissions and
18: * limitations under the License.
19: *
20: **********************************************************************************/package org.sakaiproject.metaobj.utils.mvc.impl.beans;
21:
22: import java.io.IOException;
23:
24: import org.apache.commons.logging.Log;
25: import org.apache.commons.logging.LogFactory;
26: import org.hibernate.MappingException;
27: import org.hibernate.cfg.Configuration;
28: import org.springframework.core.io.ClassPathResource;
29: import org.springframework.core.io.Resource;
30:
31: public class AdditionalHibernateMappings {
32: protected final transient Log logger = LogFactory
33: .getLog(getClass());
34:
35: private Resource[] mappingLocations;
36:
37: public void setMappingResources(String[] mappingResources) {
38: this .mappingLocations = new Resource[mappingResources.length];
39: for (int i = 0; i < mappingResources.length; i++) {
40: this .mappingLocations[i] = new ClassPathResource(
41: mappingResources[i].trim());
42: }
43: }
44:
45: public Resource[] getMappingLocations() {
46: return mappingLocations;
47: }
48:
49: public void processConfig(Configuration config) throws IOException,
50: MappingException {
51: for (int i = 0; i < this.mappingLocations.length; i++) {
52: config.addInputStream(this.mappingLocations[i]
53: .getInputStream());
54: }
55: }
56: }
|