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 at7 * 8 * http://www.apache.org/licenses/LICENSE-2.09 * 10 * Unless required by applicable law or agreed to in writing, software11 * 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 and14 * limitations under the License.15 */16package org.apache.juddi.v3.client.config;
1718import javax.servlet.ServletConfig;
19import javax.servlet.ServletException;
20import javax.servlet.http.HttpServlet;
2122import org.apache.commons.logging.Log;
23import org.apache.commons.logging.LogFactory;
2425/**26 * This servlet is to initialize the UDDIclient on deployment and27 * cleanup on shutdown.28 * 29 * @author Kurt Stam (kstam@apache.org)30 */31publicclassUDDIClerkServletextends HttpServlet {
3233privatestaticfinallong serialVersionUID = -91998529871296125L;
34privatestaticfinal Log logger = LogFactory.getLog(UDDIClerkServlet.class);
35privatetransientUDDIClient manager = null;
3637/**38 * Starting the UDDIClient39 */40 @Override
41publicvoid init(ServletConfig config) throws ServletException {
42super.init(config);
43try {
44 manager = WebHelper.getUDDIClient(config.getServletContext());
45if (manager.getClientConfig().isRegisterOnStartup()) {
46 manager.registerWSDLs();
47 manager.registerAnnotatedServices();
48 }
49 } catch (Exception e) {
50 logger.error("UDDI-client could not be started for manager " + manager.getName() + ". "51 + e.getMessage(), e);
52 } catch (Throwable t) {
53 logger.error("UDDI-client could not be started."54 + t.getMessage(), t);
55 }
56 }
5758 @Override
59publicvoid destroy() {
60try {
61 manager.stop();
62 } catch (Exception e) {
63 logger.error("UDDI-Clerk Manager could not be stopped for manager " + manager.getName() + ". "64 + e.getMessage(), e);
65 } catch (Throwable t) {
66 logger.error("UDDI-client could not be stopped."67 + t.getMessage(), t);
68 }
69super.destroy();
70 }
7172 }