KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > dd > api > common > CommonDDBean


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.j2ee.dd.api.common;
21 /**
22  * Parent of all DD API interfaces.
23  *
24  *<p><b><font color="red"><em>Important note: Do not provide an implementation of this interface unless you are a DD API provider!</em></font></b>
25  *</p>
26  *
27  * @author Milan Kuchtiak
28  */

29 public interface CommonDDBean {
30     /**
31      * Adds property change listener to particular CommonDDBean object (WebApp object).
32      * @param pcl property change listener
33      */

34     public void addPropertyChangeListener(java.beans.PropertyChangeListener JavaDoc pcl);
35     /**
36      * Removes property change listener from CommonDDBean object.
37      * @param pcl property change listener
38      */

39     public void removePropertyChangeListener(java.beans.PropertyChangeListener JavaDoc pcl);
40     /**
41      * Sets the id attribute for related dd element. E.g.<pre>
42 &lt;servlet id="xyz"&gt;
43   ...
44 &lt;/servlet&gt;
45      *</pre>
46      *
47      * @param value the value for id attribute
48      */

49     public void setId(java.lang.String JavaDoc value);
50     /**
51      * Returns the id attribute for related dd element.<br>In most cases the id attribute is not specified.
52      * @return value of id attribute or null if not specified
53      */

54     public java.lang.String JavaDoc getId();
55     /**
56      * Returns the clonned CommonDDBean object.
57      * @return the clonned (not bound to bean graph) CommonDDBean object
58      */

59     public Object JavaDoc clone();
60     /**
61      * Returns the CommonDDBean object or array of CommonDDBean object for given property.<br>
62      * E.g. for retrieving the servlet-class value on Servlet object he <b>getValue("ServletClass");</b> can be used.
63      * @param propertyName name of the property the value is looking for
64      * @return the bean/array of beans related to given property
65      */

66     public Object JavaDoc getValue(String JavaDoc propertyName);
67     /**
68      * Writes the whole DD or its fraction (element related to CommonDDBean) to output stream.<br>
69      * For DD root object there is more convenient to use the {@link org.netbeans.modules.j2ee.dd.api.common.RootInterface#write} method.<br>
70      * The correct usage with file objects is :<pre>
71 WebApp ejb;
72 FileObject fo;
73 ...
74 // code that initializes and modifies the ejb object
75 ...
76 FileLock lock;
77 try {
78     lock=fo.lock();
79 } catch (FileAlreadyLockedException e) {
80     // handling the exception
81 }
82 if (lock!=null) {
83     try {
84         OutputStream os=fo.getOutputStream(lock);
85         try {
86             ejb.write(os);
87         } finally {
88             os.close();
89         }
90     } finally {
91         lock.releaseLock();
92     }
93 }
94 ...
95      *</pre>
96      * @param os output stream for writing
97      */

98     public void write(java.io.OutputStream JavaDoc os) throws java.io.IOException JavaDoc;
99
100 }
101
Popular Tags