KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > juddi > function > GetRegisteryInfoFunction


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 JavaDoc 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("registryLastModified",Release.getLastModified());
65       info.addProperty("uddiVersion",Release.getUDDIVersion());
66       
67       return info;
68     }
69     catch(Exception JavaDoc ex)
70     {
71       log.error(ex);
72       throw new RegistryException(ex);
73     }
74   }
75
76
77   /***************************************************************************/
78   /***************************** TEST DRIVER *********************************/
79   /***************************************************************************/
80
81
82   public static void main(String JavaDoc[] args)
83   {
84     // initialize the registry
85
RegistryEngine reg = new RegistryEngine();
86     reg.init();
87
88     try
89     {
90     }
91     catch (Exception JavaDoc ex)
92     {
93       // write execption to the console
94
ex.printStackTrace();
95     }
96     finally
97     {
98       // destroy the registry
99
reg.dispose();
100     }
101   }
102 }
Popular Tags