maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ogusa...@apache.org
Subject svn commit: r718833 - in /maven/mercury/trunk: mercury-md/mercury-md-sat/src/main/java/org/apache/maven/mercury/metadata/ mercury-util/src/main/java/org/apache/maven/mercury/util/event/ mercury-util/src/test/java/org/apache/maven/mercury/util/event/
Date Wed, 19 Nov 2008 01:29:54 GMT
Author: ogusakov
Date: Tue Nov 18 17:29:53 2008
New Revision: 718833

URL: http://svn.apache.org/viewvc?rev=718833&view=rev
Log:
http://jira.codehaus.org/browse/MERCURY-6

Added:
    maven/mercury/trunk/mercury-util/src/main/java/org/apache/maven/mercury/util/event/
    maven/mercury/trunk/mercury-util/src/main/java/org/apache/maven/mercury/util/event/AbstractMercuryEvent.java
    maven/mercury/trunk/mercury-util/src/main/java/org/apache/maven/mercury/util/event/MercuryEvent.java
    maven/mercury/trunk/mercury-util/src/main/java/org/apache/maven/mercury/util/event/MercuryEventListener.java
    maven/mercury/trunk/mercury-util/src/test/java/org/apache/maven/mercury/util/event/
Modified:
    maven/mercury/trunk/mercury-md/mercury-md-sat/src/main/java/org/apache/maven/mercury/metadata/DependencyBuilder.java
    maven/mercury/trunk/mercury-md/mercury-md-sat/src/main/java/org/apache/maven/mercury/metadata/DependencyTreeBuilder.java

Modified: maven/mercury/trunk/mercury-md/mercury-md-sat/src/main/java/org/apache/maven/mercury/metadata/DependencyBuilder.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-md/mercury-md-sat/src/main/java/org/apache/maven/mercury/metadata/DependencyBuilder.java?rev=718833&r1=718832&r2=718833&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-md/mercury-md-sat/src/main/java/org/apache/maven/mercury/metadata/DependencyBuilder.java
(original)
+++ maven/mercury/trunk/mercury-md/mercury-md-sat/src/main/java/org/apache/maven/mercury/metadata/DependencyBuilder.java
Tue Nov 18 17:29:53 2008
@@ -28,9 +28,26 @@
   public abstract MetadataTreeNode buildTree( ArtifactBasicMetadata startMD, ArtifactScopeEnum
scope )
   throws MetadataTreeException;
 
-  //-----------------------------------------------------
+  /**
+   * hard to believe, but this actually resolves the conflicts, removing all duplicate GAVs
from the tree
+   * 
+   * @param root the tree to resolve conflicts on
+   * @return list of resolved GAVs
+   * @throws MetadataTreeException
+   */
   public abstract List<ArtifactMetadata> resolveConflicts( MetadataTreeNode root )
   throws MetadataTreeException;
+
+  /**
+   *  this one resolves the conflicts, removing all duplicate GAVs from the tree and
+   *  returning a copy of the resulting subtree - original tree should be intact
+   * 
+   * @param root the tree to resolve conflicts on
+   * @return resolved subtree
+   * @throws MetadataTreeException
+   */
+  public abstract MetadataTreeNode resolveConflictsAsTree( MetadataTreeNode root )
+  throws MetadataTreeException;
   //-----------------------------------------------------
   //-----------------------------------------------------
 

Modified: maven/mercury/trunk/mercury-md/mercury-md-sat/src/main/java/org/apache/maven/mercury/metadata/DependencyTreeBuilder.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-md/mercury-md-sat/src/main/java/org/apache/maven/mercury/metadata/DependencyTreeBuilder.java?rev=718833&r1=718832&r2=718833&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-md/mercury-md-sat/src/main/java/org/apache/maven/mercury/metadata/DependencyTreeBuilder.java
(original)
+++ maven/mercury/trunk/mercury-md/mercury-md-sat/src/main/java/org/apache/maven/mercury/metadata/DependencyTreeBuilder.java
Tue Nov 18 17:29:53 2008
@@ -327,6 +327,29 @@
     
   }
   //-----------------------------------------------------
