KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > websphere6 > config > ConfigurationSupportImpl


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.websphere6.config;
20
21 import java.io.File JavaDoc;
22 import javax.enterprise.deploy.model.DDBean JavaDoc;
23 import javax.enterprise.deploy.model.DeployableObject JavaDoc;
24 import javax.enterprise.deploy.shared.ModuleType JavaDoc;
25 import javax.enterprise.deploy.spi.DeploymentConfiguration JavaDoc;
26 import javax.enterprise.deploy.spi.exceptions.ConfigurationException JavaDoc;
27 import org.netbeans.modules.j2ee.deployment.common.api.OriginalCMPMapping;
28 import org.netbeans.modules.j2ee.deployment.plugins.api.ConfigurationSupport;
29
30 /**
31  * ConfigurationSupport implementation.
32  *
33  * @author dlipin
34  */

35 public class ConfigurationSupportImpl extends ConfigurationSupport {
36     public void setMappingInfo(DeploymentConfiguration JavaDoc config, OriginalCMPMapping[] mappings) {
37     }
38     
39     public void ensureResourceDefined(DeploymentConfiguration JavaDoc config, DDBean JavaDoc bean) {
40     }
41     
42     public String JavaDoc getWebContextRoot(DeploymentConfiguration JavaDoc config, DeployableObject JavaDoc deplObj)
43     throws ConfigurationException JavaDoc {
44         
45         if (config.getDeployableObject().getType() != ModuleType.WAR) {
46             throw new ConfigurationException JavaDoc("This operation is supported only by the WAR modules"); // NOI18N
47
}
48         
49         if (!(config instanceof WarDeploymentConfiguration)) {
50             throw new IllegalArgumentException JavaDoc("Wrong DeploymentConfiguration instance " + config.getClass().getName()); // NOI18N
51
}
52         return ((WarDeploymentConfiguration)config).getContextPath();
53         
54         
55     }
56     
57     public void setWebContextRoot(DeploymentConfiguration JavaDoc config, DeployableObject JavaDoc deplObj, String JavaDoc contextRoot)
58     throws ConfigurationException JavaDoc {
59         if (config.getDeployableObject().getType() != ModuleType.WAR) {
60             throw new ConfigurationException JavaDoc("This operation is supported only by the WAR modules."); // NOI18N
61
}
62         
63         if (!(config instanceof WarDeploymentConfiguration)) {
64             throw new IllegalArgumentException JavaDoc("Wrong DeploymentConfiguration instance " + config.getClass().getName()); // NOI18N
65
}
66         ((WarDeploymentConfiguration)config).setContextPath(contextRoot);
67         
68     }
69     
70     public void initConfiguration(DeploymentConfiguration JavaDoc config, File JavaDoc[] files,
71             File JavaDoc resourceDir, boolean keepUpdated) throws ConfigurationException JavaDoc {
72         
73         
74         //if (files == null || files.length != 1) {
75
// throw new IllegalArgumentException("Invalid value of the files argument."); // NOI18N
76
//}
77
if (config==null) {
78             return;
79         }
80         if (!(config instanceof WSDeploymentConfiguration)) {
81             throw new IllegalArgumentException JavaDoc("Wrong DeploymentConfiguration instance " + config.getClass().getName()); // NOI18N
82
}
83         
84         ModuleType JavaDoc type = config.getDeployableObject().getType();
85         if (type == ModuleType.WAR) {
86             ((WarDeploymentConfiguration)config).init(files);
87         } else if (type == ModuleType.EAR) {
88             ((EarDeploymentConfiguration)config).init(files);
89         } else if (type == ModuleType.EJB) {
90             ((EjbDeploymentConfiguration)config).init(files);
91         } else {
92             assert true : "Unsupported module type: " + type.toString(); // NOI18N
93
}
94     }
95     
96     public void disposeConfiguration(DeploymentConfiguration JavaDoc config) {
97         
98         if (!(config instanceof WSDeploymentConfiguration)) {
99             throw new IllegalArgumentException JavaDoc("Wrong DeploymentConfiguration instance " + config.getClass().getName()); // NOI18N
100
}
101         
102     }
103     
104     public void updateResourceDir(DeploymentConfiguration JavaDoc config, File JavaDoc resourceDir) {
105         // no op
106
}
107 }
108
109
Popular Tags