KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > calipso > reportgenerator > common > RemoteReportManager


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 JavaDoc;
7 import java.util.Hashtable JavaDoc;
8
9 /**
10  * Clase abstracta que implementa IReportManager. Se crea a partir
11  * de una instancia de ReportManagerConfiguration.
12  */

13 public abstract class RemoteReportManager implements IReportManager {
14   private ReportGeneratorConfiguration reportGeneratorConfiguration;
15   protected String JavaDoc distributedHost;
16
17   public RemoteReportManager(ReportGeneratorConfiguration reportGeneratorConfiguration, String JavaDoc distributedHost) {
18     this.reportGeneratorConfiguration = reportGeneratorConfiguration;
19     this.distributedHost = distributedHost;
20   }
21
22   /**
23    * Crea un RemoteReportManagerStateful o RemoteReportManagerStateless dependiendo
24    * de la configuracion establecida en la instancia reportGeneratorConfiguration
25    * @param reportGeneratorConfiguration
26    * @param isStateFul determina trata de un EJB Stateful o Stateless
27    * @return los metodos que encapsulan aquellos del Bean correspondiente, y cuya invocacion
28    * permite la ejecucion de los mismos en el ReportManager
29    */

30   public static IReportManager newRemoteReportManager(ReportGeneratorConfiguration reportGeneratorConfiguration, boolean isStateFul, String JavaDoc 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 JavaDoc getEnviroment() {
40     Hashtable JavaDoc env = new Hashtable JavaDoc();
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   /**
48    * Obtiene el host (nombre:puerto) de la máquina contra la cual
49    * se invocara el metodo determinado
50    * @return String que representa el host
51    */

52   protected String JavaDoc getHostName() {
53     String JavaDoc 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   /**
66    * Obtiene un ReportManagerConfiguration
67    * @return el ReportManagerConfiguration determinado de la instancia
68    */

69   public ReportGeneratorConfiguration getReportGeneratorConfiguration() {
70     return reportGeneratorConfiguration;
71   }
72
73 }
74
Popular Tags