Revision 428

tmp/org.txm.statsengine.r.core/src/org/txm/statsengine/r/core/RStatsEngine.java (revision 428)
40 40
	public boolean start() {
41 41
		try {
42 42
			
43
			if (TXMPreferences.getBoolean(RPreferences.PREFERENCES_NODE, RPreferences.DISABLE)) {
43
			if (TXMPreferences.getBoolean(RPreferences.DISABLE, RPreferences.PREFERENCES_NODE)) {
44 44
				System.err.println("Warning, Statistics Engine is disabled.");
45 45
				return false;
46 46
			}
47 47
			
48 48
			// try launching R server and connecting to it
49
			int port = TXMPreferences.getInt(RPreferences.PREFERENCES_NODE, RPreferences.PORT);
50
			String user = TXMPreferences.getString(RPreferences.PREFERENCES_NODE, RPreferences.USER);
51
			String password = TXMPreferences.getString(RPreferences.PREFERENCES_NODE, RPreferences.PASSWORD);
52
			boolean remote = TXMPreferences.getBoolean(RPreferences.PREFERENCES_NODE, RPreferences.REMOTE);
53
			boolean debug = TXMPreferences.getBoolean(RPreferences.PREFERENCES_NODE, RPreferences.DEBUG);
54
			mandatory = TXMPreferences.getBoolean(RPreferences.PREFERENCES_NODE, RPreferences.IS_MANDATORY);
49
			int port = TXMPreferences.getInt(RPreferences.PORT, RPreferences.PREFERENCES_NODE);
50
			String user = TXMPreferences.getString(RPreferences.USER, RPreferences.PREFERENCES_NODE);
51
			String password = TXMPreferences.getString(RPreferences.PASSWORD, RPreferences.PREFERENCES_NODE);
52
			boolean remote = TXMPreferences.getBoolean(RPreferences.REMOTE, RPreferences.PREFERENCES_NODE);
53
			boolean debug = TXMPreferences.getBoolean(RPreferences.DEBUG, RPreferences.PREFERENCES_NODE);
54
			mandatory = TXMPreferences.getBoolean(RPreferences.IS_MANDATORY, RPreferences.PREFERENCES_NODE);
55 55
			
56 56
			Log.info(RCoreMessages.log_startingStatsEngine + user + RCoreMessages.log_remote + remote + RCoreMessages.log_port + port + RCoreMessages.log_debug + debug);
57 57
			// System.out.println("test remote :" + R_PATH_TO_EXECUTABLE + ":" + properties.getProperty(R_PATH_TO_EXECUTABLE));
58 58
			if (!remote) {
59 59
				// start Rserve executable
60 60
				started = RWorkspace.startExec(
61
						TXMPreferences.getString(RPreferences.PREFERENCES_NODE, RPreferences.PATH_TO_EXECUTABLE), 
61
						TXMPreferences.getString(RPreferences.PATH_TO_EXECUTABLE, RPreferences.PREFERENCES_NODE), 
62 62
						port, 
63 63
						debug, 
64
						TXMPreferences.getString(RPreferences.PREFERENCES_NODE, RPreferences.RARGS),
65
						TXMPreferences.getString(RPreferences.PREFERENCES_NODE, RPreferences.RSERVEARGS));
64
						TXMPreferences.getString(RPreferences.RARGS, RPreferences.PREFERENCES_NODE),
65
						TXMPreferences.getString(RPreferences.RSERVEARGS, RPreferences.PREFERENCES_NODE));
66 66

  
67 67
				if (started) { // try connecting to R witout login
68 68
					started = RWorkspace.connect("127.0.0.1", port); //$NON-NLS-1$
69 69
				}
70 70
			} else { // try connecting to R, with login and password
71
				started = RWorkspace.connect(TXMPreferences.getString(RPreferences.PREFERENCES_NODE, RPreferences.SERVER_ADDRESS), port, user, password);
71
				started = RWorkspace.connect(TXMPreferences.getString(RPreferences.SERVER_ADDRESS, RPreferences.PREFERENCES_NODE), port, user, password);
72 72
			}
73 73

  
74 74
			if (started) { // post configuration of R
75
				String rPackagesPath = TXMPreferences.getString(RPreferences.PREFERENCES_NODE, RPreferences.PACKAGES_PATH);
75
				String rPackagesPath = TXMPreferences.getString(RPreferences.PACKAGES_PATH, RPreferences.PREFERENCES_NODE);
76 76
				started = RWorkspace.getRWorkspaceInstance().postConfiguration(rPackagesPath);
77 77
			}
78 78

  
79
			//System.out.println("try to set R_FILE_TRANSFERT to " + TXMPreferences.getBoolean(RPreferences.PREFERENCES_NODE, RPreferences.R_FILE_TRANSFERT));
80
			RWorkspace.setUseFileCommunication(TXMPreferences.getBoolean(RPreferences.PREFERENCES_NODE, RPreferences.FILE_TRANSFERT));
79
			//System.out.println("try to set R_FILE_TRANSFERT to " + TXMPreferences.getBoolean(RPreferences.R_FILE_TRANSFERT, RPreferences.PREFERENCES_NODE));
80
			RWorkspace.setUseFileCommunication(TXMPreferences.getBoolean(RPreferences.FILE_TRANSFERT, RPreferences.PREFERENCES_NODE));
81 81
			//	System.out.println("success");
82 82
			//System.out.println("file transfert ? "+RWorkspace.isFileTranfert());
83 83
		} catch (RWorkspaceException e) {
......
93 93
	 * kill Rserve process.
94 94
	 */
95 95
	public static void kill() {
96
		if (!TXMPreferences.getBoolean(RPreferences.PREFERENCES_NODE, RPreferences.REMOTE))	{
96
		if (!TXMPreferences.getBoolean(RPreferences.REMOTE, RPreferences.PREFERENCES_NODE))	{
97 97
			// Windows OS
98 98
			if (OSDetector.isFamilyWindows()) {
99 99
				try {
......
131 131
			else {
132 132
				try {
133 133
					Process p = Runtime.getRuntime().exec(
134
							"kill -9 `lsof -t -a -c Rserve-bin.so -i : " + TXMPreferences.getInt(RPreferences.PREFERENCES_NODE, RPreferences.PORT) + "`"); //$NON-NLS-1$ //$NON-NLS-2$
134
							"kill -9 `lsof -t -a -c Rserve-bin.so -i : " + TXMPreferences.getInt(RPreferences.PORT, RPreferences.PREFERENCES_NODE) + "`"); //$NON-NLS-1$ //$NON-NLS-2$
135 135
					p.waitFor();
136 136
					started = false;
137 137
				} catch (IOException e) {

Also available in: Unified diff