org.eclipse.equinox.p2.director.app_1.0.300.v20120428-0517

 172: aload_0
    //   173: aload_3
    //   174: aload 4
    //   176: invokeinterface 1746 2 0
    //   181: putfield 1460	org/eclipse/equinox/internal/p2/director/app/DirectorApplication:targetAgent	Lorg/eclipse/equinox/p2/core/IProvisioningAgent;
    //   184: aload_0
    //   185: getfield 1460	org/eclipse/equinox/internal/p2/director/app/DirectorApplication:targetAgent	Lorg/eclipse/equinox/p2/core/IProvisioningAgent;
    //   188: ldc_w 717
    //   191: aload_3
    //   192: aconst_null
    //   193: invokeinterface 1746 2 0
    //   198: invokeinterface 1744 3 0
    //   203: aload_1
    //   204: aload_2
    //   205: invokeinterface 1784 2 0
    //   210: pop
    //   211: aload_0
    //   212: getfield 1419	org/eclipse/equinox/internal/p2/director/app/DirectorApplication:profileId	Ljava/lang/String;
    //   215: ifnonnull +146 -> 361
    //   218: aload_0
    //   219: getfield 1404	org/eclipse/equinox/internal/p2/director/app/DirectorApplication:destination	Ljava/io/File;
    //   222: ifnull +139 -> 361
    //   225: new 736	java/io/File
    //   228: dup
    //   229: aload_0
    //   230: getfield 1404	org/eclipse/equinox/internal/p2/director/app/DirectorApplication:destination	Ljava/io/File;
    //   233: ldc_w 701
    //   236: invokespecial 1543	java/io/File:<init>	(Ljava/io/File;Ljava/lang/String;)V
    //   239: astore 5
    //   241: aconst_null
    //   242: astore 6
    //   244: new 766	java/util/Properties
    //   247: dup
    //   248: invokespecial 1604	java/util/Properties:<init>	()V
    //   251: astore 7
    //   253: new 735	java/io/BufferedInputStream
    //   256: dup
    //   257: new 737	java/io/FileInputStream
    //   260: dup
    //   261: aload 5
    //   263: invokespecial 1544	java/io/FileInputStream:<init>	(Ljava/io/File;)V
    //   266: invokespecial 1534	java/io/BufferedInputStream:<init>	(Ljava/io/InputStream;)V
    //   269: astore 6
    //   271: aload 7
    //   273: aload 6
    //   275: invokevirtual 1605	java/util/Properties:load	(Ljava/io/InputStream;)V
    //   278: aload_0
    //   279: aload 7
    //   281: ldc 27
    //   283: invokevirtual 1608	java/util/Properties:getProperty	(Ljava/lang/String;)Ljava/lang/String;
    //   286: putfield 1419	org/eclipse/equinox/internal/p2/director/app/DirectorApplication:profileId	Ljava/lang/String;
    //   289: goto +40 -> 329
    //   292: pop
    //   293: aload 6
    //   295: ifnull +48 -> 343
    //   298: aload 6
    //   300: invokevirtual 1545	java/io/InputStream:close	()V
    //   303: goto +40 -> 343
    //   306: pop
    //   307: goto +36 -> 343
    //   310: astore 8
    //   312: aload 6
    //   314: ifnull +12 -> 326
    //   317: aload 6
    //   319: invokevirtual 1545	java/io/InputStream:close	()V
    //   322: goto +4 -> 326
    //   325: pop
    //   326: aload 8
    //   328: athrow
    //   329: aload 6
    //   331: ifnull +12 -> 343
    //   334: aload 6
    //   336: invokevirtual 1545	java/io/InputStream:close	()V
    //   339: goto +4 -> 343
    //   342: pop
    //   343: aload_0
    //   344: getfield 1419	org/eclipse/equinox/internal/p2/director/app/DirectorApplication:profileId	Ljava/lang/String;
    //   347: ifnonnull +14 -> 361
    //   350: aload_0
    //   351: aload_0
    //   352: getfield 1404	org/eclipse/equinox/internal/p2/director/app/DirectorApplication:destination	Ljava/io/File;
    //   355: invokevirtual 1540	java/io/File:toString	()Ljava/lang/String;
    //   358: putfield 1419	org/eclipse/equinox/internal/p2/director/app/DirectorApplication:profileId	Ljava/lang/String;
    //   361: aload_0
    //   362: getfield 1419	org/eclipse/equinox/internal/p2/director/app/DirectorApplication:profileId	Ljava/lang/String;
    //   365: ifnull +21 -> 386
    //   368: aload_0
    //   369: getfield 1460	org/eclipse/equinox/internal/p2/director/app/DirectorApplication:targetAgent	Lorg/eclipse/equinox/p2/core/IProvisioningAgent;
    //   372: ldc 27
    //   374: aload_0
    //   375: getfield 1419	org/eclipse/equinox/internal/p2/director/app/DirectorApplication:profileId	Ljava/lang/String;
    //   378: invokeinterface 1744 3 0
    //   383: goto +15 -> 398
    //   386: aload_0
    //   387: getfield 1460	org/eclipse/equinox/internal/p2/director/app/DirectorApplication:targetAgent	Lorg/eclipse/equinox/p2/core/IProvisioningAgent;
    //   390: ldc 27
    //   392: aconst_null
    //   393: invokeinterface 1745 3 0
    //   398: aload_0
    //   399: getfield 1460	org/eclipse/equinox/internal/p2/director/app/DirectorApplication:targetAgent	Lorg/eclipse/equinox/p2/core/IProvisioningAgent;
    //   402: getstatic 1523	org/eclipse/equinox/internal/provisional/p2/director/IDirector:SERVICE_NAME	Ljava/lang/String;
    //   405: invokeinterface 1743 2 0
    //   410: checkcast 793	org/eclipse/equinox/internal/provisional/p2/director/IDirector
    //   413: astore 5
    //   415: aload 5
    //   417: ifnonnull +14 -> 431
    //   420: new 798	org/eclipse/equinox/p2/core/ProvisionException
    //   423: dup
    //   424: getstatic 1510	org/eclipse/equinox/internal/p2/director/app/Messages:Missing_director	Ljava/lang/String;
    //   427: invokespecial 1689	org/eclipse/equinox/p2/core/ProvisionException:<init>	(Ljava/lang/String;)V
    //   430: athrow
    //   431: aload_0
    //   432: aload_0
    //   433: getfield 1460	org/eclipse/equinox/internal/p2/director/app/DirectorApplication:targetAgent	Lorg/eclipse/equinox/p2/core/IProvisioningAgent;
    //   436: getstatic 1531	org/eclipse/equinox/p2/planner/IPlanner:SERVICE_NAME	Ljava/lang/String;
    //   439: invokeinterface 1743 2 0
    //   444: checkcast 812	org/eclipse/equinox/p2/planner/IPlanner
    //   447: putfield 1462	org/eclipse/equinox/internal/p2/director/app/DirectorApplication:planner	Lorg/eclipse/equinox/p2/planner/IPlanner;
    //   450: aload_0
    //   451: getfield 1462	org/eclipse/equinox/internal/p2/director/app/DirectorApplication:planner	Lorg/eclipse/equinox/p2/planner/IPlanner;
    //   454: ifnonnull +14 -> 468
    //   457: new 798	org/eclipse/equinox/p2/core/ProvisionException
    //   460: dup
    //   461: getstatic 1511	org/eclipse/equinox/internal/p2/director/app/Messages:Missing_planner	Ljava/lang/String;
    //   464: invokespecial 1689	org/eclipse/equinox/p2/core/ProvisionException:<init>	(Ljava/lang/String;)V
    //   467: athrow
    //   468: aload_0
    //   469: aload_0
    //   470: getfield 1460	org/eclipse/equinox/internal/p2/director/app/DirectorApplication:targetAgent	Lorg/eclipse/equinox/p2/core/IProvisioningAgent;
    //   473: getstatic 1525	org/eclipse/equinox/p2/engine/IEngine:SERVICE_NAME	Ljava/lang/String;
    //   476: invokeinterface 1743 2 0
    //   481: checkcast 800	org/eclipse/equinox/p2/engine/IEngine
    //   484: putfield 1461	org/eclipse/equinox/internal/p2/director/app/DirectorApplication:engine	Lorg/eclipse/equinox/p2/engine/IEngine;
    //   487: aload_0
    //   488: getfield 1461	org/eclipse/equinox/internal/p2/director/app/DirectorApplication:engine	Lorg/eclipse/equinox/p2/engine/IEngine;
    //   491: ifnonnull +14 -> 505
    //   494: new 798	org/eclipse/equinox/p2/core/ProvisionException
    //   497: dup
    //   498: getstatic 1507	org/eclipse/equinox/internal/p2/director/app/Messages:Missing_Engine	Ljava/lang/String;
    //   501: invokespecial 1689	org/eclipse/equinox/p2/core/ProvisionException:<init>	(Ljava/lang/String;)V
    //   504: athrow
    //   505: aload_0
    //   506: getfield 1460	org/eclipse/equinox/internal/p2/director/app/DirectorApplication:targetAgent	Lorg/eclipse/equinox/p2/core/IProvisioningAgent;
    //   509: getstatic 1524	org/eclipse/equinox/p2/core/UIServices:SERVICE_NAME	Ljava/lang/String;
    //   512: new 785	org/eclipse/equinox/internal/p2/director/app/DirectorApplication$AvoidTrustPromptService
    //   515: dup
    //   516: invokespecial 1678	org/eclipse/equinox/internal/p2/director/app/DirectorApplication$AvoidTrustPromptService:<init>	()V
    //   519: invokeinterface 1744 3 0
    //   524: aload_0
    //   525: getfield 1460	org/eclipse/equinox/internal/p2/director/app/DirectorApplication:targetAgent	Lorg/eclipse/equinox/p2/core/IProvisioningAgent;
    //   528: getstatic 1522	org/eclipse/equinox/internal/provisional/p2/core/eventbus/IProvisioningEventBus:SERVICE_NAME	Ljava/lang/String;
    //   531: invokeinterface 1743 2 0
    //   536: checkcast 791	org/eclipse/equinox/internal/provisional/p2/core/eventbus/IProvisioningEventBus
    //   539: astore 6
    //   541: aload 6
    //   543: ifnonnull +4 -> 547
    //   546: return
    //   547: aload 6
    //   549: aload_0
    //   550: invokeinterface 1740 2 0
    //   555: return
    // Line number table:
    //   Java source line #571	-> byte code offset #0
    //   Java source line #572	-> byte code offset #4
    //   Java source line #573	-> byte code offset #47
    //   Java source line #574	-> byte code offset #64
    //   Java source line #575	-> byte code offset #104
    //   Java source line #577	-> byte code offset #115
    //   Java source line #578	-> byte code offset #129
    //   Java source line #579	-> byte code offset #159
    //   Java source line #581	-> byte code offset #169
    //   Java source line #583	-> byte code offset #172
    //   Java source line #584	-> byte code offset #184
    //   Java source line #586	-> byte code offset #203
    //   Java source line #587	-> byte code offset #211
    //   Java source line #588	-> byte code offset #218
    //   Java source line #589	-> byte code offset #225
    //   Java source line #590	-> byte code offset #241
    //   Java source line #592	-> byte code offset #244
    //   Java source line #593	-> byte code offset #253
    //   Java source line #594	-> byte code offset #271
    //   Java source line #595	-> byte code offset #278
    //   Java source line #596	-> byte code offset #292
    //   Java source line #599	-> byte code offset #293
    //   Java source line #601	-> byte code offset #298
    //   Java source line #602	-> byte code offset #306
    //   Java source line #598	-> byte code offset #310
    //   Java source line #599	-> byte code offset #312
    //   Java source line #601	-> byte code offset #317
    //   Java source line #602	-> byte code offset #325
    //   Java source line #605	-> byte code offset #326
    //   Java source line #599	-> byte code offset #329
    //   Java source line #601	-> byte code offset #334
    //   Java source line #602	-> byte code offset #342
    //   Java source line #606	-> byte code offset #343
    //   Java source line #607	-> byte code offset #350
    //   Java source line #610	-> byte code offset #361
    //   Java source line #611	-> byte code offset #368
    //   Java source line #613	-> byte code offset #386
    //   Java source line #615	-> byte code offset #398
    //   Java source line #616	-> byte code offset #415
    //   Java source line #617	-> byte code offset #420
    //   Java source line #619	-> byte code offset #431
    //   Java source line #620	-> byte code offset #450
    //   Java source line #621	-> byte code offset #457
    //   Java source line #623	-> byte code offset #468
    //   Java source line #624	-> byte code offset #487
    //   Java source line #625	-> byte code offset #494
    //   Java source line #627	-> byte code offset #505
    //   Java source line #630	-> byte code offset #524
    //   Java source line #631	-> byte code offset #541
    //   Java source line #632	-> byte code offset #546
    //   Java source line #633	-> byte code offset #547
    //   Java source line #635	-> byte code offset #555
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	556	0	this	DirectorApplication
    //   3	201	1	context	BundleContext
    //   103	102	2	agentProviderRef	ServiceReference<org.eclipse.equinox.p2.core.IProvisioningAgentProvider>
    //   114	78	3	provider	org.eclipse.equinox.p2.core.IProvisioningAgentProvider
    //   164	3	4	p2DataArea	URI
    //   170	5	4	p2DataArea	URI
    //   157	3	5	dataAreaFile	File
    //   239	23	5	configIni	File
    //   413	3	5	director	org.eclipse.equinox.internal.provisional.p2.director.IDirector
    //   242	93	6	in	java.io.InputStream
    //   539	9	6	eventBus	IProvisioningEventBus
    //   251	29	7	ciProps	Properties
    //   310	17	8	localObject	Object
    //   27	1	13	localClassNotFoundException1	ClassNotFoundException
    //   86	1	14	localClassNotFoundException2	ClassNotFoundException
    //   292	1	15	localIOException1	java.io.IOException
    //   306	1	16	localIOException2	java.io.IOException
    //   325	1	17	localIOException3	java.io.IOException
    //   342	1	18	localIOException4	java.io.IOException
    // Exception table:
    //   from	to	target	type
    //   14	20	27	java/lang/ClassNotFoundException
    //   73	79	86	java/lang/ClassNotFoundException
    //   244	289	292	java/io/IOException
    //   298	303	306	java/io/IOException
    //   244	293	310	finally
    //   317	322	325	java/io/IOException
    //   334	339	342	java/io/IOException
  }
  
  public void notify(EventObject o)
  {
    if (!(o instanceof RepositoryEvent)) {
      return;
    }
    RepositoryEvent event = (RepositoryEvent)o;
    if (event.getKind() != 0) {
      return;
    }
    int type = event.getRepositoryType();
    URI location = event.getRepositoryLocation();
    if (1 == type)
    {
      for (int i = 0; i < artifactReposForRemoval.length; i++) {
        if ((artifactReposForRemoval[i] != null) && (URIUtil.sameURI(artifactReposForRemoval[i], location)))
        {
          artifactReposForRemoval[i] = null;
          break;
        }
      }
      return;
    }
    if (type == 0)
    {
      for (int i = 0; i < metadataReposForRemoval.length; i++) {
        if ((metadataReposForRemoval[i] != null) && (URIUtil.sameURI(metadataReposForRemoval[i], location)))
        {
          metadataReposForRemoval[i] = null;
          break;
        }
      }
      return;
    }
  }
  
  private void logStatus(IStatus status)
  {
    if (log != null) {
      log.log(status);
    } else {
      LogHelper.log(status);
    }
  }
  
  private void printMessage(String message)
  {
    if (log != null) {
      log.log(message);
    } else {
      System.out.println(message);
    }
  }
  
  private void logFailure(IStatus status)
  {
    if (log == null)
    {
      FrameworkLog frameworkLog = (FrameworkLog)ServiceHelper.getService(Activator.getContext(), FrameworkLog.class.getName());
      if (frameworkLog != null) {
        System.err.println("Application failed, log file location: " + frameworkLog.getFile());
      }
    }
    logStatus(status);
  }
  
  private void markRoots(IProfileChangeRequest request, Collection<IInstallableUnit> roots)
  {
    for (Iterator localIterator = roots.iterator(); localIterator.hasNext();)
    {
      IInstallableUnit root = (IInstallableUnit)localIterator.next();
      request.setInstallableUnitProfileProperty(root, "org.eclipse.equinox.p2.type.root", Boolean.TRUE.toString());
    }
  }
  
  private void missingArgument(String argumentName)
    throws CoreException
  {
    throw new ProvisionException(NLS.bind(Messages.Missing_Required_Argument, argumentName));
  }
  
  private void performList()
    throws CoreException
  {
    if (metadataRepositoryLocations.isEmpty()) {
      missingArgument("metadataRepository");
    }
    ArrayList<IInstallableUnit> allRoots = new ArrayList();
    if (rootsToList.size() == 0)
    {
      Iterator<IInstallableUnit> roots = collectRootIUs(QueryUtil.createIUAnyQuery()).iterator();
      while (roots.hasNext()) {
        allRoots.add((IInstallableUnit)roots.next());
      }
    }
    else
    {
      Iterator<IInstallableUnit> roots;
      for (localIterator = rootsToList.iterator(); localIterator.hasNext(); roots.hasNext())
      {
        IQuery<IInstallableUnit> root = (IQuery)localIterator.next();
        roots = collectRootIUs(root).iterator();
        continue;
        allRoots.add((IInstallableUnit)roots.next());
      }
    }
    Collections.sort(allRoots);
    for (Iterator localIterator = allRoots.iterator(); localIterator.hasNext();)
    {
      IInstallableUnit iu = (IInstallableUnit)localIterator.next();
      System.out.println(iu.getId() + '=' + iu.getVersion());
    }
  }
  
  /* Error */
  private void performProvisioningActions()
    throws CoreException
  {
    // Byte code:
    //   0: aload_0
    //   1: invokespecial 1653	org/eclipse/equinox/internal/p2/director/app/DirectorApplication:initializeProfile	()Lorg/eclipse/equinox/p2/engine/IProfile;
    //   4: astore_1
    //   5: aload_0
    //   6: aload_1
    //   7: aload_0
    //   8: getfield 1428	org/eclipse/equinox/internal/p2/director/app/DirectorApplication:rootsToInstall	Ljava/util/List;
    //   11: iconst_1
    //   12: invokespecial 1674	org/eclipse/equinox/internal/p2/director/app/DirectorApplication:collectRoots	(Lorg/eclipse/equinox/p2/engine/IProfile;Ljava/util/List;Z)Ljava/util/Collection;
    //   15: astore_2
    //   16: aload_0
    //   17: aload_1
    //   18: aload_0
    //   19: getfield 1430	org/eclipse/equinox/internal/p2/director/app/DirectorApplication:rootsToUninstall	Ljava/util/List;
    //   22: iconst_0
    //   23: invokespecial 1674	org/eclipse/equinox/internal/p2/director/app/DirectorApplication:collectRoots	(Lorg/eclipse/equinox/p2/engine/IProfile;Ljava/util/List;Z)Ljava/util/Collection;
    //   26: astore_3
    //   27: aload_1
    //   28: ldc_w 718
    //   31: invokeinterface 1749 2 0
    //   36: invokestatic 1551	java/lang/Boolean:valueOf	(Ljava/lang/String;)Ljava/lang/Boolean;
    //   39: invokevirtual 1549	java/lang/Boolean:booleanValue	()Z
    //   42: istore 4
    //   44: aload_0
    //   45: aload_1
    //   46: invokespecial 1654	org/eclipse/equinox/internal/p2/director/app/DirectorApplication:updateRoamingProperties	(Lorg/eclipse/equinox/p2/engine/IProfile;)V
    //   49: new 805	org/eclipse/equinox/p2/engine/ProvisioningContext
    //   52: dup
    //   53: aload_0
    //   54: getfield 1460	org/eclipse/equinox/internal/p2/director/app/DirectorApplication:targetAgent	Lorg/eclipse/equinox/p2/core/IProvisioningAgent;
    //   57: invokespecial 1694	org/eclipse/equinox/p2/engine/ProvisioningContext:<init>	(Lorg/eclipse/equinox/p2/core/IProvisioningAgent;)V
    //   60: astore 5
    //   62: aload 5
    //   64: aload_0
    //   65: getfield 1427	org/eclipse/equinox/internal/p2/director/app/DirectorApplication:metadataRepositoryLocations	Ljava/util/List;
    //   68: aload_0
    //   69: getfield 1427	org/eclipse/equinox/internal/p2/director/app/DirectorApplication:metadataRepositoryLocations	Ljava/util/List;
    //   72: invokeinterface 1713 1 0
    //   77: anewarray 755	java/net/URI
    //   80: invokeinterface 1718 2 0
    //   85: checkcast 734	[Ljava/net/URI;
    //   88: invokevirtual 1693	org/eclipse/equinox/p2/engine/ProvisioningContext:setMetadataRepositories	([Ljava/net/URI;)V
    //   91: aload 5
    //   93: aload_0
    //   94: getfield 1426	org/eclipse/equinox/internal/p2/director/app/DirectorApplication:artifactRepositoryLocations	Ljava/util/List;
    //   97: aload_0
    //   98: getfield 1426	org/eclipse/equinox/internal/p2/director/app/DirectorApplication:artifactRepositoryLocations	Ljava/util/List;
    //   101: invokeinterface 1713 1 0
    //   106: anewarray 755	java/net/URI
    //   109: invokeinterface 1718 2 0
    //   114: checkcast 734	[Ljava/net/URI;
    //   117: invokevirtual 1692	org/eclipse/equinox/p2/engine/ProvisioningContext:setArtifactRepositories	([Ljava/net/URI;)V
    //   120: aload 5
    //   122: ldc_w 714
    //   125: aload_0
    //   126: getfield 1392	org/eclipse/equinox/internal/p2/director/app/DirectorApplication:followReferences	Z
    //   129: invokestatic 1572	java/lang/String:valueOf	(Z)Ljava/lang/String;
    //   132: invokevirtual 1695	org/eclipse/equinox/p2/engine/ProvisioningContext:setProperty	(Ljava/lang/String;Ljava/lang/String;)V
    //   135: aload 5
    //   137: ldc 30
    //   139: aload_0
    //   140: getfield 1392	org/eclipse/equinox/internal/p2/director/app/DirectorApplication:followReferences	Z
    //   143: invokestatic 1572	java/lang/String:valueOf	(Z)Ljava/lang/String;
    //   146: invokevirtual 1695	org/eclipse/equinox/p2/engine/ProvisioningContext:setProperty	(Ljava/lang/String;Ljava/lang/String;)V
    //   149: aload_0
    //   150: aload_1
    //   151: aload_2
    //   152: aload_3
    //   153: invokespecial 1676	org/eclipse/equinox/internal/p2/director/app/DirectorApplication:buildProvisioningRequest	(Lorg/eclipse/equinox/p2/engine/IProfile;Ljava/util/Collection;Ljava/util/Collection;)Lorg/eclipse/equinox/internal/p2/director/ProfileChangeRequest;
    //   156: astore 6
    //   158: aload_0
    //   159: aload 6
    //   161: invokespecial 1651	org/eclipse/equinox/internal/p2/director/app/DirectorApplication:printRequest	(Lorg/eclipse/equinox/internal/p2/director/ProfileChangeRequest;)V
    //   164: aload_0
    //   165: aload_1
    //   166: aload 5
    //   168: aload 6
    //   170: invokespecial 1675	org/eclipse/equinox/internal/p2/director/app/DirectorApplication:planAndExecute	(Lorg/eclipse/equinox/p2/engine/IProfile;Lorg/eclipse/equinox/p2/engine/ProvisioningContext;Lorg/eclipse/equinox/internal/p2/director/ProfileChangeRequest;)V
    //   173: goto +37 -> 210
    //   176: astore 7
    //   178: iload 4
    //   180: ifeq +27 -> 207
    //   183: aload_1
    //   184: ldc_w 718
    //   187: invokeinterface 1749 2 0
    //   192: invokestatic 1551	java/lang/Boolean:valueOf	(Ljava/lang/String;)Ljava/lang/Boolean;
    //   195: invokevirtual 1549	java/lang/Boolean:booleanValue	()Z
    //   198: ifne +9 -> 207
    //   201: aload_0
    //   202: aload_1
    //   203: invokespecial 1671	org/eclipse/equinox/internal/p2/director/app/DirectorApplication:setRoaming	(Lorg/eclipse/equinox/p2/engine/IProfile;)Lorg/eclipse/core/runtime/IStatus;
    //   206: pop
    //   207: aload 7
    //   209: athrow
    //   210: iload 4
    //   212: ifeq +27 -> 239
    //   215: aload_1
    //   216: ldc_w 718
    //   219: invokeinterface 1749 2 0
    //   224: invokestatic 1551	java/lang/Boolean:valueOf	(Ljava/lang/String;)Ljava/lang/Boolean;
    //   227: invokevirtual 1549	java/lang/Boolean:booleanValue	()Z
    //   230: ifne +9 -> 239
    //   233: aload_0
    //   234: aload_1
    //   235: invokespecial 1671	org/eclipse/equinox/internal/p2/director/app/DirectorApplication:setRoaming	(Lorg/eclipse/equinox/p2/engine/IProfile;)Lorg/eclipse/core/runtime/IStatus;
    //   238: pop
    //   239: return
    // Line number table:
    //   Java source line #732	-> byte code offset #0
    //   Java source line #733	-> byte code offset #5
    //   Java source line #734	-> byte code offset #16
    //   Java source line #737	-> byte code offset #27
    //   Java source line #739	-> byte code offset #44
    //   Java source line #740	-> byte code offset #49
    //   Java source line #741	-> byte code offset #62
    //   Java source line #742	-> byte code offset #91
    //   Java source line #743	-> byte code offset #120
    //   Java source line #744	-> byte code offset #135
    //   Java source line #745	-> byte code offset #149
    //   Java source line #746	-> byte code offset #158
    //   Java source line #747	-> byte code offset #164
    //   Java source line #748	-> byte code offset #176
    //   Java source line #750	-> byte code offset #178
    //   Java source line #751	-> byte code offset #201
    //   Java source line #752	-> byte code offset #207
    //   Java source line #750	-> byte code offset #210
    //   Java source line #751	-> byte code offset #233
    //   Java source line #753	-> byte code offset #239
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	240	0	this	DirectorApplication
    //   4	231	1	profile	IProfile
    //   15	137	2	installs	Collection<IInstallableUnit>
    //   26	127	3	uninstalls	Collection<IInstallableUnit>
    //   42	169	4	wasRoaming	boolean
    //   60	107	5	context	ProvisioningContext
    //   156	13	6	request	ProfileChangeRequest
    //   176	32	7	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   44	176	176	finally
  }
  
  private void planAndExecute(IProfile profile, ProvisioningContext context, ProfileChangeRequest request)
    throws CoreException
  {
    IProvisioningPlan result = planner.getProvisioningPlan(request, context, new NullProgressMonitor());
    IStatus operationStatus = result.getStatus();
    if (!operationStatus.isOK()) {
      throw new CoreException(operationStatus);
    }
    executePlan(context, result);
  }
  
  private void executePlan(ProvisioningContext context, IProvisioningPlan result)
    throws CoreException
  {
    if (!verifyOnly)
    {
      IStatus operationStatus;
      IStatus operationStatus;
      if (!downloadOnly) {
        operationStatus = PlanExecutionHelper.executePlan(result, engine, context, new NullProgressMonitor());
      } else {
        operationStatus = PlanExecutionHelper.executePlan(result, engine, PhaseSetFactory.createPhaseSetIncluding(new String[] { PhaseSetFactory.PHASE_COLLECT, PhaseSetFactory.PHASE_CHECK_TRUST }), context, new NullProgressMonitor());
      }
      if (!operationStatus.isOK())
      {
        if ((noArtifactRepositorySpecified) && (hasNoRepositoryFound(operationStatus))) {
          throw new ProvisionException(Messages.Application_NoRepositories);
        }
        throw new CoreException(operationStatus);
      }
      if (tag != null)
      {
        long newState = result.getProfile().getTimestamp();
        IProfileRegistry registry = (IProfileRegistry)targetAgent.getService(IProfileRegistry.SERVICE_NAME);
        registry.setProfileStateProperty(result.getProfile().getProfileId(), newState, "org.eclipse.equinox.p2.state.tag", tag);
      }
    }
  }
  
  private boolean hasNoRepositoryFound(IStatus status)
  {
    if ((status.getException() != null) && ("noArtifactRepositoriesAvailable".equals(status.getException().getMessage()))) {
      return true;
    }
    if (status.isMultiStatus())
    {
      IStatus[] arrayOfIStatus;
      int j = (arrayOfIStatus = status.getChildren()).length;
      for (int i = 0; i < j; i++)
      {
        IStatus child = arrayOfIStatus[i];
        if (hasNoRepositoryFound(child)) {
          return true;
        }
      }
    }
    return false;
  }
  
  private void printRequest(ProfileChangeRequest request)
  {
    Collection<IInstallableUnit> toAdd = request.getAdditions();
    for (Iterator localIterator1 = toAdd.iterator(); localIterator1.hasNext();)
    {
      IInstallableUnit added = (IInstallableUnit)localIterator1.next();
      printMessage(NLS.bind(Messages.Installing, added.getId(), added.getVersion()));
    }
    Collection<IInstallableUnit> toRemove = request.getRemovals();
    for (Iterator localIterator2 = toRemove.iterator(); localIterator2.hasNext();)
    {
      IInstallableUnit removed = (IInstallableUnit)localIterator2.next();
      printMessage(NLS.bind(Messages.Uninstalling, removed.getId(), removed.getVersion()));
    }
  }
  
  public void processArguments(String[] args)
    throws CoreException
  {
    if (args == null)
    {
      printHelpInfo = true;
      return;
    }
    EnvironmentInfo info = (EnvironmentInfo)ServiceHelper.getService(Activator.getContext(), EnvironmentInfo.class.getName());
    os = info.getOS();
    ws = info.getWS();
    nl = info.getNL();
    arch = info.getOSArch();
    for (int i = 0; i < args.length; i++)
    {
      String opt = args[i];
      if (OPTION_LIST.isOption(opt))
      {
        printIUList = true;
        String optionalArgument = getOptionalArgument(args, i);
        if (optionalArgument != null)
        {
          parseIUsArgument(rootsToList, optionalArgument);
          i++;
        }
      }
      else if (OPTION_LIST_INSTALLED.isOption(opt))
      {
        printRootIUList = true;
      }
      else if (OPTION_LIST_TAGS.isOption(opt))
      {
        printTags = true;
      }
      else if (OPTION_DOWNLOAD_ONLY.isOption(opt))
      {
        downloadOnly = true;
      }
      else if (OPTION_HELP.isOption(opt))
      {
        printHelpInfo = true;
      }
      else if (OPTION_INSTALL_IU.isOption(opt))
      {
        parseIUsArgument(rootsToInstall, getRequiredArgument(args, ++i));
      }
      else if (OPTION_UNINSTALL_IU.isOption(opt))
      {
        parseIUsArgument(rootsToUninstall, getRequiredArgument(args, ++i));
      }
      else if (OPTION_REVERT.isOption(opt))
      {
        String targettedState = getOptionalArgument(args, i);
        if (targettedState == null)
        {
          revertToPreviousState = REVERT_TO_PREVIOUS;
        }
        else
        {
          i++;
          revertToPreviousState = targettedState;
        }
      }
      else if (OPTION_PROFILE.isOption(opt))
      {
        profileId = getRequiredArgument(args, ++i);
      }
      else if (OPTION_FLAVOR.isOption(opt))
      {
        flavor = getRequiredArgument(args, ++i);
      }
      else if (OPTION_SHARED.isOption(opt))
      {
        i++;
        if (i < args.length)
        {
          String nxt = args[i];
          if (nxt.startsWith("-")) {
            i--;
          } else {
            sharedLocation = processFileArgument(nxt);
          }
        }
        if (sharedLocation == null) {
          sharedLocation = Path.fromOSString(System.getProperty("user.home")).append(".p2/").toFile();
        }
      }
      else if (OPTION_DESTINATION.isOption(opt))
      {
        destination = processFileArgument(getRequiredArgument(args, ++i));
      }
      else if (OPTION_BUNDLEPOOL.isOption(opt))
      {
        bundlePool = processFileArgument(getRequiredArgument(args, ++i));
      }
      else if (OPTION_METADATAREPOS.isOption(opt))
      {
        getURIs(metadataRepositoryLocations, getRequiredArgument(args, ++i));
      }
      else if (OPTION_ARTIFACTREPOS.isOption(opt))
      {
        getURIs(artifactRepositoryLocations, getRequiredArgument(args, ++i));
      }
      else if (OPTION_REPOSITORIES.isOption(opt))
      {
        String arg = getRequiredArgument(args, ++i);
        getURIs(metadataRepositoryLocations, arg);
        getURIs(artifactRepositoryLocations, arg);
      }
      else if (OPTION_PROFILE_PROPS.isOption(opt))
      {
        profileProperties = getRequiredArgument(args, ++i);
      }
      else if (OPTION_IU_PROFILE_PROPS.isOption(opt))
      {
        iuProfileProperties = getRequiredArgument(args, ++i);
      }
      else if (OPTION_ROAMING.isOption(opt))
      {
        roamingProfile = true;
      }
      else if (OPTION_VERIFY_ONLY.isOption(opt))
      {
        verifyOnly = true;
      }
      else if (OPTION_PURGEHISTORY.isOption(opt))
      {
        purgeRegistry = true;
      }
      else if (OPTION_FOLLOW_REFERENCES.isOption(opt))
      {
        followReferences = true;
      }
      else if (OPTION_P2_OS.isOption(opt))
      {
        os = getRequiredArgument(args, ++i);
      }
      else if (OPTION_P2_WS.isOption(opt))
      {
        ws = getRequiredArgument(args, ++i);
      }
      else if (OPTION_P2_NL.isOption(opt))
      {
        nl = getRequiredArgument(args, ++i);
      }
      else if (OPTION_P2_ARCH.isOption(opt))
      {
        arch = getRequiredArgument(args, ++i);
      }
      else if (OPTION_TAG.isOption(opt))
      {
        tag = getRequiredArgument(args, ++i);
      }
      else if (OPTION_IGNORED.isOption(opt))
      {
        String optionalArgument = getOptionalArgument(args, i);
        if (optionalArgument != null) {
          i++;
        }
      }
      else
      {
        throw new ProvisionException(NLS.bind(Messages.unknown_option_0, opt));
      }
    }
    if ((!printHelpInfo) && (!printIUList) && (!printRootIUList) && (!printTags) && (!purgeRegistry) && (rootsToInstall.isEmpty()) && (rootsToUninstall.isEmpty()) && (revertToPreviousState == NOTHING_TO_REVERT_TO))
    {
      printMessage(Messages.Help_Missing_argument);
      printHelpInfo = true;
    }
  }
  
  private void putProperties(String pairs, Map<String, String> properties)
  {
    String[] propPairs = StringHelper.getArrayFromString(pairs, ',');
    for (int i = 0; i < propPairs.length; i++)
    {
      String propPair = propPairs[i];
      int eqIdx = propPair.indexOf('=');
      if (eqIdx >= 0)
      {
        String tag = propPair.substring(0, eqIdx).trim();
        if (tag.length() != 0)
        {
          String value = propPair.substring(eqIdx + 1).trim();
          if (value.length() > 0) {
            properties.put(tag, value);
          }
        }
      }
    }
  }
  
  private void cleanupServices()
  {
    BundleContext context = Activator.getContext();
    if (targetAgent != null)
    {
      targetAgent.stop();
      targetAgent = null;
    }
    if (packageAdminRef != null) {
      context.ungetService(packageAdminRef);
    }
  }
  
  public Object run(String[] args)
  {
    long time = System.currentTimeMillis();
    try
    {
      processArguments(args);
      if (printHelpInfo)
      {
        performHelpInfo();
      }
      else
      {
        initializeServices();
        initializeRepositories();
        if (revertToPreviousState != NOTHING_TO_REVERT_TO) {
          revertToPreviousState();
        } else if ((!rootsToInstall.isEmpty()) || (!rootsToUninstall.isEmpty())) {
          performProvisioningActions();
        }
        if (printIUList) {
          performList();
        }
        if (printRootIUList) {
          performListInstalledRoots();
        }
        if (printTags) {
          performPrintTags();
        }
        if (purgeRegistry) {
          purgeRegistry();
        }
        printMessage(NLS.bind(Messages.Operation_complete, new Long(System.currentTimeMillis() - time)));
      }
      return IApplication.EXIT_OK;
    }
    catch (CoreException e)
    {
      Integer localInteger;
      printMessage(Messages.Operation_failed);
      deeplyPrint(e.getStatus(), System.err, 0);
      logFailure(e.getStatus());
      
      setSystemProperty("eclipse.exitdata", "");
      return EXIT_ERROR;
    }
    finally
    {
      if (packageAdminRef != null)
      {
        cleanupRepositories();
        cleanupServices();
      }
    }
  }
  
  private void purgeRegistry()
    throws ProvisionException
  {
    if (getProfile() == null) {
      return;
    }
    IProfileRegistry registry = (IProfileRegistry)targetAgent.getService(IProfileRegistry.SERVICE_NAME);
    long[] allProfiles = registry.listProfileTimestamps(profileId);
    for (int i = 0; i < allProfiles.length - 1; i++) {
      registry.removeProfile(profileId, allProfiles[i]);
    }
  }
  
  private void revertToPreviousState()
    throws CoreException
  {
    IProfile profile = initializeProfile();
    IProfileRegistry profileRegistry = (IProfileRegistry)targetAgent.getService(IProfileRegistry.SERVICE_NAME);
    IProfile targetProfile = null;
    if (revertToPreviousState == REVERT_TO_PREVIOUS)
    {
      long[] profiles = profileRegistry.listProfileTimestamps(profile.getProfileId());
      if (profiles.length == 0) {
        return;
      }
      targetProfile = profileRegistry.getProfile(profile.getProfileId(), profiles[(profiles.length - 1)]);
    }
    else
    {
      targetProfile = profileRegistry.getProfile(profile.getProfileId(), getTimestampToRevertTo(profileRegistry, profile.getProfileId()));
    }
    if (targetProfile == null) {
      throw new CoreException(new Status(4, "org.eclipse.equinox.p2.director.app", Messages.Missing_profile));
    }
    IProvisioningPlan plan = planner.getDiffPlan(profile, targetProfile, new NullProgressMonitor());
    
    ProvisioningContext context = new ProvisioningContext(targetAgent);
    context.setMetadataRepositories((URI[])metadataRepositoryLocations.toArray(new URI[metadataRepositoryLocations.size()]));
    context.setArtifactRepositories((URI[])artifactRepositoryLocations.toArray(new URI[artifactRepositoryLocations.size()]));
    context.setProperty("org.eclipse.equinox.p2.director.followRepositoryReferences", String.valueOf(followReferences));
    context.setProperty("org.eclipse.equinox.p2.director.followArtifactRepositoryReferences", String.valueOf(followReferences));
    executePlan(context, plan);
  }
  
  private long getTimestampToRevertTo(IProfileRegistry profileRegistry, String profId)
  {
    long timestampToRevertTo = -1L;
    Iterator localIterator;
    try
    {
      timestampToRevertTo = Long.valueOf(revertToPreviousState).longValue();
    }
    catch (NumberFormatException localNumberFormatException1)
    {
      Map<String, String> tags = profileRegistry.getProfileStateProperties(profId, "org.eclipse.equinox.p2.state.tag");
      Set<Map.Entry<String, String>> entries = tags.entrySet();
      localIterator = entries.iterator();
    }
    while (localIterator.hasNext())
    {
      Map.Entry<String, String> entry = (Map.Entry)localIterator.next();
      if (((String)entry.getValue()).equals(revertToPreviousState)) {
        try
        {
          long tmp = Long.valueOf((String)entry.getKey()).longValue();
          if (tmp > timestampToRevertTo) {
            timestampToRevertTo = tmp;
          }
        }
        catch (NumberFormatException localNumberFormatException2) {}
      }
    }
    return timestampToRevertTo;
  }
  
  private void setSystemProperty(String key, String value)
  {
    EnvironmentInfo env = (EnvironmentInfo)ServiceHelper.getService(Activator.getContext(), EnvironmentInfo.class.getName());
    if (env != null) {
      env.setProperty(key, value);
    } else {
      System.getProperties().put(key, value);
    }
  }
  
  private static void appendLevelPrefix(PrintStream strm, int level)
  {
    for (int idx = 0; idx < level; idx++) {
      strm.print(' ');
    }
  }
  
  IQueryResult<IInstallableUnit> getInstallableUnits(URI location, IQuery<IInstallableUnit> query, IProgressMonitor monitor)
  {
    IQueryable<IInstallableUnit> queryable = null;
    if (location == null) {
      queryable = metadataManager;
    } else {
      try
      {
        queryable = metadataManager.loadRepository(location, monitor);
      }
      catch (ProvisionException localProvisionException) {}
    }
    if (queryable != null) {
      return queryable.query(query, monitor);
    }
    return Collector.emptyCollector();
  }
  
  private void deeplyPrint(CoreException ce, PrintStream strm, int level)
  {
    appendLevelPrefix(strm, level);
    if (stackTrace) {
      ce.printStackTrace(strm);
    }
    deeplyPrint(ce.getStatus(), strm, level);
  }
  
  private void deeplyPrint(IStatus status, PrintStream strm, int level)
  {
    appendLevelPrefix(strm, level);
    String msg = status.getMessage();
    strm.println(msg);
    Throwable cause = status.getException();
    if (cause != null)
    {
      strm.print("Caused by: ");
      if ((stackTrace) || ((!msg.equals(cause.getMessage())) && (!msg.equals(cause.toString())))) {
        deeplyPrint(cause, strm, level);
      }
    }
    if (status.isMultiStatus())
    {
      IStatus[] children = status.getChildren();
      for (int i = 0; i < children.length; i++) {
        deeplyPrint(children[i], strm, level + 1);
      }
    }
  }
  
  private void deeplyPrint(Throwable t, PrintStream strm, int level)
  {
    if ((t instanceof CoreException))
    {
      deeplyPrint((CoreException)t, strm, level);
    }
    else
    {
      appendLevelPrefix(strm, level);
      if (stackTrace)
      {
        t.printStackTrace(strm);
      }
      else
      {
        strm.println(t.toString());
        Throwable cause = t.getCause();
        if (cause != null)
        {
          strm.print("Caused by: ");
          deeplyPrint(cause, strm, level);
        }
      }
    }
  }
  
  private void performHelpInfo()
  {
    CommandLineOption[] allOptions = { OPTION_HELP, OPTION_LIST, OPTION_LIST_INSTALLED, OPTION_INSTALL_IU, OPTION_UNINSTALL_IU, OP
1 2 3

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2019. Infinite Loop Ltd