001 package railo.runtime.db; 002 003 import java.util.TimeZone; 004 005 import railo.commons.lang.ClassException; 006 import railo.runtime.config.ConfigWebFactory; 007 import railo.runtime.exp.ApplicationException; 008 import railo.runtime.exp.PageRuntimeException; 009 import railo.runtime.type.Struct; 010 011 public class ApplicationDataSource extends DataSourceSupport { 012 013 private String connStr; 014 015 private ApplicationDataSource(String name, String className, String connStr, String username, String password, 016 boolean blob, boolean clob, int connectionLimit, int connectionTimeout, long metaCacheTimeout, TimeZone timezone, int allow, boolean storage, boolean readOnly) throws ClassException { 017 this(name, toClass(className), connStr, username, password, 018 blob, clob, connectionLimit, connectionTimeout, metaCacheTimeout, timezone, allow, storage, readOnly); 019 } 020 021 private ApplicationDataSource(String name, Class clazz, String connStr, String username, String password, 022 boolean blob, boolean clob, int connectionLimit, int connectionTimeout, long metaCacheTimeout, TimeZone timezone, int allow, boolean storage, boolean readOnly) { 023 super(name, clazz,username,ConfigWebFactory.decrypt(password), 024 blob,clob,connectionLimit, connectionTimeout, metaCacheTimeout, timezone, allow<0?ALLOW_ALL:allow, storage, readOnly); 025 026 this.connStr = connStr; 027 } 028 029 030 public static DataSource getInstance(String name, String className, String connStr, String username, String password, 031 boolean blob, boolean clob, int connectionLimit, int connectionTimeout, long metaCacheTimeout, TimeZone timezone, int allow, boolean storage, boolean readOnly) throws ClassException { 032 033 return new ApplicationDataSource(name, className, connStr, username, password, blob, clob, connectionLimit, connectionTimeout, metaCacheTimeout, timezone, allow, storage, readOnly); 034 } 035 036 @Override 037 public String getDsnOriginal() { 038 throw exp(); 039 } 040 041 @Override 042 public String getConnectionString() { 043 throw exp(); 044 } 045 046 @Override 047 public String getDsnTranslated() { 048 return getConnectionStringTranslated(); 049 } 050 051 @Override 052 public String getConnectionStringTranslated() { 053 return connStr; 054 } 055 056 @Override 057 public String getDatabase() { 058 throw exp(); 059 } 060 061 @Override 062 public int getPort() { 063 throw exp(); 064 } 065 066 @Override 067 public String getHost() { 068 throw exp(); 069 } 070 071 @Override 072 public DataSource cloneReadOnly() { 073 return new ApplicationDataSource(getName(), getClazz(), connStr, getUsername(), getPassword(), 074 isBlob(), isClob(), getConnectionLimit(), getConnectionTimeout(), getMetaCacheTimeout(), getTimeZone(), allow, isStorage(), isReadOnly()); 075 } 076 077 @Override 078 public String getCustomValue(String key) { 079 throw exp(); 080 } 081 082 @Override 083 public String[] getCustomNames() { 084 throw exp(); 085 } 086 087 @Override 088 public Struct getCustoms() { 089 throw exp(); 090 } 091 092 @Override 093 public boolean validate() { 094 throw exp(); 095 } 096 097 098 private PageRuntimeException exp() { 099 //return new MethodNotSupportedException(); 100 throw new PageRuntimeException(new ApplicationException("method not supported")); 101 } 102 }