KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > xml > LoggingEntityResolver


1 /*
2  * Copyright 1999-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.cocoon.xml;
17
18 import org.apache.avalon.framework.logger.AbstractLogEnabled;
19 import org.xml.sax.EntityResolver JavaDoc;
20 import org.xml.sax.InputSource JavaDoc;
21 import org.xml.sax.SAXException JavaDoc;
22
23 import java.io.IOException JavaDoc;
24 import java.util.Collections JavaDoc;
25 import java.util.HashSet JavaDoc;
26 import java.util.Set JavaDoc;
27
28 /**
29  * Logging entity resolver to assist in caching.
30  *
31  * @author <a HREF="mailto:balld@webslingerZ.com">Donald Ball</a>
32  * @version CVS $Id: LoggingEntityResolver.java 30932 2004-07-29 17:35:38Z vgritsenko $
33  */

34 public class LoggingEntityResolver extends AbstractLogEnabled implements EntityResolver JavaDoc {
35
36   protected EntityResolver JavaDoc resolver;
37   protected Set JavaDoc dependencies;
38
39   public LoggingEntityResolver(EntityResolver JavaDoc resolver) {
40     this.resolver = resolver;
41     dependencies = new HashSet JavaDoc();
42   }
43
44   public InputSource JavaDoc resolveEntity(String JavaDoc public_id, String JavaDoc system_id) throws SAXException JavaDoc,IOException JavaDoc {
45     InputSource JavaDoc input_source = resolver.resolveEntity(public_id,system_id);
46     dependencies.add(input_source);
47     getLogger().debug("Dependency: "+input_source.getSystemId());
48     return input_source;
49   }
50
51   public Set JavaDoc getDependencies() {
52     return Collections.unmodifiableSet(dependencies);
53   }
54
55 }
56
Popular Tags