41 package com.sun.jmx.examples.scandir;
50 import java.io.IOException;
51 import java.io.InputStream;
52 import java.io.OutputStream;
53 import java.util.Date;
54 import java.util.logging.Level;
55 import java.util.logging.Logger;
56 import javax.management.*;
57 import javax.xml.bind.JAXBException;
109 private static final Logger
LOG =
149 new MBeanNotificationInfo(
151 Notification.class.getName(),
152 "Emitted when the configuration is saved"),
153 new MBeanNotificationInfo(
155 Notification.class.getName(),
156 "Emitted when the configuration is loaded"),
157 new MBeanNotificationInfo(
159 Notification.class.getName(),
160 "Emitted when the configuration is modified"),
214 this.config = initialConfig;
219 public void load() throws IOException {
221 throw new UnsupportedOperationException(
"load");
234 public void save() throws IOException {
236 throw new UnsupportedOperationException(
"load");
237 synchronized (
this) {
246 synchronized (
this) {
255 final Notification n =
new Notification(type,source,
257 "The configuration is "+
258 type.substring(type.lastIndexOf(
'.')+1));
288 public ObjectName
preRegister(MBeanServer server, ObjectName name)
291 if (
config ==
null)
return null;
298 synchronized (
this) {
346 synchronized (
this) {
364 long sizeExceedsMaxBytes,
long sinceLastModified) {
367 scanner.setRootDirectory(dir);
368 if (filePattern!=
null||sizeExceedsMaxBytes>0||sinceLastModified>0) {
372 if (sinceLastModified > 0)
374 -sinceLastModified));
375 scanner.addIncludeFiles(filter);
377 synchronized (
this) {
388 throws IOException, InstanceNotFoundException {
390 synchronized (
this) {
393 throw new IllegalArgumentException(name+
": scanner not found");
408 static String DEFAULT =
"DEFAULT";
411 final int dot = name.indexOf(
'.');
412 if (dot<0)
return name;
414 return name.substring(0,dot);
417 static String guessConfigName(String configFileName,String defaultFile) {
419 if (configFileName ==
null)
return DEFAULT;
420 final File f =
new File(configFileName);
423 if (confname !=
null && confname.length()>0)
return confname;
425 final File f2 =
new File(defaultFile);
426 if (f.equals(f2))
return DEFAULT;
428 if (guess ==
null)
return DEFAULT;
429 if (guess.length()==0)
return DEFAULT;
431 }
catch (Exception x) {