1 package org.apache.portals.bridges.struts.config;
2
3 import org.apache.commons.digester.Digester;
4 import org.apache.commons.digester.Rule;
5 import org.xml.sax.Attributes;
6
7 public abstract class AbstractConfigComponent
8 {
9 protected static class SetParentRule extends Rule
10 {
11 private Object parent;
12
13 public SetParentRule(Object parent)
14 {
15 this.parent = parent;
16 }
17
18 public void begin( String arg0, String arg1, Attributes arg2 ) throws Exception
19 {
20 digester.push(parent);
21 }
22 }
23
24 private boolean loaded = false;
25
26 public AbstractConfigComponent()
27 {
28 }
29
30 protected void checkLoaded()
31 {
32 if (loaded)
33 throw new IllegalStateException("Already loaded");
34 }
35
36 public abstract void configure(Digester digester);
37
38 public void afterLoad()
39 {
40 checkLoaded();
41 loaded = true;
42 }
43 }