View Javadoc

1   /*
2    * <cvs:source>$Source: /devel/astrogrid/filemanager/client/src/java/org/astrogrid/filemanager/client/delegate/FileManagerSoapDelegate.java,v $</cvs:source>
3    * <cvs:author>$Author: clq2 $</cvs:author>
4    * <cvs:date>$Date: 2005/01/28 10:43:58 $</cvs:date>
5    * <cvs:version>$Revision: 1.2 $</cvs:version>
6    * <cvs:log>
7    *   $Log: FileManagerSoapDelegate.java,v $
8    *   Revision 1.2  2005/01/28 10:43:58  clq2
9    *   dave_dev_200501141257 (filemanager)
10   *
11   *   Revision 1.1.2.1  2005/01/22 07:54:16  dave
12   *   Refactored delegate into a separate package ....
13   *
14   *   Revision 1.3  2005/01/13 17:23:15  jdt
15   *   merges from dave-dev-200412201250
16   *
17   *   Revision 1.2.4.2  2005/01/12 14:20:57  dave
18   *   Replaced tabs with spaces ....
19   *
20   *   Revision 1.2.4.1  2004/12/22 07:38:36  dave
21   *   Started to move towards StoreClient API ...
22   *
23   *   Revision 1.2  2004/11/25 00:20:29  jdt
24   *   Merge from dave-dev-200410061224-200411221626
25   *
26   *   Revision 1.1.2.1  2004/11/18 14:39:32  dave
27   *   Added SOAP delegate, RemoteException decoding and test case.
28   *
29   * </cvs:log>
30   *
31   */
32  package org.astrogrid.filemanager.client.delegate ;
33  
34  import java.net.URL;
35  import java.net.MalformedURLException;
36  
37  import org.apache.commons.logging.Log ;
38  import org.apache.commons.logging.LogFactory ;
39  
40  import org.astrogrid.filemanager.common.FileManager;
41  import org.astrogrid.filemanager.common.FileManagerConfig;
42  import org.astrogrid.filemanager.common.ivorn.FileManagerIvornFactory;
43  
44  import org.astrogrid.filemanager.common.FileManagerService;
45  import org.astrogrid.filemanager.common.FileManagerServiceLocator;
46  
47  
48  import org.astrogrid.filestore.resolver.FileStoreDelegateResolver ;
49  
50  /***
51   * The core implementation for the FileManager delegate.
52   *
53   */
54  public class FileManagerSoapDelegate
55      extends FileManagerCoreDelegate
56      implements FileManagerDelegate
57      {
58      /***
59       * Our debug logger.
60       *
61       */
62      protected static Log log = LogFactory.getLog(FileManagerSoapDelegate.class);
63  
64      /***
65       * Our FileStore service locator.
66       *
67       */
68      private static FileManagerService locator = new FileManagerServiceLocator() ;
69  
70      /***
71       * Public constructor, for a specific endpoint URL.
72       * @param endpoint The service endpoint URL.
73       * @todo Trap MalformedURLException.
74       *
75       */
76      public FileManagerSoapDelegate(String endpoint)
77          throws MalformedURLException
78          {
79          this(
80              new URL(
81                  endpoint
82                  )
83              ) ;
84          }
85  
86      /***
87       * Public constructor, for a specific endpoint URL.
88       * @param endpoint The service endpoint URL.
89       * @todo Better Exception handling.
90       *
91       */
92      public FileManagerSoapDelegate(URL endpoint)
93          {
94          super(
95              wrapper(
96                  endpoint
97                  )
98              ) ;
99          }
100 
101     /***
102      * Locate a SOAP client for an endpoint URL.
103      *
104      */
105     private static FileManager wrapper(URL endpoint)
106         {
107         log.debug("") ;
108         log.debug("FileManagerSoapDelegate.wrapper(URL)") ;
109         log.debug("  URL : '" + endpoint + "'") ;
110         //
111         // Check for null param.
112         if (null == endpoint)
113             {
114             throw new IllegalArgumentException(
115                 "Null endpoint"
116                 ) ;
117             }
118         //
119         // Try locate our service instance.
120         try {
121             return locator.getFileManager(
122                 endpoint
123                 ) ;
124             }
125         //
126         // Catch anything that went BANG.
127         catch (Exception ouch)
128             {
129             // TODO
130             // Log the Exception, and throw a nicer one.
131             // Unwrap RemoteExceptions.
132             //
133             return null ;
134             }
135         }
136     }