KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > modeler > modules > ModelerSource


1 package org.apache.commons.modeler.modules;
2
3 import java.io.File JavaDoc;
4 import java.io.FileInputStream JavaDoc;
5 import java.io.IOException JavaDoc;
6 import java.io.InputStream JavaDoc;
7 import java.net.URL JavaDoc;
8 import java.util.List JavaDoc;
9
10 import javax.management.ObjectName JavaDoc;
11
12 import org.apache.commons.modeler.Registry;
13
14 /** Source for descriptor data. More sources can be added.
15  *
16  */

17 public class ModelerSource {
18     protected Object JavaDoc source;
19     protected String JavaDoc location;
20
21     /** Load data, returns a list of items.
22      *
23      * @param registry
24      * @param location
25      * @param type
26      * @param source Introspected object or some other source
27      * @throws Exception
28      */

29     public List JavaDoc loadDescriptors( Registry registry, String JavaDoc location,
30                                  String JavaDoc type, Object JavaDoc source)
31             throws Exception JavaDoc
32     {
33         // TODO
34
return null;
35     }
36     
37     /** Callback from the BaseMBean to notify that an attribute has changed.
38      * Can be used to implement persistence.
39      *
40      * @param oname
41      * @param name
42      * @param value
43      */

44     public void updateField( ObjectName JavaDoc oname, String JavaDoc name,
45                              Object JavaDoc value ) {
46         // nothing by default
47
}
48
49     public void store() {
50         // nothing
51
}
52
53     protected InputStream JavaDoc getInputStream() throws IOException JavaDoc {
54         if( source instanceof URL JavaDoc ) {
55             URL JavaDoc url=(URL JavaDoc)source;
56             location=url.toString();
57             return url.openStream();
58         } else if( source instanceof File JavaDoc ) {
59             location=((File JavaDoc)source).getAbsolutePath();
60             return new FileInputStream JavaDoc((File JavaDoc)source);
61         } else if( source instanceof String JavaDoc) {
62             location=(String JavaDoc)source;
63             return new FileInputStream JavaDoc((String JavaDoc)source);
64         } else if( source instanceof InputStream JavaDoc ) {
65             return (InputStream JavaDoc)source;
66         }
67         return null;
68     }
69
70 }
71
Popular Tags