%line | %branch | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
org.apache.jetspeed.components.dao.InitablePersistenceBrokerDaoSupport |
|
|
1 | /* |
|
2 | * Licensed to the Apache Software Foundation (ASF) under one or more |
|
3 | * contributor license agreements. See the NOTICE file distributed with |
|
4 | * this work for additional information regarding copyright ownership. |
|
5 | * The ASF licenses this file to You under the Apache License, Version 2.0 |
|
6 | * (the "License"); you may not use this file except in compliance with |
|
7 | * the License. You may obtain a copy of the License at |
|
8 | * |
|
9 | * http://www.apache.org/licenses/LICENSE-2.0 |
|
10 | * |
|
11 | * Unless required by applicable law or agreed to in writing, software |
|
12 | * 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 and |
|
15 | * limitations under the License. |
|
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 | 0 | super(); |
47 | 0 | this.repositoryPath = repositoryPath; |
48 | ||
49 | 0 | } |
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 | 0 | MetadataManager metaManager = MetadataManager.getInstance(); |
65 | 0 | RepositoryPersistor persistor = new RepositoryPersistor(); |
66 | 0 | URL descriptorUrl = getClass().getClassLoader().getResource(repositoryPath); |
67 | ||
68 | 0 | logger.info("Merging OJB respository "+descriptorUrl+" for DAO class "+getClass().getName()); |
69 | 0 | DescriptorRepository repo = persistor.readDescriptorRepository(descriptorUrl.openStream()); |
70 | 0 | metaManager.mergeDescriptorRepository(repo); |
71 | 0 | } |
72 | ||
73 | } |
This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |