1 package org.kuali.common.jdbc.model.context; 2 3 import java.util.Properties; 4 5 import org.kuali.common.jdbc.model.Credentials; 6 import org.kuali.common.util.Assert; 7 import org.kuali.common.util.PropertyUtils; 8 9 public final class ConnectionContext { 10 11 private static final Properties DEFAULT_PROPERTIES = PropertyUtils.EMPTY; 12 13 public ConnectionContext(String url) { 14 this(url, Credentials.NO_USERNAME); 15 } 16 17 public ConnectionContext(String url, String username) { 18 this(url, username, Credentials.NO_PASSWORD); 19 } 20 21 public ConnectionContext(String url, String username, String password) { 22 this(url, new Credentials(username, password), DEFAULT_PROPERTIES); 23 } 24 25 public ConnectionContext(String url, Credentials credentials, Properties properties) { 26 Assert.noNulls(credentials, properties); 27 Assert.noBlanks(url); 28 this.url = url; 29 this.credentials = credentials; 30 this.properties = PropertyUtils.toImmutable(properties); 31 } 32 33 private final String url; 34 private final Credentials credentials; 35 private final Properties properties; 36 37 public String getUrl() { 38 return url; 39 } 40 41 public Credentials getCredentials() { 42 return credentials; 43 } 44 45 public Properties getProperties() { 46 return properties; 47 } 48 }