Skip to content

Commit

Permalink
Merge branch 'master' into expose-http-registerRouter-for-legacy
Browse files Browse the repository at this point in the history
  • Loading branch information
mshustov committed May 7, 2019
2 parents 97f1276 + 12b93bc commit 3786a02
Show file tree
Hide file tree
Showing 28 changed files with 834 additions and 86 deletions.
57 changes: 36 additions & 21 deletions x-pack/plugins/code/server/lsp/java_launcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { RequestExpander } from './request_expander';

export class JavaLauncher implements ILanguageServerLauncher {
private isRunning: boolean = false;
private needModuleArguments: boolean = true;
constructor(
readonly targetHost: string,
readonly options: ServerOptions,
Expand Down Expand Up @@ -115,8 +116,16 @@ export class JavaLauncher implements ILanguageServerLauncher {

if (this.getSystemJavaHome()) {
const javaHomePath = this.getSystemJavaHome();
if (await this.checkJavaVersion(javaHomePath)) {
const javaVersion = await this.getJavaVersion(javaHomePath);
if (javaVersion > 8) {
// for JDK's versiob > 8, we need extra arguments as default
return javaHomePath;
} else if (javaVersion === 8) {
// JDK's version = 8, needn't extra arguments
this.needModuleArguments = false;
return javaHomePath;
} else {
// JDK's version < 8, use bundled JDK instead, whose version > 8, so need extra arguments as default
}
}

Expand All @@ -142,22 +151,32 @@ export class JavaLauncher implements ILanguageServerLauncher {
process.platform === 'win32' ? 'java.exe' : 'java'
);

let params: string[] = [
'-Declipse.application=org.elastic.jdt.ls.core.id1',
'-Dosgi.bundles.defaultStartLevel=4',
'-Declipse.product=org.elastic.jdt.ls.core.product',
'-Dlog.level=ALL',
'-noverify',
'-Xmx4G',
'-jar',
path.resolve(installationPath, launchersFound[0]),
'-configuration',
this.options.jdtConfigPath,
'-data',
this.options.jdtWorkspacePath,
];

if (this.needModuleArguments) {
params.push('--add-modules=ALL-SYSTEM',
'--add-opens',
'java.base/java.util=ALL-UNNAMED',
'--add-opens',
'java.base/java.lang=ALL-UNNAMED');
}

const p = spawn(
javaPath,
[
'-Declipse.application=org.elastic.jdt.ls.core.id1',
'-Dosgi.bundles.defaultStartLevel=4',
'-Declipse.product=org.elastic.jdt.ls.core.product',
'-Dlog.level=ALL',
'-noverify',
'-Xmx4G',
'-jar',
path.resolve(installationPath, launchersFound[0]),
'-configuration',
this.options.jdtConfigPath,
'-data',
this.options.jdtWorkspacePath,
],
params,
{
detached: false,
stdio: 'pipe',
Expand Down Expand Up @@ -201,19 +220,15 @@ export class JavaLauncher implements ILanguageServerLauncher {
return '';
}

private checkJavaVersion(javaHome: string): Promise<boolean> {
private getJavaVersion(javaHome: string): Promise<number> {
return new Promise((resolve, reject) => {
execFile(
path.resolve(javaHome, 'bin', process.platform === 'win32' ? 'java.exe' : 'java'),
['-version'],
{},
(error, stdout, stderr) => {
const javaVersion = this.parseMajorVersion(stderr);
if (javaVersion < 8) {
resolve(false);
} else {
resolve(true);
}
resolve(javaVersion);
}
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ import { AutoFollowPatternAdd } from '../../../public/app/sections/auto_follow_p
import { ccrStore } from '../../../public/app/store';
import routing from '../../../public/app/services/routing';

const testBedOptions = {
const testBedConfig = {
store: ccrStore,
memoryRouter: {
onRouter: (router) => routing.reactRouter = router
}
};

const initTestBed = registerTestBed(AutoFollowPatternAdd, { options: testBedOptions, store: ccrStore });
const initTestBed = registerTestBed(AutoFollowPatternAdd, testBedConfig);

export const setup = (props) => {
const testBed = initTestBed(props);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import routing from '../../../public/app/services/routing';

import { AUTO_FOLLOW_PATTERN_EDIT_NAME } from './constants';

const testBedOptions = {
const testBedConfig = {
store: ccrStore,
memoryRouter: {
onRouter: (router) => routing.reactRouter = router,
// The auto-follow pattern id to fetch is read from the router ":id" param
Expand All @@ -22,7 +23,7 @@ const testBedOptions = {
}
};

const initTestBed = registerTestBed(AutoFollowPatternEdit, { options: testBedOptions, store: ccrStore });
const initTestBed = registerTestBed(AutoFollowPatternEdit, testBedConfig);

export const setup = (props) => {
const testBed = initTestBed(props);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ import { AutoFollowPatternList } from '../../../public/app/sections/home/auto_fo
import { ccrStore } from '../../../public/app/store';
import routing from '../../../public/app/services/routing';

const testBedOptions = {
const testBedConfig = {
store: ccrStore,
memoryRouter: {
onRouter: (router) => routing.reactRouter = router
}
};

const initTestBed = registerTestBed(AutoFollowPatternList, { options: testBedOptions, store: ccrStore });
const initTestBed = registerTestBed(AutoFollowPatternList, testBedConfig);

export const setup = (props) => {
const testBed = initTestBed(props);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ import { FollowerIndexAdd } from '../../../public/app/sections/follower_index_ad
import { ccrStore } from '../../../public/app/store';
import routing from '../../../public/app/services/routing';

const testBedOptions = {
const testBedConfig = {
store: ccrStore,
memoryRouter: {
onRouter: (router) => routing.reactRouter = router
}
};

const initTestBed = registerTestBed(FollowerIndexAdd, { options: testBedOptions, store: ccrStore });
const initTestBed = registerTestBed(FollowerIndexAdd, testBedConfig);

export const setup = (props) => {
const testBed = initTestBed(props);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import routing from '../../../public/app/services/routing';

import { FOLLOWER_INDEX_EDIT_NAME } from './constants';

const testBedOptions = {
const testBedConfig = {
store: ccrStore,
memoryRouter: {
onRouter: (router) => routing.reactRouter = router,
// The follower index id to fetch is read from the router ":id" param
Expand All @@ -22,7 +23,7 @@ const testBedOptions = {
}
};

const initTestBed = registerTestBed(FollowerIndexEdit, { options: testBedOptions, store: ccrStore });
const initTestBed = registerTestBed(FollowerIndexEdit, testBedConfig);

export const setup = (props) => {
const testBed = initTestBed(props);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ import { FollowerIndicesList } from '../../../public/app/sections/home/follower_
import { ccrStore } from '../../../public/app/store';
import routing from '../../../public/app/services/routing';

const testBedOptions = {
const testBedConfig = {
store: ccrStore,
memoryRouter: {
onRouter: (router) => routing.reactRouter = router
}
};

const initTestBed = registerTestBed(FollowerIndicesList, { options: testBedOptions, store: ccrStore });
const initTestBed = registerTestBed(FollowerIndicesList, testBedConfig);

export const setup = (props) => {
const testBed = initTestBed(props);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ import { ccrStore } from '../../../public/app/store';
import routing from '../../../public/app/services/routing';
import { BASE_PATH } from '../../../common/constants';

const testBedOptions = {
const testBedConfig = {
store: ccrStore,
memoryRouter: {
initialEntries: [`${BASE_PATH}/follower_indices`],
componentRoutePath: `${BASE_PATH}/:section`,
onRouter: (router) => routing.reactRouter = router
}
};

export const setup = registerTestBed(CrossClusterReplicationHome, { options: testBedOptions, store: ccrStore });
export const setup = registerTestBed(CrossClusterReplicationHome, testBedConfig);
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ import { RemoteClusterAdd } from '../../../public/sections/remote_cluster_add';
import { createRemoteClustersStore } from '../../../public/store';
import { registerRouter } from '../../../public/services/routing';

const testBedOptions = {
const testBedConfig = {
store: createRemoteClustersStore,
memoryRouter: {
onRouter: (router) => registerRouter(router)
}
};

const initTestBed = registerTestBed(RemoteClusterAdd, { options: testBedOptions, store: createRemoteClustersStore });
const initTestBed = registerTestBed(RemoteClusterAdd, testBedConfig);

export const setup = (props) => {
const testBed = initTestBed(props);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import { registerRouter } from '../../../public/services/routing';

import { REMOTE_CLUSTER_EDIT_NAME } from './constants';

const testBedOptions = {
const testBedConfig = {
store: createRemoteClustersStore,
memoryRouter: {
onRouter: (router) => registerRouter(router),
// The remote cluster name to edit is read from the router ":id" param
Expand All @@ -22,4 +23,4 @@ const testBedOptions = {
}
};

export const setup = registerTestBed(RemoteClusterEdit, { options: testBedOptions, store: createRemoteClustersStore });
export const setup = registerTestBed(RemoteClusterEdit, testBedConfig);
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ import { RemoteClusterList } from '../../../public/sections/remote_cluster_list'
import { createRemoteClustersStore } from '../../../public/store';
import { registerRouter } from '../../../public/services/routing';

const testBedOptions = {
const testBedConfig = {
store: createRemoteClustersStore,
memoryRouter: {
onRouter: (router) => registerRouter(router)
}
};

const initTestBed = registerTestBed(RemoteClusterList, { options: testBedOptions, store: createRemoteClustersStore });
const initTestBed = registerTestBed(RemoteClusterList, testBedConfig);

export const setup = (props) => {
const testBed = initTestBed(props);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import { registerRouter } from '../../../public/crud_app/services';
import { createRollupJobsStore } from '../../../public/crud_app/store';
import { JobList } from '../../../public/crud_app/sections/job_list';

const testBedOptions = {
const testBedConfig = {
store: createRollupJobsStore,
memoryRouter: {
onRouter: (router) => {
// register our react memory router
Expand All @@ -19,4 +20,4 @@ const testBedOptions = {
}
};

export const setup = registerTestBed(JobList, { options: testBedOptions, store: createRollupJobsStore });
export const setup = registerTestBed(JobList, testBedConfig);
Loading

0 comments on commit 3786a02

Please sign in to comment.