Bug 475441 - Investigate any performance issues in plugin model
initialization
Signed-off-by: Vikas Chandra <Vikas.Chandra@in.ibm.com>
diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/AbstractBundleContainer.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/AbstractBundleContainer.java
index 143bed3..5273ec4 100644
--- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/AbstractBundleContainer.java
+++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/AbstractBundleContainer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2015 IBM Corporation and others.
+ * Copyright (c) 2009, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -13,6 +13,7 @@
import java.io.File;
import java.io.IOException;
+import java.util.HashMap;
import org.eclipse.core.runtime.*;
import org.eclipse.core.variables.IStringVariableManager;
import org.eclipse.core.variables.VariablesPlugin;
@@ -49,6 +50,8 @@
*/
private String[] fVMArgs;
+ static private HashMap<AbstractBundleContainer, String[]> hash = new HashMap<>();
+
/**
* Resolves any string substitution variables in the given text returning
* the result.
@@ -203,8 +206,13 @@
@Override
public String[] getVMArguments() {
+
+ for (AbstractBundleContainer key : hash.keySet()) {
+ if (key.equals(this)) {
+ return hash.get(key);
+ }
+ }
String FWK_ADMIN_EQ = "org.eclipse.equinox.frameworkadmin.equinox"; //$NON-NLS-1$
-
if (fVMArgs == null) {
try {
FrameworkAdmin fwAdmin = (FrameworkAdmin) PDECore.getDefault().acquireService(FrameworkAdmin.class.getName());
@@ -241,8 +249,10 @@
}
if (fVMArgs == null || fVMArgs.length == 0) {
+ hash.put(this, null);
return null;
}
+ hash.put(this, fVMArgs);
return fVMArgs;
}
diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/Messages.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/Messages.java
index 87cff0b..1a84c1c 100755
--- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/Messages.java
+++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/Messages.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2013 IBM Corporation and others.
+ * Copyright (c) 2009, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -72,6 +72,7 @@
public static String TargetPlatformService_3;
public static String TargetPlatformService_4;
public static String TargetPlatformService_5;
+ public static String TargetPlatformService_6;
public static String TargetPlatformService_7;
public static String WorkspaceFileTargetHandle_0;
static {
diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/Messages.properties b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/Messages.properties
index 678fd76..4a8bc3c 100755
--- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/Messages.properties
+++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/Messages.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2009, 2013 IBM Corporation and others.
+# Copyright (c) 2009, 2016 IBM Corporation and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
@@ -64,5 +64,6 @@
TargetPlatformService_3=Error reading target extension file: {0}
TargetPlatformService_4=Target extension file does not exist: {0}
TargetPlatformService_5=Restored Target
+TargetPlatformService_6=Setting VM arguments
TargetPlatformService_7=Running Platform
WorkspaceFileTargetHandle_0=Unable to generate memento for target platform
diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/TargetDefinition.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/TargetDefinition.java
index 296c535..8b7131c 100644
--- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/TargetDefinition.java
+++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/TargetDefinition.java
@@ -71,7 +71,7 @@
public static final int MODE_FEATURE = 1;
// cache of features found for a given location, maps a string path location to a array of IFeatureModels (IFeatureModel[])
- private Map<String, TargetFeature[]> fFeaturesInLocation = new HashMap<>();
+ private static Map<String, TargetFeature[]> fFeaturesInLocation = new HashMap<>();
// internal cache for features. A target managed by features will contain a set of features as well as a set of plug-ins that don't belong to a feature
private TargetFeature[] fFeatures;
diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/TargetPlatformService.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/TargetPlatformService.java
index 78c3024..09b94e7 100644
--- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/TargetPlatformService.java
+++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/TargetPlatformService.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2013 IBM Corporation and others.
+ * Copyright (c) 2008, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -15,6 +15,8 @@
import java.util.*;
import org.eclipse.core.resources.*;
import org.eclipse.core.runtime.*;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.core.runtime.jobs.JobChangeAdapter;
import org.eclipse.equinox.frameworkadmin.BundleInfo;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.osgi.service.datalocation.Location;
@@ -46,6 +48,10 @@
* the workspace.
*/
private ITargetDefinition fWorkspaceTarget;
+ /**
+ * vm arguments for default target
+ */
+ private StringBuffer fVMArguments = null;
/**
* Collects target files in the workspace
@@ -577,6 +583,27 @@
// initialize vm arguments from the default container
ITargetLocation[] containers = target.getTargetLocations();
+ Job job = new Job(Messages.TargetPlatformService_6) {
+ @Override
+ public IStatus run(IProgressMonitor monitor) {
+ fVMArguments = getVMArguments(containers);
+ return Status.OK_STATUS;
+ }
+ };
+ job.addJobChangeListener(new JobChangeAdapter() {
+ @Override
+ public void done(org.eclipse.core.runtime.jobs.IJobChangeEvent event) {
+ if (fVMArguments != null)
+ target.setVMArguments(fVMArguments.toString().trim());
+
+ }
+ });
+ job.schedule();
+
+ return target;
+ }
+
+ private StringBuffer getVMArguments(ITargetLocation[] containers) {
StringBuffer arguments = new StringBuffer(""); //$NON-NLS-1$
for (int i = 0; i < containers.length; i++) {
String[] vmargs = containers[i].getVMArguments();
@@ -586,11 +613,8 @@
arguments.append(vmargs[j]).append(' ');
}
}
- target.setVMArguments(arguments.toString().trim());
-
- return target;
+ return arguments;
}
-
@Override
public IStatus compareWithTargetPlatform(ITargetDefinition target) throws CoreException {
if (!target.isResolved()) {