KickJava   Java API By Example, From Geeks To Geeks.

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


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.config.Enabled;
23 import com.sun.appserv.management.client.AppserverConnectionSource;
24 import com.sun.appserv.management.config.AppClientModuleConfig;
25 import com.sun.appserv.management.config.DeployedItemRefConfig;
26 import com.sun.appserv.management.j2ee.AppClientModule;
27
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 app client modules.
41  */

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

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

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

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

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

117     public boolean isEnabled() {
118         testIfServerInDebug();
119         boolean configEnabled = ((Enabled)appClientModuleConfig).getEnabled();
120         return ControllerUtil.calculateIsEnabled(appClientModuleConfig, configEnabled);
121     }
122     
123     
124     /**
125      *
126      *
127      *
128      */

129     public void setEnabled(boolean enabled) {
130         testIfServerInDebug();
131         DeployedItemRefConfig config = ControllerUtil.getDeployedItemRefConfig(appClientModuleConfig);
132         if(config != null)
133             config.setEnabled(enabled);
134     }
135
136 }
137
Popular Tags