KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > tomcat5 > 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.tomcat5.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.spi.DeploymentConfiguration JavaDoc;
27 import javax.enterprise.deploy.spi.exceptions.ConfigurationException JavaDoc;
28 import javax.enterprise.deploy.spi.exceptions.OperationUnsupportedException JavaDoc;
29 import org.netbeans.modules.j2ee.deployment.common.api.Datasource;
30 import org.netbeans.modules.j2ee.deployment.common.api.DatasourceAlreadyExistsException;
31 import org.netbeans.modules.j2ee.deployment.common.api.OriginalCMPMapping;
32 import org.netbeans.modules.j2ee.deployment.plugins.api.ConfigurationSupport;
33 import org.netbeans.modules.tomcat5.config.WebappConfiguration;
34
35
36 /**
37  * ConfigurationSupport implementation.
38  *
39  * @author sherold
40  */

41 public class ConfigurationSupportImpl extends ConfigurationSupport {
42
43     public void setMappingInfo(DeploymentConfiguration JavaDoc config, OriginalCMPMapping[] mappings) {
44     }
45
46     public void ensureResourceDefined(DeploymentConfiguration JavaDoc config, DDBean JavaDoc bean) {
47     }
48
49     public String JavaDoc getWebContextRoot(DeploymentConfiguration JavaDoc config, DeployableObject JavaDoc deplObj)
50     throws ConfigurationException JavaDoc {
51         if (!(config instanceof WebappConfiguration)) {
52             throw new IllegalArgumentException JavaDoc("Wrong DeploymentConfiguration instance " + config.getClass().getName()); // NOI18N
53
}
54         return ((WebappConfiguration)config).getContextPath();
55     }
56
57     public void setWebContextRoot(DeploymentConfiguration JavaDoc config, DeployableObject JavaDoc deplObj, String JavaDoc contextRoot)
58     throws ConfigurationException JavaDoc {
59         if (!(config instanceof WebappConfiguration)) {
60             throw new IllegalArgumentException JavaDoc("Wrong DeploymentConfiguration instance " + config.getClass().getName()); // NOI18N
61
}
62         ((WebappConfiguration)config).setContextPath(contextRoot);
63     }
64     
65     public void initConfiguration(DeploymentConfiguration JavaDoc config, File JavaDoc[] files,
66             File JavaDoc resourceDir, boolean keepUpdated) throws ConfigurationException JavaDoc {
67         if (!(config instanceof WebappConfiguration)) {
68             throw new IllegalArgumentException JavaDoc("Wrong DeploymentConfiguration instance " + config.getClass().getName()); // NOI18N
69
}
70         if (files == null || files.length != 1) {
71             throw new IllegalArgumentException JavaDoc("Invalid value of the files argument."); // NOI18N
72
}
73         ((WebappConfiguration)config).init(files[0]);
74     }
75     
76     public void disposeConfiguration(DeploymentConfiguration JavaDoc config) {
77         if (!(config instanceof WebappConfiguration)) {
78             throw new IllegalArgumentException JavaDoc("Wrong DeploymentConfiguration instance " + config.getClass().getName()); // NOI18N
79
}
80     }
81     
82     public void updateResourceDir(DeploymentConfiguration JavaDoc config, File JavaDoc resourceDir) {
83         // no op
84
}
85
86     public Set JavaDoc<Datasource> getDatasources(DeploymentConfiguration JavaDoc config) {
87         return ((WebappConfiguration) config).getDatasources();
88     }
89
90     public Datasource createDatasource(DeploymentConfiguration JavaDoc config, String JavaDoc jndiName, String JavaDoc url, String JavaDoc username, String JavaDoc password, String JavaDoc driver)
91     throws OperationUnsupportedException JavaDoc, ConfigurationException JavaDoc, DatasourceAlreadyExistsException {
92         return ((WebappConfiguration) config).createDatasource(jndiName, url, username, password, driver);
93     }
94
95     public boolean isDatasourceCreationSupported() {
96         return true;
97     }
98 }
99
Popular Tags