View Javadoc

1   /*
2    * <cvs:source>$Source: /devel/astrogrid/community/client/src/java/org/astrogrid/community/client/database/manager/DatabaseManagerSoapDelegate.java,v $</cvs:source>
3    * <cvs:author>$Author: dave $</cvs:author>
4    * <cvs:date>$Date: 2004/09/16 23:18:08 $</cvs:date>
5    * <cvs:version>$Revision: 1.6 $</cvs:version>
6    *
7    * <cvs:log>
8    *   $Log: DatabaseManagerSoapDelegate.java,v $
9    *   Revision 1.6  2004/09/16 23:18:08  dave
10   *   Replaced debug logging in Community.
11   *   Added stream close() to FileStore.
12   *
13   *   Revision 1.5.82.1  2004/09/16 09:58:48  dave
14   *   Replaced debug with commons logging ....
15   *
16   *   Revision 1.5  2004/06/18 13:45:19  dave
17   *   Merged development branch, dave-dev-200406081614, into HEAD
18   *
19   *   Revision 1.4.38.2  2004/06/17 15:10:02  dave
20   *   Removed unused imports (PMD report).
21   *
22   *   Revision 1.4.38.1  2004/06/17 13:38:58  dave
23   *   Tidied up old CVS log entries
24   *
25   * </cvs:log>
26   *
27   */
28  package org.astrogrid.community.client.database.manager ;
29  
30  import org.apache.commons.logging.Log ;
31  import org.apache.commons.logging.LogFactory ;
32  
33  import java.net.URL ;
34  import java.net.MalformedURLException ;
35  
36  import org.astrogrid.community.common.database.manager.DatabaseManagerService ;
37  import org.astrogrid.community.common.database.manager.DatabaseManagerServiceLocator ;
38  
39  /***
40   * Soap delegate for our DatabaseManager service.
41   *
42   */
43  public class DatabaseManagerSoapDelegate
44      extends DatabaseManagerCoreDelegate
45      implements DatabaseManagerDelegate
46      {
47      /***
48       * Our debug logger.
49       *
50       */
51      private static Log log = LogFactory.getLog(DatabaseManagerSoapDelegate.class);
52  
53      /***
54       * Public constructor.
55       *
56       */
57      public DatabaseManagerSoapDelegate()
58          {
59          super() ;
60          }
61  
62      /***
63       * Public constructor, for a specific endpoint URL.
64       * @param endpoint The service endpoint URL.
65       *
66       */
67      public DatabaseManagerSoapDelegate(String endpoint)
68          throws MalformedURLException
69          {
70          this(new URL(endpoint)) ;
71          }
72  
73      /***
74       * Public constructor, for a specific endpoint URL.
75       * @param endpoint - The service endpoint URL.
76       *
77       */
78      public DatabaseManagerSoapDelegate(URL endpoint)
79          {
80          super() ;
81          log.debug("") ;
82          log.debug("----\"----") ;
83          log.debug("DatabaseManagerSoapDelegate()") ;
84          log.debug("  URL : " + endpoint) ;
85          this.setEndpoint(endpoint) ;
86          }
87  
88      /***
89       * Our DatabaseManager locator.
90       *
91       */
92      private DatabaseManagerService locator = new DatabaseManagerServiceLocator() ;
93  
94      /***
95       * Our endpoint address.
96       *
97       */
98      private URL endpoint ;
99  
100     /***
101      * Get our endpoint address.
102      *
103      */
104     public URL getEndpoint()
105         {
106         return this.endpoint ;
107         }
108 
109     /***
110      * Set our endpoint address.
111      * @todo Empty catch throws away Exceptions. Need better Exception handling.
112      *
113      */
114     public void setEndpoint(URL endpoint)
115         {
116         log.debug("") ;
117         log.debug("----\"----") ;
118         log.debug("DatabaseManagerSoapDelegate.setEndpoint()") ;
119         log.debug("  URL : " + endpoint) ;
120         //
121         // Set our endpoint address.
122         this.endpoint = endpoint ;
123         //
124         // Reset our DatabaseManager reference.
125         this.setDatabaseManager(null) ;
126         //
127         // If we have a valid endpoint.
128         if (null != this.getEndpoint())
129             {
130             //
131             // If we have a valid locator.
132             if (null != locator)
133                 {
134                 try {
135                     //
136                     // Try getting our DatabaseManager service.
137                     this.setDatabaseManager(
138                         locator.getDatabaseManager(
139                             this.getEndpoint()
140                             )
141                         ) ;
142                     }
143                 //
144                 // Catch anything that went BANG.
145                 catch (Exception ouch)
146                     {
147                     // TODO
148                     // Log the Exception, and throw a nicer one.
149                     // Unwrap RemoteExceptions.
150                     //
151                     }
152                 }
153             //
154             // If we don't have a valid locator.
155             else {
156                 //
157                 // Set our manager to null and log it.
158                 this.setDatabaseManager(null) ;
159                 }
160             }
161         //
162         // If we don't have a valid endpoint.
163         else {
164             //
165             // Set our manager to null and log it.
166             this.setDatabaseManager(null) ;
167             }
168         }
169     }