KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > tests > j2eeserver > plugin > jsr88 > EjbModuleConfigBean


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.tests.j2eeserver.plugin.jsr88;
21
22 import javax.enterprise.deploy.spi.exceptions.*;
23 import javax.enterprise.deploy.spi.*;
24 import java.beans.*;
25 import javax.enterprise.deploy.model.*;
26
27 import java.util.*;
28
29 /**
30  *
31  * @author gfink
32  */

33 public class EjbModuleConfigBean implements DConfigBeanRoot {
34
35     DDBean bean;
36     DepConfig config;
37     Collection children = new HashSet();
38     String JavaDoc SESSION = "ejb-jar/enterprise-beans/session";
39     String JavaDoc ENTITY = "ejb-jar/enterprise-beans/entity";
40
41     public EjbModuleConfigBean(DDBean bean, DepConfig config) {
42         this.bean = bean; this.config = config;
43     }
44       
45     public DConfigBean getDConfigBean(DDBean dDBean) throws ConfigurationException {
46         DConfigBean ret = null;
47         if(dDBean.getXpath().endsWith(SESSION) || dDBean.getXpath().endsWith(ENTITY))
48             ret = new EjbConfigBean(dDBean, this, config);
49         if(ret != null) children.add(ret);
50         return ret;
51     }
52     
53     public DDBean getDDBean() {
54         return bean;
55     }
56     
57     public String JavaDoc[] getXpaths() {
58         return new String JavaDoc[] { SESSION, ENTITY };
59     }
60     
61     public void notifyDDChange(XpathEvent xpathEvent) {
62     }
63     
64     public void removeDConfigBean(DConfigBean dConfigBean) throws BeanNotFoundException {
65         children.remove(dConfigBean);
66         propertyChangeSupport.firePropertyChange(dConfigBean.getClass().toString(),dConfigBean,null);
67     }
68     
69       /** Utility field used by bound properties. */
70       private PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(this);
71       
72       /** Holds value of property secure. */
73       private String JavaDoc secure;
74       
75       /** Holds value of property securityDomain. */
76       private String JavaDoc securityDomain;
77       
78       /** Holds value of property resourceManager. */
79       private ResourceManager[] resourceManager;
80       
81     public void addPropertyChangeListener(PropertyChangeListener listener) {
82         propertyChangeSupport.addPropertyChangeListener(listener);
83     }
84     
85     public void removePropertyChangeListener(PropertyChangeListener listener) {
86         propertyChangeSupport.removePropertyChangeListener(listener);
87     }
88     
89     /** Getter for property secure.
90      * @return Value of property secure.
91      */

92     public String JavaDoc getSecure() {
93         return this.secure;
94     }
95     
96     /** Setter for property secure.
97      * @param secure New value of property secure.
98      */

99     public void setSecure(String JavaDoc secure) {
100         String JavaDoc oldSecure = this.secure;
101         this.secure = secure;
102         propertyChangeSupport.firePropertyChange("secure", oldSecure, secure);
103     }
104     
105     /** Getter for property securityDomain.
106      * @return Value of property securityDomain.
107      */

108     public String JavaDoc getSecurityDomain() {
109         return this.securityDomain;
110     }
111     
112     /** Setter for property securityDomain.
113      * @param securityDomain New value of property securityDomain.
114      */

115     public void setSecurityDomain(String JavaDoc securityDomain) {
116         String JavaDoc oldSecurityDomain = this.securityDomain;
117         this.securityDomain = securityDomain;
118         propertyChangeSupport.firePropertyChange("securityDomain", oldSecurityDomain, securityDomain);
119     }
120     
121     /** Indexed getter for property resourceManager.
122      * @param index Index of the property.
123      * @return Value of the property at <CODE>index</CODE>.
124      */

125     public ResourceManager getResourceManager(int index) {
126         return this.resourceManager[index];
127     }
128     
129     /** Getter for property resourceManager.
130      * @return Value of property resourceManager.
131      */

132     public ResourceManager[] getResourceManager() {
133         return this.resourceManager;
134     }
135     
136     /** Indexed setter for property resourceManager.
137      * @param index Index of the property.
138      * @param resourceManager New value of the property at <CODE>index</CODE>.
139      */

140     public void setResourceManager(int index, ResourceManager resourceManager) {
141         this.resourceManager[index] = resourceManager;
142         propertyChangeSupport.firePropertyChange("resourceManager", null, null );
143     }
144     
145     /** Setter for property resourceManager.
146      * PENDING should be package private, but NB beaninfo editor chokes on it?
147      * @param resourceManager New value of property resourceManager.
148      */

149     public void setResourceManager(ResourceManager[] resourceManager) {
150         ResourceManager[] oldResourceManager = this.resourceManager;
151         this.resourceManager = resourceManager;
152         propertyChangeSupport.firePropertyChange("resourceManager", oldResourceManager, resourceManager);
153     }
154     
155     // PENDING use reference counts and track removes too.
156
void addResource(String JavaDoc resource) {
157         for(int i = 0; i < resourceManager.length; i++)
158             if(resourceManager[i].getResourceName().equals(resource)) return;
159         ResourceManager[] newManagers = new ResourceManager[resourceManager.length + 1];
160         for(int i = 0; i < resourceManager.length; i++)
161             newManagers[i] = resourceManager[i];
162         ResourceManager manager = new ResourceManager(resource);
163         newManagers[resourceManager.length] = manager;
164         setResourceManager(newManagers);
165     }
166     
167     public DConfigBean getDConfigBean(DDBeanRoot dDBeanRoot) {
168         return null;
169     }
170     
171 }
172
Popular Tags