KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > j2ee > deployment > MockWARConfigBuilder


1 /**
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17 package org.apache.geronimo.j2ee.deployment;
18
19 import junit.framework.Assert;
20 import org.apache.geronimo.common.DeploymentException;
21 import org.apache.geronimo.kernel.repository.Environment;
22 import org.apache.geronimo.kernel.repository.Artifact;
23 import org.apache.geronimo.kernel.Naming;
24 import org.apache.geronimo.kernel.config.ConfigurationStore;
25 import org.apache.geronimo.gbean.AbstractName;
26 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
27 import org.apache.geronimo.deployment.ModuleIDBuilder;
28
29 import java.io.File JavaDoc;
30 import java.net.URL JavaDoc;
31 import java.util.Map JavaDoc;
32 import java.util.Collection JavaDoc;
33 import java.util.jar.JarFile JavaDoc;
34
35 /**
36  * @version $Rev:386276 $ $Date: 2006-11-16 23:35:17 -0500 (Thu, 16 Nov 2006) $
37  */

38 public class MockWARConfigBuilder extends Assert implements ModuleBuilder {
39     private EARContext earContext;
40     private ClassLoader JavaDoc cl;
41     private Map JavaDoc portMap = null;
42     private String JavaDoc namespace = "foo";
43     public WebModule webModule;
44     public String JavaDoc contextRoot;
45
46     public Module createModule(File JavaDoc plan, JarFile JavaDoc moduleFile, Naming naming, ModuleIDBuilder idBuilder) throws DeploymentException {
47         AbstractName earName = naming.createRootName(new Artifact("test", "test-war", "", "war"), NameFactory.NULL, NameFactory.J2EE_APPLICATION) ;
48         AbstractName moduleName = naming.createChildName(earName, "war", NameFactory.WEB_MODULE);
49         return new WebModule(true, moduleName, null, moduleFile, "war", null, null, null, contextRoot, portMap, namespace);
50     }
51
52     public Module createModule(Object JavaDoc plan, JarFile JavaDoc moduleFile, String JavaDoc targetPath, URL JavaDoc specDDUrl, Environment environment, Object JavaDoc moduleContextInfo, AbstractName earName, Naming naming, ModuleIDBuilder idBuilder) throws DeploymentException {
53         AbstractName moduleName = naming.createChildName(earName, "war", NameFactory.WEB_MODULE);
54         return new WebModule(false, moduleName, null, moduleFile, targetPath, null, null, null, contextRoot, portMap, namespace);
55     }
56
57     public void installModule(JarFile JavaDoc earFile, EARContext earContext, Module webModule, Collection JavaDoc configurationStores, ConfigurationStore targetConfigurationStore, Collection JavaDoc repository) throws DeploymentException {
58         assertNotNull(earFile);
59         assertNotNull(earContext);
60         this.earContext = earContext;
61 // assertEquals(this.webModule, webModule);
62
// if ( null != this.webModule.getAltSpecDD() ) {
63
// assertEquals(this.webModule.getAltSpecDD(), webModule.getAltSpecDD());
64
// }
65
// if ( null != this.webModule.getAltVendorDD() ) {
66
// assertEquals(this.webModule.getAltVendorDD(), webModule.getAltVendorDD());
67
// }
68
}
69
70     public void initContext(EARContext earContext, Module webModule, ClassLoader JavaDoc cl) {
71         assertEquals(this.earContext, earContext);
72 // assertEquals(this.webModule, webModule);
73
assertNotNull(cl);
74         this.cl = cl;
75     }
76
77     public void addGBeans(EARContext earContext, Module webModule, ClassLoader JavaDoc cl, Collection JavaDoc repository) throws DeploymentException {
78         assertEquals(this.earContext, earContext);
79 // assertEquals(this.webModule, webModule);
80
assertEquals(this.cl, cl);
81         assertNotNull(contextRoot);
82         this.contextRoot = ((WebModule) webModule).getContextRoot();
83     }
84
85     public String JavaDoc getSchemaNamespace() {
86         return null;
87     }
88
89 }
90
Popular Tags