Source Code Cross Referenced for DbInstance.java in  » Database-Client » dbmjui » fr » aliacom » dbmjui » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Database Client » dbmjui » fr.aliacom.dbmjui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package fr.aliacom.dbmjui;
002:
003:        import java.beans.PropertyChangeListener;
004:        import java.beans.PropertyChangeSupport;
005:        import java.io.Serializable;
006:        import java.util.Properties;
007:
008:        import org.apache.log4j.Logger;
009:
010:        import com.sap.dbtech.powertoys.DBM;
011:
012:        import fr.aliacom.dbmjui.beans.InstanceInformations;
013:
014:        /**
015:         * Most of the dbm code should be moved elsewhere
016:         * 
017:         * @author tom
018:         *
019:         * (c) 2001, 2003 Thomas Cataldo
020:         */
021:        public final class DbInstance implements  Serializable {
022:
023:            private String version;
024:            private String fullName;
025:            private String name;
026:            private DatabaseServer dbs;
027:            private Properties connectionParams;
028:
029:            private transient InstanceInformations infos;
030:
031:            private transient BackupHistory history;
032:            private transient PropertyChangeSupport changes;
033:            private transient static final Logger logger = Logger
034:                    .getLogger(DbInstance.class);
035:
036:            public DbInstance(DatabaseServer dbs) {
037:                this .dbs = dbs;
038:                infos = new InstanceInformations();
039:                history = new BackupHistory();
040:            }
041:
042:            private final PropertyChangeSupport getChanges() {
043:                if (changes == null) {
044:                    changes = new PropertyChangeSupport(this );
045:                }
046:                return changes;
047:            }
048:
049:            /**
050:             * Add a listener on a given property
051:             * 
052:             * @param prop the property changes you want to be notified of.
053:             * @param l the listener notified of the property change
054:             */
055:            public void addPropertyChangeListener(String prop,
056:                    PropertyChangeListener l) {
057:                getChanges().addPropertyChangeListener(prop, l);
058:            }
059:
060:            public String getVersion() {
061:                return version;
062:            }
063:
064:            /**
065:             * Removes a listener on a given property
066:             * 
067:             */
068:            public void removePropertyChangeListener(String prop,
069:                    PropertyChangeListener l) {
070:                getChanges().removePropertyChangeListener(prop, l);
071:            }
072:
073:            public DatabaseServer getServer() {
074:                return dbs;
075:            }
076:
077:            /**
078:             * @see DbInstance#setDbmCredential(DbmCredential)
079:             */
080:            public void setDbmCredential(DbmCredential creds)
081:                    throws DBMLoginException {
082:                try {
083:                    Properties props = new Properties();
084:                    props.put("host", dbs.getHost());
085:                    props.put("dbname", infos.getName());
086:                    props.put("user", creds.getLogin() + ","
087:                            + creds.getPassword());
088:
089:                    DBM aDbm = new DBM(props);
090:
091:                    logger.debug("Logging in...");
092:                    aDbm.cmd("user_logon " + props.get("user"));
093:                    logger.debug("logger in");
094:
095:                    connectionParams = props;
096:                    aDbm.release();
097:                    infos = HelperFactory.getInstance().getInstanceHelper(this )
098:                            .updateInformations(this );
099:                } catch (Exception e) {
100:                    logger.fatal(
101:                            "Exception occured while checking credentials", e);
102:                    throw new DBMLoginException(e.toString());
103:                }
104:            }
105:
106:            /**
107:             * Get a DBM connection. The user given at registration time
108:             * is already logged on.
109:             * 
110:             * Error generated by commands executed with the returned connection
111:             * will be reported in the UI.
112:             * 
113:             * @return a dbm connection
114:             */
115:            public DBM getDbmConnection() {
116:                DBM aDbm = null;
117:                try {
118:                    aDbm = new JuiDbmConnection(connectionParams);
119:                    aDbm.cmd("user_logon " + connectionParams.get("user"));
120:                } catch (Exception e) {
121:                    logger.fatal("user login failed", e);
122:                    throw new RuntimeException("user_logon failed !");
123:                }
124:
125:                return aDbm;
126:            }
127:
128:            /**
129:             * Get a DBM connection. The user given at registration time
130:             * is already logged on.
131:             * 
132:             * Error generated by commands executed with the returned connection
133:             * will not be reported in the UI.
134:             * 
135:             * @return a dbm connection
136:             */
137:            public DBM getPlainDbmConnection() {
138:                DBM aDbm = null;
139:                try {
140:                    aDbm = new DBM(connectionParams);
141:                    aDbm.cmd("user_logon " + connectionParams.get("user"));
142:                } catch (Exception e) {
143:                    logger.fatal("user login failed", e);
144:                    throw new RuntimeException("user_logon failed !");
145:                }
146:
147:                return aDbm;
148:            }
149:
150:            /**
151:             * @param listener
152:             */
153:            public void addPropertyChangeListener(
154:                    PropertyChangeListener listener) {
155:                getChanges().addPropertyChangeListener(listener);
156:            }
157:
158:            /**
159:             * @param listener
160:             */
161:            public void removePropertyChangeListener(
162:                    PropertyChangeListener listener) {
163:                getChanges().removePropertyChangeListener(listener);
164:            }
165:
166:            /**
167:             * @return the cached informations about the instance
168:             */
169:            public InstanceInformations getInformations() {
170:                return infos;
171:            }
172:
173:            /**
174:             * @param infos
175:             */
176:            public void setInformations(InstanceInformations infos) {
177:                this .infos = infos;
178:            }
179:
180:            public void reloadState() {
181:                infos = HelperFactory.getInstance().getInstanceHelper(this )
182:                        .updateInformations(this );
183:            }
184:
185:            /**
186:             * @return the name used to display the instance
187:             */
188:            public String getFullName() {
189:                return fullName;
190:            }
191:
192:            /**
193:             * @param string
194:             */
195:            public void setFullName(String string) {
196:                fullName = string;
197:                infos.setFullName(fullName);
198:            }
199:
200:            /**
201:             * @return the instance name
202:             */
203:            public String getName() {
204:                return name;
205:            }
206:
207:            /**
208:             * @param string
209:             */
210:            public void setName(String string) {
211:                name = string;
212:                infos.setName(name);
213:            }
214:
215:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.