|
|||||||||||||||||||
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover | |||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
PropertyPersistenceStrategySourceImpl.java | 100% | 100% | 100% | 100% |
|
1 |
// Copyright 2005 The Apache Software Foundation
|
|
2 |
//
|
|
3 |
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4 |
// you may not use this file except in compliance with the License.
|
|
5 |
// You may obtain a copy of the License at
|
|
6 |
//
|
|
7 |
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8 |
//
|
|
9 |
// Unless required by applicable law or agreed to in writing, software
|
|
10 |
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11 |
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12 |
// See the License for the specific language governing permissions and
|
|
13 |
// limitations under the License.
|
|
14 |
|
|
15 |
package org.apache.tapestry.record;
|
|
16 |
|
|
17 |
import java.util.ArrayList;
|
|
18 |
import java.util.Collection;
|
|
19 |
import java.util.HashMap;
|
|
20 |
import java.util.Iterator;
|
|
21 |
import java.util.List;
|
|
22 |
import java.util.Map;
|
|
23 |
|
|
24 |
import org.apache.hivemind.ApplicationRuntimeException;
|
|
25 |
import org.apache.tapestry.IRequestCycle;
|
|
26 |
import org.apache.tapestry.engine.ServiceEncoding;
|
|
27 |
|
|
28 |
/**
|
|
29 |
* @author Howard M. Lewis Ship
|
|
30 |
*/
|
|
31 |
public class PropertyPersistenceStrategySourceImpl implements PropertyPersistenceStrategySource |
|
32 |
{ |
|
33 |
// Set from tapestry.props.PersistenceStrategy
|
|
34 |
private List _contributions;
|
|
35 |
|
|
36 |
private Map _strategies = new HashMap(); |
|
37 |
|
|
38 | 49 |
public void initializeService() |
39 |
{ |
|
40 | 49 |
Iterator i = _contributions.iterator(); |
41 | 49 |
while (i.hasNext())
|
42 |
{ |
|
43 | 94 |
PropertyPersistenceStrategyContribution c = (PropertyPersistenceStrategyContribution) i |
44 |
.next(); |
|
45 |
|
|
46 | 94 |
_strategies.put(c.getName(), c.getStrategy()); |
47 |
} |
|
48 |
} |
|
49 |
|
|
50 | 32 |
public PropertyPersistenceStrategy getStrategy(String name)
|
51 |
{ |
|
52 | 32 |
if (!_strategies.containsKey(name))
|
53 | 1 |
throw new ApplicationRuntimeException(RecordMessages.unknownPersistenceStrategy(name)); |
54 |
|
|
55 | 31 |
return (PropertyPersistenceStrategy) _strategies.get(name);
|
56 |
} |
|
57 |
|
|
58 | 213 |
public Collection getAllStoredChanges(String pageName, IRequestCycle cycle)
|
59 |
{ |
|
60 | 213 |
Collection result = new ArrayList();
|
61 |
|
|
62 | 213 |
Iterator i = _strategies.values().iterator(); |
63 |
|
|
64 | 213 |
while (i.hasNext())
|
65 |
{ |
|
66 | 425 |
PropertyPersistenceStrategy s = (PropertyPersistenceStrategy) i.next(); |
67 |
|
|
68 | 425 |
result.addAll(s.getStoredChanges(pageName, cycle)); |
69 |
} |
|
70 |
|
|
71 | 213 |
return result;
|
72 |
} |
|
73 |
|
|
74 | 1 |
public void discardAllStoredChanged(String pageName, IRequestCycle cycle) |
75 |
{ |
|
76 | 1 |
Iterator i = _strategies.values().iterator(); |
77 |
|
|
78 | 1 |
while (i.hasNext())
|
79 |
{ |
|
80 | 1 |
PropertyPersistenceStrategy s = (PropertyPersistenceStrategy) i.next(); |
81 |
|
|
82 | 1 |
s.discardStoredChanges(pageName, cycle); |
83 |
} |
|
84 |
} |
|
85 |
|
|
86 | 161 |
public void addParametersForPersistentProperties(ServiceEncoding encoding, IRequestCycle cycle) |
87 |
{ |
|
88 | 161 |
Iterator i = _strategies.values().iterator(); |
89 |
|
|
90 | 161 |
while (i.hasNext())
|
91 |
{ |
|
92 | 321 |
PropertyPersistenceStrategy s = (PropertyPersistenceStrategy) i.next(); |
93 |
|
|
94 | 321 |
s.addParametersForPersistentProperties(encoding, cycle); |
95 |
} |
|
96 |
} |
|
97 |
|
|
98 | 50 |
public void setContributions(List contributions) |
99 |
{ |
|
100 | 50 |
_contributions = contributions; |
101 |
} |
|
102 |
} |
|