7373public class BSHLogListener implements org .jpos .util .LogListener , org .jpos .core .Configurable {
7474 /**Holds the configuration for this object*/
7575 protected Configuration cfg ;
76+ /** Pattern names used for script filename matching. */
7677 protected static final String [] patterns = {"tag" , "realm" };
78+ /** Cache of loaded BeanShell scripts keyed by filename. */
7779 protected Map <String , ScriptInfo > scripts = new HashMap <>();
7880 /** Creates a new instance of BSHLogListener */
7981 public BSHLogListener () {
@@ -83,6 +85,11 @@ public BSHLogListener() {
8385 public void setConfiguration (org .jpos .core .Configuration cfg ) {
8486 this .cfg = cfg ;
8587 }
88+ /** @param src source strings
89+ * @param patterns patterns to replace
90+ * @param to replacement strings
91+ * @return result array with patterns replaced
92+ */
8693 protected static String [] replace (String [] src , String [] patterns , String [] to ){
8794 String [] ret = new String [src .length ];
8895 for (int i =0 ; i <src .length ; i ++){
@@ -166,6 +173,10 @@ public LogEvent log(LogEvent ev) {
166173 return ret ;
167174 }
168175 }
176+ /** @param f script file to load
177+ * @return file contents as a string
178+ * @throws IOException on read failure
179+ */
169180 protected String loadCode (File f ) throws IOException {
170181 StringBuilder buf = new StringBuilder ((int )f .length ());
171182 char [] content = new char [(int )f .length ()];
@@ -179,27 +190,40 @@ protected String loadCode(File f) throws IOException{
179190 return buf .toString ();
180191 }
181192
193+ /** @param filename the script filename key
194+ * @return cached ScriptInfo or null
195+ */
182196 protected ScriptInfo getScriptInfo (String filename ){
183197 Objects .requireNonNull (filename , "The script file name cannot be null" );
184198 return scripts .get (filename );
185199 }
186200
201+ /** @param filename the script filename key
202+ * @param code the script source code
203+ * @param lastModified last-modified timestamp
204+ */
187205 protected void addScriptInfo (String filename , String code , long lastModified ){
188206 Objects .requireNonNull (filename , "The script file name cannot be null" );
189207 scripts .put (filename , new ScriptInfo (code , lastModified ));
190208 }
209+ /** Holds a cached BeanShell script and its namespace. */
191210 protected static class ScriptInfo {
192211 String code ;
193212 long lastModified ;
194213 long lastCheck ;
195214 NameSpace nameSpace ;
196215
216+ /** Default constructor creating an empty ScriptInfo. */
197217 public ScriptInfo (){
198218 }
219+ /** @param ns the BeanShell namespace to use */
199220 public ScriptInfo (NameSpace ns ){
200221 nameSpace = ns ;
201222 }
202223
224+ /** @param code the script source code
225+ * @param lastModified last-modified timestamp of the script file
226+ */
203227 public ScriptInfo (String code , long lastModified ){
204228 setCode (code );
205229 setLastModified (lastModified );
0 commit comments