Skip to content

Commits on Source 4

......@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.equinox.app; singleton:=true
Bundle-Version: 1.4.200.qualifier
Bundle-Version: 1.4.300.qualifier
Bundle-Vendor: %providerName
Bundle-Activator: org.eclipse.equinox.internal.app.Activator
Bundle-Localization: plugin
......
......@@ -14,12 +14,12 @@
<parent>
<artifactId>rt.equinox.bundles</artifactId>
<groupId>org.eclipse.equinox.bundles</groupId>
<version>4.12.0-SNAPSHOT</version>
<version>4.13.0-SNAPSHOT</version>
<relativePath>../../</relativePath>
</parent>
<groupId>org.eclipse.equinox</groupId>
<artifactId>org.eclipse.equinox.app</artifactId>
<version>1.4.200-SNAPSHOT</version>
<version>1.4.300-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
<build>
<plugins>
......
......@@ -225,9 +225,11 @@ public class Activator implements BundleActivator, ServiceTrackerCustomizer {
if (bundles == null)
return null;
//Return the first bundle that is not installed or uninstalled
for (int i = 0; i < bundles.length; i++)
if ((bundles[i].getState() & (Bundle.INSTALLED | Bundle.UNINSTALLED)) == 0)
return bundles[i];
for (Bundle bundle : bundles) {
if ((bundle.getState() & (Bundle.INSTALLED | Bundle.UNINSTALLED)) == 0) {
return bundle;
}
}
return null;
}
......
......@@ -31,7 +31,7 @@ public class AppCommands implements CommandProvider {
private final static String TAB = "\t"; //$NON-NLS-1$
// holds the mappings from command name to command arguments and command description
private Map commandsHelp = null;
private Map<String, String[]> commandsHelp = null;
private static AppCommands instance;
private BundleContext context;
......@@ -107,17 +107,17 @@ public class AppCommands implements CommandProvider {
if (commandName != null) {
if (commandsHelp.containsKey(commandName)) {
addCommand(commandName, (String[]) commandsHelp.get(commandName), sb);
addCommand(commandName, commandsHelp.get(commandName), sb);
}
return sb.toString();
}
addHeader(Messages.console_help_app_commands_header, sb);
Iterator i = commandsHelp.entrySet().iterator();
Iterator<Entry<String, String[]>> i = commandsHelp.entrySet().iterator();
while (i.hasNext()) {
Entry entry = (Entry) i.next();
String command = (String) entry.getKey();
String[] attributes = (String[]) entry.getValue();
Entry<String, String[]> entry = i.next();
String command = entry.getKey();
String[] attributes = entry.getValue();
addCommand(command, attributes, sb);
}
......@@ -125,7 +125,7 @@ public class AppCommands implements CommandProvider {
}
private void initializeCommandsHelp() {
commandsHelp = new LinkedHashMap();
commandsHelp = new LinkedHashMap<>();
commandsHelp.put("activeApps", new String[] {Messages.console_help_activeapps_description}); //$NON-NLS-1$
commandsHelp.put("apps", new String[] {Messages.console_help_apps_description}); //$NON-NLS-1$
commandsHelp.put("lockApp", new String[] {Messages.console_help_arguments, Messages.console_help_lockapp_description}); //$NON-NLS-1$
......@@ -173,11 +173,12 @@ public class AppCommands implements CommandProvider {
}
}
private Dictionary getServiceProps(ServiceReference ref) {
private Dictionary<String, Object> getServiceProps(ServiceReference ref) {
String[] keys = ref.getPropertyKeys();
Hashtable props = new Hashtable(keys.length);
for (int i = 0; i < keys.length; i++)
props.put(keys[i], ref.getProperty(keys[i]));
Hashtable<String, Object> props = new Hashtable<>(keys.length);
for (String key : keys) {
props.put(key, ref.getProperty(key));
}
return props;
}
......@@ -187,8 +188,8 @@ public class AppCommands implements CommandProvider {
intp.println("No applications found."); //$NON-NLS-1$
return;
}
for (int i = 0; i < apps.length; i++) {
String application = (String) apps[i].getProperty(ApplicationDescriptor.APPLICATION_PID);
for (ServiceReference app : apps) {
String application = (String) app.getProperty(ApplicationDescriptor.APPLICATION_PID);
intp.print(application);
if (getApplication(applicationHandles.getServiceReferences(), application, ApplicationHandle.APPLICATION_DESCRIPTOR, true) != null)
......@@ -196,14 +197,14 @@ public class AppCommands implements CommandProvider {
if (getApplication(scheduledApplications.getServiceReferences(), application, ScheduledApplication.APPLICATION_PID, true) != null)
intp.print(" [scheduled]"); //$NON-NLS-1$
if (!launchableApp.match(getServiceProps(apps[i])))
if (!launchableApp.match(getServiceProps(app))) {
intp.print(" [not launchable]"); //$NON-NLS-1$
else
} else {
intp.print(" [launchable]"); //$NON-NLS-1$
if (lockedApp.match(getServiceProps(apps[i])))
}
if (lockedApp.match(getServiceProps(app))) {
intp.print(" [locked]"); //$NON-NLS-1$
}
intp.println();
}
}
......@@ -214,10 +215,10 @@ public class AppCommands implements CommandProvider {
intp.println("No active applications found"); //$NON-NLS-1$
return;
}
for (int i = 0; i < active.length; i++) {
intp.print(active[i].getProperty(ApplicationHandle.APPLICATION_PID));
for (ServiceReference r : active) {
intp.print(r.getProperty(ApplicationHandle.APPLICATION_PID));
intp.print(" ["); //$NON-NLS-1$
intp.print(activeApp.match(getServiceProps(active[i])) ? "running" : "stopping"); //$NON-NLS-1$ //$NON-NLS-2$
intp.print(activeApp.match(getServiceProps(r)) ? "running" : "stopping"); //$NON-NLS-1$ //$NON-NLS-2$
intp.println("]"); //$NON-NLS-1$
}
}
......@@ -228,16 +229,17 @@ public class AppCommands implements CommandProvider {
ServiceReference result = null;
boolean ambigous = false;
for (int i = 0; i < apps.length; i++) {
String id = (String) apps[i].getProperty(idKey);
if (targetId.equals(id))
return apps[i]; // always return a perfect match
for (ServiceReference app : apps) {
String id = (String) app.getProperty(idKey);
if (targetId.equals(id)) {
return app; // always return a perfect match
}
if (perfectMatch)
continue;
if (id.indexOf(targetId) >= 0) {
if (id.contains(targetId)) {
if (result != null)
ambigous = true;
result = apps[i];
result = app;
}
}
return ambigous ? null : result;
......@@ -249,16 +251,16 @@ public class AppCommands implements CommandProvider {
if (application == null)
intp.println("\"" + appId + "\" does not exist or is ambigous."); //$NON-NLS-1$ //$NON-NLS-2$
else {
ArrayList argList = new ArrayList();
ArrayList<String> argList = new ArrayList<>();
String arg = null;
while ((arg = intp.nextArgument()) != null)
argList.add(arg);
String[] args = argList.size() == 0 ? null : (String[]) argList.toArray(new String[argList.size()]);
try {
HashMap launchArgs = new HashMap(1);
HashMap<String, Object> launchArgs = new HashMap<>(1);
if (args != null)
launchArgs.put(IApplicationContext.APPLICATION_ARGS, args);
ApplicationDescriptor appDesc = ((ApplicationDescriptor) context.getService(application));
ApplicationDescriptor appDesc = (context.<ApplicationDescriptor> getService(application));
ApplicationHandle handle = appDesc.launch(launchArgs);
intp.println("Launched application instance: " + handle.getInstanceId()); //$NON-NLS-1$
} finally {
......
......@@ -46,9 +46,9 @@ public class AppPersistence implements ServiceTrackerCustomizer {
private static BundleContext context;
private static ServiceTracker configTracker;
private static Location configLocation;
private static Collection locks = new ArrayList();
private static Map scheduledApps = new HashMap();
static ArrayList timerApps = new ArrayList();
private static Collection<String> locks = new ArrayList<>();
private static Map<String, EclipseScheduledApplication> scheduledApps = new HashMap<>();
static ArrayList<EclipseScheduledApplication> timerApps = new ArrayList<>();
private static StorageManager storageManager;
private static boolean scheduling = false;
static boolean shutdown = false;
......@@ -144,7 +144,7 @@ public class AppPersistence implements ServiceTrackerCustomizer {
* @throws InvalidSyntaxException
* @throws ApplicationException
*/
public static ScheduledApplication addScheduledApp(ApplicationDescriptor descriptor, String scheduleId, Map arguments, String topic, String eventFilter, boolean recurring) throws InvalidSyntaxException, ApplicationException {
public static ScheduledApplication addScheduledApp(ApplicationDescriptor descriptor, String scheduleId, Map<String, Object> arguments, String topic, String eventFilter, boolean recurring) throws InvalidSyntaxException, ApplicationException {
if (!scheduling && !checkSchedulingSupport())
throw new ApplicationException(ApplicationException.APPLICATION_SCHEDULING_FAILED, "Cannot support scheduling without org.osgi.service.event package"); //$NON-NLS-1$
// check the event filter for correct syntax
......@@ -168,7 +168,7 @@ public class AppPersistence implements ServiceTrackerCustomizer {
}
}
scheduledApps.put(scheduledApp.getScheduleId(), scheduledApp);
Hashtable serviceProps = new Hashtable();
Hashtable<String, Object> serviceProps = new Hashtable<>();
if (scheduledApp.getTopic() != null)
serviceProps.put(EventConstants.EVENT_TOPIC, new String[] {scheduledApp.getTopic()});
if (scheduledApp.getEventFilter() != null)
......@@ -299,8 +299,8 @@ public class AppPersistence implements ServiceTrackerCustomizer {
try (ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(locksData))) {
out.writeInt(DATA_VERSION);
out.writeInt(locks.size());
for (Iterator iterLocks = locks.iterator(); iterLocks.hasNext();)
out.writeUTF((String) iterLocks.next());
for (Iterator<String> iterLocks = locks.iterator(); iterLocks.hasNext();)
out.writeUTF(iterLocks.next());
}
}
......@@ -309,8 +309,8 @@ public class AppPersistence implements ServiceTrackerCustomizer {
try (ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(schedulesData))) {
out.writeInt(DATA_VERSION);
out.writeInt(scheduledApps.size());
for (Iterator apps = scheduledApps.values().iterator(); apps.hasNext();) {
EclipseScheduledApplication app = (EclipseScheduledApplication) apps.next();
for (Iterator<EclipseScheduledApplication> apps = scheduledApps.values().iterator(); apps.hasNext();) {
EclipseScheduledApplication app = apps.next();
writeStringOrNull(out, app.getScheduleId());
writeStringOrNull(out, app.getAppPid());
writeStringOrNull(out, app.getTopic());
......@@ -344,29 +344,30 @@ public class AppPersistence implements ServiceTrackerCustomizer {
if (minute == lastMin)
continue;
lastMin = minute;
Hashtable props = new Hashtable();
Hashtable<String, Object> props = new Hashtable<>();
props.put(ScheduledApplication.YEAR, Integer.valueOf(cal.get(Calendar.YEAR)));
props.put(ScheduledApplication.MONTH, Integer.valueOf(cal.get(Calendar.MONTH)));
props.put(ScheduledApplication.DAY_OF_MONTH, Integer.valueOf(cal.get(Calendar.DAY_OF_MONTH)));
props.put(ScheduledApplication.DAY_OF_WEEK, Integer.valueOf(cal.get(Calendar.DAY_OF_WEEK)));
props.put(ScheduledApplication.HOUR_OF_DAY, Integer.valueOf(cal.get(Calendar.HOUR_OF_DAY)));
props.put(ScheduledApplication.MINUTE, Integer.valueOf(minute));
Event timerEvent = new Event(ScheduledApplication.TIMER_TOPIC, (Dictionary) props);
Event timerEvent = new Event(ScheduledApplication.TIMER_TOPIC, (Dictionary<String, ?>) props);
EclipseScheduledApplication[] apps = null;
// poor mans implementation of dispatching events; the spec will not allow us to use event admin to dispatch the virtual timer events; boo!!
synchronized (timerApps) {
if (timerApps.size() == 0)
continue;
apps = (EclipseScheduledApplication[]) timerApps.toArray(new EclipseScheduledApplication[timerApps.size()]);
apps = timerApps.toArray(new EclipseScheduledApplication[timerApps.size()]);
}
for (int i = 0; i < apps.length; i++) {
for (EclipseScheduledApplication app : apps) {
try {
String filterString = apps[i].getEventFilter();
String filterString = app.getEventFilter();
Filter filter = filterString == null ? null : FrameworkUtil.createFilter(filterString);
if (filter == null || filter.match(props))
apps[i].handleEvent(timerEvent);
if (filter == null || filter.match(props)) {
app.handleEvent(timerEvent);
}
} catch (Throwable t) {
String message = NLS.bind(Messages.scheduled_app_launch_error, apps[i].getAppPid());
String message = NLS.bind(Messages.scheduled_app_launch_error, app.getAppPid());
Activator.log(new FrameworkLogEntry(Activator.PI_APP, FrameworkLogEntry.WARNING, 0, message, 0, t, null));
}
}
......
......@@ -64,7 +64,7 @@ public class EclipseAppContainer implements IRegistryEventListener, SynchronousB
private final Object lock = new Object();
// A map of ApplicationDescriptors keyed by eclipse application ID
/* @GuardedBy(lock) */
final private HashMap apps = new HashMap();
final private HashMap<String, EclipseAppDescriptor> apps = new HashMap<>();
final private IExtensionRegistry extensionRegistry;
final private ServiceTracker launcherTracker;
......@@ -72,7 +72,7 @@ public class EclipseAppContainer implements IRegistryEventListener, SynchronousB
private boolean missingProductReported;
/* @GuardedBy(lock) */
final private Collection activeHandles = new ArrayList(); // the currently active application handles
final private Collection<EclipseAppHandle> activeHandles = new ArrayList<>(); // the currently active application handles
/* @GuardedBy(lock) */
private EclipseAppHandle activeMain; // the handle currently running on the main thread
/* @GuardedBy(lock) */
......@@ -80,7 +80,7 @@ public class EclipseAppContainer implements IRegistryEventListener, SynchronousB
/* @GuardedBy(lock) */
private EclipseAppHandle activeScopedSingleton; // the current scoped singleton handle
/* @GuardedBy(lock) */
private HashMap/*<<String> <ArrayList <EclipseAppHandle>> */ activeLimited; // Map of handles that have cardinality limits
private HashMap<String, ArrayList<EclipseAppHandle>> activeLimited; // Map of handles that have cardinality limits
private String defaultAppId;
private DefaultApplicationListener defaultAppListener;
private ParameterizedRunnable defaultMainThreadAppHandle; // holds the default app handle to be run on the main thread
......@@ -129,12 +129,12 @@ public class EclipseAppContainer implements IRegistryEventListener, SynchronousB
private EclipseAppDescriptor getAppDescriptor(String applicationId) {
EclipseAppDescriptor result = null;
synchronized (lock) {
result = (EclipseAppDescriptor) apps.get(applicationId);
result = apps.get(applicationId);
}
if (result == null) {
registerAppDescriptor(applicationId); // try again just in case we are waiting for an event
synchronized (lock) {
result = (EclipseAppDescriptor) apps.get(applicationId);
result = apps.get(applicationId);
}
}
return result;
......@@ -145,7 +145,7 @@ public class EclipseAppContainer implements IRegistryEventListener, SynchronousB
System.out.println("Creating application descriptor: " + appExtension.getUniqueIdentifier()); //$NON-NLS-1$
String iconPath = null;
synchronized (lock) {
EclipseAppDescriptor appDescriptor = (EclipseAppDescriptor) apps.get(appExtension.getUniqueIdentifier());
EclipseAppDescriptor appDescriptor = apps.get(appExtension.getUniqueIdentifier());
if (appDescriptor != null)
return appDescriptor;
// the appDescriptor does not exist for the app ID; create it
......@@ -200,7 +200,7 @@ public class EclipseAppContainer implements IRegistryEventListener, SynchronousB
if (Activator.DEBUG)
System.out.println("Removing application descriptor: " + applicationId); //$NON-NLS-1$
synchronized (lock) {
EclipseAppDescriptor appDescriptor = (EclipseAppDescriptor) apps.remove(applicationId);
EclipseAppDescriptor appDescriptor = apps.remove(applicationId);
if (appDescriptor == null)
return null;
appDescriptor.unregister();
......@@ -211,7 +211,7 @@ public class EclipseAppContainer implements IRegistryEventListener, SynchronousB
/*
* Gives access to the RegisterService privileged action.
*/
PrivilegedAction getRegServiceAction(String[] serviceClasses, Object serviceObject, Dictionary serviceProps) {
PrivilegedAction getRegServiceAction(String[] serviceClasses, Object serviceObject, Dictionary<String, ?> serviceProps) {
return new RegisterService(serviceClasses, serviceObject, serviceProps);
}
......@@ -221,9 +221,9 @@ public class EclipseAppContainer implements IRegistryEventListener, SynchronousB
private class RegisterService implements PrivilegedAction {
String[] serviceClasses;
Object serviceObject;
Dictionary serviceProps;
Dictionary<String, ?> serviceProps;
RegisterService(String[] serviceClasses, Object serviceObject, Dictionary serviceProps) {
RegisterService(String[] serviceClasses, Object serviceObject, Dictionary<String, ?> serviceProps) {
this.serviceClasses = serviceClasses;
this.serviceObject = serviceObject;
this.serviceProps = serviceProps;
......@@ -239,7 +239,7 @@ public class EclipseAppContainer implements IRegistryEventListener, SynchronousB
// find the default application
String applicationId = getDefaultAppId();
EclipseAppDescriptor defaultDesc = null;
Map args = new HashMap(2);
Map<String, Object> args = new HashMap<>(2);
args.put(EclipseAppDescriptor.APP_DEFAULT, Boolean.TRUE);
if (applicationId == null && !delayError) {
// the application id is not set; use a descriptor that will throw an exception
......@@ -272,8 +272,9 @@ public class EclipseAppContainer implements IRegistryEventListener, SynchronousB
*/
private void registerAppDescriptors() {
IExtension[] availableApps = getAvailableAppExtensions();
for (int i = 0; i < availableApps.length; i++)
createAppDescriptor(availableApps[i]);
for (IExtension availableApp : availableApps) {
createAppDescriptor(availableApp);
}
}
private void registerAppDescriptor(String applicationId) {
......@@ -382,8 +383,8 @@ public class EclipseAppContainer implements IRegistryEventListener, SynchronousB
try {
ServiceReference[] runningRefs = context.getServiceReferences(ApplicationHandle.class.getName(), "(!(application.state=STOPPING))"); //$NON-NLS-1$
if (runningRefs != null)
for (int i = 0; i < runningRefs.length; i++) {
ApplicationHandle handle = (ApplicationHandle) context.getService(runningRefs[i]);
for (ServiceReference runningRef : runningRefs) {
ApplicationHandle handle = (ApplicationHandle) context.getService(runningRef);
try {
if (handle != null)
handle.destroy();
......@@ -391,8 +392,9 @@ public class EclipseAppContainer implements IRegistryEventListener, SynchronousB
String message = NLS.bind(Messages.application_error_stopping, handle.getInstanceId());
Activator.log(new FrameworkLogEntry(Activator.PI_APP, FrameworkLogEntry.WARNING, 0, message, 0, t, null));
} finally {
if (handle != null)
context.ungetService(runningRefs[i]);
if (handle != null) {
context.ungetService(runningRef);
}
}
}
} catch (InvalidSyntaxException e) {
......@@ -438,29 +440,28 @@ public class EclipseAppContainer implements IRegistryEventListener, SynchronousB
return branding;
}
IConfigurationElement[] elements = extensionRegistry.getConfigurationElementsFor(PI_RUNTIME, PT_PRODUCTS);
List logEntries = null;
for (int i = 0; i < elements.length; i++) {
IConfigurationElement element = elements[i];
List<FrameworkLogEntry> logEntries = null;
for (IConfigurationElement element : elements) {
if (element.getName().equalsIgnoreCase("provider")) { //$NON-NLS-1$
try {
Object provider = element.createExecutableExtension("run"); //$NON-NLS-1$
Object[] products = (Object[]) EclipseAppContainer.callMethod(provider, "getProducts", null, null); //$NON-NLS-1$
if (products != null)
for (int j = 0; j < products.length; j++) {
if (productId.equalsIgnoreCase((String) EclipseAppContainer.callMethod(products[j], "getId", null, null))) { //$NON-NLS-1$
branding = new ProviderExtensionBranding(products[j]);
for (Object product : products) {
if (productId.equalsIgnoreCase((String) EclipseAppContainer.callMethod(product, "getId", null, null))) { //$NON-NLS-1$
branding = new ProviderExtensionBranding(product);
return branding;
}
}
} catch (CoreException e) {
if (logEntries == null)
logEntries = new ArrayList(3);
logEntries = new ArrayList<>(3);
logEntries.add(new FrameworkLogEntry(Activator.PI_APP, NLS.bind(Messages.provider_invalid, element.getParent().toString()), 0, e, null));
}
}
}
if (logEntries != null)
Activator.log(new FrameworkLogEntry(Activator.PI_APP, Messages.provider_invalid_general, 0, null, (FrameworkLogEntry[]) logEntries.toArray(new FrameworkLogEntry[logEntries.size()])));
Activator.log(new FrameworkLogEntry(Activator.PI_APP, Messages.provider_invalid_general, 0, null, logEntries.toArray(new FrameworkLogEntry[logEntries.size()])));
if (!missingProductReported) {
Activator.log(new FrameworkLogEntry(Activator.PI_APP, NLS.bind(Messages.product_notFound, productId), 0, null, null));
......@@ -471,8 +472,8 @@ public class EclipseAppContainer implements IRegistryEventListener, SynchronousB
private void refreshAppDescriptors() {
synchronized (lock) {
for (Iterator allApps = apps.values().iterator(); allApps.hasNext();)
((EclipseAppDescriptor) allApps.next()).refreshProperties();
for (Iterator<EclipseAppDescriptor> allApps = apps.values().iterator(); allApps.hasNext();)
allApps.next().refreshProperties();
}
}
......@@ -506,10 +507,10 @@ public class EclipseAppContainer implements IRegistryEventListener, SynchronousB
break;
case EclipseAppDescriptor.FLAG_CARD_LIMITED :
if (activeLimited == null)
activeLimited = new HashMap(3);
ArrayList limited = (ArrayList) activeLimited.get(eclipseApp.getApplicationId());
activeLimited = new HashMap<>(3);
ArrayList<EclipseAppHandle> limited = activeLimited.get(eclipseApp.getApplicationId());
if (limited == null) {
limited = new ArrayList(eclipseApp.getCardinality());
limited = new ArrayList<>(eclipseApp.getCardinality());
activeLimited.put(eclipseApp.getApplicationId(), limited);
}
limited.add(appHandle);
......@@ -534,7 +535,7 @@ public class EclipseAppContainer implements IRegistryEventListener, SynchronousB
activeScopedSingleton = null;
else if (((EclipseAppDescriptor) appHandle.getApplicationDescriptor()).getCardinalityType() == EclipseAppDescriptor.FLAG_CARD_LIMITED) {
if (activeLimited != null) {
ArrayList limited = (ArrayList) activeLimited.get(((EclipseAppDescriptor) appHandle.getApplicationDescriptor()).getApplicationId());
ArrayList<EclipseAppHandle> limited = activeLimited.get(((EclipseAppDescriptor) appHandle.getApplicationDescriptor()).getApplicationId());
if (limited != null)
limited.remove(appHandle);
}
......@@ -561,7 +562,7 @@ public class EclipseAppContainer implements IRegistryEventListener, SynchronousB
break;
case EclipseAppDescriptor.FLAG_CARD_LIMITED :
if (activeLimited != null) {
ArrayList limited = (ArrayList) activeLimited.get(eclipseApp.getApplicationId());
ArrayList<EclipseAppHandle> limited = activeLimited.get(eclipseApp.getApplicationId());
if (limited != null && limited.size() >= eclipseApp.getCardinality())
return LOCKED_SINGLETON_LIMITED_RUNNING;
}
......@@ -577,7 +578,7 @@ public class EclipseAppContainer implements IRegistryEventListener, SynchronousB
}
}
static Object callMethod(Object obj, String methodName, Class[] argTypes, Object[] args) {
static Object callMethod(Object obj, String methodName, Class<?>[] argTypes, Object[] args) {
try {
return callMethodWithException(obj, methodName, argTypes, args);
} catch (Throwable t) {
......@@ -586,7 +587,7 @@ public class EclipseAppContainer implements IRegistryEventListener, SynchronousB
return null;
}
static Object callMethodWithException(Object obj, String methodName, Class[] argTypes, Object[] args) throws Exception {
static Object callMethodWithException(Object obj, String methodName, Class<?>[] argTypes, Object[] args) throws Exception {
try {
Method method = obj.getClass().getMethod(methodName, argTypes);
return method.invoke(obj, args);
......@@ -633,8 +634,9 @@ public class EclipseAppContainer implements IRegistryEventListener, SynchronousB
@Override
public void added(IExtension[] extensions) {
for (int i = 0; i < extensions.length; i++)
createAppDescriptor(extensions[i]);
for (IExtension extension : extensions) {
createAppDescriptor(extension);
}
}
@Override
......@@ -644,8 +646,9 @@ public class EclipseAppContainer implements IRegistryEventListener, SynchronousB
@Override
public void removed(IExtension[] extensions) {
for (int i = 0; i < extensions.length; i++)
removeAppDescriptor(extensions[i].getUniqueIdentifier());
for (IExtension extension : extensions) {
removeAppDescriptor(extension.getUniqueIdentifier());
}
}
@Override
......
......@@ -73,9 +73,9 @@ public class EclipseAppDescriptor extends ApplicationDescriptor {
baseIconDir = iconPath.substring(0, lastSlash);
iconFile = iconPath.substring(lastSlash + 1);
}
Enumeration urls = contributor.findEntries(baseIconDir, iconFile, false);
Enumeration<URL> urls = contributor.findEntries(baseIconDir, iconFile, false);
if (urls != null && urls.hasMoreElements())
iconResult = (URL) urls.nextElement();
iconResult = urls.nextElement();
}
this.iconURL = iconResult;
}
......@@ -163,8 +163,8 @@ public class EclipseAppDescriptor extends ApplicationDescriptor {
/*
* Gets a snapshot of the current service properties.
*/
Hashtable getServiceProperties() {
Hashtable props = new Hashtable(10);
Hashtable<String, Object> getServiceProperties() {
Hashtable<String, Object> props = new Hashtable<>(10);
props.put(ApplicationDescriptor.APPLICATION_PID, getApplicationId());
if (name != null)
props.put(ApplicationDescriptor.APPLICATION_NAME, name);
......@@ -192,7 +192,7 @@ public class EclipseAppDescriptor extends ApplicationDescriptor {
/*
* Returns the appHandle. If it does not exist then one is created.
*/
private EclipseAppHandle createAppHandle(Map arguments) throws ApplicationException {
private EclipseAppHandle createAppHandle(Map<String, Object> arguments) throws ApplicationException {
EclipseAppHandle newAppHandle = new EclipseAppHandle(getInstanceID(), arguments, this);
appContainer.lock(newAppHandle);
ServiceRegistration appHandleReg = (ServiceRegistration) AccessController.doPrivileged(appContainer.getRegServiceAction(new String[] {ApplicationHandle.class.getName(), IApplicationContext.class.getName()}, newAppHandle, newAppHandle.getServiceProperties()));
......
......@@ -45,7 +45,7 @@ public class EclipseAppHandle extends ApplicationHandle implements ApplicationRu
private volatile ServiceRegistration handleRegistration;
private int status = EclipseAppHandle.FLAG_STARTING;
private final Map arguments;
private final Map<String, Object> arguments;
private Object application;
private final Boolean defaultAppInstance;
private Object result;
......@@ -56,13 +56,13 @@ public class EclipseAppHandle extends ApplicationHandle implements ApplicationRu
/*
* Constructs a handle for a single running instance of a eclipse application.
*/
EclipseAppHandle(String instanceId, Map arguments, EclipseAppDescriptor descriptor) {
EclipseAppHandle(String instanceId, Map<String, Object> arguments, EclipseAppDescriptor descriptor) {
super(instanceId, descriptor);
defaultAppInstance = arguments == null || arguments.get(EclipseAppDescriptor.APP_DEFAULT) == null ? Boolean.FALSE : (Boolean) arguments.remove(EclipseAppDescriptor.APP_DEFAULT);
if (arguments == null)
this.arguments = new HashMap(2);
this.arguments = new HashMap<>(2);
else
this.arguments = new HashMap(arguments);
this.arguments = new HashMap<>(arguments);
}
@Override
......@@ -131,8 +131,8 @@ public class EclipseAppHandle extends ApplicationHandle implements ApplicationRu
/*
* Gets a snapshot of the current service properties.
*/
Dictionary getServiceProperties() {
Dictionary props = new Hashtable(6);
Dictionary<String, Object> getServiceProperties() {
Dictionary<String, Object> props = new Hashtable<>(6);
props.put(ApplicationHandle.APPLICATION_PID, getInstanceId());
props.put(ApplicationHandle.APPLICATION_STATE, getState());
props.put(ApplicationHandle.APPLICATION_DESCRIPTOR, getApplicationDescriptor().getApplicationId());
......@@ -273,11 +273,11 @@ public class EclipseAppHandle extends ApplicationHandle implements ApplicationRu
@Override
public void run() throws Exception {
for (int i = 0; i < monitors.length; i++) {
StartupMonitor monitor = (StartupMonitor) Activator.getContext().getService(monitors[i]);
for (ServiceReference m : monitors) {
StartupMonitor monitor = (StartupMonitor) Activator.getContext().getService(m);
if (monitor != null) {
monitor.applicationRunning();
Activator.getContext().ungetService(monitors[i]);
Activator.getContext().ungetService(m);
}
}
}
......@@ -296,13 +296,11 @@ public class EclipseAppHandle extends ApplicationHandle implements ApplicationRu
if (refs == null || refs.length == 0)
return null;
// Implement our own Comparator to sort services
Arrays.sort(refs, new Comparator() {
Arrays.sort(refs, new Comparator<ServiceReference>() {
@Override
public int compare(Object o1, Object o2) {
public int compare(ServiceReference ref1, ServiceReference ref2) {
// sort in descending order
// sort based on service ranking first; highest rank wins
ServiceReference ref1 = (ServiceReference) o1;
ServiceReference ref2 = (ServiceReference) o2;
Object property = ref1.getProperty(Constants.SERVICE_RANKING);
int rank1 = (property instanceof Integer) ? ((Integer) property).intValue() : 0;
property = ref2.getProperty(Constants.SERVICE_RANKING);
......
......@@ -33,14 +33,14 @@ public class EclipseScheduledApplication implements ScheduledApplication, EventH
private boolean recurring;
private String topic;
private String eventFilter;
private Map args;
private Map<String, Object> args;
private String appPid;
private String id;
private ServiceRegistration sr;
private ServiceTracker appTracker;
private boolean removed = false;
EclipseScheduledApplication(BundleContext context, String id, String appPid, Map args, String topic, String eventFilter, boolean recurring) throws InvalidSyntaxException {
EclipseScheduledApplication(BundleContext context, String id, String appPid, Map<String, Object> args, String topic, String eventFilter, boolean recurring) throws InvalidSyntaxException {
this.id = id;
this.appPid = appPid;
this.args = args;
......@@ -89,14 +89,14 @@ public class EclipseScheduledApplication implements ScheduledApplication, EventH
}
@Override
public synchronized Map getArguments() {
public synchronized Map<String, Object> getArguments() {
if (removed)
throw new IllegalStateException(Messages.scheduled_app_removed);
return args == null ? null : new HashMap(args);
return args == null ? null : new HashMap<>(args);
}
private Map getArguments(Event trigger) {
Map result = args == null ? new HashMap() : getArguments();
private Map<String, Object> getArguments(Event trigger) {
Map<String, Object> result = args == null ? new HashMap<String, Object>() : getArguments();
result.put(TRIGGERING_EVENT, new GuardedObject(trigger, new TriggerGuard(trigger.getTopic())));
return result;
}
......
......@@ -27,7 +27,7 @@ public class ProductExtensionBranding implements IBranding {
String name = null;
String id = null;
String description = null;
HashMap properties;
HashMap<String, String> properties;
Bundle definingBundle = null;
public ProductExtensionBranding(String id, IConfigurationElement element) {
......@@ -42,9 +42,8 @@ public class ProductExtensionBranding implements IBranding {
private void loadProperties(IConfigurationElement element) {
IConfigurationElement[] children = element.getChildren();
properties = new HashMap(children.length);
for (int i = 0; i < children.length; i++) {
IConfigurationElement child = children[i];
properties = new HashMap<>(children.length);
for (IConfigurationElement child : children) {
String key = child.getAttribute(ATTR_NAME);
String value = child.getAttribute(ATTR_VALUE);
if (key != null && value != null)
......@@ -80,7 +79,7 @@ public class ProductExtensionBranding implements IBranding {
@Override
public String getProperty(String key) {
return (String) properties.get(key);
return properties.get(key);
}
@Override
......
......@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: BiDi tests
Bundle-SymbolicName: org.eclipse.equinox.bidi.tests;singleton:=true
Bundle-Version: 1.1.0.qualifier
Bundle-Version: 1.1.100.qualifier
Require-Bundle: org.eclipse.equinox.bidi;bundle-version="1.0.0",
org.eclipse.equinox.registry;bundle-version="3.5.0",
org.junit;bundle-version="4.12.0"
......
......@@ -14,11 +14,11 @@
<parent>
<artifactId>tests-pom</artifactId>
<groupId>org.eclipse.equinox.bundles</groupId>
<version>4.12.0-SNAPSHOT</version>
<version>4.13.0-SNAPSHOT</version>
<relativePath>../../tests-pom/</relativePath>
</parent>
<groupId>org.eclipse.equinox</groupId>
<artifactId>org.eclipse.equinox.bidi.tests</artifactId>
<version>1.1.0-SNAPSHOT</version>
<version>1.1.100-SNAPSHOT</version>
<packaging>eclipse-test-plugin</packaging>
</project>
......@@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-Vendor: %providerName
Bundle-SymbolicName: org.eclipse.equinox.bidi;singleton:=true
Bundle-Version: 1.2.0.qualifier
Bundle-Version: 1.2.100.qualifier
Bundle-Localization: plugin
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Bundle-ActivationPolicy: lazy
......
......@@ -14,11 +14,11 @@
<parent>
<artifactId>rt.equinox.bundles</artifactId>
<groupId>org.eclipse.equinox.bundles</groupId>
<version>4.12.0-SNAPSHOT</version>
<version>4.13.0-SNAPSHOT</version>
<relativePath>../../</relativePath>
</parent>
<groupId>org.eclipse.equinox</groupId>
<artifactId>org.eclipse.equinox.bidi</artifactId>
<version>1.2.0-SNAPSHOT</version>
<version>1.2.100-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>