KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > jmx > examples > scandir > DirectoryScannerMXBean


1 /*
2  * DirectoryScannerMXBean.java
3  *
4  * Created on July 10, 2006, 4:20 PM
5  *
6  * @(#)DirectoryScannerMXBean.java 1.2 06/08/02
7  *
8  * Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions are met:
12  *
13  * -Redistribution of source code must retain the above copyright notice, this
14  * list of conditions and the following disclaimer.
15  *
16  * -Redistribution in binary form must reproduce the above copyright notice,
17  * this list of conditions and the following disclaimer in the documentation
18  * and/or other materials provided with the distribution.
19  *
20  * Neither the name of Sun Microsystems, Inc. or the names of contributors may
21  * be used to endorse or promote products derived from this software without
22  * specific prior written permission.
23  *
24  * This software is provided "AS IS," without a warranty of any kind. ALL
25  * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
26  * ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
27  * OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN")
28  * AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE
29  * AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
30  * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
31  * REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
32  * INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY
33  * OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE,
34  * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
35  *
36  * You acknowledge that this software is not designed, licensed or intended
37  * for use in the design, construction, operation or maintenance of any
38  * nuclear facility.
39  */

40
41 package com.sun.jmx.examples.scandir;
42
43 import com.sun.jmx.examples.scandir.ScanManagerMXBean.ScanState;
44 import com.sun.jmx.examples.scandir.config.DirectoryScannerConfig;
45 import java.io.IOException JavaDoc;
46 import javax.management.InstanceNotFoundException JavaDoc;
47
48 /**
49  * A <code>DirectoryScannerMXBean</code> is an MBean that
50  * scans a file system starting at a given root directory,
51  * and then looks for files that match a given criteria.
52  * <p>
53  * When such a file is found, the <code>DirectoryScannerMXBean</code> takes
54  * the actions for which it was configured: see {@link #scan scan()}.
55  * <p>
56  * <code>DirectoryScannerMXBeans</code> are created, initialized, and
57  * registered by the {@link ScanManagerMXBean}.
58  * The {@link ScanManagerMXBean} will also schedule and run them in
59  * background by calling their {@link #scan} method.
60  * </p>
61  * @author Sun Microsystems, 2006 - All rights reserved.
62  */

63 public interface DirectoryScannerMXBean {
64     /**
65      * Get The {@link DirectoryScanner} state.
66      * @return the current state of the <code>DirectoryScanner</code>.
67      * @throws IOException A connection problem occurred when accessing
68      * the underlying resource.
69      * @throws InstanceNotFoundException The underlying MBean is not
70      * registered in the MBeanServer.
71      **/

72     public ScanState getState()
73         throws IOException JavaDoc, InstanceNotFoundException JavaDoc;
74    
75     /**
76      * Stops the current scan if {@link ScanState#RUNNING running}.
77      * After this method completes the state of the application will
78      * be {@link ScanState#STOPPED STOPPED}.
79      * @throws IOException A connection problem occurred when accessing
80      * the underlying resource.
81      * @throws InstanceNotFoundException The underlying MBean is not
82      * registered in the MBeanServer.
83      **/

84     public void stop()
85         throws IOException JavaDoc, InstanceNotFoundException JavaDoc;
86     
87     /**
88      * Scans the file system starting at the specified {@link #getRootDirectory
89      * root directory}.
90      * <p>If a file that matches this <code>DirectoryScannerMXBean</code>
91      * {@link #getConfiguration} criteria is found,
92      * the <code>DirectoryScannerMXBean</code> takes the {@link
93      * DirectoryScannerConfig#getActions() actions} for which
94      * it was {@link #getConfiguration configured}: emit a notification,
95      * <i>and or</i> log a {@link
96      * com.sun.jmx.examples.scandir.config.ResultRecord} for this file,
97      * <i>and or</i> delete that file.
98      * </p>
99      * <p>
100      * The code that would actually delete the file is commented out - so that
101      * nothing valuable is lost if this example is run by mistake on the wrong
102      * set of directories.
103      * </p>
104      * <p>This method returns only when the directory scan is completed, or
105      * if it was {@link #stop stopped} by another thread.
106      * </p>
107      * @throws IllegalStateException if already {@link ScanState#RUNNING}
108      * @throws IOException A connection problem occurred when accessing
109      * the underlying resource.
110      * @throws InstanceNotFoundException The underlying MBean is not
111      * registered in the MBeanServer.
112      **/

113     public void scan()
114         throws IOException JavaDoc, InstanceNotFoundException JavaDoc;
115     
116     /**
117      * Gets the root directory at which this <code>DirectoryScannerMXBean</code>
118      * will start scanning the file system.
119      * <p>
120      * This is a shortcut to {@link #getConfiguration
121      * getConfiguration()}.{@link
122      * DirectoryScannerConfig#getRootDirectory
123      * getRootDirectory()}.
124      * </p>
125      * @return This <code>DirectoryScannerMXBean</code> root directory.
126      * @throws IOException A connection problem occurred when accessing
127      * the underlying resource.
128      * @throws InstanceNotFoundException The underlying MBean is not
129      * registered in the MBeanServer.
130      **/

131     public String JavaDoc getRootDirectory()
132         throws IOException JavaDoc, InstanceNotFoundException JavaDoc;
133
134     /**
135      * The configuration data from which this {@link DirectoryScanner} was
136      * created.
137      * <p>
138      * You cannot change this configuration here. You can however
139      * {@link ScanDirConfigMXBean#setConfiguration modify} the
140      * {@link ScanDirConfigMXBean} configuration, and ask the
141      * {@link ScanManagerMXBean} to {@link ScanManagerMXBean#applyConfiguration
142      * apply} it. This will get all <code>DirectoryScannerMXBean</code>
143      * replaced by new MBeans created from the modified configuration.
144      * </p>
145      *
146      * @return This <code>DirectoryScannerMXBean</code> configuration data.
147      * @throws IOException A connection problem occurred when accessing
148      * the underlying resource.
149      * @throws InstanceNotFoundException The underlying MBean is not
150      * registered in the MBeanServer.
151      **/

152     public DirectoryScannerConfig getConfiguration()
153         throws IOException JavaDoc, InstanceNotFoundException JavaDoc;
154     
155     /**
156      * A short string describing what's happening in current/latest scan.
157      * @return a short info string.
158      * @throws IOException A connection problem occurred when accessing
159      * the underlying resource.
160      * @throws InstanceNotFoundException The underlying MBean is not
161      * registered in the MBeanServer.
162      **/

163     public String JavaDoc getCurrentScanInfo()
164         throws IOException JavaDoc, InstanceNotFoundException JavaDoc;
165 }
166
167
168
Popular Tags