001 /** 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017 package org.apache.geronimo.j2ee.deployment; 018 019 import java.io.IOException; 020 import java.net.URI; 021 import java.net.URISyntaxException; 022 import java.util.Collection; 023 import java.util.jar.JarFile; 024 025 import org.apache.geronimo.deployment.DeploymentContext; 026 import org.apache.geronimo.gbean.AbstractName; 027 import org.apache.geronimo.j2ee.deployment.annotation.AnnotatedApplicationClient; 028 import org.apache.geronimo.kernel.config.ConfigurationModuleType; 029 import org.apache.geronimo.kernel.repository.Environment; 030 import org.apache.xmlbeans.XmlObject; 031 032 /** 033 * TODO there is almost certainly a problem with the serverEnvironment when deploying a stand alone app client outside an ear. 034 * 035 * @version $Rev: 535939 $ $Date: 2007-05-07 14:03:52 -0400 (Mon, 07 May 2007) $ 036 */ 037 public class AppClientModule extends Module { 038 private final Environment serverEnvironment; 039 private JarFile earFile; 040 private final AbstractName appClientName; 041 private final String mainClassName; 042 private final Collection<ConnectorModule> resourceModules; 043 044 045 public AppClientModule(boolean standAlone, AbstractName moduleName, AbstractName appClientName, Environment serverEnvironment, Environment clientEnvironment, JarFile moduleFile, String targetPath, XmlObject specDD, String mainClassName, XmlObject vendorDD, String originalSpecDD, Collection<ConnectorModule> resourceModules, AnnotatedApplicationClient annotatedAppClient ) { 046 super(standAlone, moduleName, clientEnvironment, moduleFile, targetPath, specDD, vendorDD, originalSpecDD, null, annotatedAppClient ); 047 this.serverEnvironment = serverEnvironment; 048 this.appClientName = appClientName; 049 this.mainClassName = mainClassName; 050 this.resourceModules = resourceModules; 051 } 052 053 public ConfigurationModuleType getType() { 054 return ConfigurationModuleType.CAR; 055 } 056 057 public Environment getServerEnvironment() { 058 return serverEnvironment; 059 } 060 061 public JarFile getEarFile() { 062 return earFile; 063 } 064 065 public void setEarFile(JarFile earFile) { 066 this.earFile = earFile; 067 } 068 069 public AbstractName getAppClientName() { 070 return appClientName; 071 } 072 073 public String getMainClassName() { 074 return mainClassName; 075 } 076 077 public void addClass(URI location, String fqcn, byte[] bytes, DeploymentContext context) throws IOException, URISyntaxException { 078 context.addClass(location, fqcn, bytes); 079 } 080 081 public Collection<ConnectorModule> getResourceModules() { 082 return resourceModules; 083 } 084 085 public void close() { 086 if (resourceModules != null) { 087 for (ConnectorModule resourceModule : resourceModules) { 088 resourceModule.close(); 089 } 090 } 091 super.close(); 092 } 093 094 } 095 096