commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1740021 - /commons/dev/plugins/commonsdev-example-plugin/trunk/src/main/java/org/apache/commons/dev_plugins/example/ExampleMojo.java
Date Tue, 19 Apr 2016 22:07:15 GMT
Author: sebb
Date: Tue Apr 19 22:07:15 2016
New Revision: 1740021

URL: http://svn.apache.org/viewvc?rev=1740021&view=rev
Log:
Fix code so it works

Modified:
    commons/dev/plugins/commonsdev-example-plugin/trunk/src/main/java/org/apache/commons/dev_plugins/example/ExampleMojo.java

Modified: commons/dev/plugins/commonsdev-example-plugin/trunk/src/main/java/org/apache/commons/dev_plugins/example/ExampleMojo.java
URL: http://svn.apache.org/viewvc/commons/dev/plugins/commonsdev-example-plugin/trunk/src/main/java/org/apache/commons/dev_plugins/example/ExampleMojo.java?rev=1740021&r1=1740020&r2=1740021&view=diff
==============================================================================
--- commons/dev/plugins/commonsdev-example-plugin/trunk/src/main/java/org/apache/commons/dev_plugins/example/ExampleMojo.java
(original)
+++ commons/dev/plugins/commonsdev-example-plugin/trunk/src/main/java/org/apache/commons/dev_plugins/example/ExampleMojo.java
Tue Apr 19 22:07:15 2016
@@ -33,14 +33,13 @@ import org.codehaus.plexus.PlexusConstan
 import org.codehaus.plexus.PlexusContainer;
 import org.codehaus.plexus.context.Context;
 import org.codehaus.plexus.context.ContextException;
-import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
 import org.sonatype.plexus.components.sec.dispatcher.SecDispatcher;
 
 /**
  * Example MOJO that displays some information from settings and project.
  */
 @Mojo (name = "example")
-public class ExampleMojo  extends AbstractMojo  implements Contextualizable {
+public class ExampleMojo  extends AbstractMojo {
 
     private static final String[] EXPECTED_PROPERTIES = {
         "maven.compiler.source",
@@ -60,8 +59,8 @@ public class ExampleMojo  extends Abstra
     @Component
     private Settings settings;
 
-    // @Component does not work for the container
-    private PlexusContainer container;
+    @Component( role = org.sonatype.plexus.components.sec.dispatcher.SecDispatcher.class,
hint = "default" )
+    private SecDispatcher securityDispatcher;
 
     /**
      * Whether to decode the passwords and passPhrases found in settings.xml
@@ -69,11 +68,6 @@ public class ExampleMojo  extends Abstra
     @Parameter( property="example.decodePassword", defaultValue="false")
     private boolean decodePassword;
 
-    // Canonical way to get the container
-    public void contextualize( Context context ) throws ContextException {  
-        container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
-    }
-
     public void execute() throws MojoExecutionException, MojoFailureException {
         System.out.println("Id: " + project.getId());
         System.out.println("Parent: " + project.getParent().getId());
@@ -101,8 +95,7 @@ public class ExampleMojo  extends Abstra
             if (encryptedString != null) {
                 if (decodePassword) {
                     try {
-                        final SecDispatcher sd = (SecDispatcher) container.lookup( SecDispatcher.ROLE,
"maven" );
-                        pass = " " + sd.decrypt(encryptedString);
+                        pass = " " + securityDispatcher.decrypt(encryptedString);
                     } catch (Exception e) {
                         throw new MojoExecutionException("Failed to decode password", e);
                     }



Mime
View raw message