|
|||||||||||||||||||
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 | |||||||||||||||
DeferredObjectImpl.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.services.impl;
|
|
16 |
|
|
17 |
import org.apache.hivemind.Location;
|
|
18 |
import org.apache.hivemind.internal.Module;
|
|
19 |
import org.apache.hivemind.schema.Translator;
|
|
20 |
|
|
21 |
/**
|
|
22 |
* An encapsulation of an invocation of
|
|
23 |
* {@link org.apache.hivemind.schema.Translator#translate(org.apache.hivemind.internal.Module, java.lang.Class, java.lang.String, org.apache.hivemind.Location)},
|
|
24 |
* allowing the actual invocation (and all the object creation, etc., that entails) to be deferred,
|
|
25 |
* or even avoided all together.
|
|
26 |
*
|
|
27 |
* @author Howard M. Lewis Ship
|
|
28 |
* @since 4.0
|
|
29 |
*/
|
|
30 |
public class DeferredObjectImpl implements DeferredObject |
|
31 |
{ |
|
32 |
private final Module _module;
|
|
33 |
|
|
34 |
private final Translator _objectTranslator;
|
|
35 |
|
|
36 |
private final String _objectReference;
|
|
37 |
|
|
38 |
private final Location _location;
|
|
39 |
|
|
40 |
private Object _object;
|
|
41 |
|
|
42 | 1397 |
public DeferredObjectImpl(final Translator objectTranslator, final Module module,
|
43 |
final String objectReference, final Location location) |
|
44 |
{ |
|
45 | 1397 |
_objectTranslator = objectTranslator; |
46 | 1397 |
_module = module; |
47 | 1397 |
_objectReference = objectReference; |
48 | 1397 |
_location = location; |
49 |
} |
|
50 |
|
|
51 | 1354 |
public synchronized Object getObject() |
52 |
{ |
|
53 | 1354 |
if (_object == null) |
54 | 1352 |
_object = _objectTranslator.translate( |
55 |
_module, |
|
56 |
Object.class,
|
|
57 |
_objectReference, |
|
58 |
_location); |
|
59 |
|
|
60 | 1354 |
return _object;
|
61 |
} |
|
62 |
|
|
63 | 2 |
public Location getLocation()
|
64 |
{ |
|
65 | 2 |
return _location;
|
66 |
} |
|
67 |
} |
|