01: /*
02: * Copyright 2001-2006 C:1 Financial Services GmbH
03: *
04: * This software is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License Version 2.1, as published by the Free Software Foundation.
07: *
08: * This software is distributed in the hope that it will be useful,
09: * but WITHOUT ANY WARRANTY; without even the implied warranty of
10: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11: * Lesser General Public License for more details.
12: *
13: * You should have received a copy of the GNU Lesser General Public
14: * License along with this library; if not, write to the Free Software
15: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
16: */
17:
18: package de.finix.contelligent;
19:
20: import de.finix.contelligent.logging.LoggingService;
21: import de.finix.contelligent.search.Metainfo;
22:
23: /**
24: * A simple base class for components.
25: */
26: public abstract class AbstractComponent implements Component {
27: final static org.apache.log4j.Logger log = LoggingService
28: .getLogger(AbstractComponent.class);
29:
30: protected ComponentContext ctx;
31:
32: public void setComponentContext(ComponentContext ctx) {
33: this .ctx = ctx;
34: }
35:
36: public ComponentContext getComponentContext() {
37: return ctx;
38: }
39:
40: public boolean isDynamic() {
41: return false;
42: }
43:
44: public void postCreate() throws Exception {
45: }
46:
47: /**
48: * returns the path of this component as string. (without a trailing
49: * separator!)
50: */
51: final public String toString() {
52: if (ctx != null) {
53: return ctx.getPath().toString();
54: } else {
55: return "Component (name unknown)";
56: }
57: }
58:
59: /**
60: * This is the implementation of {@link Component#getSearchMetainfo}.
61: * Overwrite that method for extension.
62: *
63: * @returns
64: */
65: public void putSearchMetainfo(Metainfo metainfo, CallData callData) {
66: }
67:
68: /**
69: * Answer true if the content of this component may be changed
70: *
71: * @return
72: */
73: public boolean mayChangeContent() {
74: return true;
75: }
76:
77: protected String renderComponent(Component component,
78: CallData callData) {
79: return getComponentContext().getSystem().render(component,
80: callData);
81: }
82: }
|