当前位置: 首页>>代码示例>>Java>>正文


Java NetUtils.findAvailableSocketPort方法代码示例

本文整理汇总了Java中com.intellij.util.net.NetUtils.findAvailableSocketPort方法的典型用法代码示例。如果您正苦于以下问题:Java NetUtils.findAvailableSocketPort方法的具体用法?Java NetUtils.findAvailableSocketPort怎么用?Java NetUtils.findAvailableSocketPort使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.util.net.NetUtils的用法示例。


在下文中一共展示了NetUtils.findAvailableSocketPort方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getJavacManager

import com.intellij.util.net.NetUtils; //导入方法依赖的package包/类
@Nullable
private ExternalJavacManager getJavacManager() throws IOException {
  ExternalJavacManager manager = myExternalJavacManager;
  if (manager == null) {
    synchronized (this) {
      manager = myExternalJavacManager;
      if (manager == null) {
        final File compilerWorkingDir = getJavacCompilerWorkingDir();
        if (compilerWorkingDir == null) {
          return null; // should not happen for real projects
        }
        final int listenPort = NetUtils.findAvailableSocketPort();
        manager = new ExternalJavacManager(compilerWorkingDir);
        manager.start(listenPort);
        myExternalJavacManager = manager;
      }
    }
  }
  return manager;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:CompilerManagerImpl.java

示例2: MyRunnableState

import com.intellij.util.net.NetUtils; //导入方法依赖的package包/类
public MyRunnableState(@NotNull ExternalSystemTaskExecutionSettings settings,
                       @NotNull Project project,
                       boolean debug,
                       @NotNull ExternalSystemRunConfiguration configuration,
                       @NotNull ExecutionEnvironment env) {
  mySettings = settings;
  myProject = project;
  myConfiguration = configuration;
  myEnv = env;
  int port;
  if (debug) {
    try {
      port = NetUtils.findAvailableSocketPort();
    }
    catch (IOException e) {
      LOG.warn("Unexpected I/O exception occurred on attempt to find a free port to use for external system task debugging", e);
      port = 0;
    }
  }
  else {
    port = 0;
  }
  myDebugPort = port;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:ExternalSystemRunConfiguration.java

示例3: MyRunnableState

import com.intellij.util.net.NetUtils; //导入方法依赖的package包/类
public MyRunnableState(@NotNull ExternalSystemTaskExecutionSettings settings, @NotNull Project project, boolean debug) {
  mySettings = settings;
  myProject = project;
  int port;
  if (debug) {
    try {
      port = NetUtils.findAvailableSocketPort();
    }
    catch (IOException e) {
      LOG.warn("Unexpected I/O exception occurred on attempt to find a free port to use for external system task debugging", e);
      port = 0;
    }
  }
  else {
    port = 0;
  }
  myDebugPort = port;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:19,代码来源:ExternalSystemRunConfiguration.java

示例4: MyRunnableState

import com.intellij.util.net.NetUtils; //导入方法依赖的package包/类
public MyRunnableState(@Nonnull ExternalSystemTaskExecutionSettings settings, @Nonnull Project project, boolean debug) {
  mySettings = settings;
  myProject = project;
  int port;
  if (debug) {
    try {
      port = NetUtils.findAvailableSocketPort();
    }
    catch (IOException e) {
      LOG.warn("Unexpected I/O exception occurred on attempt to find a free port to use for external system task debugging", e);
      port = 0;
    }
  }
  else {
    port = 0;
  }
  myDebugPort = port;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:19,代码来源:ExternalSystemRunConfiguration.java

示例5: createJavaParameters

import com.intellij.util.net.NetUtils; //导入方法依赖的package包/类
@Override
protected JavaParameters createJavaParameters() throws ExecutionException {
  final JavaParameters javaParameters = super.createJavaParameters();
  javaParameters.setupEnvs(getConfiguration().getPersistantData().getEnvs(), getConfiguration().getPersistantData().PASS_PARENT_ENVS);
  javaParameters.setMainClass("org.testng.RemoteTestNGStarter");

  try {
    port = NetUtils.findAvailableSocketPort();
  }
  catch (IOException e) {
    throw new ExecutionException("Unable to bind to port " + port, e);
  }

  final TestData data = getConfiguration().getPersistantData();

  javaParameters.getProgramParametersList().add(supportSerializationProtocol(getConfiguration()) ? RemoteArgs.PORT : CommandLineArgs.PORT, String.valueOf(port));

  if (data.getOutputDirectory() != null && !data.getOutputDirectory().isEmpty()) {
    javaParameters.getProgramParametersList().add(CommandLineArgs.OUTPUT_DIRECTORY, data.getOutputDirectory());
  }

  javaParameters.getProgramParametersList().add(CommandLineArgs.USE_DEFAULT_LISTENERS, String.valueOf(data.USE_DEFAULT_REPORTERS));

  @NonNls final StringBuilder buf = new StringBuilder();
  if (data.TEST_LISTENERS != null && !data.TEST_LISTENERS.isEmpty()) {
    buf.append(StringUtil.join(data.TEST_LISTENERS, ";"));
  }
  collectListeners(javaParameters, buf, IDEATestNGListener.EP_NAME, ";");
  if (buf.length() > 0) javaParameters.getProgramParametersList().add(CommandLineArgs.LISTENER, buf.toString());

  createServerSocket(javaParameters);
  createTempFiles(javaParameters);
  return javaParameters;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:35,代码来源:TestNGRunnableState.java

示例6: init

import com.intellij.util.net.NetUtils; //导入方法依赖的package包/类
@BeforeClass
public static void init() throws Exception {
  int port = NetUtils.findAvailableSocketPort();
  STAT_URL = "http://localhost:" + port + "/stat.jsp";
  STAT_CONFIG_URL = "http://localhost:" + port + "/config.jsp";
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:7,代码来源:RemotelyConfigurableStatServiceTest.java

示例7: createProcessHandler

import com.intellij.util.net.NetUtils; //导入方法依赖的package包/类
private void createProcessHandler() {

        // Make sure we have a node interpreter
        final String nodeInterpreter = getNodeInterpreter(project);
        if (nodeInterpreter == null) {
            if(log.isDebugEnabled()) {
                log.debug("Can't create process handler: No Node.js interpreter configured.");
            }
            return;
        }

        try {

            if(log.isDebugEnabled()) {
                log.debug("Resolving node.js file...");
            }

            final File jsGraphQLNodeFile = getOrCreateJSGraphQLLanguageServiceFileName();
            if(jsGraphQLNodeFile == null) {
                if(log.isDebugEnabled()) {
                    log.debug("Can't create process handler: Got null from getOrCreateJSGraphQLLanguageServiceFileName.");
                }
                return;
            }

            final int socketPort = NetUtils.findAvailableSocketPort();
            final GeneralCommandLine commandLine = new GeneralCommandLine(nodeInterpreter);

            commandLine.withWorkDirectory(jsGraphQLNodeFile.getParent());
            commandLine.addParameter(jsGraphQLNodeFile.getAbsolutePath());

            commandLine.addParameter("--port=" + socketPort);

            if(log.isDebugEnabled()) {
                log.debug("Creating processHandler using command line " + commandLine.toString());
            }

            processHandler = new OSProcessHandler(commandLine);
            JSGraphQLLanguageUIProjectService languageService = JSGraphQLLanguageUIProjectService.getService(project);
            final Runnable onInitialized = languageService.connectToProcessHandler(processHandler);

            if (waitForListeningNotification(processHandler, project)) {
                url = new URL("http", NetUtils.getLocalHostString(), socketPort, JSGRAPHQL_LANGUAGE_SERVICE_MAPPING);
                onInitialized.run();
            } else {
                log.error("Unable to start JS GraphQL Language Service using Node.js with commandline " + commandLine.toString());
            }



        } catch (IOException | ExecutionException e) {
            if (e instanceof ProcessNotCreatedException) {
                Notifications.Bus.notify(new Notification("GraphQL", "Unable to start JS GraphQL Language Service", "Node.js was not started: " + e.getMessage(), NotificationType.ERROR));
            } else {
                log.error("Error running JS GraphQL Language Service using Node.js", e);
            }
        }
    }
 
开发者ID:jimkyndemeyer,项目名称:js-graphql-intellij-plugin,代码行数:59,代码来源:JSGraphQLNodeLanguageServiceInstance.java


注:本文中的com.intellij.util.net.NetUtils.findAvailableSocketPort方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。