01: // Copyright (c) 2004-2005 Sun Microsystems Inc., All Rights Reserved.
02:
03: /*
04: * FileBindingResolver.java
05: * SUN PROPRIETARY/CONFIDENTIAL.
06: * This software is the proprietary information of Sun Microsystems, Inc.
07: * Use is subject to license terms.
08: *
09: */
10: package com.sun.jbi.binding.file;
11:
12: import org.w3c.dom.Document;
13:
14: import java.util.Hashtable;
15:
16: import javax.jbi.servicedesc.ServiceEndpoint;
17:
18: /**
19: * This class implements the Resolver contract with the NMR. Resolver is used
20: * by other components of JBI to query meta-data of endpoints deployed in file
21: * binding.
22: *
23: * @author Sun Microsystems, Inc.
24: */
25: public class FileBindingResolver {
26: /**
27: * Holds the descriptor objects.
28: */
29: private Hashtable mDescriptorCache;
30:
31: /**
32: * Creates a new FileBindingResolver object.
33: */
34: public FileBindingResolver() {
35: mDescriptorCache = new Hashtable();
36: }
37:
38: /**
39: * Contract with framework. This method is used by other components to
40: * query meta-data.
41: *
42: * @param ef endpoint reference.
43: *
44: * @return descriptor object.
45: */
46: public Document getServiceDescription(ServiceEndpoint ef) {
47: try {
48: Document df = (Document) mDescriptorCache.get(ef
49: .getServiceName().toString()
50: + ef.getEndpointName());
51:
52: return df;
53: } catch (Exception e) {
54: return null;
55: }
56: }
57:
58: /**
59: * Adds endpoint meta-data.
60: *
61: * @param epname endpoint name.
62: * @param df document fragment.
63: */
64: public void addEndpointDoc(String epname, Document df) {
65: if ((epname != null) && (df != null)) {
66: try {
67: mDescriptorCache.put(epname, df);
68: } catch (Exception e) {
69: e.printStackTrace();
70: }
71: }
72: }
73:
74: /**
75: * Clears the descriptor cache. Removes all information.
76: */
77: public void clearCache() {
78: mDescriptorCache = new Hashtable();
79: }
80: }
|