camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1178956 - in /camel/trunk: camel-core/src/main/java/org/apache/camel/impl/ camel-core/src/test/java/org/apache/camel/ camel-core/src/test/java/org/apache/camel/management/ components/camel-spring/src/test/java/org/apache/camel/spring/confi...
Date Tue, 04 Oct 2011 21:20:33 GMT
Author: dkulp
Date: Tue Oct  4 21:20:32 2011
New Revision: 1178956

URL: http://svn.apache.org/viewvc?rev=1178956&view=rev
Log:
Work on reducing compiler warnings related to deprecated methods and
related to use of untyped collections.

Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultRouteNode.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/ContextTestSupport.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedRegisterRouteTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/management/RemoveRouteDefinitionTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/XmlConfigTestSupport.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/scan/SpringComponentScanTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/scan/SpringComponentScanWithDeprecatedPackagesTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringSetExchangePatternWithCustomIdTest.java
    camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/CamelTestSupport.java
    camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/junit4/CamelTestSupport.java
    camel/trunk/tooling/maven/camel-maven-plugin/src/main/java/org/apache/camel/maven/RunMojo.java
    camel/trunk/tooling/maven/guice-maven-plugin/src/main/java/org/apache/camel/guice/maven/RunMojo.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultRouteNode.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultRouteNode.java?rev=1178956&r1=1178955&r2=1178956&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultRouteNode.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultRouteNode.java Tue Oct
 4 21:20:32 2011
@@ -52,6 +52,7 @@ public class DefaultRouteNode implements
         return processorDefinition;
     }
 
