01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.cocoon.xml;
18:
19: import org.apache.avalon.framework.logger.AbstractLogEnabled;
20: import org.xml.sax.EntityResolver;
21: import org.xml.sax.InputSource;
22: import org.xml.sax.SAXException;
23:
24: import java.io.IOException;
25: import java.util.Collections;
26: import java.util.HashSet;
27: import java.util.Set;
28:
29: /**
30: * Logging entity resolver to assist in caching.
31: *
32: * @author <a href="mailto:balld@webslingerZ.com">Donald Ball</a>
33: * @version CVS $Id: LoggingEntityResolver.java 433543 2006-08-22 06:22:54Z crossley $
34: */
35: public class LoggingEntityResolver extends AbstractLogEnabled implements
36: EntityResolver {
37:
38: protected EntityResolver resolver;
39: protected Set dependencies;
40:
41: public LoggingEntityResolver(EntityResolver resolver) {
42: this .resolver = resolver;
43: dependencies = new HashSet();
44: }
45:
46: public InputSource resolveEntity(String public_id, String system_id)
47: throws SAXException, IOException {
48: InputSource input_source = resolver.resolveEntity(public_id,
49: system_id);
50: dependencies.add(input_source);
51: getLogger().debug("Dependency: " + input_source.getSystemId());
52: return input_source;
53: }
54:
55: public Set getDependencies() {
56: return Collections.unmodifiableSet(dependencies);
57: }
58:
59: }
|