+  public MetadataTreeNode resolveConflictsAsTree( MetadataTreeNode root )
+  throws MetadataTreeException
+  {
+    if( root == null )
+      throw new MetadataTreeException(_lang.getMessage( "empty.tree" ));
+    
+    try
+    {
+      DefaultSatSolver solver = new DefaultSatSolver( root );
+      
+      solver.applyPolicies( getComparators() );
+
+      MetadataTreeNode res = solver.solveAsTree();
+      
+      return res;
+    }
+    catch (SatException e)
+    {
+      throw new MetadataTreeException(e);
+    }
+    
+  }
+  //-----------------------------------------------------
   private List<Comparator<MetadataTreeNode>> getComparators()
   {
     if( Util.isEmpty( _comparators ) )

Added: maven/mercury/trunk/mercury-util/src/main/java/org/apache/maven/mercury/util/event/AbstractMercuryEvent.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-util/src/main/java/org/apache/maven/mercury/util/event/AbstractMercuryEvent.java?rev=718833&view=auto
==============================================================================
--- maven/mercury/trunk/mercury-util/src/main/java/org/apache/maven/mercury/util/event/AbstractMercuryEvent.java
(added)
+++ maven/mercury/trunk/mercury-util/src/main/java/org/apache/maven/mercury/util/event/AbstractMercuryEvent.java
Tue Nov 18 17:29:53 2008
@@ -0,0 +1,69 @@
+package org.apache.maven.mercury.util.event;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ *
+ *
+ * @author Oleg Gusakov
+ * @version $Id$
+ *
+ */
+public abstract class AbstractMercuryEvent
+    implements MercuryEvent
+{
+  String tag;
+  long start;
+  long duration;
+  Map<String, Object> payload;
+
+  public long getDuration()
+  {
+    return duration;
+  }
+
+  public Map<String, Object> getPayload()
+  {
+    return null;
+  }
+
+  public long getStart()
+  {
+    return start;
+  }
+
+  public String getTag()
+  {
+    return tag;
+  }
+
+  public Object getPayload( String name )
+  {
+    return payload == null ? null : payload.get( name );
+  }
+
+  public void setPayload( Map<String, Object> payload )
+  {
+    this.payload = payload;
+  }
+
+  public void setPayload( String name, Object value )
+  {
+    if( payload == null )
+      payload = new HashMap<String, Object>(4);
+    
+    payload.put( name, value );
+  }
+
+  public void start()
+  {
+    this.start = System.currentTimeMillis();
+  }
+
+  public void stop()
+  {
+    duration = System.currentTimeMillis() - start;
+  }
+
+}

Added: maven/mercury/trunk/mercury-util/src/main/java/org/apache/maven/mercury/util/event/MercuryEvent.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-util/src/main/java/org/apache/maven/mercury/util/event/MercuryEvent.java?rev=718833&view=auto
==============================================================================
--- maven/mercury/trunk/mercury-util/src/main/java/org/apache/maven/mercury/util/event/MercuryEvent.java
(added)
+++ maven/mercury/trunk/mercury-util/src/main/java/org/apache/maven/mercury/util/event/MercuryEvent.java
Tue Nov 18 17:29:53 2008
@@ -0,0 +1,73 @@
+package org.apache.maven.mercury.util.event;
+
+import java.util.Map;
+
+/**
+ *
+ *
+ * @author Oleg Gusakov
+ * @version $Id$
+ *
+ */
+public interface MercuryEvent
+{
+  /**
+   * aggregate tag of this event. Used to trace event propagation in the system 
+   * 
+   * @return
+   */
+  String getTag();
+  
+  /**
+   * get the event start time as UTC timestapm
+   * 
+   * @return start time as UTC timestamp
+   */
+  long getStart();
+  
+  /**
+   * start the event
+   */
+  void start();
+  
+  /**
+   * stop the event and calculate the duration
+   */
+  void stop();
+  
+  /**
+   * duration of this event in millis
+   * 
+   * @return duration of this event
+   */
+  long getDuration();
+  
+  /**
+   * event's payload
+   *  
+   * @return results, associated with this event
+   */
+  Map<String,Object> getPayload();
+  
+  /**
+   * get one of payload values
+   *  
+   * @param name element name  
+   * @return results, associated with this event
+   */
+  Object getPayload( String name );
+  
+  /**
+   * set the whole payload
+   * @param payload
+   */
+  void setPayload( Map<String,Object> payload );
+  
+  /**
+   * set the whole payload
+   * @param name
+   * @param value
+   */
+  void setPayload( String name, Object value );
+  
+}

Added: maven/mercury/trunk/mercury-util/src/main/java/org/apache/maven/mercury/util/event/MercuryEventListener.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-util/src/main/java/org/apache/maven/mercury/util/event/MercuryEventListener.java?rev=718833&view=auto
==============================================================================
--- maven/mercury/trunk/mercury-util/src/main/java/org/apache/maven/mercury/util/event/MercuryEventListener.java
(added)
+++ maven/mercury/trunk/mercury-util/src/main/java/org/apache/maven/mercury/util/event/MercuryEventListener.java
Tue Nov 18 17:29:53 2008
@@ -0,0 +1,13 @@
+package org.apache.maven.mercury.util.event;
+
+/**
+ *
+ *
+ * @author Oleg Gusakov
+ * @version $Id$
+ *
+ */
+public interface MercuryEventListener
+{
+  void fire( MercuryEvent event );
+}



Mime
View raw message