archiva-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdu...@apache.org
Subject svn commit: r671520 - in /archiva/sandbox/new-repository-api/src/main/java/org/apache/archiva/repository: RepositoryInterceptor.java RepositoryInterceptorDispacher.java ResourceRepository.java
Date Wed, 25 Jun 2008 12:03:19 GMT
Author: jdumay
Date: Wed Jun 25 05:03:18 2008
New Revision: 671520

URL: http://svn.apache.org/viewvc?rev=671520&view=rev
Log:
Repository interceptors/dispachers. These are used for modifing the ResourceContext in cases
like m1 to m2 path translation.

Added:
    archiva/sandbox/new-repository-api/src/main/java/org/apache/archiva/repository/RepositoryInterceptor.java
    archiva/sandbox/new-repository-api/src/main/java/org/apache/archiva/repository/RepositoryInterceptorDispacher.java
Modified:
    archiva/sandbox/new-repository-api/src/main/java/org/apache/archiva/repository/ResourceRepository.java

Added: archiva/sandbox/new-repository-api/src/main/java/org/apache/archiva/repository/RepositoryInterceptor.java
URL: http://svn.apache.org/viewvc/archiva/sandbox/new-repository-api/src/main/java/org/apache/archiva/repository/RepositoryInterceptor.java?rev=671520&view=auto
==============================================================================
--- archiva/sandbox/new-repository-api/src/main/java/org/apache/archiva/repository/RepositoryInterceptor.java
(added)
+++ archiva/sandbox/new-repository-api/src/main/java/org/apache/archiva/repository/RepositoryInterceptor.java
Wed Jun 25 05:03:18 2008
@@ -0,0 +1,28 @@
+/*
+ * 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.
+ */
+package org.apache.archiva.repository;
+
+/**
+ *
+ * @author <a href="mailto:james@atlassian.com">James William Dumay</a>
+ */
+public interface RepositoryInterceptor 
+{
+    ResourceContext intercept(ResourceContext context);
+}

Added: archiva/sandbox/new-repository-api/src/main/java/org/apache/archiva/repository/RepositoryInterceptorDispacher.java
URL: http://svn.apache.org/viewvc/archiva/sandbox/new-repository-api/src/main/java/org/apache/archiva/repository/RepositoryInterceptorDispacher.java?rev=671520&view=auto
==============================================================================
--- archiva/sandbox/new-repository-api/src/main/java/org/apache/archiva/repository/RepositoryInterceptorDispacher.java
(added)
+++ archiva/sandbox/new-repository-api/src/main/java/org/apache/archiva/repository/RepositoryInterceptorDispacher.java
Wed Jun 25 05:03:18 2008
@@ -0,0 +1,44 @@
+/*
+ * 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.
+ */
+package org.apache.archiva.repository;
+
+import java.util.List;
+
+/**
+ *
+ * @author <a href="mailto:james@atlassian.com">James William Dumay</a>
+ */
+public class RepositoryInterceptorDispacher implements RepositoryInterceptor
+{
+    private final List<RepositoryInterceptor> interceptors;
+
+    public RepositoryInterceptorDispacher(List<RepositoryInterceptor> interceptors)

+    {
+        this.interceptors = interceptors;
+    }
+    
+    public ResourceContext intercept(ResourceContext context)
+    {
+        for (RepositoryInterceptor interceptor : interceptors)
+        {
+            context = interceptor.intercept(context);
+        }
+        return context;
+    }
+}

Modified: archiva/sandbox/new-repository-api/src/main/java/org/apache/archiva/repository/ResourceRepository.java
URL: http://svn.apache.org/viewvc/archiva/sandbox/new-repository-api/src/main/java/org/apache/archiva/repository/ResourceRepository.java?rev=671520&r1=671519&r2=671520&view=diff
==============================================================================
--- archiva/sandbox/new-repository-api/src/main/java/org/apache/archiva/repository/ResourceRepository.java
(original)
+++ archiva/sandbox/new-repository-api/src/main/java/org/apache/archiva/repository/ResourceRepository.java
Wed Jun 25 05:03:18 2008
@@ -30,11 +30,14 @@
     private final RepositoryProxyManager proxyManager;
     
     private final Repository sourceRepository;
+    
+    private final RepositoryInterceptorDispacher interceptorDispacher;
 
-    public ResourceRepository(RepositoryProxyManager proxyManager, Repository sourceRepository)

+    public ResourceRepository(RepositoryProxyManager proxyManager, Repository sourceRepository,
RepositoryInterceptorDispacher interceptorDispacher) 
     {
         this.proxyManager = proxyManager;
         this.sourceRepository = sourceRepository;
+        this.interceptorDispacher = interceptorDispacher;
     }
     
     public InputStream getStream(ResourceContext context)
@@ -43,11 +46,12 @@
         InputStream is = proxyManager.retrieve(context);
         if (is == null)
         {
+            context = interceptorDispacher.intercept(context);
             is = sourceRepository.getStream(context);
         }
         return is;
     }
-
+    
     public void writeStream(ResourceContext context, InputStream is)
         throws RepositoryWriteException
     {



Mime
View raw message