View Javadoc

1   /*
2    * Copyright 2004 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package com.nordija.tapestry.bayeux.downloads;
17  
18  import org.apache.tapestry.IRequestCycle;
19  
20  import java.io.IOException;
21  
22  /**
23   * A source for resources that can be downloaded by the bayeux downloads service.
24   * <p/>
25   * An implementation of this interface must be configured in the application using the
26   * bayeux downloads service as an extension.
27   * The downloads service will ask the defined implementation for a resource based on an
28   * id when links are clicked.
29   *
30   * @see DownloadService
31   * @author Per Olesen www.nordija.com
32   * @version $Id: DownloadResourceSource.java 72 2007-05-13 13:10:58Z jeyben $
33   */
34  public interface DownloadResourceSource {
35  
36      /**
37       * Called by downloads service when a download link has been clicked
38       * and the resource to be downloaded is to be obtained from somewhere.
39       *
40       * @param cycle       the request cycle which originated the incoming request for a download resource
41       * @param resourceId  the id from the download link
42       * @return an instance of the resource identified by the given id or null if resource not found
43       * @throws IOException if obtaining the resource fails with an exception (no resource on id should not result in this exception!)
44       */
45      DownloadResource getDownloadResource(IRequestCycle cycle, String resourceId) throws IOException;
46  }