KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > sun > ide > controllers > ConnectorModuleController


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 package org.netbeans.modules.j2ee.sun.ide.controllers;
20
21 import java.util.List JavaDoc;
22 import com.sun.appserv.management.client.AppserverConnectionSource;
23 import com.sun.appserv.management.config.Enabled;
24 import com.sun.appserv.management.j2ee.J2EEDeployedObject;
25 import com.sun.appserv.management.j2ee.ResourceAdapterModule;
26 import com.sun.appserv.management.j2ee.ResourceAdapter;
27 import com.sun.appserv.management.config.RARModuleConfig;
28 import javax.enterprise.deploy.spi.DeploymentManager JavaDoc;
29 import org.netbeans.modules.j2ee.sun.bridge.apis.AppserverMgmtControllerBase;
30
31 import org.netbeans.modules.j2ee.sun.util.NodeTypes;
32
33
34 /**
35  * Used as a conduit between the Netbeans API's and the AMX MBean API
36  * data model. This API contains convenient methods for retrieving
37  * components allowing the netbeans module heirarchy remain agnostic to the
38  * underlying data model.
39  *
40  * This controller is used to navigate through deployed EJB modules.
41  */

42 public class ConnectorModuleController extends AppserverMgmtControllerBase
43         implements DeployedItemsController, EnablerController {
44     
45     private ResourceAdapterModule connectorModule;
46     private RARModuleConfig connectorConfig;
47     
48     /**
49      * Create an instance of J2EEServerMgmtController used in the interaction
50      * with AMX API for Sun Java System Application Server.
51      *
52      * @param server The AMX J2EEServer object representing a particular server.
53      */

54     public ConnectorModuleController(ResourceAdapterModule connectorModule,
55             AppserverConnectionSource connection) {
56         super(connectorModule, connection);
57         this.connectorModule = connectorModule;
58     }
59     
60     
61     /**
62      * Create an instance of J2EEServerMgmtController used in the interaction
63      * with AMX API for Sun Java System Application Server.
64      *
65      * @param server The AMX J2EEServer object representing a particular server.
66      */

67     public ConnectorModuleController(
68             final ResourceAdapterModule connectorModule,
69             final DeploymentManager JavaDoc dplmtMgr,
70             final AppserverConnectionSource connection) {
71         super(connectorModule, dplmtMgr, connection);
72         this.connectorModule = connectorModule;
73     }
74
75     public ConnectorModuleController(
76             final ResourceAdapterModule connectorModule,
77             final RARModuleConfig connectorConfig,
78             final DeploymentManager JavaDoc dplmtMgr,
79             final AppserverConnectionSource connection) {
80         super(connectorConfig, dplmtMgr, connection);
81         this.connectorModule = connectorModule;
82         this.connectorConfig = connectorConfig;
83     }
84     
85     /**
86      * Returns the properties of the application given the name.
87      *
88      * @param propsToIgnore String properties to ignore.
89      * @return All the application properties.
90      */

91     public java.util.Map JavaDoc getProperties(List JavaDoc propsToIgnore) {
92         return getJ2EEAndConfigProperties(NodeTypes.CONNECTOR_MODULE,
93             connectorModule, connectorConfig, propsToIgnore);
94     }
95     
96     
97     /**
98      * Sets the properties.
99      *
100      * @param attrname The name of the attribute.
101      * @param value The value of the attribute to set.
102      *
103      * @return updated Attribute
104      */

105     public javax.management.Attribute JavaDoc setProperty(final String JavaDoc attrName, final Object JavaDoc value) {
106         
107         testIfServerInDebug();
108         
109         return ControllerUtil.setAttributeValue(connectorModule, connectorConfig, attrName, value,
110             getMBeanServerConnection());
111     }
112     
113     /**
114      *
115      *
116      */

117     public String JavaDoc[] getResourceAdaptors() {
118         
119         testIfServerInDebug();
120         
121         return ControllerUtil.getComponentNamesFromMap(
122             connectorModule.getContaineeMap(
123                 NodeTypes.getAMXJ2EETypeByNodeType(NodeTypes.RESOURCE_ADAPTER)));
124     }
125     
126     
127     /**
128      *
129      */

130     public java.util.Map JavaDoc getResourceAdapterProperties(
131             final String JavaDoc resAdapterName, final List JavaDoc propsToIgnore) {
132         return getJ2EEAndConfigProperties(NodeTypes.RESOURCE_ADAPTER,
133             getResourceAdapterByName(resAdapterName), connectorConfig, propsToIgnore);
134     }
135     
136     
137     /**
138      *
139      */

140     public javax.management.Attribute JavaDoc setResourceAdapterProperty(
141             final String JavaDoc resAdapterName, final String JavaDoc attrName,
142             final Object JavaDoc value) {
143         
144         testIfServerInDebug();
145         
146         return ControllerUtil.setAttributeValue(
147             getResourceAdapterByName(resAdapterName), attrName, value,
148                 getMBeanServerConnection());
149     }
150     
151     
152     /**
153      *
154      *
155      */

156     public ResourceAdapter getResourceAdapterByName(final String JavaDoc name) {
157         
158         testIfServerInDebug();
159         
160         return (ResourceAdapter) connectorModule.getContainee(
161             NodeTypes.getAMXJ2EETypeByNodeType(
162                 NodeTypes.RESOURCE_ADAPTER), name);
163     }
164     
165     
166     /**
167      *
168      *
169      *
170      */

171     public boolean isEnabled() {
172         testIfServerInDebug();
173         boolean configEnabled = ((Enabled)connectorConfig).getEnabled();
174         return ControllerUtil.calculateIsEnabled(connectorConfig, configEnabled);
175     }
176     
177     
178     /**
179      *
180      *
181      *
182      */

183     public void setEnabled(boolean enabled) {
184         testIfServerInDebug();
185         ControllerUtil.getDeployedItemRefConfig(connectorConfig).setEnabled(enabled);
186     }
187     
188     public J2EEDeployedObject getJ2EEObject() {
189         return connectorModule;
190     }
191     
192 }
193
Popular Tags