KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > common > deploy > BaseResource


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 /*
25  * BaseResource.java
26  *
27  * Created on January 12, 2002, 6:35 PM
28  */

29  
30 package com.sun.enterprise.tools.common.deploy;
31
32 import java.beans.*;
33 import java.util.List JavaDoc;
34
35 public class BaseResource implements java.io.Serializable JavaDoc {
36   
37     private String JavaDoc name;
38     private String JavaDoc Description;
39     protected String JavaDoc JndiName;
40     private String JavaDoc ResType;
41 /* private String FactoryClassName;
42     private String LogLevel;
43 */
private String JavaDoc Enabled;
44     
45     transient protected PropertyChangeSupport propertySupport;
46
47     public BaseResource(List JavaDoc resources, String JavaDoc resName) {
48         propertySupport = new PropertyChangeSupport ( this );
49         JndiName = "JndiName"; // NOI18N
50
Description = ""; // NOI18N
51
ResType = "ResourceType";//NOI18N
52
// FactoryClassName = "FactoryClassName";
53
// LogLevel = "ERROR";
54
Enabled = "true"; // NOI18N
55

56         String JavaDoc t_name = null;
57         if(resources.size() != 0){
58            int num = resources.size()+1;
59            t_name = resName + "_" + num;//NOI18N
60
boolean resource_exists = FactoryName(t_name, resources);
61            while(resource_exists){
62              num++;
63              t_name = resName + "_" + num;//NOI18N
64
resource_exists = FactoryName(t_name, resources);
65            }
66         }else{
67           t_name = resName + "_1";//NOI18N
68
}
69         name = t_name;
70     }
71     
72    public boolean FactoryName(String JavaDoc value, List JavaDoc resources){
73       boolean exists = false;
74       for(int i=0; i<resources.size(); i++){
75         IResource instance = (IResource) resources.get(i);
76         String JavaDoc inst = instance.getName();
77         if(inst.equals(value))
78            exists = true;
79       }//for
80
return exists;
81     }
82    
83     public String JavaDoc getJndiName() {
84         return JndiName;
85     }
86
87     public void setJndiName(String JavaDoc value) {
88         String JavaDoc oldValue = JndiName;
89         this.JndiName = value;
90         initPropertyChangeSupport();
91         propertySupport.firePropertyChange ("JndiName", oldValue, JndiName);//NOI18N
92
setName(JndiName);
93     }
94     
95     public void simpleSetJndiName(String JavaDoc value) {
96         this.JndiName = value;
97         setName(JndiName);
98     }
99     
100     public String JavaDoc getDescription() {
101         return Description;
102     }
103
104     public void setDescription(String JavaDoc value) {
105         String JavaDoc oldValue = Description;
106         this.Description = value;
107         initPropertyChangeSupport();
108         propertySupport.firePropertyChange ("Description", oldValue, Description);//NOI18N
109
}
110     
111     public String JavaDoc getResType() {
112         return ResType;
113     }
114
115     public void setResType(String JavaDoc value) {
116         String JavaDoc oldValue = ResType;
117         this.ResType = value;
118         initPropertyChangeSupport();
119         propertySupport.firePropertyChange ("ResType", oldValue, ResType);//NOI18N
120
}
121 /*
122     public String getFactoryClassName() {
123         return FactoryClassName;
124     }
125
126     public void setFactoryClassName(String value) {
127         String oldValue = FactoryClassName;
128         this.FactoryClassName = value;
129         initPropertyChangeSupport();
130         propertySupport.firePropertyChange ("FactoryClassName", oldValue, FactoryClassName);//NOI18N
131     }
132
133     public String getLogLevel() {
134         return LogLevel;
135     }
136
137     public void setLogLevel(String value) {
138         String oldValue = LogLevel;
139         this.LogLevel = value;
140         initPropertyChangeSupport();
141         propertySupport.firePropertyChange ("LogLevel", oldValue, LogLevel);//NOI18N
142     }
143  */

144     public String JavaDoc getEnabled() {
145         return Enabled;
146     }
147
148     public void setEnabled(String JavaDoc value) {
149         String JavaDoc oldValue = Enabled;
150         this.Enabled = value;
151         initPropertyChangeSupport();
152         propertySupport.firePropertyChange ("Enabled", oldValue, Enabled);//NOI18N
153
}
154     
155     protected void initPropertyChangeSupport(){
156          if(propertySupport==null)
157          propertySupport = new PropertyChangeSupport ( this );
158
159     }
160     public void addPropertyChangeListener (PropertyChangeListener listener) {
161         initPropertyChangeSupport();
162         propertySupport.addPropertyChangeListener (listener);
163     }
164
165     public void removePropertyChangeListener (PropertyChangeListener listener) {
166         initPropertyChangeSupport();
167         propertySupport.removePropertyChangeListener (listener);
168     }
169
170     public String JavaDoc getName() {
171         return name;
172     }
173     public void setName(String JavaDoc value) {
174         String JavaDoc oldValue = name;
175         this.name = value;
176         initPropertyChangeSupport();
177         propertySupport.firePropertyChange ("name", oldValue, name);//NOI18N
178
}
179 }
180
Popular Tags