View Javadoc

1   /*$Id: JavaClassCEAComponentManager.java,v 1.5 2004/11/27 13:20:03 pah Exp $
2    * Created on 10-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.component;
12  
13  import org.astrogrid.applications.javaclass.JavaClassApplicationDescriptionLibrary;
14  import org.astrogrid.applications.javaclass.SampleJavaClassApplications;
15  import org.astrogrid.config.Config;
16  import org.astrogrid.config.SimpleConfig;
17  
18  import org.apache.commons.logging.Log;
19  import org.apache.commons.logging.LogFactory;
20  import org.picocontainer.MutablePicoContainer;
21  
22  /*** Simple component manager that defines a  standalone JavaClass CEA server
23   * @author Noel Winstanley nw@jb.man.ac.uk 10-Jun-2004
24   *@see org.astrogrid.applications.javaclass
25   *@todo factor into the javaclass package?
26   */
27  public class JavaClassCEAComponentManager extends EmptyCEAComponentManager {
28      /***
29       * Commons Logger for this class
30       */
31      private static final Log logger = LogFactory.getLog(JavaClassCEAComponentManager.class);
32      /*** key to look in config under for the name of the java class to expose as cea applications (optional, defaulrs to {@link SampleJavaClassApplications})
33       * @see #registerJavaClassProvider(MutablePicoContainer, Config)*/
34      public final static String SERVER_CLASS_NAME = "cea.javaclass.server.class";
35      /*** Construct a new JavaClassCEAComponentManger, with all necessary components registered
36       * <p />
37       * registers the java class provider, plus all the standard services defined in {@link EmptyCEAComponentManager}
38       */
39      public JavaClassCEAComponentManager() {
40          super();
41          final Config config = SimpleConfig.getSingleton();
42          // controller & queriers        
43          EmptyCEAComponentManager.registerDefaultServices(pico);
44          // store
45          EmptyCEAComponentManager.registerDefaultPersistence(pico,config);
46          // metadata
47          EmptyCEAComponentManager.registerDefaultVOProvider(pico,config);
48          //registry uploader
49          EmptyCEAComponentManager.registerDefaultRegistryUploader(pico);
50          // the protocol lib
51          EmptyCEAComponentManager.registerProtocolLibrary(pico);
52          EmptyCEAComponentManager.registerStandardIndirectionProtocols(pico);
53          EmptyCEAComponentManager.registerAstrogridIndirectionProtocols(pico);
54          // now hook in out own implementation
55          registerJavaClassProvider(pico,config);
56      }
57      /*** just register the components specific to the java-class provider, but none of the generic components 
58       * @see {@link #SERVER_CLASS_NAME}
59       * @see {@link #COMMUNITY_KEY} */       
60      public static final void registerJavaClassProvider(MutablePicoContainer pico, final Config config){    
61          pico.registerComponentImplementation(JavaClassApplicationDescriptionLibrary.class,JavaClassApplicationDescriptionLibrary.class);
62  
63          // implementation class for the java cea server
64          final String classname = config.getString(SERVER_CLASS_NAME,SampleJavaClassApplications.class.getName());
65          Class serverClass = SampleJavaClassApplications.class;
66          try {
67              serverClass = Class.forName(classname);
68          } catch (Exception e) {
69              logger.fatal("Could not instantiate required server class '" + classname + "' falling back to sample java applications");
70          }
71          pico.registerComponentInstance(Class.class,serverClass);
72      }
73  }
74  
75  
76  /* 
77  $Log: JavaClassCEAComponentManager.java,v $
78  Revision 1.5  2004/11/27 13:20:03  pah
79  result of merge of pah_cea_bz561 branch
80  
81  Revision 1.4.70.1  2004/11/09 09:21:16  pah
82  initial attempt to rationalise authorityID use & self registering
83  
84  Revision 1.4  2004/07/26 12:07:38  nw
85  renamed indirect package to protocol,
86  renamed classes and methods within protocol package
87  javadocs
88  
89  Revision 1.3  2004/07/23 13:21:21  nw
90  Javadocs
91  
92  Revision 1.2  2004/07/01 11:16:22  nw
93  merged in branch
94  nww-itn06-componentization
95  
96  Revision 1.1.2.3  2004/07/01 01:42:46  nw
97  final version, before merge
98  
99  Revision 1.1.2.2  2004/06/17 09:21:23  nw
100 finished all major functionality additions to core
101 
102 Revision 1.1.2.1  2004/06/14 08:56:58  nw
103 factored applications into sub-projects,
104 got packaging of wars to work again
105  
106 */