01: /**********************************************************************************
02: * $URL: https://source.sakaiproject.org/svn/master/trunk/header.java $
03: * $Id: header.java 9220 2006-05-09 23:09:28Z ggolden@umich.edu $
04: ***********************************************************************************
05: *
06: * Copyright (c) 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.springframework.orm.hibernate.impl;
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.sakaiproject.springframework.orm.hibernate.AdditionalHibernateMappings;
29: import org.springframework.core.io.ClassPathResource;
30: import org.springframework.core.io.Resource;
31:
32: public class AdditionalHibernateMappingsImpl implements
33: AdditionalHibernateMappings, Comparable {
34: protected final transient Log logger = LogFactory
35: .getLog(getClass());
36:
37: private Resource[] mappingLocations;
38:
39: private Integer sortOrder = new Integer(Integer.MAX_VALUE);
40:
41: public void setMappingResources(String[] mappingResources) {
42: this .mappingLocations = new Resource[mappingResources.length];
43: for (int i = 0; i < mappingResources.length; i++) {
44: this .mappingLocations[i] = new ClassPathResource(
45: mappingResources[i].trim());
46: }
47: }
48:
49: public Resource[] getMappingLocations() {
50: return mappingLocations;
51: }
52:
53: public void processConfig(Configuration config) throws IOException,
54: MappingException {
55: for (int i = 0; i < this .mappingLocations.length; i++) {
56: config.addInputStream(this .mappingLocations[i]
57: .getInputStream());
58: }
59: }
60:
61: public int compareTo(Object o) {
62: return getSortOrder().compareTo(
63: ((AdditionalHibernateMappingsImpl) o).getSortOrder());
64: }
65:
66: public Integer getSortOrder() {
67: return sortOrder;
68: }
69:
70: public void setSortOrder(Integer sortOrder) {
71: this.sortOrder = sortOrder;
72: }
73: }
|