KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > admin > wsmgmt > transform > TransformMgr


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23 package com.sun.enterprise.admin.wsmgmt.transform;
24
25 import com.sun.enterprise.admin.wsmgmt.config.spi.WebServiceConfig;
26
27 import java.util.logging.Logger JavaDoc;
28 import java.util.logging.Level JavaDoc;
29 import com.sun.logging.LogDomains;
30 import com.sun.enterprise.util.i18n.StringManager;
31
32 /**
33  * Transformation initialization and cleanup facilitator
34  */

35 public class TransformMgr {
36
37     /**
38      * Returns the singleton instance of this class.
39      *
40      * @return singleton instance of this class
41      */

42     public static TransformMgr getInstance() {
43         if (_instance == null) {
44             _instance = new TransformMgr();
45         }
46
47         return _instance;
48     }
49
50     /**
51      * Private constructor.
52      */

53     private TransformMgr() {
54     }
55
56     /**
57      * Initializes the transformation capability for an endpoint.
58      */

59     public void init(String JavaDoc appId, WebServiceConfig wsc) {
60         if ( wsc == null) {
61             return;
62         }
63
64         try {
65             // if there is atleast one transformation register a filter
66
if ((wsc.getRequestTransformationRule() != null) ||
67               (wsc.getResponseTransformationRule() != null)) {
68                 TransformHandler tHandler = new TransformHandler(wsc, appId);
69                 tHandler.registerFilter(wsc);
70             }
71
72         } catch (Exception JavaDoc e) {
73             String JavaDoc msg="Configuration initialization error.";
74             _logger.log(Level.FINE, msg, e);
75         }
76     }
77
78     /**
79      * Shuts down transformation capabilities for an endpoint
80      */

81     public void stop(String JavaDoc appId, WebServiceConfig wsc) {
82         if ( wsc == null) {
83             return;
84         }
85
86         try {
87             // if there is atleast one transformation register a filter
88
if ((wsc.getRequestTransformationRule() != null) ||
89               (wsc.getResponseTransformationRule() != null)) {
90                 TransformHandler tHandler = new TransformHandler(wsc, appId);
91                 tHandler.unregisterFilter(appId,wsc);
92             }
93
94         } catch (Exception JavaDoc e) {
95             String JavaDoc msg="Configuration initialization error.";
96             _logger.log(Level.FINE, msg, e);
97         }
98     }
99
100     // ---- VARIABLES - PRIVATE ---------------------------------------
101
private static TransformMgr _instance = null;
102     private static final Logger JavaDoc _logger =
103         Logger.getLogger(LogDomains.ADMIN_LOGGER);
104     private static final StringManager _stringMgr =
105         StringManager.getManager(TransformMgr.class);
106
107 }
108
Popular Tags