| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| ContextBindingFactory |
|
| 1.0;1 |
| 1 | // Copyright 2009 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.tapestry5.internal.bindings; | |
| 16 | ||
| 17 | import org.apache.tapestry5.Asset; | |
| 18 | import org.apache.tapestry5.Binding; | |
| 19 | import org.apache.tapestry5.ComponentResources; | |
| 20 | import org.apache.tapestry5.ioc.Location; | |
| 21 | import org.apache.tapestry5.services.AssetSource; | |
| 22 | import org.apache.tapestry5.services.BindingFactory; | |
| 23 | ||
| 24 | /** | |
| 25 | * Specialization of {@link org.apache.tapestry5.internal.bindings.AssetBindingFactory} that is explicitly limited to | |
| 26 | * context assets. | |
| 27 | * | |
| 28 | * @since 5.1.0.0 | |
| 29 | */ | |
| 30 | public class ContextBindingFactory implements BindingFactory | |
| 31 | { | |
| 32 | private final AssetSource source; | |
| 33 | ||
| 34 | public ContextBindingFactory(AssetSource source) | |
| 35 | 2 | { |
| 36 | 2 | this.source = source; |
| 37 | 2 | } |
| 38 | ||
| 39 | public Binding newBinding(String description, ComponentResources container, ComponentResources component, | |
| 40 | String expression, Location location) | |
| 41 | { | |
| 42 | 2 | Asset asset = source.getContextAsset(expression, container.getLocale()); |
| 43 | ||
| 44 | 2 | return new AssetBinding(location, description, asset); |
| 45 | } | |
| 46 | } |