2009/05/20 - Apache Shale has been retired.

For more information, please explore the Attic.

View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to you under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  
18  /*
19   * $Id: ConfigBean.java 464373 2006-10-16 04:21:54Z rahul $
20   */
21  package org.apache.shale.clay.config.beans;
22  
23  import java.net.URL;
24  
25  import javax.servlet.ServletContext;
26  
27  /***
28   * <p>This interfaces should be implemented by a object pool that
29   *  is registered with the {@link ConfigBeanFactory}.
30   * </p>
31   */
32  public interface ConfigBean extends Comparable {
33  
34       /***
35        * <p>Top-level interface that defines a single configuration
36        * file entry.<p>
37        */
38       interface ConfigDefinition {
39           /***
40            * <p>Returns the URL of the config file.</p>
41            *
42            * @return config file
43            */
44           URL getConfigUrl();
45           /***
46            * <p>Returns the last modified date of the config file.</p>
47            *
48            * @return date last modified
49            */
50           long getLastModified();
51           /***
52            * <p>Sets the last modified date of the config file.</p>
53            *
54            * @param lastModified timestamp the file was last changed
55            */
56           void setLastModified(long lastModified);
57       }
58  
59      /***
60       * <p>Factory method that returns a {@link ComponentBean}
61       * using an identifier.
62       * </p>
63       *
64       * @param id jsfid of a config bean
65       * @return config bean
66       */
67      ComponentBean getElement(String id);
68      /***
69       * <p>Returns <code>true</code> if the <code>jsfid</code> can be
70       * used by the <code>getElement(jsfid)</code> to return a
71       * {@link ComponentBean}.</p>
72       *
73       * @param id jsfid of a config bean
74       * @return <code>true</code> if the config bean is handled here
75       */
76      boolean validMoniker(String id);
77      /***
78       * <p>A ordering weight used by the {@link ConfigBeanFactory}
79       * for determining the ConfigBean that will return a {@link ComponentBean}
80       * for a <code>jsfid</code>.
81       * </p>
82       *
83       * @return ordinal value representing the handlers precedence
84       */
85      int getWeight();
86      /***
87       * <p>Initialization method passing the <code>ServletContext</code>.</p>
88       *
89       * @param context web container servlet context
90       */
91      void init(ServletContext context);
92      /***
93       * <p>This method is invoked with the application is unloaded.  The
94       * {@link ConfigBeanFactory} will invoke this method on all
95       * registered <code>ConfigBean</code>.  This sequence will be started
96       * by the {@link org.apache.shale.clay.config.ClayConfigureListener}
97       * </p>
98       */
99      void destroy();
100     /***
101      * <p>Returns an instance of the <code>ServletContext</code> set
102      * by the <code>init(ServletContext)</code> method.
103      *
104      * @return web container servlet context
105      */
106     ServletContext getServletContext();
107     /***
108      * <p>Fixes up the meta inheritance of a {@link ComponentBean}.  It
109      * assumes that <code>assignParent(ComponentBean</code> has already
110      * been called</p>
111      *
112      * @param b config bean needing inheritance resolved
113      */
114     void realizingInheritance(ComponentBean b);
115     /***
116      * <p>Sets the isA parent's for a {@link ComponentBean}.  The next
117      * step would be to call the <code>realizeInheritance(ComponentBean)</code>
118      * method.
119      * </p>
120      *
121      * @param b config bean needing heritage fixed-up
122      */
123     void assignParent(ComponentBean b);
124 
125     /***
126      * <p>This method should be called from key points in the application to invoke
127      * automatic reloading of the configuration files if they have been modified since
128      * last reloaded.  If the parameter <code>forceReload</code> is <code>true</code>,
129      * all files will be reloaded.  The return value is <code>true</code>, if the
130      * files were reloaded.</p>
131      *
132      * @param forceReload <code>true</code> if all template and config files are reloaded
133      * @return <code>true</code> if a modifed file was found
134      */
135     boolean refresh(boolean forceReload);
136 
137     /***
138      * <p>Verifies there is not a duplicate component id within a naming container.
139      * A root {@link ComponentBean} is passed as a single parameter.</p>
140      *
141      * @param b root config bean
142      */
143      void checkTree(ComponentBean b);
144 
145 
146 }