1 23 24 package com.sun.enterprise.deployment.util; 25 26 import java.util.*; 27 import java.util.logging.Level ; 28 import com.sun.enterprise.deployment.Application; 29 import com.sun.enterprise.deployment.BundleDescriptor; 30 import com.sun.enterprise.deployment.EjbBundleDescriptor; 31 import com.sun.enterprise.deployment.ApplicationClientDescriptor; 32 import com.sun.enterprise.deployment.WebBundleDescriptor; 33 import com.sun.enterprise.deployment.WebComponentDescriptor; 34 import com.sun.enterprise.deployment.EjbDescriptor; 35 import com.sun.enterprise.deployment.EjbIORConfigurationDescriptor; 36 import com.sun.enterprise.deployment.LifecycleCallbackDescriptor; 37 import com.sun.enterprise.deployment.util.DOLUtils; 38 import com.sun.enterprise.deployment.util.ModuleDescriptor; 39 import java.io.File ; 40 41 48 public class ApplicationValidator extends EjbBundleValidator 49 implements ApplicationVisitor, EjbBundleVisitor, EjbVisitor { 50 51 52 private Application application; 53 54 58 public void accept(Application application) { 59 this.application = application; 60 } 61 62 66 public void accept(EjbBundleDescriptor bundleDescriptor) { 67 68 this.bundleDescriptor = bundleDescriptor; 69 super.accept(bundleDescriptor); 70 79 String rlm = application.getRealm(); 80 Iterator ejbs = bundleDescriptor.getEjbs().iterator(); 81 for(; ejbs.hasNext();){ 82 EjbDescriptor ejb = (EjbDescriptor) ejbs.next(); 83 Iterator iorconfig = ejb.getIORConfigurationDescriptors().iterator(); 84 for (;iorconfig.hasNext(); ){ 85 EjbIORConfigurationDescriptor desc = 86 (EjbIORConfigurationDescriptor)iorconfig.next(); 87 desc.setRealmName(rlm); 88 } 89 } 90 } 91 92 93 98 public void accept(WebBundleDescriptor descriptor) { 99 bundleDescriptor = descriptor; 100 ModuleDescriptor md = bundleDescriptor.getModuleDescriptor( ); 101 String uri = md.getArchiveUri( ); 103 if( ( md.getContextRoot() == null ) 104 && ( ( uri != null ) && (uri.length() != 0) ) ) 105 { 106 int beginIndex = uri.lastIndexOf( "/" ); 109 110 if( beginIndex < 0 ) { 113 beginIndex = uri.lastIndexOf( File.separator ); 114 } 115 116 if( beginIndex < 0 ) { 119 beginIndex = 0; 120 } else { 121 beginIndex++; 124 } 125 126 130 int endIndex = uri.lastIndexOf( ".war" ); 133 if (endIndex==-1) { 134 return; 135 } 136 String warFileName = uri.substring( beginIndex, endIndex ); 137 md.setContextRoot( warFileName ); 138 if( DOLUtils.getDefaultLogger().isLoggable(Level.INFO) ) { 139 DOLUtils.getDefaultLogger().info( 140 "Context Root is not provided by the user, Using [" 141 + warFileName + "] as Context Root" ); 142 } 143 } 144 } 145 146 150 public void accept(ApplicationClientDescriptor appclientdescriptor) { 151 bundleDescriptor = appclientdescriptor; 152 153 for (LifecycleCallbackDescriptor next : 155 appclientdescriptor.getPreDestroyDescriptors()) { 156 next.setDefaultLifecycleCallbackClass( 157 appclientdescriptor.getMainClassName()); 158 } 159 160 for (LifecycleCallbackDescriptor next : 161 appclientdescriptor.getPostConstructDescriptors()) { 162 next.setDefaultLifecycleCallbackClass( 163 appclientdescriptor.getMainClassName()); 164 } 165 } 166 167 172 public void accept(WebComponentDescriptor descriptor) { 173 computeRuntimeDefault(descriptor); 174 } 175 176 private void computeRuntimeDefault(WebComponentDescriptor webComp) { 177 if (!webComp.getUsesCallerIdentity()) { 178 computeRunAsPrincipalDefault( 179 webComp.getRunAsIdentity(), webComp.getApplication()); 180 } 181 } 182 183 186 protected Collection getEjbDescriptors() { 187 if (application!=null) 188 return application.getEjbDescriptors(); 189 return new HashSet(); 190 } 191 192 195 protected Application getApplication() { 196 return application; 197 } 198 199 202 protected BundleDescriptor getBundleDescriptor() { 203 return bundleDescriptor; 204 } 205 206 207 } 208 | Popular Tags |