You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by be...@apache.org on 2009/08/13 11:03:07 UTC

svn commit: r803811 - in /maven/components/trunk/maven-core/src/main/java/org/apache/maven/classrealm: ClassRealmManagerDelegate.java DefaultClassRealmManager.java

Author: bentmann
Date: Thu Aug 13 09:03:07 2009
New Revision: 803811

URL: http://svn.apache.org/viewvc?rev=803811&view=rev
Log:
[MNG-4296] allow core extensions configure new classrealms
Submitted by: Igor Fedorenko


Added:
    maven/components/trunk/maven-core/src/main/java/org/apache/maven/classrealm/ClassRealmManagerDelegate.java   (with props)
Modified:
    maven/components/trunk/maven-core/src/main/java/org/apache/maven/classrealm/DefaultClassRealmManager.java

Added: maven/components/trunk/maven-core/src/main/java/org/apache/maven/classrealm/ClassRealmManagerDelegate.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/classrealm/ClassRealmManagerDelegate.java?rev=803811&view=auto
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/classrealm/ClassRealmManagerDelegate.java (added)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/classrealm/ClassRealmManagerDelegate.java Thu Aug 13 09:03:07 2009
@@ -0,0 +1,34 @@
+package org.apache.maven.classrealm;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+import org.codehaus.plexus.classworlds.realm.ClassRealm;
+
+/**
+ * ClassRealmManagerDelegate is used to perform addition configuration of
+ * class realms created by ClassRealmManager.
+ * 
+ * @author igor
+ */
+public interface ClassRealmManagerDelegate
+{
+    void setupRealm( ClassRealm classRealm );
+}

Propchange: maven/components/trunk/maven-core/src/main/java/org/apache/maven/classrealm/ClassRealmManagerDelegate.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/trunk/maven-core/src/main/java/org/apache/maven/classrealm/ClassRealmManagerDelegate.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/classrealm/DefaultClassRealmManager.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/classrealm/DefaultClassRealmManager.java?rev=803811&r1=803810&r2=803811&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/classrealm/DefaultClassRealmManager.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/classrealm/DefaultClassRealmManager.java Thu Aug 13 09:03:07 2009
@@ -19,6 +19,8 @@
  * under the License.
  */
 
+import java.util.Collections;
+import java.util.List;
 import java.util.Random;
 
 import org.apache.maven.artifact.ArtifactUtils;
@@ -31,6 +33,7 @@
 import org.codehaus.plexus.classworlds.realm.DuplicateRealmException;
 import org.codehaus.plexus.component.annotations.Component;
 import org.codehaus.plexus.component.annotations.Requirement;
+import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
 import org.codehaus.plexus.logging.Logger;
 
 /**
@@ -93,6 +96,11 @@
 
             importMavenApi( classRealm );
 
+            for ( ClassRealmManagerDelegate delegate : getDelegates() )
+            {
+                delegate.setupRealm( classRealm );
+            }
+
             return classRealm;
         }
     }
@@ -178,4 +186,16 @@
         return "plugin>" + plugin.getGroupId() + ":" + plugin.getArtifactId() + ":" + version;
     }
 
+    private List<ClassRealmManagerDelegate> getDelegates()
+    {
+        try
+        {
+            return container.lookupList( ClassRealmManagerDelegate.class );
+        }
+        catch ( ComponentLookupException e )
+        {
+            return Collections.emptyList();
+        }
+    }
+
 }