View Javadoc

1   /*$Id: BaseApplicationDescriptionLibrary.java,v 1.9 2004/12/03 15:37:05 jdt Exp $
2    * Created on 17-Jun-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.description;
12  
13  import org.astrogrid.applications.description.base.ApplicationDescriptionEnvironment;
14  import org.astrogrid.applications.description.exception.ApplicationDescriptionNotFoundException;
15  import org.astrogrid.component.descriptor.ComponentDescriptor;
16  
17  import org.apache.commons.logging.Log;
18  import org.apache.commons.logging.LogFactory;
19  
20  import java.util.HashMap;
21  import java.util.Iterator;
22  import java.util.Map;
23  
24  import junit.framework.Test;
25  
26  /*** Basic implementation of an {@link org.astrogrid.applications.description.ApplicationDescriptionLibrary}
27   * <p />
28   * Unsurprisingly, based on a map. Provides methods to add descriptions to the library. 
29   * @author Noel Winstanley nw@jb.man.ac.uk 17-Jun-2004
30   *
31   */
32  public class BaseApplicationDescriptionLibrary implements ApplicationDescriptionLibrary, ComponentDescriptor {
33      /***
34       * Commons Logger for this class
35       */
36      private static final Log logger = LogFactory.getLog(BaseApplicationDescriptionLibrary.class);
37      
38      /*** configuration interface - defines the name of the authority the applications will be added to. 
39       * @TODO - this should probably not be here - there is of course a tie in with the @see org.astrogrid.applications.manager.MetadataService and @see org.astrogrid.applications.component.ProvidesVODescription - they all need refactoring slightly to make clear which has overall control, when the exact interaction with the registry is determined - what protocol is to be used to detemine the authorityid that will be allowed?*/
40  
41      public interface AppAuthorityIDResolver {
42          String getAuthorityID();
43      }
44  
45  
46      /***Construct a new BaseApplicationDescriptionLibrary
47      * @param env2
48      */
49     public BaseApplicationDescriptionLibrary(ApplicationDescriptionEnvironment env2) {
50        
51       this.env = env2;
52     }
53  
54     /***
55           * @see org.astrogrid.applications.description.ApplicationDescriptionLibrary#getDescription(java.lang.String)
56           */
57      public ApplicationDescription getDescription(String name) throws ApplicationDescriptionNotFoundException {
58          ApplicationDescription ad = (ApplicationDescription) descMap.get(name);
59          if (ad == null) {
60              throw new ApplicationDescriptionNotFoundException(name);
61          }
62          return ad;
63      }
64      /***
65           * @see org.astrogrid.applications.description.ApplicationDescriptionLibrary#getApplicationNames()
66           */
67      public String[] getApplicationNames() {
68      return (String[])descMap.keySet().toArray(new String[0]);
69        }
70      private final Map descMap = new HashMap();
71      
72      /*** add an application description to the library
73       * <p> if an application with the same name already exists, it will be overridden. 
74       * @param desc the application description, which will be stored under key <tt>desc.getName()</tt>*/
75      public void addApplicationDescription(ApplicationDescription desc) {
76          logger.info("Adding description for " + desc.getName());
77          descMap.put(desc.getName(),desc);
78      }
79      /***
80       * @see org.astrogrid.component.descriptor.ComponentDescriptor#getName()
81       */
82      public String getName() {
83          return "Basic Application Description Library";
84      }
85      /***
86       * @see org.astrogrid.component.descriptor.ComponentDescriptor#getDescription()
87       */
88      public String getDescription() {
89          return this.toString();
90      }
91       
92     public String toString() {     
93          StringBuffer appList = new StringBuffer();
94          for (Iterator i = descMap.values().iterator(); i.hasNext(); ) {
95              ApplicationDescription desc = (ApplicationDescription)i.next();
96              appList.append("\n");
97              appList.append(desc.toString());
98              appList.append("\n");
99          }
100         return "Applications in Library:'"  + appList.toString();
101     }
102     /***
103      * @see org.astrogrid.component.descriptor.ComponentDescriptor#getInstallationTest()
104      */
105     public Test getInstallationTest() {
106         return null;
107     }
108    protected final ApplicationDescriptionEnvironment env;    
109 }
110 
111 
112 /* 
113 $Log: BaseApplicationDescriptionLibrary.java,v $
114 Revision 1.9  2004/12/03 15:37:05  jdt
115 restored it how it was....change PAL instead.
116 
117 Revision 1.8  2004/12/03 15:33:39  jdt
118 restored the default ctor, otherwise PAL breaks.
119 
120 Revision 1.7  2004/11/27 13:20:02  pah
121 result of merge of pah_cea_bz561 branch
122 
123 Revision 1.6.28.1  2004/11/09 09:21:16  pah
124 initial attempt to rationalise authorityID use & self registering
125 
126 Revision 1.6  2004/09/07 08:06:39  pah
127 todo added - need to remove confusion between community and authorityid
128 
129 Revision 1.5  2004/09/01 15:42:26  jdt
130 Merged in Case 3
131 
132 Revision 1.4.2.1  2004/08/09 16:36:25  jdt
133 pulled up an interface so I can use it in http apps
134 
135 Revision 1.4  2004/07/26 12:07:38  nw
136 renamed indirect package to protocol,
137 renamed classes and methods within protocol package
138 javadocs
139 
140 Revision 1.3  2004/07/26 00:57:46  nw
141 javadoc
142 
143 Revision 1.2  2004/07/01 11:16:22  nw
144 merged in branch
145 nww-itn06-componentization
146 
147 Revision 1.1.2.1  2004/07/01 01:42:46  nw
148 final version, before merge
149  
150 */