01: /*
02: * Copyright 2004-2007 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: *
16: */
17:
18: package org.jpublish.component;
19:
20: import org.jpublish.SiteContext;
21: import org.jpublish.JPublishContext;
22: import org.jpublish.JPublishComponent;
23:
24: /** Runtime map which provides access to components via ID.
25:
26: @author Anthony Eden
27: @since 2.0
28: */
29:
30: public class ComponentMap {
31:
32: private JPublishContext context;
33:
34: /** Construct a new ComponentMap. */
35:
36: public ComponentMap(JPublishContext context) {
37: this .context = context;
38: }
39:
40: /** Get the specified component.
41:
42: @param id The component ID
43: @throws Exception
44: */
45:
46: public ComponentWrapper get(String id) throws Exception {
47: SiteContext siteContext = (SiteContext) context
48: .get(JPublishContext.JPUBLISH_SITE);
49: JPublishComponent component = siteContext.getComponentManager()
50: .getComponent(id);
51: return new ComponentWrapper(component, context);
52: }
53:
54: }
|