KickJava   Java API By Example, From Geeks To Geeks.

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

43 public class ConfigurationSupportImpl extends ConfigurationSupport {
44
45     public void setMappingInfo(DeploymentConfiguration JavaDoc config, OriginalCMPMapping[] mappings) {
46     }
47
48     public void ensureResourceDefined(DeploymentConfiguration JavaDoc config, DDBean JavaDoc bean) {
49     }
50
51     public String JavaDoc getWebContextRoot(DeploymentConfiguration JavaDoc config, DeployableObject JavaDoc deplObj)
52     throws ConfigurationException JavaDoc {
53         if (config.getDeployableObject().getType() != ModuleType.WAR) {
54             throw new ConfigurationException JavaDoc("This operation is supported only by the WAR modules"); // NOI18N
55
}
56         if (!(config instanceof WarDeploymentConfiguration)) {
57             throw new IllegalArgumentException JavaDoc("Wrong DeploymentConfiguration instance " + config.getClass().getName()); // NOI18N
58
}
59         return ((WarDeploymentConfiguration)config).getContextPath();
60     }
61
62     public void setWebContextRoot(DeploymentConfiguration JavaDoc config, DeployableObject JavaDoc deplObj, String JavaDoc contextRoot)
63     throws ConfigurationException JavaDoc {
64         if (config.getDeployableObject().getType() != ModuleType.WAR) {
65             throw new ConfigurationException JavaDoc("This operation is supported only by the WAR modules."); // NOI18N
66
}
67         if (!(config instanceof WarDeploymentConfiguration)) {
68             throw new IllegalArgumentException JavaDoc("Wrong DeploymentConfiguration instance " + config.getClass().getName()); // NOI18N
69
}
70         ((WarDeploymentConfiguration)config).setContextPath(contextRoot);
71     }
72     
73     public void initConfiguration(DeploymentConfiguration JavaDoc config, File JavaDoc[] files,
74             File JavaDoc resourceDir, boolean keepUpdated) throws ConfigurationException JavaDoc {
75         if (!(config instanceof JBDeploymentConfiguration)) {
76             throw new IllegalArgumentException JavaDoc("Wrong DeploymentConfiguration instance " + config.getClass().getName()); // NOI18N
77
}
78         if (files == null || files.length != 1) {
79             throw new IllegalArgumentException JavaDoc("Invalid value of the files argument."); // NOI18N
80
}
81         ModuleType JavaDoc type = config.getDeployableObject().getType();
82         if (type == ModuleType.WAR) {
83             ((WarDeploymentConfiguration)config).init(files[0], resourceDir);
84         } else if (type == ModuleType.EAR) {
85             ((EarDeploymentConfiguration)config).init(files[0]);
86         } else if (type == ModuleType.EJB) {
87             ((EjbDeploymentConfiguration)config).init(files[0], resourceDir);
88         } else if (type == ModuleType.CAR) {
89             ((CarDeploymentConfiguration)config).init(files[0], resourceDir);
90         } else {
91             assert true : "Unsupported module type: " + type.toString(); // NOI18N
92
}
93     }
94     
95     public void disposeConfiguration(DeploymentConfiguration JavaDoc config) {
96         if (!(config instanceof JBDeploymentConfiguration)) {
97             throw new IllegalArgumentException JavaDoc("Wrong DeploymentConfiguration instance " + config.getClass().getName()); // NOI18N
98
}
99     }
100     
101     public void updateResourceDir(DeploymentConfiguration JavaDoc config, File JavaDoc resourceDir) {
102         // no op
103
}
104     
105     public Set JavaDoc<Datasource> getDatasources(DeploymentConfiguration JavaDoc config) {
106         Set JavaDoc<Datasource> projectDS = ((JBDeploymentConfiguration)config).getDatasources();
107         return projectDS;
108     }
109     
110     public boolean isDatasourceCreationSupported() {
111         return true;
112     }
113     
114     public Datasource createDatasource(DeploymentConfiguration JavaDoc config, String JavaDoc jndiName, String JavaDoc url, String JavaDoc username, String JavaDoc password, String JavaDoc driver)
115     throws OperationUnsupportedException JavaDoc, ConfigurationException JavaDoc, DatasourceAlreadyExistsException
116     {
117         JBossDatasource ds = ((JBDeploymentConfiguration)config).createDatasource(jndiName, url, username, password, driver);
118         return ds;
119     }
120     
121 }
122
Popular Tags