static boolean shouldLoadPlugins() {
   try {
     // no plugins during bootstrap
     Class.forName("com.intellij.openapi.extensions.Extensions");
   } catch (ClassNotFoundException e) {
     return false;
   }
   //noinspection HardCodedStringLiteral
   final String loadPlugins = System.getProperty("idea.load.plugins");
   return loadPlugins == null || Boolean.TRUE.toString().equals(loadPlugins);
 }
Beispiel #2
0
  /** Main client entry point for stand-alone operation. */
  public static void main(String[] args) {
    BasicConfigurator.configure(new ConsoleAppender(new PatternLayout("%d [%-25t] %-5p: %m%n")));

    CmdLineParser parser = new CmdLineParser();
    CmdLineParser.Option help = parser.addBooleanOption('h', "help");
    CmdLineParser.Option output = parser.addStringOption('o', "output");
    CmdLineParser.Option iface = parser.addStringOption('i', "iface");

    try {
      parser.parse(args);
    } catch (CmdLineParser.OptionException oe) {
      System.err.println(oe.getMessage());
      usage(System.err);
      System.exit(1);
    }

    // Display help and exit if requested
    if (Boolean.TRUE.equals(parser.getOptionValue(help))) {
      usage(System.out);
      System.exit(0);
    }

    String outputValue = (String) parser.getOptionValue(output, DEFAULT_OUTPUT_DIRECTORY);
    String ifaceValue = (String) parser.getOptionValue(iface);

    String[] otherArgs = parser.getRemainingArgs();
    if (otherArgs.length != 1) {
      usage(System.err);
      System.exit(1);
    }

    try {
      Client c = new Client(getIPv4Address(ifaceValue));
      SharedTorrent torrent =
          SharedTorrent.fromFile(new File(otherArgs[0]), new File(outputValue), false);
      c.addTorrent(torrent);

      // Set a shutdown hook that will stop the sharing/seeding and send
      // a STOPPED announce request.
      Runtime.getRuntime().addShutdownHook(new Thread(new ClientShutdown(c, null)));

      c.share();
      if (ClientState.ERROR.equals(torrent.getClientState())) {
        System.exit(1);
      }
    } catch (Exception e) {
      logger.error("Fatal error: {}", e.getMessage(), e);
      System.exit(2);
    }
  }
Beispiel #3
0
 public static synchronized IFileArtifactRepository getBundlePoolRepository(
     IProvisioningAgent agent, IProfile profile) {
   URI location = getBundlePoolLocation(agent, profile);
   if (location == null) return null;
   IArtifactRepositoryManager manager = getArtifactRepositoryManager(agent);
   try {
     return (IFileArtifactRepository) manager.loadRepository(location, null);
   } catch (ProvisionException e) {
     // the repository doesn't exist, so fall through and create a new one
   }
   try {
     String repositoryName = Messages.BundlePool;
     Map<String, String> properties = new HashMap<String, String>(1);
     properties.put(IRepository.PROP_SYSTEM, Boolean.TRUE.toString());
     return (IFileArtifactRepository)
         manager.createRepository(location, repositoryName, REPOSITORY_TYPE, properties);
   } catch (ProvisionException e) {
     LogHelper.log(e);
     throw new IllegalArgumentException(NLS.bind(Messages.bundle_pool_not_writeable, location));
   }
 }