Source Code Cross Referenced for DRDAServerStarter.java in  » Database-DBMS » db-derby-10.2 » org » apache » derby » iapi » jdbc » 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 DBMS » db derby 10.2 » org.apache.derby.iapi.jdbc 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:
003:           Derby - Class org.apache.derby.iapi.jdbc.DRDAServerStarter
004:
005:           Licensed to the Apache Software Foundation (ASF) under one or more
006:           contributor license agreements.  See the NOTICE file distributed with
007:           this work for additional information regarding copyright ownership.
008:           The ASF licenses this file to you under the Apache License, Version 2.0
009:           (the "License"); you may not use this file except in compliance with
010:           the License.  You may obtain a copy of the License at
011:
012:              http://www.apache.org/licenses/LICENSE-2.0
013:
014:           Unless required by applicable law or agreed to in writing, software
015:           distributed under the License is distributed on an "AS IS" BASIS,
016:           WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017:           See the License for the specific language governing permissions and
018:           limitations under the License.
019:
020:         */
021:
022:        package org.apache.derby.iapi.jdbc;
023:
024:        import org.apache.derby.iapi.services.sanity.SanityManager;
025:        import org.apache.derby.iapi.services.monitor.Monitor;
026:        import org.apache.derby.iapi.services.monitor.ModuleControl;
027:        import org.apache.derby.iapi.reference.MessageId;
028:        import org.apache.derby.iapi.reference.Property;
029:        import java.io.PrintWriter;
030:        import java.lang.Runnable;
031:        import java.lang.Thread;
032:        import java.lang.reflect.Constructor;
033:        import java.lang.reflect.Method;
034:        import java.lang.reflect.InvocationTargetException;
035:        import java.net.InetAddress;
036:        import java.security.AccessController;
037:        import java.security.PrivilegedActionException;
038:        import java.security.PrivilegedExceptionAction;
039:
040:        public final class DRDAServerStarter implements  ModuleControl, Runnable {
041:
042:            private Object server;
043:            private Method serverStartMethod;
044:            private Method serverShutdownMethod;
045:            private boolean loadSysIBM;
046:            private Thread serverThread;
047:            private static final String serverClassName = "org.apache.derby.impl.drda.NetworkServerControlImpl";
048:            private Class serverClass;
049:
050:            private InetAddress listenAddress = null;
051:            private int portNumber = -1;
052:            private PrintWriter consoleWriter = null;
053:
054:            /**
055:             * Try to start the DRDA server. Log an error in error log and continue if it cannot be started.
056:             */
057:            //     public static void start()
058:            //     {
059:
060:            public void setStartInfo(InetAddress listenAddress, int portNumber,
061:                    PrintWriter consoleWriter) {
062:                this .listenAddress = listenAddress;
063:                this .portNumber = portNumber;
064:
065:                // wrap the user-set consoleWriter with autoflush to true.
066:                // this will ensure that messages to console will be 
067:                // written out to the consoleWriter on a println.
068:                // DERBY-1466
069:                if (consoleWriter != null)
070:                    this .consoleWriter = new PrintWriter(consoleWriter, true);
071:                else
072:                    this .consoleWriter = consoleWriter;
073:            }
074:
075:            public void boot(boolean create, java.util.Properties properties) {
076:                if (server != null) {
077:                    if (SanityManager.DEBUG)
078:                        SanityManager
079:                                .THROWASSERT("Network server starter module booted twice.");
080:                    return;
081:                }
082:                // Load the server class indirectly so that Cloudscape does not require the network code
083:                try {
084:                    serverClass = Class.forName(serverClassName);
085:                } catch (ClassNotFoundException cnfe) {
086:                    Monitor.logTextMessage(
087:                            MessageId.CONN_NETWORK_SERVER_CLASS_FIND,
088:                            serverClassName);
089:                    return;
090:                } catch (java.lang.Error e) {
091:                    Monitor.logTextMessage(
092:                            MessageId.CONN_NETWORK_SERVER_CLASS_LOAD,
093:                            serverClassName, e.getMessage());
094:                    return;
095:                }
096:                try {
097:                    Constructor serverConstructor;
098:                    try {
099:                        serverConstructor = (Constructor) AccessController
100:                                .doPrivileged(new PrivilegedExceptionAction() {
101:                                    public Object run()
102:                                            throws NoSuchMethodException,
103:                                            SecurityException {
104:                                        if (listenAddress == null)
105:                                            return serverClass
106:                                                    .getConstructor(null);
107:                                        else
108:                                            return serverClass
109:                                                    .getConstructor(new Class[] {
110:                                                            java.net.InetAddress.class,
111:                                                            Integer.TYPE });
112:                                    }
113:                                });
114:                        serverStartMethod = (Method) AccessController
115:                                .doPrivileged(new PrivilegedExceptionAction() {
116:                                    public Object run()
117:                                            throws NoSuchMethodException,
118:                                            SecurityException {
119:                                        return serverClass
120:                                                .getMethod(
121:                                                        "blockingStart",
122:                                                        new Class[] { java.io.PrintWriter.class });
123:                                    }
124:                                });
125:
126:                        serverShutdownMethod = (Method) AccessController
127:                                .doPrivileged(new PrivilegedExceptionAction() {
128:                                    public Object run()
129:                                            throws NoSuchMethodException,
130:                                            SecurityException {
131:                                        return serverClass.getMethod(
132:                                                "directShutdown", null);
133:                                    }
134:                                });
135:                    } catch (PrivilegedActionException e) {
136:                        Exception e1 = e.getException();
137:                        Monitor.logTextMessage(
138:                                MessageId.CONN_NETWORK_SERVER_START_EXCEPTION,
139:                                e1.getMessage());
140:                        e.printStackTrace(Monitor.getStream().getPrintWriter());
141:                        return;
142:
143:                    }
144:                    if (listenAddress == null)
145:                        server = serverConstructor.newInstance(null);
146:                    else
147:                        server = serverConstructor.newInstance(new Object[] {
148:                                listenAddress, new Integer(portNumber) });
149:
150:                    serverThread = Monitor.getMonitor().getDaemonThread(this ,
151:                            "NetworkServerStarter", false);
152:                    serverThread.start();
153:                } catch (Exception e) {
154:                    Monitor.logTextMessage(
155:                            MessageId.CONN_NETWORK_SERVER_START_EXCEPTION, e
156:                                    .getMessage());
157:                    server = null;
158:                    e.printStackTrace(Monitor.getStream().getPrintWriter());
159:                }
160:            } // end of boot
161:
162:            public void run() {
163:                try {
164:                    serverStartMethod.invoke(server,
165:                            new Object[] { consoleWriter });
166:                } catch (InvocationTargetException ite) {
167:                    Monitor.logTextMessage(
168:                            MessageId.CONN_NETWORK_SERVER_START_EXCEPTION, ite
169:                                    .getTargetException().getMessage());
170:                    ite.printStackTrace(Monitor.getStream().getPrintWriter());
171:
172:                    server = null;
173:                } catch (Exception e) {
174:                    Monitor.logTextMessage(
175:                            MessageId.CONN_NETWORK_SERVER_START_EXCEPTION, e
176:                                    .getMessage());
177:                    server = null;
178:                    e.printStackTrace(Monitor.getStream().getPrintWriter());
179:                }
180:            }
181:
182:            public void stop() {
183:                try {
184:                    if (serverThread != null && serverThread.isAlive()) {
185:                        serverShutdownMethod.invoke(server, null);
186:                        serverThread.interrupt();
187:                        serverThread = null;
188:                    }
189:
190:                } catch (InvocationTargetException ite) {
191:                    Monitor.logTextMessage(
192:                            MessageId.CONN_NETWORK_SERVER_SHUTDOWN_EXCEPTION,
193:                            ite.getTargetException().getMessage());
194:                    ite.printStackTrace(Monitor.getStream().getPrintWriter());
195:
196:                } catch (Exception e) {
197:                    Monitor.logTextMessage(
198:                            MessageId.CONN_NETWORK_SERVER_SHUTDOWN_EXCEPTION, e
199:                                    .getMessage());
200:                    e.printStackTrace(Monitor.getStream().getPrintWriter());
201:                }
202:
203:                serverThread = null;
204:                server = null;
205:                serverClass = null;
206:                serverStartMethod = null;
207:                serverShutdownMethod = null;
208:                listenAddress = null;
209:                portNumber = -1;
210:                consoleWriter = null;
211:
212:            } // end of stop
213:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.