Hmm, if we just do not wish the DeploymentLoader to be extended, I think private method or final class are enough, just feel curious why those private and protected methods are marked as static. The reason I hope to extend DeploymentLoader and ReadDescriptor is that, I found they do "too much" in the Geronimo integration :-) They would also analysis other module types except for ejb module, that is not required, I even could find DeploymentLoader would check tld files. Those behaviors are reasonable in OpenEJB server as it also need to support other module types, but in Geornimo ...
I pasted some of my draft codes below, and look forward to your comments, thanks. /** * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.geronimo.openejb.deployment; import java.io.File; import java.io.IOException; import java.net.URL; import java.util.Map; import org.apache.openejb.ClassLoaderUtil; import org.apache.openejb.OpenEJBException; import org.apache.openejb.config.DeploymentLoader; import org.apache.openejb.config.ReadDescriptors; import org.apache.openejb.config.WebModule; import org.apache.openejb.jee.WebApp; /** * @version $Rev$ $Date$ * GeronimoDeploymentLoader will prevent DeploymentLoader collecting non-EJB related information. */ public class GeronimoDeploymentLoader extends DeploymentLoader { public GeronimoDeploymentLoader() { super(); } public GeronimoDeploymentLoader(String ddDir) { super(ddDir); } @Override protected WebModule createWebModule(String appId, String warPath, ClassLoader parentClassLoader, String contextRoot, String moduleName) throws OpenEJBException { File warFile = new File(warPath); warFile = unpack(warFile); // read web.xml file Map<String, URL> descriptors; try { descriptors = getWebDescriptors(warFile); } catch (IOException e) { throw new OpenEJBException("Unable to determine descriptors in jar.", e); } WebApp webApp = null; URL webXmlUrl = descriptors.get("web.xml"); if (webXmlUrl != null) { webApp = ReadDescriptors.readWebApp(webXmlUrl); } // determine war class path URL[] webUrls = getWebappUrls(warFile); ClassLoader warClassLoader = ClassLoaderUtil.createTempClassLoader(appId, webUrls, parentClassLoader); // create web module WebModule webModule = new WebModule(webApp, contextRoot, warClassLoader, warFile.getAbsolutePath(), moduleName); //webModule.getAltDDs().putAll(descriptors); //webModule.getWatchedResources().add(warPath); //webModule.getWatchedResources().add(warFile.getAbsolutePath()); //if (webXmlUrl != null && "file".equals(webXmlUrl.getProtocol())) { // webModule.getWatchedResources().add(URLs.toFilePath(webXmlUrl)); //} return webModule; } } /** * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.geronimo.openejb.deployment; import org.apache.openejb.OpenEJBException; import org.apache.openejb.config.AppModule; import org.apache.openejb.config.EjbModule; import org.apache.openejb.config.ReadDescriptors; /** * @version $Rev$ $Date$ */ public class GeronimoReadDescriptors extends ReadDescriptors { @Override public AppModule deploy(AppModule appModule) throws OpenEJBException { for (EjbModule ejbModule : appModule.getEjbModules()) { if (ejbModule.getEjbJar() == null) { readEjbJar(ejbModule, appModule); } if (ejbModule.getOpenejbJar() == null) { readOpenejbJar(ejbModule); } if (ejbModule.getBeans() == null) { readBeans(ejbModule, appModule); } readCmpOrm(ejbModule); } return appModule; } } 2010/12/10 David Blevins <[email protected]> > On Thu, Dec 9, 2010 at 12:19 AM, Ivan <[email protected]> wrote: > > I found that there are many private and proected static methods in the > > o.a.o.config.DeploymentLoader, it prevents to overrides those protected > > methods in the subclass.. So is there any special reason for this ? If > not, > > I would like to remove those static key words. > > I'm sure we can figure out a way to do what you need, but let's > definitely not do more subclassing. The stateful container is > subclassed in the geronimo-openejb-clustering-wadi module and it's > always quite painful to make changes that don't break it. > > If you have any details on the overall goal, I'm sure we can find > something clever. > > > -David > -- Ivan
