View Javadoc

1   /*$Id: HttpApplicationDescriptionLibrary.java,v 1.7 2004/12/18 15:43:57 jdt Exp $
2    * Created on Jul 24, 2004
3    *
4    * Copyright (C) AstroGrid. All rights reserved.
5    *
6    * This software is published under the terms of the AstroGrid 
7    * Software License version 1.2, a copy of which has been included 
8    * with this distribution in the LICENSE.txt file.  
9    *
10  **/
11  package org.astrogrid.applications.http;
12  
13  import java.io.IOException;
14  import java.util.Collection;
15  import java.util.Iterator;
16  
17  import org.apache.commons.logging.Log;
18  import org.apache.commons.logging.LogFactory;
19  import org.astrogrid.applications.description.BaseApplicationDescriptionLibrary;
20  import org.astrogrid.applications.description.base.ApplicationDescriptionEnvironment;
21  import org.astrogrid.applications.http.registry.RegistryQuerier;
22  import org.astrogrid.component.descriptor.ComponentDescriptor;
23  import org.astrogrid.registry.beans.cea.CeaHttpApplicationType;
24  
25  /*** 
26   * library of HttpApplication application descriptions.
27   * @author JDT
28   *
29   */
30  public class HttpApplicationDescriptionLibrary extends BaseApplicationDescriptionLibrary implements  ComponentDescriptor{
31      /***
32       * Commons Logger for this class
33       */
34      private static final Log log = LogFactory.getLog(HttpApplicationDescriptionLibrary.class);
35  	private RegistryQuerier querier;
36  
37      /*** Construct a new HttpApplicationDescriptionLibrary, based on methods of parameter class
38       * @param querier does all the hard work of talking to the registry and getting the stuff we need to create HttpAppplicationDescriptions
39       * @throws IOException if there was a problem in the querier.  Typically this will be a failure of the 
40       * querier to contact the registry
41       * 
42       */
43      public HttpApplicationDescriptionLibrary(RegistryQuerier querier, ApplicationDescriptionEnvironment env) throws IOException {
44          super(env);
45          if (log.isTraceEnabled()) {
46              log.trace("HttpApplicationDescriptionLibrary(RegistryQuerier querier = " + querier
47                      + ", ApplicationDescriptionEnvironment env = " + env
48                      + ") - start");
49          }
50  
51          this.querier = querier;
52          populate();
53  
54          if (log.isTraceEnabled()) {
55              log.trace("HttpApplicationDescriptionLibrary(RegistryQuerier, Community, ApplicationDescriptionEnvironment) - end");
56          }
57      }
58      
59      
60      /*** 
61       * Populate the library
62       * @throws IOException if there was a problem in the querier.  Typically this will be a failure of the 
63       * querier to contact the registry
64       */
65      protected final void populate() throws IOException {
66          if (log.isTraceEnabled()) {
67              log.trace("populate() - start");
68          }
69  
70          final Collection apps = querier.getHttpApplications();
71          assert apps!=null;
72  
73          final Iterator it = apps.iterator();
74          while (it.hasNext()) {
75              final CeaHttpApplicationType app = (CeaHttpApplicationType) it.next(); 
76              super.addApplicationDescription(new HttpApplicationDescription(app, env)); 
77          }
78  
79          if (log.isTraceEnabled()) {
80              log.trace("populate() - end");
81          }
82      }
83  
84      /***
85       * @see org.astrogrid.component.descriptor.ComponentDescriptor#getDescription()
86       */
87      public String getDescription() {
88          String returnString = "HttpApplication server serving applications found by RegistryQuerier" + querier + "\n"
89                  + super.getDescription();
90          return returnString;
91      }
92  
93      /***
94       * @see org.astrogrid.component.descriptor.ComponentDescriptor#getName()
95       */
96      public String getName() {
97          return "HttpApplication Library";
98      }
99  
100     public String toString() {
101         StringBuffer buffer = new StringBuffer();
102         buffer.append("[HttpApplicationDescriptionLibrary:");
103         buffer.append(" logger: ");
104         buffer.append(log);
105         buffer.append(" querier: ");
106         buffer.append(querier);
107         buffer.append(super.toString());
108         buffer.append("]");
109         String returnString = buffer.toString();
110         return returnString;
111     }
112 }
113 
114 /* 
115 $Log: HttpApplicationDescriptionLibrary.java,v $
116 Revision 1.7  2004/12/18 15:43:57  jdt
117 merge from  cea_pah_561b
118 
119 Revision 1.6.2.1  2004/12/07 07:32:26  pah
120 update to pass band information properly
121 
122 Revision 1.6  2004/11/27 13:20:03  pah
123 result of merge of pah_cea_bz561 branch
124 
125 Revision 1.5.36.1  2004/11/09 09:21:16  pah
126 initial attempt to rationalise authorityID use & self registering
127 
128 Revision 1.5  2004/09/01 15:42:26  jdt
129 Merged in Case 3
130 
131 Revision 1.1.4.8  2004/08/30 14:54:42  jdt
132 tidied some imports
133 
134 Revision 1.1.4.7  2004/08/11 12:11:59  jdt
135 Some refactoring of the registry querier.  Made the test registry
136 querier easier to use.
137 
138 Revision 1.1.4.6  2004/08/09 16:37:13  jdt
139 Brought into line following pah's suggested schema changes
140 
141 Revision 1.1.4.5  2004/08/06 13:30:22  jdt
142 safety checkin
143 
144 Revision 1.1.4.4  2004/07/29 21:30:47  jdt
145 *** empty log message ***
146 
147 Revision 1.1.4.3  2004/07/29 17:08:22  jdt
148 Think about how I'm going to get stuff out of the registry
149 
150 Revision 1.1.4.2  2004/07/29 16:35:21  jdt
151 Safety checkin, while I think about what happens next.
152 
153 Revision 1.1.4.1  2004/07/27 17:20:25  jdt
154 merged from applications_JDT_case3
155 
156 Revision 1.1.2.1  2004/07/24 17:16:16  jdt
157 Borrowed from javaclass application....stealing is always quicker.
158 
159  
160 */