1 22 23 package org.xquark.mediator; 24 25 import org.xquark.xml.xdbc.*; 26 27 public class XDBCWrapper { 28 private static final String RCSRevision = "$Revision: 1.4 $"; 32 private static final String RCSName = "Name"; 33 34 private Mediator mediator = null; 38 private XMLDataSource dataSource = null; 39 40 private String name; 41 private String driver; 42 private String uri; 43 private String login = null; 44 private String passwd = null; 45 private boolean isConnected; 46 47 48 54 public XDBCWrapper(String name, String driver, String connection) { 55 this(name, driver, connection, null, null); 56 } 57 58 61 public XDBCWrapper(String name, String driver, String connection, String login, String passwd) { 62 this.name = name; 63 this.driver = driver; 64 this.uri = connection; 65 this.login = login; 66 this.passwd = passwd; 67 this.isConnected = false; 68 } 69 70 public XDBCWrapper(String name, XMLDataSource source) { 71 this.name = name; 72 dataSource = source; 73 } 74 75 void setMediator(Mediator mediator) { 76 this.mediator = mediator; 77 } 78 79 83 public synchronized XMLDataSource getDataSource() throws XMLDBCException { 84 if (dataSource == null) { 85 if (login != null && passwd != null) { 86 dataSource = XMLDriverManager.getDataSource(uri, login, passwd); 87 } else { 88 dataSource = XMLDriverManager.getDataSource(uri); 89 } 90 } 91 return dataSource; 92 } 93 94 97 public XMLConnection getConnection() throws XMLDBCException { 98 return getDataSource().getConnection(); 99 } 100 101 104 public void close() { 105 isConnected = false; 106 } 107 108 114 public String getName() { 115 return name; 116 } 117 } 118 | Popular Tags |