1 23 24 package com.sun.ejb.base.sfsb.initialization; 25 26 import java.io.File ; 27 28 import java.util.logging.Level ; 29 import java.util.logging.Logger ; 30 31 import java.util.HashMap ; 32 import java.util.Map ; 33 34 import com.sun.ejb.spi.sfsb.initialization.SFSBContainerInitialization; 35 36 import com.sun.ejb.spi.sfsb.store.SFSBStoreManager; 37 import com.sun.ejb.spi.sfsb.store.SFSBStoreManagerException; 38 39 import com.sun.enterprise.deployment.Application; 40 import com.sun.enterprise.deployment.EjbDescriptor; 41 42 import com.sun.ejb.base.sfsb.store.FileStoreManager; 43 import com.sun.ejb.base.sfsb.store.FileStoreManagerConstants; 44 45 import com.sun.enterprise.server.ServerContext; 46 import com.sun.enterprise.server.ApplicationServer; 47 import com.sun.enterprise.instance.InstanceEnvironment; 48 49 import com.sun.enterprise.config.ConfigException; 50 import com.sun.enterprise.config.serverbeans.*; 51 import com.sun.enterprise.instance.*; 52 import com.sun.enterprise.server.*; 53 import com.sun.enterprise.server.ServerContext; 54 import com.sun.enterprise.server.ApplicationServer; 55 import com.sun.enterprise.util.io.FileUtils; 56 57 import com.sun.ejb.base.container.util.CacheProperties; 58 59 64 public class FileStrategyBuilder 65 extends AbstractPersistenceStrategyBuilder 66 { 67 68 public FileStrategyBuilder() { 69 } 70 71 public void initializePersistenceStrategy( 72 SFSBContainerInitialization container, EjbDescriptor descriptor) 73 { 74 try { 75 super.initializePersistenceStrategy(container, descriptor); 76 77 SFSBStoreManager storeManager = createStoreManager( 78 container, descriptor); 79 container.setSFSBStoreManager(storeManager); 80 81 } catch (Throwable th) { 82 _logger.log(Level.SEVERE, "Could not initialize container " 83 + "using FilestrategyBuilder", th); 84 } 85 } 86 87 private SFSBStoreManager createStoreManager( 88 SFSBContainerInitialization container, EjbDescriptor descriptor) 89 { 90 FileStoreManager manager = new FileStoreManager(); 92 93 Map map = new HashMap (); 95 map.put(FileStoreManagerConstants.STORE_MANAGER_NAME, 96 descriptor.getName()); 97 98 map.put(FileStoreManagerConstants.CONTAINER_ID, 99 new Long (descriptor.getUniqueId())); 100 101 CacheProperties cacheProps = new CacheProperties(descriptor); 102 map.put(FileStoreManagerConstants.SESSION_TIMEOUT_IN_SECONDS, 103 new Integer (cacheProps.getRemovalTimeoutInSeconds())); 104 105 map.put(FileStoreManagerConstants.GRACE_SESSION_TIMEOUT_IN_SECONDS, 106 new Integer (super.getRemovalGracePeriodInSeconds())); 107 108 map.put(FileStoreManagerConstants.PASSIVATION_DIRECTORY_NAME, 109 getPassivationDirectoryName(descriptor)); 110 111 _logger.log(Level.FINE, "Initialzing FileStoreManager with: " + map); 113 manager.initSessionStore(map); 114 115 _logger.log(Level.FINE, "INITIALZED FileStoreManager: " + manager); 116 return manager; 117 } 118 119 private String getPassivationDirectoryName(EjbDescriptor desc) { 120 121 String passivationDirName = null; 122 123 try { 124 125 ServerContext ctx = ApplicationServer.getServerContext(); 127 128 InstanceEnvironment env = ctx.getInstanceEnvironment(); 130 131 Application application = desc.getApplication(); 133 String dirName = null; 134 String componentSeparator = "_"; 135 if (application.isVirtual()) { 136 String archURI = desc.getEjbBundleDescriptor(). 138 getModuleDescriptor().getArchiveUri(); 139 passivationDirName = env.getModulePassivatedEjbPath() 140 + File.separator + FileUtils.makeFriendlyFilename(archURI) 141 + componentSeparator + desc.getName(); 142 } else { 143 passivationDirName = env.getApplicationPassivatedEjbPath() 145 + File.separator + application.getRegistrationName() 146 + componentSeparator + desc.getName() 147 + componentSeparator + desc.getUniqueId(); 148 } 149 150 } catch (Throwable th) { 151 _logger.log(Level.SEVERE, 152 "ejb.sfsb_helper_get_passivation_dir_failed", th); 153 } 154 155 return passivationDirName; 156 } 157 158 } 159 160 | Popular Tags |