KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > sun > ws7 > j2ee > WS70ConfigurationSupportImpl


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 /*
21  * WS70ConfigurationSupportImpl.java
22  * Reused from Appserver 81
23  */

24
25 package org.netbeans.modules.j2ee.sun.ws7.j2ee;
26
27 import java.io.File JavaDoc;
28
29 import javax.enterprise.deploy.model.DDBean JavaDoc;
30 import javax.enterprise.deploy.model.DeployableObject JavaDoc;
31 import javax.enterprise.deploy.spi.DeploymentConfiguration JavaDoc;
32 import javax.enterprise.deploy.spi.exceptions.ConfigurationException JavaDoc;
33
34 import org.netbeans.modules.j2ee.deployment.common.api.OriginalCMPMapping;
35 import org.netbeans.modules.j2ee.deployment.plugins.api.ConfigurationSupport;
36
37 import org.netbeans.modules.j2ee.sun.share.configbean.EjbJarRoot;
38 import org.netbeans.modules.j2ee.sun.share.configbean.SunONEDeploymentConfiguration;
39
40
41 /** Implementation of ConfigurationSupport.
42  *
43  * Primarily serves to delegate directly to the specified DeploymentConfiguration
44  * instance, as that is in shared code and has appropriate access and this instance
45  * is not.
46  * Reused from Sun Java System Appserver 81 plugin
47  */

48 public class WS70ConfigurationSupportImpl extends ConfigurationSupport {
49
50     /** Creates a new instance of ConfigurationSupport */
51     public WS70ConfigurationSupportImpl() {
52     }
53
54     
55     /** Called by j2eeserver to initialize the deployment configuration object
56      * for this J2EE project.
57      */

58     public void initConfiguration(DeploymentConfiguration JavaDoc config, File JavaDoc[] files, File JavaDoc resourceDir, boolean keepUpdated) throws ConfigurationException JavaDoc {
59         checkConfiguration(config);
60         if(files == null || files.length == 0) {
61             throw new IllegalArgumentException JavaDoc("Invalid value of the files argument.");
62         }
63         ((SunONEDeploymentConfiguration)config).init(files, resourceDir, keepUpdated);
64     }
65
66     
67     /** Called by j2eeserver to allow us to cleanup the deployment configuration object
68      * for this J2EE project.
69      */

70     public void disposeConfiguration(DeploymentConfiguration JavaDoc config) {
71         checkConfiguration(config);
72         ((SunONEDeploymentConfiguration)config).dispose();
73     }
74
75     
76     /** Called through j2eeserver when a new resource may need to be added to the
77      * user's project.
78      */

79     public void ensureResourceDefined(DeploymentConfiguration JavaDoc config, DDBean JavaDoc ddBean) {
80         checkConfiguration(config);
81         if(ddBean == null) {
82             throw new IllegalArgumentException JavaDoc("DDBean parameter cannot be null.");
83         }
84         ((SunONEDeploymentConfiguration)config).ensureResourceDefined(ddBean);
85     }
86
87     
88     /** Conduit to pass the cmp mapping information directly to the configuration
89      * backend.
90      */

91     public void setMappingInfo(DeploymentConfiguration JavaDoc config, OriginalCMPMapping[] mapping){
92         checkConfiguration(config);
93         SunONEDeploymentConfiguration s1config = (SunONEDeploymentConfiguration) config;
94         EjbJarRoot ejbJarRoot = s1config.getEjbJarRoot();
95         if(ejbJarRoot != null) {
96             ejbJarRoot.mapCmpBeans(mapping);
97         }
98     }
99
100
101     /** Retrieves the context root field from sun-web.xml for this module, if the module is a
102      * web application. Otherwise, returns null.
103      */

104     public String JavaDoc getWebContextRoot(DeploymentConfiguration JavaDoc config, DeployableObject JavaDoc deplObj) throws ConfigurationException JavaDoc {
105         checkConfiguration(config);
106         assert config.getDeployableObject() == deplObj;
107         return ((SunONEDeploymentConfiguration)config).getContextRoot();
108     }
109
110     
111     /** Sets the context root field in sun-web.xml for this module, if the module is a
112      * web application.
113      */

114     public void setWebContextRoot(DeploymentConfiguration JavaDoc config, DeployableObject JavaDoc deplObj, String JavaDoc contextRoot) throws ConfigurationException JavaDoc {
115         checkConfiguration(config);
116         assert config.getDeployableObject() == deplObj;
117         ((SunONEDeploymentConfiguration)config).setContextRoot(contextRoot);
118     }
119     
120     
121     /** Updates the resource dir in use by this project.
122      */

123     public void updateResourceDir(DeploymentConfiguration JavaDoc config, File JavaDoc resourceDir) {
124         checkConfiguration(config);
125         ((SunONEDeploymentConfiguration) config).updateResourceDir(resourceDir);
126     }
127     
128     /** Utility method to validate the configuration object being passed to the
129      * other methods in this class.
130      */

131     private void checkConfiguration(DeploymentConfiguration JavaDoc config) {
132         if(config == null) {
133             throw new IllegalArgumentException JavaDoc("DeploymentConfiguration is null");
134         }
135         if(!(config instanceof SunONEDeploymentConfiguration)) {
136             throw new IllegalArgumentException JavaDoc("Wrong DeploymentConfiguration instance " + config.getClass().getName());
137         }
138     }
139 }
140
141
Popular Tags