History

My first initial commit with all of mine experimental changes.

Dmitry Kabak (userdima committed 13 years ago

Commit d37b88d1 parent 3f5b46618352 files · +2598093 −-8690Browse files

Showing the changes to java/pkg/com/sun/jmx/snmp/daemon/ClientHandler.java (1 of 18352 files). Show all

Unified · Split

java/pkg/com/sun/jmx/snmp/daemon/ClientHandler.java+133−0
@@ -0,0 +1,133 @@
1/*
2 * Copyright (c) 1999, 2006, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26
27package com.sun.jmx.snmp.daemon;
28
29
30
31// java import
32//
33import java.io.*;
34import java.util.logging.Level;
35
36// jmx import
37//
38import javax.management.MBeanServer;
39import javax.management.ObjectName;
40
41// jmx RI import
42//
43import static com.sun.jmx.defaults.JmxProperties.SNMP_ADAPTOR_LOGGER;
44
45/**
46 * The <CODE>ClientHandler</CODE> class is the base class of each
47 * adaptor.<p>
48 */
49
50abstract class ClientHandler implements Runnable {
51
52 public ClientHandler(CommunicatorServer server, int id, MBeanServer f, ObjectName n) {
53 adaptorServer = server ;
54 requestId = id ;
55 mbs = f ;
56 objectName = n ;
57 interruptCalled = false ;
58 dbgTag = makeDebugTag() ;
59 //if (mbs == null ){
60 //thread = new Thread (this) ;
61 thread = createThread(this);
62
63 //} else {
64 //thread = mbs.getThreadAllocatorSrvIf().obtainThread(objectName,this) ;
65 //}
66 // Note: the thread will be started by the subclass.
67 }
68
69 // thread service
70 Thread createThread(Runnable r) {
71 return new Thread(this);
72 }
73
74 public void interrupt() {
75 SNMP_ADAPTOR_LOGGER.entering(dbgTag, "interrupt");
76 interruptCalled = true ;
77 if (thread != null) {
78 thread.interrupt() ;
79 }
80 SNMP_ADAPTOR_LOGGER.exiting(dbgTag, "interrupt");
81 }
82
83
84 public void join() {
85 if (thread != null) {
86 try {
87 thread.join() ;
88 }
89 catch(InterruptedException x) {
90 }
91 }
92 }
93
94 public void run() {
95
96 try {
97 //
98 // Notify the server we are now active
99 //
100 adaptorServer.notifyClientHandlerCreated(this) ;
101
102 //
103 // Call protocol specific sequence
104 //
105 doRun() ;
106 }
107 finally {
108 //
109 // Now notify the adaptor server that the handler is terminating.
110 // This is important because the server may be blocked waiting for
111 // a handler to terminate.
112 //
113 adaptorServer.notifyClientHandlerDeleted(this) ;
114 }
115 }
116
117 //
118 // The protocol-dependent part of the request
119 //
120 public abstract void doRun() ;
121
122 protected CommunicatorServer adaptorServer = null ;
123 protected int requestId = -1 ;
124 protected MBeanServer mbs = null ;
125 protected ObjectName objectName = null ;
126 protected Thread thread = null ;
127 protected boolean interruptCalled = false ;
128 protected String dbgTag = null ;
129
130 protected String makeDebugTag() {
131 return "ClientHandler[" + adaptorServer.getProtocol() + ":" + adaptorServer.getPort() + "][" + requestId + "]";
132 }
133}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t