KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tapestry > services > impl > PropertyObjectProvider


1 // Copyright 2004, 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.ApplicationRuntimeException;
18 import org.apache.hivemind.Location;
19 import org.apache.hivemind.internal.Module;
20 import org.apache.hivemind.service.ObjectProvider;
21 import org.apache.tapestry.engine.IPropertySource;
22
23 /**
24  * An implementation of {@link org.apache.hivemind.service.ObjectProvider}
25  * that gets the actual value from the
26  * <code>tapestry.GlobalPropertySource</code> service.
27  *
28  * @author Howard Lewis Ship
29  * @since 4.0
30  */

31 public class PropertyObjectProvider implements ObjectProvider
32 {
33     private IPropertySource _source;
34
35     /**
36      * Gets the value; the locator is the key passed to
37      * {@link IPropertySource#getPropertyValue(String)}.
38      */

39     public Object JavaDoc provideObject(
40         Module contributingModule,
41         Class JavaDoc propertyType,
42         String JavaDoc locator,
43         Location location)
44     {
45         try
46         {
47             return _source.getPropertyValue(locator);
48         }
49         catch (Exception JavaDoc ex)
50         {
51             throw new ApplicationRuntimeException(ex.getMessage(), location, ex);
52         }
53     }
54
55     public void setSource(IPropertySource source)
56     {
57         _source = source;
58     }
59
60 }
61
Popular Tags