KickJava   Java API By Example, From Geeks To Geeks.

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

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