+    @SuppressWarnings("deprecation")
     public String getLabel(Exchange exchange) {
         if (expression != null) {
             return expression.evaluate(exchange, String.class);

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/ContextTestSupport.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/ContextTestSupport.java?rev=1178956&r1=1178955&r2=1178956&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/ContextTestSupport.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/ContextTestSupport.java Tue Oct
 4 21:20:32 2011
@@ -26,6 +26,7 @@ import org.apache.camel.component.mock.M
 import org.apache.camel.impl.DefaultCamelContext;
 import org.apache.camel.impl.JndiRegistry;
 import org.apache.camel.management.JmxSystemPropertyKeys;
+import org.apache.camel.model.ModelCamelContext;
 import org.apache.camel.spi.Language;
 import org.apache.camel.util.jndi.JndiTest;
 
@@ -37,7 +38,7 @@ import org.apache.camel.util.jndi.JndiTe
  */
 public abstract class ContextTestSupport extends TestSupport {
     
-    protected volatile CamelContext context;
+    protected volatile ModelCamelContext context;
     protected volatile ProducerTemplate template;
     protected volatile ConsumerTemplate consumer;
     protected volatile NotifyBuilder oneExchangeDone;
@@ -85,7 +86,12 @@ public abstract class ContextTestSupport
         } else {
             enableJMX();
         }
-        context = createCamelContext();
+        CamelContext c2 = createCamelContext();
+        if (c2 instanceof ModelCamelContext) {
+            context = (ModelCamelContext)c2;
+        } else {
+            throw new Exception("Context must be a ModelCamelContext");
+        }
         assertValidContext(context);
 
         // reduce default shutdown timeout to avoid waiting for 300 seconds

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedRegisterRouteTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedRegisterRouteTest.java?rev=1178956&r1=1178955&r2=1178956&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedRegisterRouteTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedRegisterRouteTest.java
Tue Oct  4 21:20:32 2011
@@ -28,7 +28,6 @@ import org.apache.camel.builder.RouteBui
  */
 public class ManagedRegisterRouteTest extends ManagementTestSupport {
 
-    @SuppressWarnings("deprecation")
     public void testRoutes() throws Exception {
         MBeanServer mbeanServer = getMBeanServer();
 

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/management/RemoveRouteDefinitionTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/management/RemoveRouteDefinitionTest.java?rev=1178956&r1=1178955&r2=1178956&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/management/RemoveRouteDefinitionTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/management/RemoveRouteDefinitionTest.java
Tue Oct  4 21:20:32 2011
@@ -63,7 +63,6 @@ public class RemoveRouteDefinitionTest e
         boolean registered = mbeanServer.isRegistered(on);
         assertEquals("Should be registered", true, registered);
 
-        @SuppressWarnings("deprecation")
         RouteDefinition definition = context.getRouteDefinition("route1");
         List<RouteDefinition> routeDefinitions = new ArrayList<RouteDefinition>();
         routeDefinitions.add(definition);
@@ -87,7 +86,6 @@ public class RemoveRouteDefinitionTest e
         boolean registered = mbeanServer.isRegistered(on);
         assertEquals("Should be registered", true, registered);
         
-        @SuppressWarnings("deprecation")
         RouteDefinition definition = context.getRouteDefinition("route1");
         List<RouteDefinition> routeDefinitions = new ArrayList<RouteDefinition>();
         routeDefinitions.add(definition);

Modified: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/XmlConfigTestSupport.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/XmlConfigTestSupport.java?rev=1178956&r1=1178955&r2=1178956&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/XmlConfigTestSupport.java
(original)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/XmlConfigTestSupport.java
Tue Oct  4 21:20:32 2011
@@ -21,6 +21,7 @@ import java.util.List;
 import org.apache.camel.CamelContext;
 import org.apache.camel.TestSupport;
 import org.apache.camel.model.FromDefinition;
+import org.apache.camel.model.ModelCamelContext;
 import org.apache.camel.model.ProcessorDefinition;
 import org.apache.camel.model.RouteDefinition;
 import org.slf4j.Logger;
@@ -35,7 +36,7 @@ public class XmlConfigTestSupport extend
     protected void assertValidContext(CamelContext context) {
         assertNotNull("No context found!", context);
 
-        List<RouteDefinition> routes = context.getRouteDefinitions();
+        List<RouteDefinition> routes = ((ModelCamelContext)context).getRouteDefinitions();
         LOG.debug("Found routes: " + routes);
 
         assertEquals("One Route should be found", 1, routes.size());

Modified: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/scan/SpringComponentScanTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/scan/SpringComponentScanTest.java?rev=1178956&r1=1178955&r2=1178956&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/scan/SpringComponentScanTest.java
(original)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/scan/SpringComponentScanTest.java
Tue Oct  4 21:20:32 2011
@@ -21,6 +21,7 @@ import java.util.concurrent.TimeUnit;
 import org.apache.camel.CamelContext;
 import org.apache.camel.ContextTestSupport;
 import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.model.ModelCamelContext;
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 
@@ -33,7 +34,7 @@ public class SpringComponentScanTest ext
             context.stop();
         }
         ApplicationContext c = new ClassPathXmlApplicationContext("org/apache/camel/spring/config/scan/componentScan.xml");
-        context = (CamelContext)c.getBean("camelScan");
+        context = (ModelCamelContext)c.getBean("camelScan");
         template = context.createProducerTemplate();
         template.start();
     }

Modified: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/scan/SpringComponentScanWithDeprecatedPackagesTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/scan/SpringComponentScanWithDeprecatedPackagesTest.java?rev=1178956&r1=1178955&r2=1178956&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/scan/SpringComponentScanWithDeprecatedPackagesTest.java
(original)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/scan/SpringComponentScanWithDeprecatedPackagesTest.java
Tue Oct  4 21:20:32 2011
@@ -20,6 +20,7 @@ package org.apache.camel.spring.config.s
 import org.apache.camel.CamelContext;
 import org.apache.camel.ContextTestSupport;
 import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.model.ModelCamelContext;
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 
@@ -29,7 +30,7 @@ public class SpringComponentScanWithDepr
     protected void setUp() throws Exception {
         super.setUp();
         ApplicationContext c = new ClassPathXmlApplicationContext("org/apache/camel/spring/config/scan/componentScanWithPackages.xml");
-        context = (CamelContext)c.getBean("camelContext");
+        context = (ModelCamelContext)c.getBean("camelContext");
         template = context.createProducerTemplate();
         template.start();
     }

Modified: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringSetExchangePatternWithCustomIdTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringSetExchangePatternWithCustomIdTest.java?rev=1178956&r1=1178955&r2=1178956&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringSetExchangePatternWithCustomIdTest.java
(original)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringSetExchangePatternWithCustomIdTest.java
Tue Oct  4 21:20:32 2011
@@ -24,7 +24,6 @@ import static org.apache.camel.spring.pr
 
 public class SpringSetExchangePatternWithCustomIdTest extends SetExchangePatternTest {
 
-    @SuppressWarnings("deprecation")
     @Override
     public void testToWithInOnlyParam() throws Exception {
         super.testToWithInOnlyParam();

Modified: camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/CamelTestSupport.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/CamelTestSupport.java?rev=1178956&r1=1178955&r2=1178956&view=diff
==============================================================================
--- camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/CamelTestSupport.java
(original)
+++ camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/CamelTestSupport.java
Tue Oct  4 21:20:32 2011
@@ -42,6 +42,7 @@ import org.apache.camel.impl.DefaultDebu
 import org.apache.camel.impl.InterceptSendToMockEndpointStrategy;
 import org.apache.camel.impl.JndiRegistry;
 import org.apache.camel.management.JmxSystemPropertyKeys;
+import org.apache.camel.model.ModelCamelContext;
 import org.apache.camel.model.ProcessorDefinition;
 import org.apache.camel.spi.Language;
 import org.apache.camel.spring.CamelBeanPostProcessor;
@@ -56,7 +57,7 @@ import org.apache.camel.util.TimeUtils;
  */
 public abstract class CamelTestSupport extends TestSupport {
     
-    protected volatile CamelContext context;
+    protected volatile ModelCamelContext context;
     protected volatile ProducerTemplate template;
     protected volatile ConsumerTemplate consumer;
     private boolean useRouteBuilder = true;
@@ -139,7 +140,7 @@ public abstract class CamelTestSupport e
             enableJMX();
         }
 
-        context = createCamelContext();
+        context = (ModelCamelContext)createCamelContext();
         assertNotNull("No context found!", context);
 
         // reduce default shutdown timeout to avoid waiting for 300 seconds

Modified: camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/junit4/CamelTestSupport.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/junit4/CamelTestSupport.java?rev=1178956&r1=1178955&r2=1178956&view=diff
==============================================================================
--- camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/junit4/CamelTestSupport.java
(original)
+++ camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/junit4/CamelTestSupport.java
Tue Oct  4 21:20:32 2011
@@ -42,6 +42,7 @@ import org.apache.camel.impl.DefaultDebu
 import org.apache.camel.impl.InterceptSendToMockEndpointStrategy;
 import org.apache.camel.impl.JndiRegistry;
 import org.apache.camel.management.JmxSystemPropertyKeys;
+import org.apache.camel.model.ModelCamelContext;
 import org.apache.camel.model.ProcessorDefinition;
 import org.apache.camel.spi.Language;
 import org.apache.camel.spring.CamelBeanPostProcessor;
@@ -64,8 +65,8 @@ public abstract class CamelTestSupport e
     private static final ThreadLocal<Boolean> INIT = new ThreadLocal<Boolean>();
     
     
-    private static ThreadLocal<CamelContext> threadCamelContext 
-        = new ThreadLocal<CamelContext>();
+    private static ThreadLocal<ModelCamelContext> threadCamelContext 
+        = new ThreadLocal<ModelCamelContext>();
     private static ThreadLocal<ProducerTemplate> threadTemplate 
         = new ThreadLocal<ProducerTemplate>();
     private static ThreadLocal<ConsumerTemplate> threadConsumer 
@@ -73,7 +74,7 @@ public abstract class CamelTestSupport e
     private static ThreadLocal<Service> threadService 
         = new ThreadLocal<Service>();
     
-    protected volatile CamelContext context;
+    protected volatile ModelCamelContext context;
     protected volatile ProducerTemplate template;
     protected volatile ConsumerTemplate consumer;
     protected volatile Service camelContextService;
@@ -230,7 +231,7 @@ public abstract class CamelTestSupport e
             enableJMX();
         }
 
-        context = createCamelContext();
+        context = (ModelCamelContext)createCamelContext();
         threadCamelContext.set(context);
 
         assertNotNull("No context found!", context);

Modified: camel/trunk/tooling/maven/camel-maven-plugin/src/main/java/org/apache/camel/maven/RunMojo.java
URL: http://svn.apache.org/viewvc/camel/trunk/tooling/maven/camel-maven-plugin/src/main/java/org/apache/camel/maven/RunMojo.java?rev=1178956&r1=1178955&r2=1178956&view=diff
==============================================================================
--- camel/trunk/tooling/maven/camel-maven-plugin/src/main/java/org/apache/camel/maven/RunMojo.java
(original)
+++ camel/trunk/tooling/maven/camel-maven-plugin/src/main/java/org/apache/camel/maven/RunMojo.java
Tue Oct  4 21:20:32 2011
@@ -31,6 +31,7 @@ import java.util.List;
 import java.util.Properties;
 import java.util.Set;
 
+import org.apache.camel.util.CastUtils;
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.factory.ArtifactFactory;
 import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
@@ -142,7 +143,7 @@ public class RunMojo extends AbstractExe
      * @parameter expression="${plugin.artifacts}"
      * @readonly
      */
-    private List pluginDependencies;
+    private List<Artifact> pluginDependencies;
 
     /**
      * Whether to enable the tracer or not
@@ -523,9 +524,9 @@ public class RunMojo extends AbstractExe
 
     private void terminateThreads(ThreadGroup threadGroup) {
         long startTime = System.currentTimeMillis();
-        Set uncooperativeThreads = new HashSet(); // these were not responsive
+        Set<Thread> uncooperativeThreads = new HashSet<Thread>(); // these were
not responsive
         // to interruption
-        for (Collection threads = getActiveThreads(threadGroup); !threads.isEmpty(); threads
= getActiveThreads(threadGroup), threads
+        for (Collection<Thread> threads = getActiveThreads(threadGroup); !threads.isEmpty();
threads = getActiveThreads(threadGroup), threads
             .removeAll(uncooperativeThreads)) {
             // Interrupt all threads we know about as of this instant (harmless
             // if spuriously went dead (! isAlive())
@@ -584,10 +585,10 @@ public class RunMojo extends AbstractExe
         }
     }
 
-    private Collection getActiveThreads(ThreadGroup threadGroup) {
+    private Collection<Thread> getActiveThreads(ThreadGroup threadGroup) {
         Thread[] threads = new Thread[threadGroup.activeCount()];
         int numThreads = threadGroup.enumerate(threads);
-        Collection result = new ArrayList(numThreads);
+        Collection<Thread> result = new ArrayList<Thread>(numThreads);
         for (int i = 0; i < threads.length && threads[i] != null; i++) {
             result.add(threads[i]);
         }
@@ -616,7 +617,7 @@ public class RunMojo extends AbstractExe
      * @throws MojoExecutionException
      */
     private ClassLoader getClassLoader() throws MojoExecutionException {
-        List classpathURLs = new ArrayList();
+        List<URL> classpathURLs = new ArrayList<URL>();
         this.addRelevantPluginDependenciesToClasspath(classpathURLs);
         this.addRelevantProjectDependenciesToClasspath(classpathURLs);
 
@@ -631,7 +632,7 @@ public class RunMojo extends AbstractExe
      * @param path classpath of {@link java.net.URL} objects
      * @throws MojoExecutionException
      */
-    private void addRelevantPluginDependenciesToClasspath(List path) throws MojoExecutionException
{
+    private void addRelevantPluginDependenciesToClasspath(List<URL> path) throws MojoExecutionException
{
         if (hasCommandlineArgs()) {
             arguments = parseCommandlineArgs();
         }
@@ -657,7 +658,7 @@ public class RunMojo extends AbstractExe
      * @param path classpath of {@link java.net.URL} objects
      * @throws MojoExecutionException
      */
-    private void addRelevantProjectDependenciesToClasspath(List path) throws MojoExecutionException
{
+    private void addRelevantProjectDependenciesToClasspath(List<URL> path) throws MojoExecutionException
{
         if (this.includeProjectDependencies) {
             try {
                 getLog().debug("Project Dependencies will be included.");
@@ -666,7 +667,7 @@ public class RunMojo extends AbstractExe
                 getLog().debug("Adding to classpath : " + mainClasses);
                 path.add(mainClasses);
 
-                Set dependencies = project.getArtifacts();
+                Set<Artifact> dependencies = CastUtils.cast(project.getArtifacts());
 
                 // system scope dependencies are not returned by maven 2.0. See
                 // MEXEC-17
@@ -692,8 +693,8 @@ public class RunMojo extends AbstractExe
 
     }
 
-    private Collection getAllNonTestScopedDependencies() throws MojoExecutionException {
-        List answer = new ArrayList();
+    private Collection<Artifact> getAllNonTestScopedDependencies() throws MojoExecutionException
{
+        List<Artifact> answer = new ArrayList<Artifact>();
 
         for (Iterator artifacts = getAllDependencies().iterator(); artifacts.hasNext();)
{
             Artifact artifact = (Artifact)artifacts.next();
@@ -707,8 +708,8 @@ public class RunMojo extends AbstractExe
     }
 
     // generic method to retrieve all the transitive dependencies
-    private Collection getAllDependencies() throws MojoExecutionException {
-        List artifacts = new ArrayList();
+    private Collection<Artifact> getAllDependencies() throws MojoExecutionException
{
+        List<Artifact> artifacts = new ArrayList<Artifact>();
 
         for (Iterator dependencies = project.getDependencies().iterator(); dependencies.hasNext();)
{
             Dependency dependency = (Dependency)dependencies.next();
@@ -741,7 +742,7 @@ public class RunMojo extends AbstractExe
                 art.setFile(new File(dependency.getSystemPath()));
             }
 
-            List exclusions = new ArrayList();
+            List<String> exclusions = new ArrayList<String>();
             for (Iterator j = dependency.getExclusions().iterator(); j.hasNext();) {
                 Exclusion e = (Exclusion)j.next();
                 exclusions.add(e.getGroupId() + ":" + e.getArtifactId());
@@ -765,12 +766,12 @@ public class RunMojo extends AbstractExe
      *         relevant plugin dependencies.)
      * @throws MojoExecutionException
      */
-    private Set determineRelevantPluginDependencies() throws MojoExecutionException {
-        Set relevantDependencies;
+    private Set<Artifact> determineRelevantPluginDependencies() throws MojoExecutionException
{
+        Set<Artifact> relevantDependencies;
         if (this.includePluginDependencies) {
             if (this.executableDependency == null) {
                 getLog().debug("All Plugin Dependencies will be included.");
-                relevantDependencies = new HashSet(this.pluginDependencies);
+                relevantDependencies = new HashSet<Artifact>(this.pluginDependencies);
             } else {
                 getLog().debug("Selected plugin Dependencies will be included.");
                 Artifact executableArtifact = this.findExecutableArtifact();
@@ -778,7 +779,7 @@ public class RunMojo extends AbstractExe
                 relevantDependencies = this.resolveExecutableDependencies(executablePomArtifact);
             }
         } else {
-            relevantDependencies = Collections.EMPTY_SET;
+            relevantDependencies = Collections.emptySet();
             getLog().debug("Plugin Dependencies will be excluded.");
         }
         return relevantDependencies;
@@ -823,20 +824,21 @@ public class RunMojo extends AbstractExe
         return executableTool;
     }
 
-    private Set resolveExecutableDependencies(Artifact executablePomArtifact) throws MojoExecutionException
{
+    private Set<Artifact> resolveExecutableDependencies(Artifact executablePomArtifact)
throws MojoExecutionException {
 
-        Set executableDependencies;
+        Set<Artifact> executableDependencies;
         try {
             MavenProject executableProject = this.projectBuilder.buildFromRepository(executablePomArtifact,
                                                                                      this.remoteRepositories,
                                                                                      this.localRepository);
 
             // get all of the dependencies for the executable project
-            List dependencies = executableProject.getDependencies();
+            List<Artifact> dependencies = CastUtils.cast(executableProject.getDependencies());
 
             // make Artifacts of all the dependencies
-            Set dependencyArtifacts = MavenMetadataSource.createArtifacts(this.artifactFactory,
dependencies,
-                                                                          null, null, null);
+            Set<Artifact> dependencyArtifacts 
+                = CastUtils.cast(MavenMetadataSource.createArtifacts(this.artifactFactory,
dependencies,
+                                                                          null, null, null));
 
             // not forgetting the Artifact of the project itself
             dependencyArtifacts.add(executableProject.getArtifact());
@@ -850,7 +852,7 @@ public class RunMojo extends AbstractExe
                                                                                    this.remoteRepositories,
                                                                                    metadataSource,
null,
                                                                                    Collections.EMPTY_LIST);
-            executableDependencies = result.getArtifacts();
+            executableDependencies = CastUtils.cast(result.getArtifacts());
 
         } catch (Exception ex) {
             throw new MojoExecutionException("Encountered problems resolving dependencies
of the executable "

Modified: camel/trunk/tooling/maven/guice-maven-plugin/src/main/java/org/apache/camel/guice/maven/RunMojo.java
URL: http://svn.apache.org/viewvc/camel/trunk/tooling/maven/guice-maven-plugin/src/main/java/org/apache/camel/guice/maven/RunMojo.java?rev=1178956&r1=1178955&r2=1178956&view=diff
==============================================================================
--- camel/trunk/tooling/maven/guice-maven-plugin/src/main/java/org/apache/camel/guice/maven/RunMojo.java
(original)
+++ camel/trunk/tooling/maven/guice-maven-plugin/src/main/java/org/apache/camel/guice/maven/RunMojo.java
Tue Oct  4 21:20:32 2011
@@ -31,6 +31,7 @@ import java.util.List;
 import java.util.Properties;
 import java.util.Set;
 
+import org.apache.camel.util.CastUtils;
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.factory.ArtifactFactory;
 import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
@@ -142,7 +143,7 @@ public class RunMojo extends AbstractExe
      * @parameter expression="${plugin.artifacts}"
      * @readonly
      */
-    private List pluginDependencies;
+    private List<Artifact> pluginDependencies;
 
     /**
      * Whether to enable the debugger or not
@@ -477,9 +478,9 @@ public class RunMojo extends AbstractExe
 
     private void terminateThreads(ThreadGroup threadGroup) {
         long startTime = System.currentTimeMillis();
-        Set uncooperativeThreads = new HashSet(); // these were not responsive
+        Set<Thread> uncooperativeThreads = new HashSet<Thread>(); // these were
not responsive
         // to interruption
-        for (Collection threads = getActiveThreads(threadGroup); !threads.isEmpty(); threads
= getActiveThreads(threadGroup), threads
+        for (Collection<Thread> threads = getActiveThreads(threadGroup); !threads.isEmpty();
threads = getActiveThreads(threadGroup), threads
             .removeAll(uncooperativeThreads)) {
             // Interrupt all threads we know about as of this instant (harmless
             // if spuriously went dead (! isAlive())
@@ -538,10 +539,10 @@ public class RunMojo extends AbstractExe
         }
     }
 
-    private Collection getActiveThreads(ThreadGroup threadGroup) {
+    private Collection<Thread> getActiveThreads(ThreadGroup threadGroup) {
         Thread[] threads = new Thread[threadGroup.activeCount()];
         int numThreads = threadGroup.enumerate(threads);
-        Collection result = new ArrayList(numThreads);
+        Collection<Thread> result = new ArrayList<Thread>(numThreads);
         for (int i = 0; i < threads.length && threads[i] != null; i++) {
             result.add(threads[i]);
         }
@@ -570,7 +571,7 @@ public class RunMojo extends AbstractExe
      * @throws org.apache.maven.plugin.MojoExecutionException
      */
     private ClassLoader getClassLoader() throws MojoExecutionException {
-        List classpathURLs = new ArrayList();
+        List<URL> classpathURLs = new ArrayList<URL>();
         this.addRelevantPluginDependenciesToClasspath(classpathURLs);
         this.addRelevantProjectDependenciesToClasspath(classpathURLs);
 
@@ -585,7 +586,7 @@ public class RunMojo extends AbstractExe
      * @param path classpath of {@link java.net.URL} objects
      * @throws org.apache.maven.plugin.MojoExecutionException
      */
-    private void addRelevantPluginDependenciesToClasspath(List path) throws MojoExecutionException
{
+    private void addRelevantPluginDependenciesToClasspath(List<URL> path) throws MojoExecutionException
{
         if (hasCommandlineArgs()) {
             arguments = parseCommandlineArgs();
         }
@@ -611,7 +612,7 @@ public class RunMojo extends AbstractExe
      * @param path classpath of {@link java.net.URL} objects
      * @throws org.apache.maven.plugin.MojoExecutionException
      */
-    private void addRelevantProjectDependenciesToClasspath(List path) throws MojoExecutionException
{
+    private void addRelevantProjectDependenciesToClasspath(List<URL> path) throws MojoExecutionException
{
         if (this.includeProjectDependencies) {
             try {
                 getLog().debug("Project Dependencies will be included.");
@@ -620,7 +621,7 @@ public class RunMojo extends AbstractExe
                 getLog().debug("Adding to classpath : " + mainClasses);
                 path.add(mainClasses);
 
-                Set dependencies = project.getArtifacts();
+                Set<Artifact> dependencies = CastUtils.cast(project.getArtifacts());
 
                 // system scope dependencies are not returned by maven 2.0. See
                 // MEXEC-17
@@ -646,8 +647,8 @@ public class RunMojo extends AbstractExe
 
     }
 
-    private Collection getAllNonTestScopedDependencies() throws MojoExecutionException {
-        List answer = new ArrayList();
+    private Collection<Artifact> getAllNonTestScopedDependencies() throws MojoExecutionException
{
+        List<Artifact> answer = new ArrayList<Artifact>();
 
         for (Iterator artifacts = getAllDependencies().iterator(); artifacts.hasNext();)
{
             Artifact artifact = (Artifact)artifacts.next();
@@ -661,8 +662,8 @@ public class RunMojo extends AbstractExe
     }
 
     // generic method to retrieve all the transitive dependencies
-    private Collection getAllDependencies() throws MojoExecutionException {
-        List artifacts = new ArrayList();
+    private Collection<Artifact> getAllDependencies() throws MojoExecutionException
{
+        List<Artifact> artifacts = new ArrayList<Artifact>();
 
         for (Iterator dependencies = project.getDependencies().iterator(); dependencies.hasNext();)
{
             Dependency dependency = (Dependency)dependencies.next();
@@ -695,7 +696,7 @@ public class RunMojo extends AbstractExe
                 art.setFile(new File(dependency.getSystemPath()));
             }
 
-            List exclusions = new ArrayList();
+            List<String> exclusions = new ArrayList<String>();
             for (Iterator j = dependency.getExclusions().iterator(); j.hasNext();) {
                 Exclusion e = (Exclusion)j.next();
                 exclusions.add(e.getGroupId() + ":" + e.getArtifactId());
@@ -719,12 +720,12 @@ public class RunMojo extends AbstractExe
      *         relevant plugin dependencies.)
      * @throws org.apache.maven.plugin.MojoExecutionException
      */
-    private Set determineRelevantPluginDependencies() throws MojoExecutionException {
-        Set relevantDependencies;
+    private Set<Artifact> determineRelevantPluginDependencies() throws MojoExecutionException
{
+        Set<Artifact> relevantDependencies;
         if (this.includePluginDependencies) {
             if (this.executableDependency == null) {
                 getLog().debug("All Plugin Dependencies will be included.");
-                relevantDependencies = new HashSet(this.pluginDependencies);
+                relevantDependencies = new HashSet<Artifact>(this.pluginDependencies);
             } else {
                 getLog().debug("Selected plugin Dependencies will be included.");
                 Artifact executableArtifact = this.findExecutableArtifact();
@@ -732,7 +733,7 @@ public class RunMojo extends AbstractExe
                 relevantDependencies = this.resolveExecutableDependencies(executablePomArtifact);
             }
         } else {
-            relevantDependencies = Collections.EMPTY_SET;
+            relevantDependencies = Collections.emptySet();
             getLog().debug("Plugin Dependencies will be excluded.");
         }
         return relevantDependencies;
@@ -777,20 +778,21 @@ public class RunMojo extends AbstractExe
         return executableTool;
     }
 
-    private Set resolveExecutableDependencies(Artifact executablePomArtifact) throws MojoExecutionException
{
+    private Set<Artifact> resolveExecutableDependencies(Artifact executablePomArtifact)
throws MojoExecutionException {
 
-        Set executableDependencies;
+        Set<Artifact> executableDependencies;
         try {
             MavenProject executableProject = this.projectBuilder.buildFromRepository(executablePomArtifact,
                                                                                      this.remoteRepositories,
                                                                                      this.localRepository);
 
             // get all of the dependencies for the executable project
-            List dependencies = executableProject.getDependencies();
+            List<Artifact> dependencies = CastUtils.cast(executableProject.getDependencies());
 
             // make Artifacts of all the dependencies
-            Set dependencyArtifacts = MavenMetadataSource.createArtifacts(this.artifactFactory,
dependencies,
-                                                                          null, null, null);
+            Set<Artifact> dependencyArtifacts 
+                = CastUtils.cast(MavenMetadataSource.createArtifacts(this.artifactFactory,
dependencies,
+                                                                          null, null, null));
 
             // not forgetting the Artifact of the project itself
             dependencyArtifacts.add(executableProject.getArtifact());
@@ -804,7 +806,7 @@ public class RunMojo extends AbstractExe
                                                                                    this.remoteRepositories,
                                                                                    metadataSource,
null,
                                                                                    Collections.EMPTY_LIST);
-            executableDependencies = result.getArtifacts();
+            executableDependencies = CastUtils.cast(result.getArtifacts());
 
         } catch (Exception ex) {
             throw new MojoExecutionException("Encountered problems resolving dependencies
of the executable "



Mime
View raw message