1 package com.calipso.reportgenerator.common; 2 3 import com.calipso.reportgenerator.common.ReportGeneratorConfiguration; 4 import com.calipso.reportgenerator.common.IReportManager; 5 6 import javax.naming.Context ; 7 import java.util.Hashtable ; 8 9 13 public abstract class RemoteReportManager implements IReportManager { 14 private ReportGeneratorConfiguration reportGeneratorConfiguration; 15 protected String distributedHost; 16 17 public RemoteReportManager(ReportGeneratorConfiguration reportGeneratorConfiguration, String distributedHost) { 18 this.reportGeneratorConfiguration = reportGeneratorConfiguration; 19 this.distributedHost = distributedHost; 20 } 21 22 30 public static IReportManager newRemoteReportManager(ReportGeneratorConfiguration reportGeneratorConfiguration, boolean isStateFul, String distributedHost) { 31 if (isStateFul) { 32 return new RemoteReportManagerStateFul(reportGeneratorConfiguration, distributedHost); 33 } 34 else { 35 return new RemoteReportManagerStateLess(reportGeneratorConfiguration, distributedHost); 36 } 37 } 38 39 protected Hashtable getEnviroment() { 40 Hashtable env = new Hashtable (); 41 env.put(Context.INITIAL_CONTEXT_FACTORY, getReportGeneratorConfiguration().getINITIAL_CONTEXT_FACTORY()); 42 env.put(Context.PROVIDER_URL, getHostName()); 43 env.put("java.naming.factory.url.pkgs", getReportGeneratorConfiguration().getJavaNamingFactoryUrlPkgs()); 44 return env; 45 } 46 47 52 protected String getHostName() { 53 String hostName = ""; 54 if(distributedHost!= null && !distributedHost.equals("")){ 55 hostName = distributedHost; 56 }else{ 57 hostName = getReportGeneratorConfiguration().getDistributedHost(); 58 } 59 if (getReportGeneratorConfiguration().getDistributedPort() != "") { 60 hostName = hostName + ":" + getReportGeneratorConfiguration().getDistributedPort(); 61 } 62 return hostName; 63 } 64 65 69 public ReportGeneratorConfiguration getReportGeneratorConfiguration() { 70 return reportGeneratorConfiguration; 71 } 72 73 } 74 | Popular Tags |