|
|||||||||||||||||||
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 | |||||||||||||||
DeferredScriptImpl.java | - | 90% | 75% | 85.7% |
|
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.enhance;
|
|
16 |
|
|
17 |
import org.apache.hivemind.ApplicationRuntimeException;
|
|
18 |
import org.apache.hivemind.Locatable;
|
|
19 |
import org.apache.hivemind.Location;
|
|
20 |
import org.apache.hivemind.Resource;
|
|
21 |
import org.apache.hivemind.util.Defense;
|
|
22 |
import org.apache.tapestry.IScript;
|
|
23 |
import org.apache.tapestry.engine.IScriptSource;
|
|
24 |
|
|
25 |
/**
|
|
26 |
* @author Howard M. Lewis Ship
|
|
27 |
* @since 4.0
|
|
28 |
*/
|
|
29 |
public class DeferredScriptImpl implements DeferredScript, Locatable |
|
30 |
{ |
|
31 |
final Resource _scriptResource; |
|
32 |
|
|
33 |
final IScriptSource _scriptSource; |
|
34 |
|
|
35 |
final Location _location; |
|
36 |
|
|
37 | 4 |
public DeferredScriptImpl(Resource resource, IScriptSource source, Location location)
|
38 |
{ |
|
39 | 4 |
Defense.notNull(resource, "resource");
|
40 | 4 |
Defense.notNull(source, "source");
|
41 |
|
|
42 | 4 |
_scriptResource = resource; |
43 | 4 |
_scriptSource = source; |
44 | 4 |
_location = location; |
45 |
} |
|
46 |
|
|
47 | 2 |
public IScript getScript()
|
48 |
{ |
|
49 |
// No real reason to cache the script here, because a) they are rarely used
|
|
50 |
// and b) the IScriptSource caches.
|
|
51 |
|
|
52 | 2 |
try
|
53 |
{ |
|
54 | 2 |
return _scriptSource.getScript(_scriptResource);
|
55 |
} |
|
56 |
catch (Exception ex)
|
|
57 |
{ |
|
58 |
// Decorate the thrown exception with the correct location.
|
|
59 |
|
|
60 | 1 |
throw new ApplicationRuntimeException(ex.getMessage(), _location, ex); |
61 |
} |
|
62 |
} |
|
63 |
|
|
64 | 0 |
public Location getLocation()
|
65 |
{ |
|
66 | 0 |
return _location;
|
67 |
} |
|
68 |
|
|
69 | 1 |
public String toString()
|
70 |
{ |
|
71 | 1 |
return "DeferredScriptImpl[" + _scriptResource + "]"; |
72 |
} |
|
73 |
} |
|
74 |
|
|