Skip to content

Remote console integration #113

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion electron/app/js/ipcRendererPreload.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,8 @@ contextBridge.exposeInMainWorld(
'get-wrc-home-directory',
'get-wrc-app-image',
'wrc-get-home-default-value',
'wrc-set-home-and-start'
'wrc-set-home-and-start',
'get-wrc-port'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we discussed a few weeks back, I don't understand the purpose of this IPC call. The electron side is getting the port number and pushing it to the webui side once it is available. Making the webui side pull the port number doesn't eliminate the asynchronous nature of this and your code still has to be prepared to get undefined back since your code may call this method before the backend has started and the port is known.

My sense is that you think you are eliminating the asynchrony because you haven't seen the race condition but rest assured that you are not eliminating the race condition by doing this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was not thinking that the get-wrc-port IPC eliminated the race condition. In fact, lines 51-53 in the model-design-view.js model look for whether the port number sent to windowStateUtils.js was undefined, or not.

The get-wrc-port IPC is there because there scenarios involving the WRC, which could leave the WKT-UI/WRC piece in an unstable state. For instance, if the spawned WRC app dies (or literally gets killed by the end user) and the user is interacting with the "Design View" tab, then the get-wrc-port IPC is the way to gracefully recover. To see this, click on the "Design View" tab, kill the process associated with the started WRC app, then change a field in the WRC form or click on the navtree. The get-wrc-port IPC is the reason you end up back on the "WRC not installed" version of the "Design View" tab, and not dangling in a state where the embedded WRC is still trying to make REST calls to the CBE. You have it so the electron side prints the exit code of the killed WRC, but that doesn't 1) help the embedded WRC know that the backend is now invalid, and 2) set things up so that the "WRC not installed" version of the "Design View" tab gets displayed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's the stdout showing log entries from both the electron and webui side, in the scenario described above:

info: [renderer:2] showWdtModelDesigner: backendPort=52301
info: WebLogic Remote Console backend process exited with code 0
info: [renderer:2] showWdtModelDesigner: backendPort=undefined
info: [renderer:2] showWdtModelDesigner: backendPort=52340

The get-wrc-port IPC is what's allowing the model-design-view.js to figure out what's going on, and communicate the valid backendPort to the wdt-model-designer JET composite, so it can in turn set the valid backendURL to be used when doing CBE REST calls.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So rather than this elaborate scheme that requires a new IPC every time the user switches to the Design View tab, why wouldn’t we just make the call to push the new value of the port when the process exits?

];
return new Promise((resolve, reject) => {
if (validChannels.includes(channel)) {
Expand Down
18 changes: 14 additions & 4 deletions electron/app/js/wlRemoteConsoleUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const { spawnDaemonChildProcess } = require('./childProcessExecutor');
const { wlRemoteConsoleFrontendVersion } = require('../webui.json');

let _wlRemoteConsoleChildProcess;

let _wlRemoteConsolePort;

async function startWebLogicRemoteConsoleBackend(currentWindow, skipVersionCheck = false) {
if (_wlRemoteConsoleChildProcess) {
Expand All @@ -45,6 +45,8 @@ async function startWebLogicRemoteConsoleBackend(currentWindow, skipVersionCheck
});
_wlRemoteConsoleChildProcess.on('exit', (code) => {
getLogger().info('WebLogic Remote Console backend process exited with code %s', code);
_wlRemoteConsoleChildProcess = undefined;
_wlRemoteConsolePort = undefined;
});

const stdoutLines = readline.createInterface({ input: _wlRemoteConsoleChildProcess.stdout });
Expand All @@ -58,6 +60,9 @@ async function startWebLogicRemoteConsoleBackend(currentWindow, skipVersionCheck
const matcher = line.match(portRegex);
if (matcher) {
foundPort = true;
// The exported getWebLogicRemoteConsolePort function returns
// the current port, so we need to save it.
_wlRemoteConsolePort = matcher[1];
sendToWindow(currentWindow, 'set-wrc-backend-port', matcher[1]);
}
}
Expand Down Expand Up @@ -150,6 +155,10 @@ function getDefaultDirectoryForOpenDialog(isAppImage = false) {
return result;
}

function getWebLogicRemoteConsolePort() {
return _wlRemoteConsolePort;
}

async function _getWebLogicRemoteConsoleHome(skipVersionCheck = false) {
const rcHome = userSettings.getWebLogicRemoteConsoleHome();
if (!rcHome) {
Expand Down Expand Up @@ -236,7 +245,7 @@ async function _getWebLogicRemoteConsoleExecutableData(rcHome) {
_getDevExecutablePath(rcHome, pathToDirectoryWithExecutable).then(exeResult => {
if (exeResult.exists) {
results['executable'] = exeResult.executable;
results['arguments'] = ['.', 'dev', '--showPort', '--stdin', '--quiet', '--headless'];
results['arguments'] = ['.', 'dev', '--showPort', `--check-pid=${process.pid}`, '--quiet', '--headless', '--useTokenNotCookie'];
results['options'] = { cwd: rcHome };
} else {
const message = i18n.t('wrc-dev-executable-existence-check-failed',
Expand All @@ -254,7 +263,7 @@ async function _getWebLogicRemoteConsoleExecutableData(rcHome) {
_getInstalledExecutablePath(rcHome).then(exeResult => {
if (exeResult['exists']) {
results['executable'] = exeResult['executable'];
results['arguments'] = ['--showPort', '--stdin', '--quiet', '--headless'];
results['arguments'] = ['--showPort', '--useTokenNotCookie', `--check-pid=${process.pid}`, '--quiet', '--headless'];
resolve(results);
} else {
const message = i18n.t('wrc-executable-not-exists', { rcHome: rcHome, executable: results['executable'] });
Expand Down Expand Up @@ -495,5 +504,6 @@ module.exports = {
getDefaultDirectoryForOpenDialog,
getDefaultWebLogicRemoteConsoleHome,
setWebLogicRemoteConsoleHomeAndStart,
startWebLogicRemoteConsoleBackend
startWebLogicRemoteConsoleBackend,
getWebLogicRemoteConsolePort
};
7 changes: 6 additions & 1 deletion electron/app/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const openSSLUtils = require('./js/openSSLUtils');
const osUtils = require('./js/osUtils');
const { initializeAutoUpdater, registerAutoUpdateListeners, installUpdates, getUpdateInformation } = require('./js/appUpdater');
const { startWebLogicRemoteConsoleBackend, getDefaultDirectoryForOpenDialog, setWebLogicRemoteConsoleHomeAndStart,
getDefaultWebLogicRemoteConsoleHome } = require('./js/wlRemoteConsoleUtils');
getDefaultWebLogicRemoteConsoleHome, getWebLogicRemoteConsolePort } = require('./js/wlRemoteConsoleUtils');

const { getHttpsProxyUrl, getBypassProxyHosts } = require('./js/userSettings');
const { sendToWindow } = require('./js/windowUtils');
Expand Down Expand Up @@ -931,6 +931,11 @@ class Main {
ipcMain.handle('wrc-get-home-default-value', async (event) => {
return getDefaultWebLogicRemoteConsoleHome();
});

// eslint-disable-next-line no-unused-vars
ipcMain.handle('get-wrc-port', async (event) => {
return getWebLogicRemoteConsolePort();
});
}

async getLatestWdtInstaller(targetWindow) {
Expand Down
18 changes: 17 additions & 1 deletion webui/src/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -194,16 +194,32 @@
}

/* container for model design view, currently text */
.wkt-model-edit-design,
.wkt-model-code-view
{
display: flex;
height: 100%;
width: 100%;
}

.wkt-model-edit-design > a > img {
margin: 0 3px 0 0;
height: 24px;
width: 18px;
}

/*
///MLW
.wkt-model-edit-design {
margin: 10px;
}

/* container for model design view, currently text */
.wkt-model-code-view {
display: flex;
height: 100%;
width: 100%;
}
*/

/* the ace editor pane */
#model-editor {
Expand Down
15 changes: 14 additions & 1 deletion webui/src/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,22 @@
'corejs' : 'libs/corejs/shim',
'chai': 'libs/chai/chai-4.2.0',
'regenerator-runtime' : 'libs/regenerator-runtime/runtime',
'ace': 'libs/ace/ace'
'ace': 'libs/ace/ace',
'wrc-translations': 'resources',
'wrc-frontend': 'jet-composites/wrc-frontend/1.0.0',
'wdt-model-designer': 'jet-composites/wdt-model-designer/1.0.0',
'cfe-navtree': 'jet-composites/cfe-navtree/1.0.0',
'cfe-multi-select': 'jet-composites/cfe-multi-select/1.0.0',
'cfe-property-list-editor': 'jet-composites/cfe-property-list-editor/1.0.0'
}
// endinjector
, config: {
ojL10n: {
merge: {
'ojtranslations/nls/ojtranslations': 'resources/nls/frontend'
}
}
}
}
);
}());
Expand Down
91 changes: 91 additions & 0 deletions webui/src/js/path_mapping.json
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,97 @@
"path": "libs/ace/ace.js",
"cdnPath": ""
}
},

"wrc-translations": {
"cdn": "3rdparty",
"cwd": "node_modules/@oracle/wrc-jet-pack/dist/resources",
"debug": {
"src": ["**"],
"path": "resources",
"cdnPath": ""
},
"release": {
"src": ["**"],
"path": "resources",
"cdnPath": ""
}
},

"wrc-frontend": {
"cdn": "3rdparty",
"cwd": "node_modules/@oracle/wrc-jet-pack/dist/jet-composites/wrc-frontend",
"debug": {
"src": ["**"],
"path": "jet-composites/wrc-frontend/1.0.0",
"cdnPath": ""
},
"release": {
"src": ["**"],
"path": "jet-composites/wrc-frontend/1.0.0",
"cdnPath": ""
}
},

"wdt-model-designer": {
"cdn": "3rdparty",
"cwd": "node_modules/@oracle/wrc-jet-pack/dist/jet-composites/wdt-model-designer",
"debug": {
"src": ["**"],
"path": "jet-composites/wdt-model-designer/1.0.0",
"cdnPath": ""
},
"release": {
"src": ["**"],
"path": "jet-composites/wdt-model-designer/1.0.0",
"cdnPath": ""
}
},

"cfe-navtree": {
"cdn": "3rdparty",
"cwd": "node_modules/@oracle/wrc-jet-pack/dist/jet-composites/cfe-navtree",
"debug": {
"src": ["**"],
"path": "jet-composites/cfe-navtree/1.0.0",
"cdnPath": ""
},
"release": {
"src": ["**"],
"path": "jet-composites/cfe-navtree/1.0.0",
"cdnPath": ""
}
},

"cfe-multi-select": {
"cdn": "3rdparty",
"cwd": "node_modules/@oracle/wrc-jet-pack/dist/jet-composites/cfe-multi-select",
"debug": {
"src": ["**"],
"path": "jet-composites/cfe-multi-select/1.0.0",
"cdnPath": ""
},
"release": {
"src": ["**"],
"path": "jet-composites/cfe-multi-select/1.0.0",
"cdnPath": ""
}
},

"cfe-property-list-editor": {
"cdn": "3rdparty",
"cwd": "node_modules/@oracle/wrc-jet-pack/dist/jet-composites/cfe-property-list-editor",
"debug": {
"src": ["**"],
"path": "jet-composites/cfe-property-list-editor/1.0.0",
"cdnPath": ""
},
"release": {
"src": ["**"],
"path": "jet-composites/cfe-property-list-editor/1.0.0",
"cdnPath": ""
}
}

}
}
Loading