Show MaseSystem.java syntax highlighted
package connector;
import java.io.IOException;
import java.util.Hashtable;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import fitService.util.EditorConstants;
import mase.fit.FitPages;
public class MaseSystem {
private static final String jndiFitLookUp = "ebe/FitPagesBean/remote";
private FitPages pages = null;
public static Hashtable environment = new Hashtable();
private Context context;
private static String serverHost = EditorConstants.DEFAULT_SERVER_HOST;
private static String serverPort = EditorConstants.DEFAULT_SERVER_BEAN_PORT;
private static MaseSystem instance = null;
public static MaseSystem getMaseSystem(){
return instance;
}
public static boolean logIn(String host, String port){
// String command = "java -classpath c:\\Temp\\fit.jar;c:\\Temp\\test fit.FileRunner c:\\Temp\\test.html c:\\Temp\\report_jre.html";
//
// Runtime rt = Runtime.getRuntime();
// try {
// Process p = rt.exec(command);
//
//
// } catch (IOException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
//
String url = host + ":" + port;
try {
instance = new MaseSystem(url);
instance.setServerHost(host);
instance.setServerPort(port);
System.out.println("Successfully Logged In.");
return true;
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println("Login Failed");
return false;
}
}
@SuppressWarnings("unchecked")
private MaseSystem( String url)throws Exception{
environment.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
environment.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
environment.put(Context.PROVIDER_URL, url);
context = new InitialContext(environment);
pages = (FitPages) context.lookup(MaseSystem.jndiFitLookUp);
}
public String getFitPageText(String name){
return pages.getFitPageText(name);
}
public boolean saveFitPageText(String name, String content){
return pages.saveFitPageText(name, content);
}
public String getFitPageTree(){
try{
return pages.getFitPageTreeXML();
}catch(Exception e){
e.printStackTrace();
return null;
}
}
public static String getServerHost(){
return serverHost;
}
public static String getServerPort(){
return serverPort;
}
public static void setServerHost(String serverHost) {
serverHost = serverHost;
}
public static void setServerPort(String serverPort) {
serverPort = serverPort;
}
public boolean doesPageExist(String pName){
try {
return pages.doesPageExist(pName);
}catch (Exception e){
return false;
}
}
}
See more files for this project here