diff options
author | Violeta Georgieva | 2014-12-31 19:05:09 +0000 |
---|---|---|
committer | Violeta Georgieva | 2014-12-31 19:05:09 +0000 |
commit | 5c5baed68cc3db29dd34a03f7acc75c99265ae60 (patch) | |
tree | 24390771fe53d84b4f73305c52fa0b1ccc14d7f8 | |
parent | 19744e8c783422d2430564edaa27bc65d03a9a79 (diff) | |
download | org.eclipse.gemini.web.gemini-web-container-5c5baed68cc3db29dd34a03f7acc75c99265ae60.tar.gz org.eclipse.gemini.web.gemini-web-container-5c5baed68cc3db29dd34a03f7acc75c99265ae60.tar.xz org.eclipse.gemini.web.gemini-web-container-5c5baed68cc3db29dd34a03f7acc75c99265ae60.zip |
1. Use the diamond operator. 2. Remove unnecessary else clause. 3. Remove unnecessary null check.
49 files changed, 168 insertions, 196 deletions
diff --git a/org.eclipse.gemini.web.core/src/main/java/org/eclipse/gemini/web/internal/EventManager.java b/org.eclipse.gemini.web.core/src/main/java/org/eclipse/gemini/web/internal/EventManager.java index edbd5ed..ffd4d88 100644 --- a/org.eclipse.gemini.web.core/src/main/java/org/eclipse/gemini/web/internal/EventManager.java +++ b/org.eclipse.gemini.web.core/src/main/java/org/eclipse/gemini/web/internal/EventManager.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 VMware Inc. + * Copyright (c) 2009, 2014 VMware Inc. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -54,7 +54,7 @@ final class EventManager { public EventManager(BundleContext context) { if (isEventAdminAvailable()) { - this.template = new ServiceTemplate<EventAdmin>(context, EventAdmin.class); + this.template = new ServiceTemplate<>(context, EventAdmin.class); } else { this.template = null; } @@ -100,7 +100,7 @@ final class EventManager { @Override public Void doWithService(EventAdmin eventAdmin) { - Dictionary<String, Object> props = new Hashtable<String, Object>(); + Dictionary<String, Object> props = new Hashtable<>(); if (applicationBundle.getSymbolicName() != null) { props.put(EventConstants.BUNDLE_SYMBOLICNAME, applicationBundle.getSymbolicName()); } diff --git a/org.eclipse.gemini.web.core/src/main/java/org/eclipse/gemini/web/internal/StandardWebApplication.java b/org.eclipse.gemini.web.core/src/main/java/org/eclipse/gemini/web/internal/StandardWebApplication.java index c9c6c10..b6070cb 100644 --- a/org.eclipse.gemini.web.core/src/main/java/org/eclipse/gemini/web/internal/StandardWebApplication.java +++ b/org.eclipse.gemini.web.core/src/main/java/org/eclipse/gemini/web/internal/StandardWebApplication.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2012 VMware Inc. + * Copyright (c) 2009, 2014 VMware Inc. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -140,7 +140,7 @@ final class StandardWebApplication implements WebApplication { } private Set<Long> getWebContextPathBundleIds(String webContextPath) { - Set<Long> bundleIds = new HashSet<Long>(); + Set<Long> bundleIds = new HashSet<>(); // Use this bundle context to retrieve all bundles // Extender bundle cannot be used because it might be null // Web app bundle cannot be use because its bundle context might not be a valid one and RuntimeException will be @@ -192,7 +192,7 @@ final class StandardWebApplication implements WebApplication { } private Dictionary<String, String> constructServletContextProperties() { - Dictionary<String, String> properties = new Hashtable<String, String>(); + Dictionary<String, String> properties = new Hashtable<>(); WebContainerUtils.setServletContextBundleProperties(properties, getBundle()); properties.put("osgi.web.contextpath", getContextPath()); return properties; diff --git a/org.eclipse.gemini.web.core/src/main/java/org/eclipse/gemini/web/internal/SystemBundleExportsResolver.java b/org.eclipse.gemini.web.core/src/main/java/org/eclipse/gemini/web/internal/SystemBundleExportsResolver.java index a1e7fce..bbb0094 100644 --- a/org.eclipse.gemini.web.core/src/main/java/org/eclipse/gemini/web/internal/SystemBundleExportsResolver.java +++ b/org.eclipse.gemini.web.core/src/main/java/org/eclipse/gemini/web/internal/SystemBundleExportsResolver.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2012 VMware Inc. + * Copyright (c) 2009, 2014 VMware Inc. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -55,7 +55,7 @@ final class SystemBundleExportsResolver { } static Map<String, VersionRange> combineDuplicateExports(List<BundleCapability> capabilities, boolean isStrictMode) { - Map<String, VersionRange> exportedPackages = new HashMap<String, VersionRange>(); + Map<String, VersionRange> exportedPackages = new HashMap<>(); for (BundleCapability exportedPackage : capabilities) { if (isStrictMode) { Map<String, String> directives = exportedPackage.getDirectives(); @@ -82,8 +82,7 @@ final class SystemBundleExportsResolver { Version ceiling = versionRange.getCeiling(); if (version.compareTo(ceiling) > 0) { return new VersionRange("[" + versionRange.getFloor() + "," + version + "]"); - } else { - return new VersionRange("[" + version + "," + versionRange.getCeiling() + "]"); } + return new VersionRange("[" + version + "," + versionRange.getCeiling() + "]"); } } diff --git a/org.eclipse.gemini.web.core/src/main/java/org/eclipse/gemini/web/internal/WebApplicationStartFailureRetryController.java b/org.eclipse.gemini.web.core/src/main/java/org/eclipse/gemini/web/internal/WebApplicationStartFailureRetryController.java index 23d1bc6..5f31802 100644 --- a/org.eclipse.gemini.web.core/src/main/java/org/eclipse/gemini/web/internal/WebApplicationStartFailureRetryController.java +++ b/org.eclipse.gemini.web.core/src/main/java/org/eclipse/gemini/web/internal/WebApplicationStartFailureRetryController.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2012 VMware Inc. + * Copyright (c) 2009, 2014 VMware Inc. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -34,7 +34,7 @@ final class WebApplicationStartFailureRetryController { private final Object monitor = new Object(); - private final ConcurrentMap<String, Set<StandardWebApplication>> failures = new ConcurrentHashMap<String, Set<StandardWebApplication>>(); + private final ConcurrentMap<String, Set<StandardWebApplication>> failures = new ConcurrentHashMap<>(); void recordFailure(StandardWebApplication failedWebApplication) { String contextPath = failedWebApplication.getContextPath(); @@ -46,7 +46,7 @@ final class WebApplicationStartFailureRetryController { private void addFailureForWebContextPath(String contextPath, StandardWebApplication failedWebApplication) { Set<StandardWebApplication> contextFailures = this.failures.get(contextPath); if (contextFailures == null) { - contextFailures = new HashSet<StandardWebApplication>(); + contextFailures = new HashSet<>(); Set<StandardWebApplication> previousContextFailures = this.failures.putIfAbsent(contextPath, contextFailures); if (previousContextFailures != null) { contextFailures = previousContextFailures; @@ -86,7 +86,7 @@ final class WebApplicationStartFailureRetryController { } private Set<StandardWebApplication> createSetSortedByBundleId() { - return new TreeSet<StandardWebApplication>(new Comparator<StandardWebApplication>() { + return new TreeSet<>(new Comparator<StandardWebApplication>() { @Override public int compare(StandardWebApplication wa1, StandardWebApplication wa2) { diff --git a/org.eclipse.gemini.web.core/src/main/java/org/eclipse/gemini/web/internal/WebContainerActivator.java b/org.eclipse.gemini.web.core/src/main/java/org/eclipse/gemini/web/internal/WebContainerActivator.java index c68eaa6..43d31d1 100644 --- a/org.eclipse.gemini.web.core/src/main/java/org/eclipse/gemini/web/internal/WebContainerActivator.java +++ b/org.eclipse.gemini.web.core/src/main/java/org/eclipse/gemini/web/internal/WebContainerActivator.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2012 VMware Inc. + * Copyright (c) 2009, 2014 VMware Inc. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -57,8 +57,7 @@ public class WebContainerActivator implements BundleActivator { this.eventManager = new EventManager(context); this.eventManager.start(); - this.serviceTracker = new ServiceTracker<ServletContainer, WebContainer>(context, ServletContainer.class, new ServletContainerTracker( - context, this.eventManager)); + this.serviceTracker = new ServiceTracker<>(context, ServletContainer.class, new ServletContainerTracker(context, this.eventManager)); this.serviceTracker.open(); } @@ -87,7 +86,7 @@ public class WebContainerActivator implements BundleActivator { } private void registerUrlStreamHandler(BundleContext context, WebBundleManifestTransformer transformer) { - Dictionary<String, Object> props = new Hashtable<String, Object>(); + Dictionary<String, Object> props = new Hashtable<>(); props.put(URLConstants.URL_HANDLER_PROTOCOL, new String[] { WebBundleUrl.SCHEME }); ServiceRegistration<URLStreamHandlerService> reg = context.registerService(URLStreamHandlerService.class, diff --git a/org.eclipse.gemini.web.core/src/main/java/org/eclipse/gemini/web/internal/WebContainerUtils.java b/org.eclipse.gemini.web.core/src/main/java/org/eclipse/gemini/web/internal/WebContainerUtils.java index 7f80c0d..15058f2 100644 --- a/org.eclipse.gemini.web.core/src/main/java/org/eclipse/gemini/web/internal/WebContainerUtils.java +++ b/org.eclipse.gemini.web.core/src/main/java/org/eclipse/gemini/web/internal/WebContainerUtils.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2012 VMware Inc. + * Copyright (c) 2009, 2014 VMware Inc. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -230,8 +230,7 @@ public final class WebContainerUtils { URI uri = source.toURI(); if (uri.isOpaque()) { return new File(uri.getSchemeSpecificPart()); - } else { - return new File(uri); } + return new File(uri); } } diff --git a/org.eclipse.gemini.web.core/src/main/java/org/eclipse/gemini/web/internal/template/ServiceTemplate.java b/org.eclipse.gemini.web.core/src/main/java/org/eclipse/gemini/web/internal/template/ServiceTemplate.java index 09f042a..4610557 100644 --- a/org.eclipse.gemini.web.core/src/main/java/org/eclipse/gemini/web/internal/template/ServiceTemplate.java +++ b/org.eclipse.gemini.web.core/src/main/java/org/eclipse/gemini/web/internal/template/ServiceTemplate.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 VMware Inc. + * Copyright (c) 2009, 2014 VMware Inc. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -26,7 +26,7 @@ public class ServiceTemplate<S> { private final ServiceTracker<Object, Object> tracker; public ServiceTemplate(BundleContext context, Class<S> clazz) { - this.tracker = new ServiceTracker<Object, Object>(context, clazz.getName(), new ServiceTemplateCustomizer(context)); + this.tracker = new ServiceTracker<>(context, clazz.getName(), new ServiceTemplateCustomizer(context)); } public void start() { diff --git a/org.eclipse.gemini.web.core/src/main/java/org/eclipse/gemini/web/internal/url/DefaultsWebBundleManifestTransformer.java b/org.eclipse.gemini.web.core/src/main/java/org/eclipse/gemini/web/internal/url/DefaultsWebBundleManifestTransformer.java index 38805f4..9831104 100644 --- a/org.eclipse.gemini.web.core/src/main/java/org/eclipse/gemini/web/internal/url/DefaultsWebBundleManifestTransformer.java +++ b/org.eclipse.gemini.web.core/src/main/java/org/eclipse/gemini/web/internal/url/DefaultsWebBundleManifestTransformer.java @@ -77,7 +77,7 @@ public final class DefaultsWebBundleManifestTransformer implements WebBundleMani bundleClassPath.add(0, WEB_INF_CLASSES); } - final List<String> entries = new ArrayList<String>(); + final List<String> entries = new ArrayList<>(); WebBundleScanner scanner = new WebBundleScanner(source, new WebBundleScannerCallback() { @Override diff --git a/org.eclipse.gemini.web.core/src/main/java/org/eclipse/gemini/web/internal/url/PackagesInWarScanner.java b/org.eclipse.gemini.web.core/src/main/java/org/eclipse/gemini/web/internal/url/PackagesInWarScanner.java index 6bc925a..adad708 100644 --- a/org.eclipse.gemini.web.core/src/main/java/org/eclipse/gemini/web/internal/url/PackagesInWarScanner.java +++ b/org.eclipse.gemini.web.core/src/main/java/org/eclipse/gemini/web/internal/url/PackagesInWarScanner.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 VMware Inc. + * Copyright (c) 2009, 2014 VMware Inc. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -24,7 +24,7 @@ import java.util.Set; class PackagesInWarScanner { Set<String> getPackagesContainedInWar(URL warURL) throws IOException { - final Set<String> packagesInWar = new HashSet<String>(); + final Set<String> packagesInWar = new HashSet<>(); if (warURL != null) { WebBundleScanner scanner = new WebBundleScanner(warURL, new WebBundleScannerCallback() { diff --git a/org.eclipse.gemini.web.core/src/main/java/org/eclipse/gemini/web/internal/url/Path.java b/org.eclipse.gemini.web.core/src/main/java/org/eclipse/gemini/web/internal/url/Path.java index 9b45dac..d6aea68 100644 --- a/org.eclipse.gemini.web.core/src/main/java/org/eclipse/gemini/web/internal/url/Path.java +++ b/org.eclipse.gemini.web.core/src/main/java/org/eclipse/gemini/web/internal/url/Path.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010, 2012 VMware Inc. + * Copyright (c) 2010, 2014 VMware Inc. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -50,9 +50,8 @@ final class Path { private String head() { if (!isEmpty()) { return this.baseComponents[0]; - } else { - throw new IllegalStateException("head not applicable to an empty path"); } + throw new IllegalStateException("head not applicable to an empty path"); } private Path tail() { @@ -60,9 +59,8 @@ final class Path { String[] c = new String[this.baseComponents.length - 1]; System.arraycopy(this.baseComponents, 1, c, 0, c.length); return new Path(c); - } else { - throw new IllegalStateException("tail not applicable to an empty path"); } + throw new IllegalStateException("tail not applicable to an empty path"); } private Path front() { @@ -70,9 +68,8 @@ final class Path { String[] c = new String[this.baseComponents.length - 1]; System.arraycopy(this.baseComponents, 0, c, 0, c.length); return new Path(c); - } else { - throw new IllegalStateException("front not applicable to an empty path"); } + throw new IllegalStateException("front not applicable to an empty path"); } private static void validatePath(String basePath) { diff --git a/org.eclipse.gemini.web.core/src/main/java/org/eclipse/gemini/web/internal/url/SpecificationWebBundleManifestTransformer.java b/org.eclipse.gemini.web.core/src/main/java/org/eclipse/gemini/web/internal/url/SpecificationWebBundleManifestTransformer.java index ff8c996..13f1f3c 100644 --- a/org.eclipse.gemini.web.core/src/main/java/org/eclipse/gemini/web/internal/url/SpecificationWebBundleManifestTransformer.java +++ b/org.eclipse.gemini.web.core/src/main/java/org/eclipse/gemini/web/internal/url/SpecificationWebBundleManifestTransformer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2012 VMware Inc. + * Copyright (c) 2009, 2014 VMware Inc. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -201,9 +201,8 @@ public final class SpecificationWebBundleManifestTransformer implements WebBundl } if (trimmedWebContextPathOption.charAt(0) == SLASH) { return trimmedWebContextPathOption; - } else { - return SLASH + trimmedWebContextPathOption; } + return SLASH + trimmedWebContextPathOption; } private static class TransformerParserLogger implements ParserLogger { diff --git a/org.eclipse.gemini.web.core/src/main/java/org/eclipse/gemini/web/internal/url/WebBundleScanner.java b/org.eclipse.gemini.web.core/src/main/java/org/eclipse/gemini/web/internal/url/WebBundleScanner.java index eec09a1..86df315 100644 --- a/org.eclipse.gemini.web.core/src/main/java/org/eclipse/gemini/web/internal/url/WebBundleScanner.java +++ b/org.eclipse.gemini.web.core/src/main/java/org/eclipse/gemini/web/internal/url/WebBundleScanner.java @@ -65,13 +65,13 @@ final class WebBundleScanner { private final String localSourcePath; - private final Collection<ZipEntry> sourceZipEntries = new HashSet<ZipEntry>(); + private final Collection<ZipEntry> sourceZipEntries = new HashSet<>(); private final WebBundleScannerCallback callBack; private final boolean findClassesInNestedJars; - private final Set<String> scannedJars = new HashSet<String>(); + private final Set<String> scannedJars = new HashSet<>(); private static final Logger LOGGER = LoggerFactory.getLogger(WebBundleScanner.class); diff --git a/org.eclipse.gemini.web.core/src/main/java/org/eclipse/gemini/web/internal/url/WebBundleUrl.java b/org.eclipse.gemini.web.core/src/main/java/org/eclipse/gemini/web/internal/url/WebBundleUrl.java index 62a3cea..380e097 100644 --- a/org.eclipse.gemini.web.core/src/main/java/org/eclipse/gemini/web/internal/url/WebBundleUrl.java +++ b/org.eclipse.gemini.web.core/src/main/java/org/eclipse/gemini/web/internal/url/WebBundleUrl.java @@ -55,7 +55,7 @@ public class WebBundleUrl { public WebBundleUrl(String location, Map<String, String> options) throws MalformedURLException { this.url = createURL(location, options); this.location = location; - this.options = options == null ? Collections.<String, String> emptyMap() : unmodifiableMap(new HashMap<String, String>(options)); + this.options = options == null ? Collections.<String, String> emptyMap() : unmodifiableMap(new HashMap<>(options)); } public WebBundleUrl(URL url) { @@ -119,7 +119,7 @@ public class WebBundleUrl { } private static Map<String, String> parseQueryString(String query) { - Map<String, String> options = new HashMap<String, String>(); + Map<String, String> options = new HashMap<>(); if (query != null) { String[] parms = query.split(AMPERSAND); for (String parm : parms) { diff --git a/org.eclipse.gemini.web.core/src/main/java/org/eclipse/gemini/web/internal/url/WebBundleUrlStreamHandlerService.java b/org.eclipse.gemini.web.core/src/main/java/org/eclipse/gemini/web/internal/url/WebBundleUrlStreamHandlerService.java index 2228d5d..bd0dcaf 100644 --- a/org.eclipse.gemini.web.core/src/main/java/org/eclipse/gemini/web/internal/url/WebBundleUrlStreamHandlerService.java +++ b/org.eclipse.gemini.web.core/src/main/java/org/eclipse/gemini/web/internal/url/WebBundleUrlStreamHandlerService.java @@ -70,10 +70,9 @@ public final class WebBundleUrlStreamHandlerService extends AbstractURLStreamHan if (FILE_PROTOCOL.equals(actualUrl.getProtocol()) && new File(actualUrl.getPath()).isDirectory()) { DirTransformer dirTransformer = new DirTransformer(new Callback(actualUrl, url, this.transformer)); return new DirTransformingURLConnection(actualUrl, dirTransformer, true); - } else { - JarTransformer jarTransformer = new JarTransformer(new Callback(actualUrl, url, this.transformer)); - return new JarTransformingURLConnection(actualUrl, jarTransformer, true); } + JarTransformer jarTransformer = new JarTransformer(new Callback(actualUrl, url, this.transformer)); + return new JarTransformingURLConnection(actualUrl, jarTransformer, true); } private static final class Callback implements JarTransformerCallback, DirTransformerCallback { diff --git a/org.eclipse.gemini.web.core/src/test/java/org/eclipse/gemini/web/internal/EventManagerTests.java b/org.eclipse.gemini.web.core/src/test/java/org/eclipse/gemini/web/internal/EventManagerTests.java index 5f2ef17..f1e1f50 100644 --- a/org.eclipse.gemini.web.core/src/test/java/org/eclipse/gemini/web/internal/EventManagerTests.java +++ b/org.eclipse.gemini.web.core/src/test/java/org/eclipse/gemini/web/internal/EventManagerTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2012 VMware Inc. + * Copyright (c) 2009, 2014 VMware Inc. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -108,7 +108,7 @@ public class EventManagerTests { @Test public void failed() { Exception failure = new Exception(); - Set<Long> collidingBundles = new HashSet<Long>(); + Set<Long> collidingBundles = new HashSet<>(); collidingBundles.add(2L); collidingBundles.add(3L); this.eventManager.sendFailed(this.bundle, null, CONTEXT_PATH, failure, "/path", collidingBundles); diff --git a/org.eclipse.gemini.web.core/src/test/java/org/eclipse/gemini/web/internal/ManifestAsserts.java b/org.eclipse.gemini.web.core/src/test/java/org/eclipse/gemini/web/internal/ManifestAsserts.java index f480584..2a35917 100644 --- a/org.eclipse.gemini.web.core/src/test/java/org/eclipse/gemini/web/internal/ManifestAsserts.java +++ b/org.eclipse.gemini.web.core/src/test/java/org/eclipse/gemini/web/internal/ManifestAsserts.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 VMware Inc. + * Copyright (c) 2009, 2014 VMware Inc. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -39,9 +39,8 @@ public final class ManifestAsserts { if (importName.equals(packageName)) { if (vr.includes(version)) { return; - } else { - fail("Package '" + packageName + "' not found at version '" + version + "'. Found range :" + vr); } + fail("Package '" + packageName + "' not found at version '" + version + "'. Found range :" + vr); } } fail("Import-Package '" + packageName + "' not found at any version"); @@ -49,16 +48,15 @@ public final class ManifestAsserts { public static void assertIncludesExport(String packageName, Version version, BundleManifest manifest) { List<ExportedPackage> exportedPackages = manifest.getExportPackage().getExportedPackages(); - List<Version> nearMatches = new ArrayList<Version>(); + List<Version> nearMatches = new ArrayList<>(); for (ExportedPackage packageExport : exportedPackages) { String v = packageExport.getAttributes().get(Constants.VERSION_ATTRIBUTE); Version pv = v == null ? Version.emptyVersion : new Version(v); if (packageExport.getPackageName().equals(packageName)) { if (pv.equals(version)) { return; - } else { - nearMatches.add(pv); } + nearMatches.add(pv); } } if (nearMatches.isEmpty()) { diff --git a/org.eclipse.gemini.web.core/src/test/java/org/eclipse/gemini/web/internal/StandardWebApplicationTests.java b/org.eclipse.gemini.web.core/src/test/java/org/eclipse/gemini/web/internal/StandardWebApplicationTests.java index 061becd..fea4529 100755 --- a/org.eclipse.gemini.web.core/src/test/java/org/eclipse/gemini/web/internal/StandardWebApplicationTests.java +++ b/org.eclipse.gemini.web.core/src/test/java/org/eclipse/gemini/web/internal/StandardWebApplicationTests.java @@ -199,10 +199,9 @@ public class StandardWebApplicationTests { if (withExtender) {
return new StandardWebApplication(this.bundle, this.extender, this.webApplicationHandle, this.servletContainer, this.eventManager,
this.webApplicationStartFailureRetryController, this.thisBundle.getBundleContext());
- } else {
- return new StandardWebApplication(this.bundle, null, this.webApplicationHandle, this.servletContainer, this.eventManager,
- this.webApplicationStartFailureRetryController, this.thisBundle.getBundleContext());
}
+ return new StandardWebApplication(this.bundle, null, this.webApplicationHandle, this.servletContainer, this.eventManager,
+ this.webApplicationStartFailureRetryController, this.thisBundle.getBundleContext());
}
private StandardWebApplication startStopExpectations() {
diff --git a/org.eclipse.gemini.web.core/src/test/java/org/eclipse/gemini/web/internal/SystemBundleExportsResolverTests.java b/org.eclipse.gemini.web.core/src/test/java/org/eclipse/gemini/web/internal/SystemBundleExportsResolverTests.java index cff6a92..ec1432c 100644 --- a/org.eclipse.gemini.web.core/src/test/java/org/eclipse/gemini/web/internal/SystemBundleExportsResolverTests.java +++ b/org.eclipse.gemini.web.core/src/test/java/org/eclipse/gemini/web/internal/SystemBundleExportsResolverTests.java @@ -45,7 +45,7 @@ public class SystemBundleExportsResolverTests { BundleCapability capability2 = createBundleCapabilityMock("", "", "b", new Version(2, 3, 4)); - List<BundleCapability> input = new ArrayList<BundleCapability>(); + List<BundleCapability> input = new ArrayList<>(); input.add(capability1); input.add(capability2); @@ -80,7 +80,7 @@ public class SystemBundleExportsResolverTests { BundleCapability capability4 = createBundleCapabilityMock("", "", "a", new Version(1, 2, 0)); - List<BundleCapability> input = new ArrayList<BundleCapability>(); + List<BundleCapability> input = new ArrayList<>(); input.add(capability1); input.add(capability2); input.add(capability3); @@ -106,7 +106,7 @@ public class SystemBundleExportsResolverTests { BundleCapability capability1 = createBundleCapabilityMock("", "", "a", new Version("1.0.0")); BundleCapability capability2 = createBundleCapabilityMock(SystemBundleExportsResolver.INTERNAL_DIRECTIVE, "true", "b", new Version("1.0.0")); BundleCapability capability3 = createBundleCapabilityMock(SystemBundleExportsResolver.FRIENDS_DIRECTIVE, "", "c", new Version("1.0.0")); - List<BundleCapability> input = new ArrayList<BundleCapability>(); + List<BundleCapability> input = new ArrayList<>(); input.add(capability1); input.add(capability2); input.add(capability3); @@ -139,11 +139,11 @@ public class SystemBundleExportsResolverTests { private BundleCapability createBundleCapabilityMock(String directive, String directiveValue, String exportPackage, Version version) { BundleCapability bundleCapability = createMock(BundleCapability.class); - Map<String, String> directives = new HashMap<String, String>(); + Map<String, String> directives = new HashMap<>(); directives.put(directive, directiveValue); expect(bundleCapability.getDirectives()).andReturn(directives).anyTimes(); - Map<String, Object> attributes = new HashMap<String, Object>(); + Map<String, Object> attributes = new HashMap<>(); attributes.put(BundleRevision.PACKAGE_NAMESPACE, exportPackage); attributes.put(SystemBundleExportsResolver.VERSION, version); expect(bundleCapability.getAttributes()).andReturn(attributes).anyTimes(); @@ -156,7 +156,7 @@ public class SystemBundleExportsResolverTests { BundleCapability capability2 = createBundleCapabilityMock("", "", "a", versions[1]); - List<BundleCapability> input = new ArrayList<BundleCapability>(); + List<BundleCapability> input = new ArrayList<>(); input.add(capability1); input.add(capability2); diff --git a/org.eclipse.gemini.web.core/src/test/java/org/eclipse/gemini/web/internal/WebContainerUtilsTests.java b/org.eclipse.gemini.web.core/src/test/java/org/eclipse/gemini/web/internal/WebContainerUtilsTests.java index 98ef8d1..5e0c22d 100644 --- a/org.eclipse.gemini.web.core/src/test/java/org/eclipse/gemini/web/internal/WebContainerUtilsTests.java +++ b/org.eclipse.gemini.web.core/src/test/java/org/eclipse/gemini/web/internal/WebContainerUtilsTests.java @@ -39,7 +39,7 @@ public class WebContainerUtilsTests { private static final String TEST_SYMBOLIC_NAME = "a"; - private static final Dictionary<String, String> EMPTY_PROPERTIES = new Hashtable<String, String>(); + private static final Dictionary<String, String> EMPTY_PROPERTIES = new Hashtable<>(); @Test public void testGetBaseNameNoExtension() { @@ -91,7 +91,7 @@ public class WebContainerUtilsTests { @Test public void testIsWebBundleWithWebContextPath() throws Exception { - Dictionary<String, String> p = new Hashtable<String, String>(); + Dictionary<String, String> p = new Hashtable<>(); p.put(WebContainerUtils.HEADER_WEB_CONTEXT_PATH, "/foo"); testIsBundleWith("file:foo.jar", p, null, "/foo", true); @@ -114,7 +114,7 @@ public class WebContainerUtilsTests { @Test public void testContextPathSupplied() throws Exception { - Dictionary<String, String> p = new Hashtable<String, String>(); + Dictionary<String, String> p = new Hashtable<>(); p.put(WebContainerUtils.HEADER_WEB_CONTEXT_PATH, "/foo"); testIsBundleWith(null, p, null, "/foo", false); @@ -132,7 +132,7 @@ public class WebContainerUtilsTests { @Test public void testContextPathDefaultedComplexPath() throws Exception { - Dictionary<String, String> p = new Hashtable<String, String>(); + Dictionary<String, String> p = new Hashtable<>(); Bundle bundle = createNiceMock(Bundle.class); expect(bundle.getLocation()).andReturn("file:../formtags.war?Import-Package:org.foo.bar").andReturn("initial@file:../formtags.war").andReturn( @@ -162,7 +162,7 @@ public class WebContainerUtilsTests { @Test public void testServletContextOsgiWebVersionPropertySupplied() { - Dictionary<String, String> headers = new Hashtable<String, String>(); + Dictionary<String, String> headers = new Hashtable<>(); headers.put(WebContainerUtils.BUNDLE_VERSION_HEADER, TEST_BUNDLE_VERSION.toString()); testVersion(TEST_BUNDLE_VERSION, headers); @@ -207,7 +207,7 @@ public class WebContainerUtilsTests { expect(bundle.getHeaders()).andReturn(headers).anyTimes(); replay(bundle); - Dictionary<String, String> p = new Hashtable<String, String>(); + Dictionary<String, String> p = new Hashtable<>(); WebContainerUtils.setServletContextBundleProperties(p, bundle); if (symbolicName == null) { assertNull(p.get(WebContainerUtils.OSGI_WEB_SYMBOLICNAME)); @@ -222,7 +222,7 @@ public class WebContainerUtilsTests { expect(bundle.getHeaders()).andReturn(headers).anyTimes(); replay(bundle); - Dictionary<String, String> p = new Hashtable<String, String>(); + Dictionary<String, String> p = new Hashtable<>(); WebContainerUtils.setServletContextBundleProperties(p, bundle); if (version == null) { assertNull(p.get(WebContainerUtils.OSGI_WEB_VERSION)); diff --git a/org.eclipse.gemini.web.core/src/test/java/org/eclipse/gemini/web/internal/url/DirTransformerTests.java b/org.eclipse.gemini.web.core/src/test/java/org/eclipse/gemini/web/internal/url/DirTransformerTests.java index a908a6c..e770d95 100644 --- a/org.eclipse.gemini.web.core/src/test/java/org/eclipse/gemini/web/internal/url/DirTransformerTests.java +++ b/org.eclipse.gemini.web.core/src/test/java/org/eclipse/gemini/web/internal/url/DirTransformerTests.java @@ -68,7 +68,7 @@ public class DirTransformerTests { webXml.createFile(); PathReference manifest = webAppDir.newChild(JarFile.MANIFEST_NAME); - final List<PathReference> transformedFiles = new ArrayList<PathReference>(); + final List<PathReference> transformedFiles = new ArrayList<>(); DirTransformer transformer = new DirTransformer(new DirTransformerCallback() { @Override @@ -114,9 +114,8 @@ public class DirTransformerTests { toFile.getParent().createDirectory(); createManifest(toFile.toFile(), HEADER_3); return true; - } else { - return false; } + return false; } }); diff --git a/org.eclipse.gemini.web.core/src/test/java/org/eclipse/gemini/web/internal/url/DirTransformingURLConnectionTests.java b/org.eclipse.gemini.web.core/src/test/java/org/eclipse/gemini/web/internal/url/DirTransformingURLConnectionTests.java index 20237a9..fc64b0e 100644 --- a/org.eclipse.gemini.web.core/src/test/java/org/eclipse/gemini/web/internal/url/DirTransformingURLConnectionTests.java +++ b/org.eclipse.gemini.web.core/src/test/java/org/eclipse/gemini/web/internal/url/DirTransformingURLConnectionTests.java @@ -50,7 +50,7 @@ public class DirTransformingURLConnectionTests { PathReference webXml = webAppDir.newChild(WEB_INF + File.separator + WEB_XML); webXml.createFile(); - final List<PathReference> files = new ArrayList<PathReference>(); + final List<PathReference> files = new ArrayList<>(); DirTransformer transformer = new DirTransformer(new DirTransformerCallback() { @Override diff --git a/org.eclipse.gemini.web.core/src/test/java/org/eclipse/gemini/web/internal/url/InstallationOptionsTests.java b/org.eclipse.gemini.web.core/src/test/java/org/eclipse/gemini/web/internal/url/InstallationOptionsTests.java index b9c27ab..cc130e1 100644 --- a/org.eclipse.gemini.web.core/src/test/java/org/eclipse/gemini/web/internal/url/InstallationOptionsTests.java +++ b/org.eclipse.gemini.web.core/src/test/java/org/eclipse/gemini/web/internal/url/InstallationOptionsTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2012 VMware Inc. + * Copyright (c) 2009, 2014 VMware Inc. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -35,7 +35,7 @@ public class InstallationOptionsTests { @Test public void testBundleManifestVersion() { - Map<String, String> map = new HashMap<String, String>(); + Map<String, String> map = new HashMap<>(); map.put(Constants.BUNDLE_MANIFESTVERSION, "2"); InstallationOptions options = new InstallationOptions(map); assertEquals("2", options.getBundleManifestVersion()); @@ -43,7 +43,7 @@ public class InstallationOptionsTests { @Test public void testBundleClassPath() { - Map<String, String> map = new HashMap<String, String>(); + Map<String, String> map = new HashMap<>(); map.put(Constants.BUNDLE_CLASSPATH, "foo,bar"); InstallationOptions options = new InstallationOptions(map); @@ -78,7 +78,7 @@ public class InstallationOptionsTests { String contextPath = "/test"; String extractLocation = "/tmp"; - Map<String, String> map = new HashMap<String, String>(); + Map<String, String> map = new HashMap<>(); map.put(Constants.BUNDLE_SYMBOLICNAME, symbolicName); map.put(Constants.BUNDLE_MANIFESTVERSION, bundleManifestVersion); @@ -108,7 +108,7 @@ public class InstallationOptionsTests { @Test public void testNonCamelCaseOption() { - Map<String, String> map = new HashMap<String, String>(); + Map<String, String> map = new HashMap<>(); map.put("bundle-manifestversion", "3"); InstallationOptions options = new InstallationOptions(map); assertEquals("3", options.getBundleManifestVersion()); diff --git a/org.eclipse.gemini.web.core/src/test/java/org/eclipse/gemini/web/internal/url/SpecificationWebBundleManifestTransformerTests.java b/org.eclipse.gemini.web.core/src/test/java/org/eclipse/gemini/web/internal/url/SpecificationWebBundleManifestTransformerTests.java index c2f4f2b..b176c5b 100644 --- a/org.eclipse.gemini.web.core/src/test/java/org/eclipse/gemini/web/internal/url/SpecificationWebBundleManifestTransformerTests.java +++ b/org.eclipse.gemini.web.core/src/test/java/org/eclipse/gemini/web/internal/url/SpecificationWebBundleManifestTransformerTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2012 VMware Inc. + * Copyright (c) 2009, 2014 VMware Inc. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -50,7 +50,7 @@ public class SpecificationWebBundleManifestTransformerTests { @Test public void transformFromNothing() throws Exception { - Map<String, String> options = new HashMap<String, String>(); + Map<String, String> options = new HashMap<>(); options.put(WebContainerUtils.HEADER_WEB_CONTEXT_PATH, "/"); BundleManifest manifest = BundleManifestFactory.createBundleManifest(); @@ -65,7 +65,7 @@ public class SpecificationWebBundleManifestTransformerTests { String symbolicName = "my.bundle"; String version = "1.2.3"; - Map<String, String> options = new HashMap<String, String>(); + Map<String, String> options = new HashMap<>(); options.put(WebContainerUtils.HEADER_WEB_CONTEXT_PATH, "/"); options.put(Constants.BUNDLE_SYMBOLICNAME, symbolicName); options.put(Constants.BUNDLE_VERSION, version); @@ -84,7 +84,7 @@ public class SpecificationWebBundleManifestTransformerTests { @Test(expected = IllegalArgumentException.class) public void testSpecifyBundleSymbolicNameForWAB() throws Exception { - Map<String, String> options = new HashMap<String, String>(); + Map<String, String> options = new HashMap<>(); options.put(WebContainerUtils.HEADER_WEB_CONTEXT_PATH, "/"); options.put(Constants.BUNDLE_SYMBOLICNAME, "my.bundle"); @@ -96,7 +96,7 @@ public class SpecificationWebBundleManifestTransformerTests { @Test(expected = IllegalArgumentException.class) public void testSpecifyBundleVersionForWAB() throws Exception { - Map<String, String> options = new HashMap<String, String>(); + Map<String, String> options = new HashMap<>(); options.put(WebContainerUtils.HEADER_WEB_CONTEXT_PATH, "/"); options.put(Constants.BUNDLE_VERSION, "0"); @@ -108,7 +108,7 @@ public class SpecificationWebBundleManifestTransformerTests { @Test(expected = IllegalArgumentException.class) public void testSpecifyBundleManifestVersionForWAB() throws Exception { - Map<String, String> options = new HashMap<String, String>(); + Map<String, String> options = new HashMap<>(); options.put(WebContainerUtils.HEADER_WEB_CONTEXT_PATH, "/"); options.put(Constants.BUNDLE_MANIFESTVERSION, "2"); @@ -120,7 +120,7 @@ public class SpecificationWebBundleManifestTransformerTests { @Test(expected = IllegalArgumentException.class) public void testSpecifyBundleManifestVersion() throws Exception { - Map<String, String> options = new HashMap<String, String>(); + Map<String, String> options = new HashMap<>(); options.put(WebContainerUtils.HEADER_WEB_CONTEXT_PATH, "/"); options.put(Constants.BUNDLE_MANIFESTVERSION, "0"); @@ -131,7 +131,7 @@ public class SpecificationWebBundleManifestTransformerTests { @Test(expected = IllegalArgumentException.class) public void testSpecifyBundleManifestVersionStringValue() throws Exception { - Map<String, String> options = new HashMap<String, String>(); + Map<String, String> options = new HashMap<>(); options.put(WebContainerUtils.HEADER_WEB_CONTEXT_PATH, "/"); options.put(Constants.BUNDLE_MANIFESTVERSION, "version"); @@ -143,7 +143,7 @@ public class SpecificationWebBundleManifestTransformerTests { @Test public void testSpecifyImports() throws Exception { - Map<String, String> options = new HashMap<String, String>(); + Map<String, String> options = new HashMap<>(); options.put(WebContainerUtils.HEADER_WEB_CONTEXT_PATH, "/"); options.put(Constants.IMPORT_PACKAGE, "p;version=\"1.2.3\",q;version=\"1.2.4\",r;version=\"1.2.3\""); @@ -159,7 +159,7 @@ public class SpecificationWebBundleManifestTransformerTests { @Test(expected = IllegalArgumentException.class) public void testSpecifyImportsForWAB() throws Exception { - Map<String, String> options = new HashMap<String, String>(); + Map<String, String> options = new HashMap<>(); options.put(WebContainerUtils.HEADER_WEB_CONTEXT_PATH, "/"); options.put(Constants.IMPORT_PACKAGE, "p;version=\"1.2.3\",q;version=\"1.2.4\",r;version=\"1.2.3\""); // implies // WAB @@ -173,7 +173,7 @@ public class SpecificationWebBundleManifestTransformerTests { @Test public void testSpecifyExports() throws Exception { - Map<String, String> options = new HashMap<String, String>(); + Map<String, String> options = new HashMap<>(); options.put(WebContainerUtils.HEADER_WEB_CONTEXT_PATH, "/"); options.put(Constants.EXPORT_PACKAGE, "p;version=\"1.2.3\",q,r;version=\"1.2.3\""); @@ -190,7 +190,7 @@ public class SpecificationWebBundleManifestTransformerTests { @Test(expected = IllegalArgumentException.class) public void testSpecifyExportsForWAB() throws Exception { - Map<String, String> options = new HashMap<String, String>(); + Map<String, String> options = new HashMap<>(); options.put(WebContainerUtils.HEADER_WEB_CONTEXT_PATH, "/"); options.put(Constants.EXPORT_PACKAGE, "p;version=\"1.2.3\",q;version=\"1.2.4\",r;version=\"1.2.3\""); @@ -204,7 +204,7 @@ public class SpecificationWebBundleManifestTransformerTests { @Test public void testSpecifyWebContextPath() throws Exception { - Map<String, String> options = new HashMap<String, String>(); + Map<String, String> options = new HashMap<>(); options.put(WebContainerUtils.HEADER_WEB_CONTEXT_PATH, "/foo"); BundleManifest manifest = BundleManifestFactory.createBundleManifest(); @@ -216,7 +216,7 @@ public class SpecificationWebBundleManifestTransformerTests { @Test public void testSpecifyWebContextPathForWAB() throws Exception { - Map<String, String> options = new HashMap<String, String>(); + Map<String, String> options = new HashMap<>(); options.put(WebContainerUtils.HEADER_WEB_CONTEXT_PATH, "/foo"); BundleManifest manifest = BundleManifestFactory.createBundleManifest(); @@ -230,7 +230,7 @@ public class SpecificationWebBundleManifestTransformerTests { @Test public void testSpecifyWebContextPathWithMissingSlash() throws Exception { - Map<String, String> options = new HashMap<String, String>(); + Map<String, String> options = new HashMap<>(); options.put(WebContainerUtils.HEADER_WEB_CONTEXT_PATH, "foo"); BundleManifest manifest = BundleManifestFactory.createBundleManifest(); @@ -242,7 +242,7 @@ public class SpecificationWebBundleManifestTransformerTests { @Test(expected = IllegalArgumentException.class) public void testSpecifyEmptyWebContextPath() throws Exception { - Map<String, String> options = new HashMap<String, String>(); + Map<String, String> options = new HashMap<>(); options.put(WebContainerUtils.HEADER_WEB_CONTEXT_PATH, " "); BundleManifest manifest = BundleManifestFactory.createBundleManifest(); @@ -252,7 +252,7 @@ public class SpecificationWebBundleManifestTransformerTests { @Test(expected = IllegalArgumentException.class) public void testDoNotSpecifyWebContextPath() throws Exception { - Map<String, String> options = new HashMap<String, String>(); + Map<String, String> options = new HashMap<>(); BundleManifest manifest = BundleManifestFactory.createBundleManifest(); this.transformer.transform(manifest, this.sourceURL, new InstallationOptions(options), WebContainerUtils.isWebApplicationBundle(manifest)); @@ -260,7 +260,7 @@ public class SpecificationWebBundleManifestTransformerTests { @Test(expected = IllegalArgumentException.class) public void testSpecifyBundleClassPathForWAB() throws Exception { - Map<String, String> options = new HashMap<String, String>(); + Map<String, String> options = new HashMap<>(); options.put(Constants.BUNDLE_CLASSPATH, "foo"); BundleManifest manifest = BundleManifestFactory.createBundleManifest(); @@ -272,7 +272,7 @@ public class SpecificationWebBundleManifestTransformerTests { @Test(expected = IllegalArgumentException.class) public void testSpecifyBundleClassPathWithEmptyEntry() throws Exception { - Map<String, String> options = new HashMap<String, String>(); + Map<String, String> options = new HashMap<>(); options.put(Constants.BUNDLE_CLASSPATH, "foo,,foo"); options.put(WebContainerUtils.HEADER_WEB_CONTEXT_PATH, "/"); @@ -284,7 +284,7 @@ public class SpecificationWebBundleManifestTransformerTests { @Test(expected = IllegalArgumentException.class) public void testSpecifyBundleClassPathWithSlash() throws Exception { - Map<String, String> options = new HashMap<String, String>(); + Map<String, String> options = new HashMap<>(); options.put(Constants.BUNDLE_CLASSPATH, "foo,/,foo"); options.put(WebContainerUtils.HEADER_WEB_CONTEXT_PATH, "/"); @@ -296,7 +296,7 @@ public class SpecificationWebBundleManifestTransformerTests { @Test public void testSpecifyBundleClassPath() throws Exception { - Map<String, String> options = new HashMap<String, String>(); + Map<String, String> options = new HashMap<>(); options.put(Constants.BUNDLE_CLASSPATH, "foo,bar,path/"); options.put(WebContainerUtils.HEADER_WEB_CONTEXT_PATH, "/"); diff --git a/org.eclipse.gemini.web.core/src/test/java/org/eclipse/gemini/web/internal/url/SystemBundleExportsImportingWebBundleManifestTransformerTests.java b/org.eclipse.gemini.web.core/src/test/java/org/eclipse/gemini/web/internal/url/SystemBundleExportsImportingWebBundleManifestTransformerTests.java index 8e9abaa..b3aebf0 100644 --- a/org.eclipse.gemini.web.core/src/test/java/org/eclipse/gemini/web/internal/url/SystemBundleExportsImportingWebBundleManifestTransformerTests.java +++ b/org.eclipse.gemini.web.core/src/test/java/org/eclipse/gemini/web/internal/url/SystemBundleExportsImportingWebBundleManifestTransformerTests.java @@ -57,7 +57,7 @@ public class SystemBundleExportsImportingWebBundleManifestTransformerTests { @Test public void importOfExports() throws IOException { - Map<String, VersionRange> exports = new HashMap<String, VersionRange>(); + Map<String, VersionRange> exports = new HashMap<>(); VersionRange vr1 = new VersionRange("[1.2.3,2.0.0)"); VersionRange vr2 = new VersionRange("[2.0.0,3.0.0]"); exports.put("a", vr1); @@ -85,7 +85,7 @@ public class SystemBundleExportsImportingWebBundleManifestTransformerTests { @Test public void existingImportsShouldNotBeOverridden() throws IOException { - Map<String, VersionRange> exports = new HashMap<String, VersionRange>(); + Map<String, VersionRange> exports = new HashMap<>(); VersionRange vr1 = new VersionRange("[1.2.3,2.0.0)"); VersionRange vr2 = new VersionRange("[2.0.0,3.0.0]"); exports.put("a", vr1); @@ -106,7 +106,7 @@ public class SystemBundleExportsImportingWebBundleManifestTransformerTests { @Test public void packagesInWarShouldNotBeImported() throws IOException { - Map<String, VersionRange> exports = new HashMap<String, VersionRange>(); + Map<String, VersionRange> exports = new HashMap<>(); exports.put("from.classes", new VersionRange("[1.0.0,1.0.0]")); exports.put("from.lib", new VersionRange("[1.0.0,1.0.0]")); exports.put("javax.sql", new VersionRange("[0,0]")); diff --git a/org.eclipse.gemini.web.core/src/test/java/org/eclipse/gemini/web/internal/url/WebBundleUrlStreamHandlerServiceTests.java b/org.eclipse.gemini.web.core/src/test/java/org/eclipse/gemini/web/internal/url/WebBundleUrlStreamHandlerServiceTests.java index 194be35..60c3753 100644 --- a/org.eclipse.gemini.web.core/src/test/java/org/eclipse/gemini/web/internal/url/WebBundleUrlStreamHandlerServiceTests.java +++ b/org.eclipse.gemini.web.core/src/test/java/org/eclipse/gemini/web/internal/url/WebBundleUrlStreamHandlerServiceTests.java @@ -124,15 +124,12 @@ public class WebBundleUrlStreamHandlerServiceTests { // Check Manifest try (InputStream is = new FileInputStream(new File(webAppDir, JarFile.MANIFEST_NAME));) { Manifest manifest = new Manifest(is); - - if (manifest != null) { - Attributes mainAttributes = manifest.getMainAttributes(); - Set<Entry<Object, Object>> entrySet = mainAttributes.entrySet(); - for (Entry<Object, Object> entry : entrySet) { - System.out.println(entry.getKey() + ": " + entry.getValue()); - if ("Web-ContextPath".equals(entry.getKey().toString())) { - assertTrue(contextPath.equals(entry.getValue().toString())); - } + Attributes mainAttributes = manifest.getMainAttributes(); + Set<Entry<Object, Object>> entrySet = mainAttributes.entrySet(); + for (Entry<Object, Object> entry : entrySet) { + System.out.println(entry.getKey() + ": " + entry.getValue()); + if ("Web-ContextPath".equals(entry.getKey().toString())) { + assertTrue(contextPath.equals(entry.getValue().toString())); } } } diff --git a/org.eclipse.gemini.web.core/src/test/java/org/eclipse/gemini/web/internal/url/WebBundleUrlTests.java b/org.eclipse.gemini.web.core/src/test/java/org/eclipse/gemini/web/internal/url/WebBundleUrlTests.java index 14d4735..75d55fc 100644 --- a/org.eclipse.gemini.web.core/src/test/java/org/eclipse/gemini/web/internal/url/WebBundleUrlTests.java +++ b/org.eclipse.gemini.web.core/src/test/java/org/eclipse/gemini/web/internal/url/WebBundleUrlTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2012 VMware Inc. + * Copyright (c) 2009, 2014 VMware Inc. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -47,7 +47,7 @@ public class WebBundleUrlTests { @Test public void encodeWithOptions() throws Exception { - Map<String, String> options = new TreeMap<String, String>(); + Map<String, String> options = new TreeMap<>(); options.put("Web-ContextPath", "/foo"); options.put("name", "Rob Harrop"); WebBundleUrl url = new TestWarUrl(FILE_LOCATION, options); diff --git a/org.eclipse.gemini.web.extender/src/main/java/org/eclipse/gemini/web/extender/ExtenderActivator.java b/org.eclipse.gemini.web.extender/src/main/java/org/eclipse/gemini/web/extender/ExtenderActivator.java index 37459eb..fcab577 100644 --- a/org.eclipse.gemini.web.extender/src/main/java/org/eclipse/gemini/web/extender/ExtenderActivator.java +++ b/org.eclipse.gemini.web.extender/src/main/java/org/eclipse/gemini/web/extender/ExtenderActivator.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 VMware Inc. + * Copyright (c) 2009, 2014 VMware Inc. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -31,7 +31,7 @@ public final class ExtenderActivator implements BundleActivator { @Override public void start(BundleContext context) { - this.serviceTracker = new ServiceTracker<WebContainer, String>(context, WebContainer.class, new ExtendedWebContainerTracker(context)); + this.serviceTracker = new ServiceTracker<>(context, WebContainer.class, new ExtendedWebContainerTracker(context)); this.serviceTracker.open(); } @@ -53,7 +53,7 @@ public final class ExtenderActivator implements BundleActivator { @Override public String addingService(ServiceReference<WebContainer> reference) { if (this.bundleTracker == null) { - this.bundleTracker = new BundleTracker<Object>(this.context, Bundle.ACTIVE, new WebContainerBundleCustomizer( + this.bundleTracker = new BundleTracker<>(this.context, Bundle.ACTIVE, new WebContainerBundleCustomizer( this.context.getService(reference), this.context.getBundle())); } this.bundleTracker.open(); diff --git a/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/Activator.java b/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/Activator.java index 68ed37e..d57fa51 100644 --- a/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/Activator.java +++ b/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/Activator.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2012 VMware Inc. + * Copyright (c) 2009, 2014 VMware Inc. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -74,7 +74,7 @@ public class Activator implements BundleActivator { } private void registerURLStreamHandler(BundleContext context) { - Dictionary<String, Object> properties = new Hashtable<String, Object>(); + Dictionary<String, Object> properties = new Hashtable<>(); properties.put(URLConstants.URL_HANDLER_PROTOCOL, new String[] { JNDI_SCHEME }); DirContextURLStreamHandlerService handler = new DirContextURLStreamHandlerService(); diff --git a/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/BundleDependenciesJarScanner.java b/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/BundleDependenciesJarScanner.java index e4e45e9..d71f676 100644 --- a/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/BundleDependenciesJarScanner.java +++ b/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/BundleDependenciesJarScanner.java @@ -169,7 +169,7 @@ final class BundleDependenciesJarScanner implements JarScanner { } private Set<String> getBundlesToSkip(BundleContext bundleContext) { - Set<String> result = new HashSet<String>(); + Set<String> result = new HashSet<>(); String property = bundleContext.getProperty(SCANNER_SKIP_BUNDLES_PROPERTY_NAME); if (property == null) { diff --git a/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/DelegatingClassLoaderCustomizer.java b/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/DelegatingClassLoaderCustomizer.java index d204c71..5f9c2f9 100644 --- a/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/DelegatingClassLoaderCustomizer.java +++ b/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/DelegatingClassLoaderCustomizer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2013 VMware Inc. + * Copyright (c) 2009, 2014 VMware Inc. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -40,7 +40,7 @@ final class DelegatingClassLoaderCustomizer implements ClassLoaderCustomizer { public DelegatingClassLoaderCustomizer(BundleContext context) { this.context = context; - this.tracker = new ServiceTracker<ClassLoaderCustomizer, Object>(context, ClassLoaderCustomizer.class.getName(), new Customizer()); + this.tracker = new ServiceTracker<>(context, ClassLoaderCustomizer.class.getName(), new Customizer()); } public void open() { @@ -63,31 +63,28 @@ final class DelegatingClassLoaderCustomizer implements ClassLoaderCustomizer { @Override public ClassLoader createThrowawayClassLoader(Bundle bundle) { if (this.delegate != null && this.delegate.size() > 0) { - Set<ClassLoader> result = new HashSet<ClassLoader>(); + Set<ClassLoader> result = new HashSet<>(); for (ClassLoaderCustomizer classLoaderCustomizer : this.delegate) { result.add(classLoaderCustomizer.createThrowawayClassLoader(bundle)); } if (result.size() > 0) { return ChainedClassLoader.create(result.toArray(new ClassLoader[result.size()])); - } else { - return null; } - } else { return null; } + return null; } @Override public ClassLoader[] extendClassLoaderChain(Bundle bundle) { if (this.delegate != null && this.delegate.size() > 0) { - Set<ClassLoader> result = new LinkedHashSet<ClassLoader>(); + Set<ClassLoader> result = new LinkedHashSet<>(); for (ClassLoaderCustomizer classLoaderCustomizer : this.delegate) { result.addAll(Arrays.asList(classLoaderCustomizer.extendClassLoaderChain(bundle))); } return result.toArray(new ClassLoader[result.size()]); - } else { - return new ClassLoader[0]; } + return new ClassLoader[0]; } private class Customizer implements ServiceTrackerCustomizer<ClassLoaderCustomizer, Object> { @@ -97,7 +94,7 @@ final class DelegatingClassLoaderCustomizer implements ClassLoaderCustomizer { ClassLoaderCustomizer newDelegate = DelegatingClassLoaderCustomizer.this.context.getService(reference); if (DelegatingClassLoaderCustomizer.this.delegate == null) { - DelegatingClassLoaderCustomizer.this.delegate = new HashSet<ClassLoaderCustomizer>(); + DelegatingClassLoaderCustomizer.this.delegate = new HashSet<>(); } DelegatingClassLoaderCustomizer.this.delegate.add(newDelegate); diff --git a/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/DelegatingJarScannerCustomizer.java b/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/DelegatingJarScannerCustomizer.java index d2c8429..e9e9b9c 100755 --- a/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/DelegatingJarScannerCustomizer.java +++ b/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/DelegatingJarScannerCustomizer.java @@ -1,5 +1,5 @@ /*******************************************************************************
- * Copyright (c) 2012 SAP AG
+ * Copyright (c) 2012, 2014 SAP AG
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -38,7 +38,7 @@ final class DelegatingJarScannerCustomizer implements JarScannerCustomizer { DelegatingJarScannerCustomizer(BundleContext context) {
this.context = context;
- this.tracker = new ServiceTracker<JarScannerCustomizer, Object>(context, JarScannerCustomizer.class.getName(), new Customizer());
+ this.tracker = new ServiceTracker<>(context, JarScannerCustomizer.class.getName(), new Customizer());
}
void open() {
@@ -52,14 +52,13 @@ final class DelegatingJarScannerCustomizer implements JarScannerCustomizer { @Override
public JarScanner[] extendJarScannerChain(Bundle bundle) {
if (this.delegate != null && this.delegate.size() > 0) {
- Set<JarScanner> jarScanners = new HashSet<JarScanner>();
+ Set<JarScanner> jarScanners = new HashSet<>();
for (JarScannerCustomizer jarScannerCustomizer : this.delegate) {
jarScanners.addAll(Arrays.asList(jarScannerCustomizer.extendJarScannerChain(bundle)));
}
return jarScanners.toArray(new JarScanner[jarScanners.size()]);
- } else {
- return new JarScanner[0];
}
+ return new JarScanner[0];
}
private class Customizer implements ServiceTrackerCustomizer<JarScannerCustomizer, Object> {
@@ -69,7 +68,7 @@ final class DelegatingJarScannerCustomizer implements JarScannerCustomizer { JarScannerCustomizer newDelegate = DelegatingJarScannerCustomizer.this.context.getService(reference);
if (DelegatingJarScannerCustomizer.this.delegate == null) {
- DelegatingJarScannerCustomizer.this.delegate = new HashSet<JarScannerCustomizer>();
+ DelegatingJarScannerCustomizer.this.delegate = new HashSet<>();
}
DelegatingJarScannerCustomizer.this.delegate.add(newDelegate);
diff --git a/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/ExtendedStandardContext.java b/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/ExtendedStandardContext.java index c68014a..063f80d 100644 --- a/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/ExtendedStandardContext.java +++ b/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/ExtendedStandardContext.java @@ -35,7 +35,7 @@ public class ExtendedStandardContext extends StandardContext { private final static Logger LOGGER = LoggerFactory.getLogger(ExtendedStandardContext.class);
- private Bundle bundle;
+ private final Bundle bundle;
public ExtendedStandardContext(Bundle bundle) {
super();
@@ -54,20 +54,23 @@ public class ExtendedStandardContext extends StandardContext { @Override
public synchronized void reload() {
- if (!getState().isAvailable())
+ if (!getState().isAvailable()) {
throw new IllegalStateException("Context with name [" + getName() + "] has not yet been started.");
+ }
- if (LOGGER.isInfoEnabled())
+ if (LOGGER.isInfoEnabled()) {
LOGGER.info("Reloading Context with name [" + getName() + "] has started.");
+ }
final Bundle systemBundle = this.bundle.getBundleContext().getBundle(0);
final FrameworkWiring frameworkWiring = systemBundle.adapt(FrameworkWiring.class);
- Set<Bundle> bundles = new HashSet<Bundle>();
+ Set<Bundle> bundles = new HashSet<>();
bundles.add(this.bundle);
frameworkWiring.refreshBundles(bundles);
- if (LOGGER.isInfoEnabled())
+ if (LOGGER.isInfoEnabled()) {
LOGGER.info("Reloading Context with name [" + getName() + "] is completed");
+ }
}
diff --git a/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/OsgiAwareEmbeddedTomcat.java b/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/OsgiAwareEmbeddedTomcat.java index ae981c5..b2c2471 100644 --- a/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/OsgiAwareEmbeddedTomcat.java +++ b/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/OsgiAwareEmbeddedTomcat.java @@ -365,7 +365,7 @@ public final class OsgiAwareEmbeddedTomcat extends org.apache.catalina.startup.T if (this.authenticators == null) { synchronized (this.monitor) { if (this.authenticators == null) { - this.authenticators = new HashMap<String, Authenticator>(); + this.authenticators = new HashMap<>(); } } } @@ -463,7 +463,7 @@ public final class OsgiAwareEmbeddedTomcat extends org.apache.catalina.startup.T * In the traditional way this factory is specified via <code>java.naming.factory.initial</code> system property. */ private void registerJavaURLContextFactory() { - Dictionary<String, String> serviceProperties = new Hashtable<String, String>(); + Dictionary<String, String> serviceProperties = new Hashtable<>(); serviceProperties.put(JNDI_URLSCHEME, JAVA_JNDI_URLSCHEME); ServiceRegistration<ObjectFactory> serviceRegistration = this.bundleContext.registerService(ObjectFactory.class, new javaURLContextFactory(), serviceProperties); diff --git a/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/TomcatWebContainerProperties.java b/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/TomcatWebContainerProperties.java index 0ba9f5a..d06fbdf 100644 --- a/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/TomcatWebContainerProperties.java +++ b/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/TomcatWebContainerProperties.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 VMware Inc. + * Copyright (c) 2009, 2014 VMware Inc. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -57,7 +57,7 @@ final class TomcatWebContainerProperties implements WebContainerProperties { */ @Override public Set<ConnectorDescriptor> getConnectorDescriptors() { - Set<ConnectorDescriptor> connectorDescriptors = new HashSet<ConnectorDescriptor>(); + Set<ConnectorDescriptor> connectorDescriptors = new HashSet<>(); MBeanServer mBeanServer = this.getMBeanServer(); try { ObjectName portNamesQuery = new ObjectName(CATALINA_TYPE_PROTOCOL_HANDLER); diff --git a/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/WebappConfigLocator.java b/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/WebappConfigLocator.java index 4dae2fc..80a3856 100755 --- a/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/WebappConfigLocator.java +++ b/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/WebappConfigLocator.java @@ -74,9 +74,8 @@ public class WebappConfigLocator { File defaultContextXml = new File(configLocation, DEFAULT_CONTEXT_XML); if (defaultContextXml.exists()) { return defaultContextXml.getAbsolutePath(); - } else { - return null; } + return null; } /** @@ -135,9 +134,8 @@ public class WebappConfigLocator { if (EMPTY_STRING.equals(docBase)) { if (bundle != null) { return resolveWebappContextXmlFromJarURLConnection(bundle); - } else { - return null; } + return null; } File docBaseFile = new File(docBase); diff --git a/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/loading/BundleClassPathURLExtractor.java b/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/loading/BundleClassPathURLExtractor.java index 83f7276..841f7e5 100644 --- a/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/loading/BundleClassPathURLExtractor.java +++ b/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/loading/BundleClassPathURLExtractor.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 VMware Inc. + * Copyright (c) 2009, 2014 VMware Inc. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -33,7 +33,7 @@ final class BundleClassPathURLExtractor { private static final String JAR_EXTENSION = ".jar"; public static Set<URI> extractBundleClassPathURLs(Bundle bundle) { - Set<URI> results = new HashSet<URI>(); + Set<URI> results = new HashSet<>(); String bcp = bundle.getHeaders().get(org.osgi.framework.Constants.BUNDLE_CLASSPATH); if (bcp != null) { String[] entries = bcp.split(","); diff --git a/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/loading/BundleDirContext.java b/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/loading/BundleDirContext.java index 9d1a16b..3a9c7ae 100644 --- a/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/loading/BundleDirContext.java +++ b/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/loading/BundleDirContext.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2013 VMware Inc. + * Copyright (c) 2009, 2014 VMware Inc. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -100,7 +100,7 @@ public final class BundleDirContext extends AbstractReadOnlyDirContext { private List<NamingEntry> doList(BundleEntry bundleEntry) { List<BundleEntry> list = bundleEntry.list(); - List<NamingEntry> resources = new ArrayList<NamingEntry>(); + List<NamingEntry> resources = new ArrayList<>(); for (BundleEntry entry : list) { Object object; object = entryToResult(entry); diff --git a/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/loading/BundleEntry.java b/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/loading/BundleEntry.java index 996e196..f060b8b 100644 --- a/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/loading/BundleEntry.java +++ b/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/loading/BundleEntry.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2013 VMware Inc. + * Copyright (c) 2009, 2014 VMware Inc. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -99,7 +99,7 @@ public final class BundleEntry { } public List<BundleEntry> list() { - List<BundleEntry> entries = new ArrayList<BundleEntry>(); + List<BundleEntry> entries = new ArrayList<>(); Set<String> paths = getEntryPathsFromBundle(); if (paths != null) { Iterator<String> iterator = paths.iterator(); @@ -133,7 +133,7 @@ public final class BundleEntry { private Set<String> getEntryPathsFromBundle(Bundle bundle) { final Enumeration<String> ep = bundle.getEntryPaths(this.path); - Set<String> paths = new HashSet<String>(); + Set<String> paths = new HashSet<>(); if (ep != null) { while (ep.hasMoreElements()) { paths.add(ep.nextElement()); @@ -147,12 +147,11 @@ public final class BundleEntry { String finalPath = this.path + subPath; URL entryURL = getEntryFromBundle(finalPath); if (entryURL != null) { - Map<BundleEntry, URL> result = new HashMap<BundleEntry, URL>(); + Map<BundleEntry, URL> result = new HashMap<>(); result.put(createBundleEntry(finalPath), entryURL); return result.entrySet().iterator().next(); - } else { - return null; } + return null; } /** @@ -214,9 +213,8 @@ public final class BundleEntry { if (name.length() == 0) { return PATH_SEPARATOR; - } else { - return name; } + return name; } public URL getURL() { @@ -253,7 +251,7 @@ public final class BundleEntry { } private List<Bundle> getFragments(Bundle bundle) { - List<Bundle> fragments = new ArrayList<Bundle>(); + List<Bundle> fragments = new ArrayList<>(); BundleRevision bundleRevision = bundle.adapt(BundleRevision.class); if (bundleRevision != null) { BundleWiring bundleWiring = bundleRevision.getWiring(); diff --git a/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/loading/BundleEntryAttributes.java b/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/loading/BundleEntryAttributes.java index facf360..feda801 100644 --- a/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/loading/BundleEntryAttributes.java +++ b/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/loading/BundleEntryAttributes.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2013 VMware Inc. + * Copyright (c) 2009, 2014 VMware Inc. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -208,9 +208,8 @@ final class BundleEntryAttributes extends ResourceAttributes { try { if (url != null) { return url.openConnection(); - } else { - return null; } + return null; } catch (IOException e) { return null; } diff --git a/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/loading/ChainedClassLoader.java b/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/loading/ChainedClassLoader.java index 46e7025..5912b68 100644 --- a/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/loading/ChainedClassLoader.java +++ b/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/loading/ChainedClassLoader.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2013 VMware Inc. + * Copyright (c) 2009, 2014 VMware Inc. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -52,7 +52,7 @@ public final class ChainedClassLoader extends ClassLoader implements BundleRefer */ ChainedClassLoader(ClassLoader... loaders) { - List<ClassLoader> l = new ArrayList<ClassLoader>(); + List<ClassLoader> l = new ArrayList<>(); for (int i = 0; i < loaders.length; i++) { ClassLoader classLoader = loaders[i]; @@ -85,9 +85,8 @@ public final class ChainedClassLoader extends ClassLoader implements BundleRefer return doGetResource(name); } }); - } else { - return doGetResource(name); } + return doGetResource(name); } @Override @@ -112,13 +111,12 @@ public final class ChainedClassLoader extends ClassLoader implements BundleRefer throw new IllegalStateException("Unexpected Exception from privileged action.", exception); } } - } else { - return doGetResources(name); } + return doGetResources(name); } private Enumeration<URL> doGetResources(String name) throws IOException { - Map<String, URL> urls = new HashMap<String, URL>(); + Map<String, URL> urls = new HashMap<>(); for (ClassLoader loader : this.loaders) { Enumeration<URL> resources = loader.getResources(name); if (resources != null) { @@ -160,9 +158,8 @@ public final class ChainedClassLoader extends ClassLoader implements BundleRefer } catch (PrivilegedActionException pae) { throw (ClassNotFoundException) pae.getException(); } - } else { - return doLoadClass(name); } + return doLoadClass(name); } private Class<?> doLoadClass(String name) throws ClassNotFoundException { diff --git a/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/support/BundleFileResolverFactory.java b/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/support/BundleFileResolverFactory.java index b4be4f8..09949b0 100644 --- a/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/support/BundleFileResolverFactory.java +++ b/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/support/BundleFileResolverFactory.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 VMware Inc. + * Copyright (c) 2009, 2014 VMware Inc. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -29,9 +29,8 @@ public final class BundleFileResolverFactory { public static BundleFileResolver createBundleFileResolver() { if (EquinoxBundleFileResolver.canUse()) { return new EquinoxBundleFileResolver(); - } else { - return new NoOpBundleFileResolver(); } + return new NoOpBundleFileResolver(); } private static class NoOpBundleFileResolver implements BundleFileResolver { diff --git a/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/support/PackageAdminBundleDependencyDeterminer.java b/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/support/PackageAdminBundleDependencyDeterminer.java index 56cce12..e9fa1a1 100644 --- a/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/support/PackageAdminBundleDependencyDeterminer.java +++ b/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/support/PackageAdminBundleDependencyDeterminer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2012 VMware Inc. + * Copyright (c) 2009, 2014 VMware Inc. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -44,7 +44,7 @@ public final class PackageAdminBundleDependencyDeterminer implements BundleDepen */ @Override public Set<Bundle> getDependencies(Bundle rootBundle) { - Set<Bundle> dependencies = new HashSet<Bundle>(); + Set<Bundle> dependencies = new HashSet<>(); BundleWiring bundleWiring = rootBundle.adapt(BundleRevision.class).getWiring(); @@ -58,7 +58,7 @@ public final class PackageAdminBundleDependencyDeterminer implements BundleDepen } private Set<Bundle> getRequiredWires(BundleWiring bundleWiring, String namespace) { - Set<Bundle> dependencies = new HashSet<Bundle>(); + Set<Bundle> dependencies = new HashSet<>(); List<BundleWire> bundleWires = bundleWiring.getRequiredWires(namespace); if (bundleWires != null) { diff --git a/org.eclipse.gemini.web.tomcat/src/test/java/org/eclipse/gemini/web/tomcat/internal/BundleDependenciesJarScannerTests.java b/org.eclipse.gemini.web.tomcat/src/test/java/org/eclipse/gemini/web/tomcat/internal/BundleDependenciesJarScannerTests.java index 8e3ebde..e585ada 100644 --- a/org.eclipse.gemini.web.tomcat/src/test/java/org/eclipse/gemini/web/tomcat/internal/BundleDependenciesJarScannerTests.java +++ b/org.eclipse.gemini.web.tomcat/src/test/java/org/eclipse/gemini/web/tomcat/internal/BundleDependenciesJarScannerTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2012 VMware Inc. + * Copyright (c) 2009, 2014 VMware Inc. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -78,7 +78,7 @@ public class BundleDependenciesJarScannerTests { @Test public void scanDirectory() throws IOException { expect(this.bundle.getHeaders()).andReturn(new Hashtable<String, String>()); - expect(this.dependencyDeterminer.getDependencies(this.bundle)).andReturn(new HashSet<Bundle>(Arrays.asList(this.dependency))); + expect(this.dependencyDeterminer.getDependencies(this.bundle)).andReturn(new HashSet<>(Arrays.asList(this.dependency))); File dependencyFile = new File("src/test/resources"); expect(this.bundleFileResolver.resolve(this.dependency)).andReturn(dependencyFile); @@ -96,7 +96,7 @@ public class BundleDependenciesJarScannerTests { @Test public void scanFile() throws IOException { expect(this.bundle.getHeaders()).andReturn(new Hashtable<String, String>()); - expect(this.dependencyDeterminer.getDependencies(this.bundle)).andReturn(new HashSet<Bundle>(Arrays.asList(this.dependency))); + expect(this.dependencyDeterminer.getDependencies(this.bundle)).andReturn(new HashSet<>(Arrays.asList(this.dependency))); File dependencyFile = new File(""); expect(this.bundleFileResolver.resolve(this.dependency)).andReturn(dependencyFile); @@ -114,7 +114,7 @@ public class BundleDependenciesJarScannerTests { @Test public void scanJarUrlConnection() throws IOException { expect(this.bundle.getHeaders()).andReturn(new Hashtable<String, String>()); - expect(this.dependencyDeterminer.getDependencies(this.bundle)).andReturn(new HashSet<Bundle>(Arrays.asList(this.dependency))).times(2); + expect(this.dependencyDeterminer.getDependencies(this.bundle)).andReturn(new HashSet<>(Arrays.asList(this.dependency))).times(2); expect(this.dependency.getLocation()).andReturn("file:src/test/resources/bundle.jar").andReturn( "reference:file:src/test/resources/bundle.jar"); expect(this.dependency.getSymbolicName()).andReturn("bundle").anyTimes(); diff --git a/org.eclipse.gemini.web.tomcat/src/test/java/org/eclipse/gemini/web/tomcat/internal/ChainingJarScannerTests.java b/org.eclipse.gemini.web.tomcat/src/test/java/org/eclipse/gemini/web/tomcat/internal/ChainingJarScannerTests.java index c666960..400e9c8 100755 --- a/org.eclipse.gemini.web.tomcat/src/test/java/org/eclipse/gemini/web/tomcat/internal/ChainingJarScannerTests.java +++ b/org.eclipse.gemini.web.tomcat/src/test/java/org/eclipse/gemini/web/tomcat/internal/ChainingJarScannerTests.java @@ -1,5 +1,5 @@ /*******************************************************************************
- * Copyright (c) 2012 SAP AG
+ * Copyright (c) 2012, 2014 SAP AG
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -30,7 +30,7 @@ import org.junit.Test; public class ChainingJarScannerTests {
- private final List<String> scannedResources = new ArrayList<String>();
+ private final List<String> scannedResources = new ArrayList<>();
@Test
public void testScan() {
diff --git a/org.eclipse.gemini.web.tomcat/src/test/java/org/eclipse/gemini/web/tomcat/internal/TomcatConfigLocatorTests.java b/org.eclipse.gemini.web.tomcat/src/test/java/org/eclipse/gemini/web/tomcat/internal/TomcatConfigLocatorTests.java index 90639cd..0db9ec8 100644 --- a/org.eclipse.gemini.web.tomcat/src/test/java/org/eclipse/gemini/web/tomcat/internal/TomcatConfigLocatorTests.java +++ b/org.eclipse.gemini.web.tomcat/src/test/java/org/eclipse/gemini/web/tomcat/internal/TomcatConfigLocatorTests.java @@ -47,7 +47,7 @@ public class TomcatConfigLocatorTests { @Test public void testStartAndStopWithUserConfig() throws Exception { URL url = new URL("file:src/test/resources/server.xml"); - Vector<URL> v = new Vector<URL>(); + Vector<URL> v = new Vector<>(); v.add(url); startAndStop(v.elements()); diff --git a/org.eclipse.gemini.web.tomcat/src/test/java/org/eclipse/gemini/web/tomcat/internal/loading/BundleDelegatingClassLoaderTests.java b/org.eclipse.gemini.web.tomcat/src/test/java/org/eclipse/gemini/web/tomcat/internal/loading/BundleDelegatingClassLoaderTests.java index 18efa2c..b782a68 100755 --- a/org.eclipse.gemini.web.tomcat/src/test/java/org/eclipse/gemini/web/tomcat/internal/loading/BundleDelegatingClassLoaderTests.java +++ b/org.eclipse.gemini.web.tomcat/src/test/java/org/eclipse/gemini/web/tomcat/internal/loading/BundleDelegatingClassLoaderTests.java @@ -188,20 +188,18 @@ public class BundleDelegatingClassLoaderTests extends TestCase { } catch (MalformedURLException e) { return null; } - } else { - return null; } + return null; } @Override public Enumeration<URL> getResources(String name) throws IOException { if ("file://bla-bla".equals(name)) { - List<URL> resources = new ArrayList<URL>(); + List<URL> resources = new ArrayList<>(); resources.add(new URL("file://bla-bla")); return Collections.enumeration(resources); - } else { - return null; } + return null; } } diff --git a/org.eclipse.gemini.web.tomcat/src/test/java/org/eclipse/gemini/web/tomcat/internal/loading/BundleEntryTests.java b/org.eclipse.gemini.web.tomcat/src/test/java/org/eclipse/gemini/web/tomcat/internal/loading/BundleEntryTests.java index 4d14f73..6ed9640 100644 --- a/org.eclipse.gemini.web.tomcat/src/test/java/org/eclipse/gemini/web/tomcat/internal/loading/BundleEntryTests.java +++ b/org.eclipse.gemini.web.tomcat/src/test/java/org/eclipse/gemini/web/tomcat/internal/loading/BundleEntryTests.java @@ -175,7 +175,7 @@ public class BundleEntryTests { } private Enumeration<String> createPathsEnumeration(String... paths) { - Vector<String> vector = new Vector<String>(); + Vector<String> vector = new Vector<>(); for (String path : paths) { vector.add(path); diff --git a/org.eclipse.gemini.web.tomcat/src/test/java/org/eclipse/gemini/web/tomcat/naming/factory/OsgiServiceFactoryTests.java b/org.eclipse.gemini.web.tomcat/src/test/java/org/eclipse/gemini/web/tomcat/naming/factory/OsgiServiceFactoryTests.java index b6e72de..bc5eeb1 100755 --- a/org.eclipse.gemini.web.tomcat/src/test/java/org/eclipse/gemini/web/tomcat/naming/factory/OsgiServiceFactoryTests.java +++ b/org.eclipse.gemini.web.tomcat/src/test/java/org/eclipse/gemini/web/tomcat/naming/factory/OsgiServiceFactoryTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011 SAP AG + * Copyright (c) 2011, 2014 SAP AG * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -59,8 +59,8 @@ public class OsgiServiceFactoryTests { @Test public void testGetObjectInstance() throws Exception { - expect(this.initialContextFactoryBuilder.createInitialContextFactory(new Hashtable<Object, Object>())).andReturn(this.initialContextFactory); - expect(this.initialContextFactory.getInitialContext(new Hashtable<Object, Object>())).andReturn(this.context); + expect(this.initialContextFactoryBuilder.createInitialContextFactory(new Hashtable<>())).andReturn(this.initialContextFactory); + expect(this.initialContextFactory.getInitialContext(new Hashtable<>())).andReturn(this.context); expect(this.context.lookup(OsgiServiceFactory.OSGI_JNDI_URLSCHEME + LOOKUP)).andReturn(new Object()); replay(this.initialContextFactoryBuilder, this.initialContextFactory, this.context); diff --git a/test-bundles/war-with-resource-references/src/main/java/test/Bug53180Servlet.java b/test-bundles/war-with-resource-references/src/main/java/test/Bug53180Servlet.java index b76ff0e..d1e40d1 100644 --- a/test-bundles/war-with-resource-references/src/main/java/test/Bug53180Servlet.java +++ b/test-bundles/war-with-resource-references/src/main/java/test/Bug53180Servlet.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2012 SAP AG + * Copyright (c) 2012, 2014 SAP AG * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -55,9 +55,8 @@ public class Bug53180Servlet extends HttpServlet { if (override) { this.resource = "setter method: " + resource; return true; - } else { - return false; } + return false; } } |