1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.jetspeed.components.dao;
18
19 import java.net.URL;
20
21 import org.apache.ojb.broker.metadata.DescriptorRepository;
22 import org.apache.ojb.broker.metadata.MetadataManager;
23 import org.apache.ojb.broker.metadata.RepositoryPersistor;
24 import org.springframework.orm.ojb.support.PersistenceBrokerDaoSupport;
25
26 /***
27 * <p>
28 * InitablePersistenceBrokerDaoSupport
29 * </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 */
37 public class InitablePersistenceBrokerDaoSupport extends PersistenceBrokerDaoSupport
38 {
39
40 protected String repositoryPath;
41 /***
42 *
43 */
44 public InitablePersistenceBrokerDaoSupport(String repositoryPath)
45 {
46 super();
47 this.repositoryPath = repositoryPath;
48
49 }
50
51
52 /***
53 *
54 * <p>
55 * init
56 * </p>
57 * Loads the correct repository descriptor for InitablePersistenceBrokerDaoSupport
58 *
59 * @see org.springframework.orm.ojb.support.PersistenceBrokerDaoSupport
60 * @throws Exception
61 */
62 public void init() throws Exception
63 {
64 MetadataManager metaManager = MetadataManager.getInstance();
65 RepositoryPersistor persistor = new RepositoryPersistor();
66 URL descriptorUrl = getClass().getClassLoader().getResource(repositoryPath);
67
68 logger.info("Merging OJB respository "+descriptorUrl+" for DAO class "+getClass().getName());
69 DescriptorRepository repo = persistor.readDescriptorRepository(descriptorUrl.openStream());
70 metaManager.mergeDescriptorRepository(repo);
71 }
72
73 }