1/*2 * Licensed to the Apache Software Foundation (ASF) under one or more3 * contributor license agreements. See the NOTICE file distributed with4 * this work for additional information regarding copyright ownership.5 * The ASF licenses this file to You under the Apache License, Version 2.06 * (the "License"); you may not use this file except in compliance with7 * the License. You may obtain a copy of the License at8 * 9 * http://www.apache.org/licenses/LICENSE-2.010 * 11 * Unless required by applicable law or agreed to in writing, software12 * distributed under the License is distributed on an "AS IS" BASIS,13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.14 * See the License for the specific language governing permissions and15 * limitations under the License.16 */17packageorg.apache.jetspeed.components.dao;
1819import java.net.URL;
2021import org.apache.ojb.broker.metadata.DescriptorRepository;
22import org.apache.ojb.broker.metadata.MetadataManager;
23import org.apache.ojb.broker.metadata.RepositoryPersistor;
24import org.springframework.orm.ojb.support.PersistenceBrokerDaoSupport;
2526/***27 * <p>28 * InitablePersistenceBrokerDaoSupport29 * </p>30 * <p>31 *32 * </p>33 * @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a>34 * @version $Id: InitablePersistenceBrokerDaoSupport.java 224631 2005-07-24 17:03:46Z taylor $35 *36 */37publicclassInitablePersistenceBrokerDaoSupportextends PersistenceBrokerDaoSupport
38 {
3940protected String repositoryPath;
41/***42 * 43 */44publicInitablePersistenceBrokerDaoSupport(String repositoryPath)
45 {
46super();
47this.repositoryPath = repositoryPath;
4849 }
505152/***53 * 54 * <p>55 * init56 * </p>57 * Loads the correct repository descriptor for InitablePersistenceBrokerDaoSupport58 *59 * @see org.springframework.orm.ojb.support.PersistenceBrokerDaoSupport60 * @throws Exception61 */62publicvoid init() throws Exception
63 {
64 MetadataManager metaManager = MetadataManager.getInstance();
65 RepositoryPersistor persistor = new RepositoryPersistor();
66 URL descriptorUrl = getClass().getClassLoader().getResource(repositoryPath);
6768 logger.info("Merging OJB respository "+descriptorUrl+" for DAO class "+getClass().getName());
69 DescriptorRepository repo = persistor.readDescriptorRepository(descriptorUrl.openStream());
70 metaManager.mergeDescriptorRepository(repo);
71 }
7273 }