01: /**
02: *
03: * Licensed to the Apache Software Foundation (ASF) under one or more
04: * contributor license agreements. See the NOTICE file distributed with
05: * this work for additional information regarding copyright ownership.
06: * The ASF licenses this file to You under the Apache License, Version 2.0
07: * (the "License"); you may not use this file except in compliance with
08: * the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing, software
13: * distributed under the License is distributed on an "AS IS" BASIS,
14: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: * See the License for the specific language governing permissions and
16: * limitations under the License.
17: */package org.apache.openejb.server.cxf;
18:
19: import org.apache.cxf.Bus;
20: import org.apache.cxf.catalog.OASISCatalogManager;
21: import org.apache.xml.resolver.Catalog;
22: import org.apache.openejb.util.Logger;
23: import org.apache.openejb.util.LogCategory;
24:
25: import java.io.FileNotFoundException;
26: import java.io.IOException;
27: import java.net.MalformedURLException;
28: import java.net.URL;
29:
30: public final class CxfCatalogUtils {
31: private static final Logger logger = Logger.getInstance(
32: LogCategory.CXF, CxfCatalogUtils.class);
33:
34: public static void loadOASISCatalog(Bus bus, URL baseURL,
35: String catalogName) {
36: URL catalogURL = null;
37: try {
38: catalogURL = new URL(baseURL, catalogName);
39: logger.debug("Checking for " + catalogURL + " catalog.");
40: catalogURL.openStream().close();
41: loadOASISCatalog(bus, catalogURL);
42: } catch (MalformedURLException e) {
43: logger.warning("Error constructing catalog URL: " + baseURL
44: + " " + catalogName);
45: } catch (FileNotFoundException e) {
46: logger.debug("Catalog " + catalogURL
47: + " is not present in the module");
48: } catch (IOException e) {
49: logger.warning(
50: "Failed to load catalog file: " + catalogURL, e);
51: }
52: }
53:
54: private static void loadOASISCatalog(Bus bus, URL catalogURL) {
55: OASISCatalogManager catalog = new OASISCatalogManager();
56: try {
57: catalog.loadCatalog(catalogURL);
58: logger.debug("Loaded " + catalogURL + " catalog.");
59: bus.setExtension(catalog.getCatalog(), Catalog.class);
60: } catch (IOException e) {
61: logger.warning(
62: "Failed to load catalog file: " + catalogURL, e);
63: }
64: }
65: }
|