View Javadoc

1   /*
2    * Copyright 2001-2004 The Apache Software Foundation.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.apache.juddi.function;
17  
18  import org.apache.commons.logging.Log;
19  import org.apache.commons.logging.LogFactory;
20  import org.apache.juddi.datatype.RegistryObject;
21  import org.apache.juddi.datatype.request.GetRegistryInfo;
22  import org.apache.juddi.datatype.response.RegistryInfo;
23  import org.apache.juddi.error.RegistryException;
24  import org.apache.juddi.registry.RegistryEngine;
25  import org.apache.juddi.util.Config;
26  import org.apache.juddi.util.Release;
27  
28  /***
29   * @author Steve Viens (sviens@apache.org)
30   */
31  public class GetRegisteryInfoFunction extends AbstractFunction
32  {
33    // private reference to jUDDI Logger
34    private static Log log = LogFactory.getLog(GetRegisteryInfoFunction.class);
35  
36    /***
37     *
38     */
39    public GetRegisteryInfoFunction(RegistryEngine registry)
40    {
41      super(registry);
42    }
43  
44    /***
45     *
46     */
47    public RegistryObject execute(RegistryObject regObject)
48      throws RegistryException
49    {
50      GetRegistryInfo request = (GetRegistryInfo)regObject;
51      String generic = request.getGeneric();
52  
53      try
54      {
55        // create a new RegisteryInfo instance and 
56        // add Registry name/value properties to it.
57  
58        RegistryInfo info = new RegistryInfo();
59        info.setGeneric(generic);
60        info.setOperator(Config.getOperator());
61        info.addProperty("operatorName",Config.getStringProperty("juddi.operatorName"));
62        info.addProperty("operatorEmailAddress",Config.getStringProperty("juddi.operatorEmailAddress"));
63        info.addProperty("registryVersion",Release.getRegistryVersion());
64        info.addProperty("uddiVersion",Release.getUDDIVersion());
65        
66        return info;
67      }
68      catch(Exception ex)
69      {
70        log.error(ex);
71        throw new RegistryException(ex);
72      }
73    }
74  
75  
76    /****************************************************************************/
77    /****************************** TEST DRIVER *********************************/
78    /****************************************************************************/
79  
80  
81    public static void main(String[] args)
82    {
83      // initialize the registry
84      RegistryEngine reg = new RegistryEngine();
85      reg.init();
86  
87      try
88      {
89      }
90      catch (Exception ex)
91      {
92        // write execption to the console
93        ex.printStackTrace();
94      }
95      finally
96      {
97        // destroy the registry
98        reg.dispose();
99      }
100   }
101 }