1 16 package org.apache.pluto.driver.deploy.impl; 17 18 import java.io.File ; 19 import java.io.IOException ; 20 import java.io.RandomAccessFile ; 21 22 import org.apache.pluto.driver.deploy.PortalRegistrarService; 23 import org.apache.pluto.descriptors.services.PortletAppDescriptorService; 24 25 33 public class ContextRegistryRegistrarService implements PortalRegistrarService { 34 35 public static final String CONTEXT_FILE = "WEB-INF/data/portletcontexts.txt"; 36 37 private File webAppDir; 38 39 public ContextRegistryRegistrarService(File webAppDir) { 40 this.webAppDir = webAppDir; 41 } 42 43 public void register(PortletAppDescriptorService service) 44 throws IOException { 45 System.out.println("<VERBOSE> Registering Applicaiton Context"); 46 File file = new File (webAppDir, CONTEXT_FILE); 47 RandomAccessFile ras = new RandomAccessFile (file, "rw"); 48 49 long length = ras.length(); 50 byte[] contentByte = new byte[(int) length]; 51 ras.read(contentByte); 52 String contents = new String (contentByte); 53 long pos = contents.lastIndexOf("/"+service.getContextPath()); 54 if(pos > -1) { 55 System.out.println("<VERBOSE> Found previous context registration; Registration aborted."); 56 ras.close(); 57 return; 58 } 59 ras.seek(length); 60 ras.writeBytes("/"+service.getContextPath()); 61 ras.writeBytes("\n"); 62 ras.close(); 63 } 64 } 65 66 | Popular Tags |