Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell11
提交
60175fc8
D
dragonwell11
项目概览
openanolis
/
dragonwell11
通知
7
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell11
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
60175fc8
编写于
10月 27, 2009
作者:
A
alanb
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6888179: Separate out dependency on CORBA
Reviewed-by: dfuchs
上级
a8588bfa
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
589 addition
and
100 deletion
+589
-100
jdk/src/share/classes/com/sun/jmx/remote/internal/IIOPHelper.java
...share/classes/com/sun/jmx/remote/internal/IIOPHelper.java
+188
-0
jdk/src/share/classes/com/sun/jmx/remote/internal/IIOPProxy.java
.../share/classes/com/sun/jmx/remote/internal/IIOPProxy.java
+110
-0
jdk/src/share/classes/com/sun/jmx/remote/protocol/iiop/IIOPProxyImpl.java
...asses/com/sun/jmx/remote/protocol/iiop/IIOPProxyImpl.java
+119
-0
jdk/src/share/classes/com/sun/jmx/remote/protocol/iiop/ProxyInputStream.java
...es/com/sun/jmx/remote/protocol/iiop/ProxyInputStream.java
+1
-1
jdk/src/share/classes/javax/management/remote/rmi/NoCallStackClassLoader.java
...s/javax/management/remote/rmi/NoCallStackClassLoader.java
+68
-0
jdk/src/share/classes/javax/management/remote/rmi/RMIConnector.java
...are/classes/javax/management/remote/rmi/RMIConnector.java
+90
-87
jdk/src/share/classes/javax/management/remote/rmi/RMIConnectorServer.java
...asses/javax/management/remote/rmi/RMIConnectorServer.java
+6
-6
jdk/src/share/classes/javax/management/remote/rmi/RMIIIOPServerImpl.java
...lasses/javax/management/remote/rmi/RMIIIOPServerImpl.java
+7
-6
未找到文件。
jdk/src/share/classes/com/sun/jmx/remote/internal/IIOPHelper.java
0 → 100644
浏览文件 @
60175fc8
/*
* Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
package
com.sun.jmx.remote.internal
;
import
java.util.Properties
;
import
java.rmi.Remote
;
import
java.rmi.RemoteException
;
import
java.rmi.NoSuchObjectException
;
import
java.util.Properties
;
import
java.rmi.Remote
;
import
java.rmi.RemoteException
;
import
java.rmi.NoSuchObjectException
;
import
java.security.AccessController
;
import
java.security.PrivilegedAction
;
/**
* A helper class for RMI-IIOP and CORBA APIs.
*/
public
final
class
IIOPHelper
{
private
IIOPHelper
()
{
}
// loads IIOPProxy implementation class if available
private
static
final
String
IMPL_CLASS
=
"com.sun.jmx.remote.protocol.iiop.IIOPProxyImpl"
;
private
static
final
IIOPProxy
proxy
=
AccessController
.
doPrivileged
(
new
PrivilegedAction
<
IIOPProxy
>()
{
public
IIOPProxy
run
()
{
try
{
Class
<?>
c
=
Class
.
forName
(
IMPL_CLASS
,
true
,
null
);
return
(
IIOPProxy
)
c
.
newInstance
();
}
catch
(
ClassNotFoundException
cnf
)
{
return
null
;
}
catch
(
InstantiationException
e
)
{
throw
new
AssertionError
(
e
);
}
catch
(
IllegalAccessException
e
)
{
throw
new
AssertionError
(
e
);
}
}});
/**
* Returns true if RMI-IIOP and CORBA is available.
*/
public
static
boolean
isAvailable
()
{
return
proxy
!=
null
;
}
private
static
void
ensureAvailable
()
{
if
(
proxy
==
null
)
throw
new
AssertionError
(
"Should not here"
);
}
/**
* Returns true if the given object is a Stub.
*/
public
static
boolean
isStub
(
Object
obj
)
{
return
(
proxy
==
null
)
?
false
:
proxy
.
isStub
(
obj
);
}
/**
* Returns the Delegate to which the given Stub delegates.
*/
public
static
Object
getDelegate
(
Object
stub
)
{
ensureAvailable
();
return
proxy
.
getDelegate
(
stub
);
}
/**
* Sets the Delegate for a given Stub.
*/
public
static
void
setDelegate
(
Object
stub
,
Object
delegate
)
{
ensureAvailable
();
proxy
.
setDelegate
(
stub
,
delegate
);
}
/**
* Returns the ORB associated with the given stub
*
* @throws UnsupportedOperationException
* if the object does not support the operation that
* was invoked
*/
public
static
Object
getOrb
(
Object
stub
)
{
ensureAvailable
();
return
proxy
.
getOrb
(
stub
);
}
/**
* Connects the Stub to the given ORB.
*/
public
static
void
connect
(
Object
stub
,
Object
orb
)
throws
RemoteException
{
ensureAvailable
();
proxy
.
connect
(
stub
,
orb
);
}
/**
* Returns true if the given object is an ORB.
*/
public
static
boolean
isOrb
(
Object
obj
)
{
ensureAvailable
();
return
proxy
.
isOrb
(
obj
);
}
/**
* Creates, and returns, a new ORB instance.
*/
public
static
Object
createOrb
(
String
[]
args
,
Properties
props
)
{
ensureAvailable
();
return
proxy
.
createOrb
(
args
,
props
);
}
/**
* Converts a string, produced by the object_to_string method, back
* to a CORBA object reference.
*/
public
static
Object
stringToObject
(
Object
orb
,
String
str
)
{
ensureAvailable
();
return
proxy
.
stringToObject
(
orb
,
str
);
}
/**
* Converts the given CORBA object reference to a string.
*/
public
static
String
objectToString
(
Object
orb
,
Object
obj
)
{
ensureAvailable
();
return
proxy
.
objectToString
(
orb
,
obj
);
}
/**
* Checks to ensure that an object of a remote or abstract interface
* type can be cast to a desired type.
*/
public
static
<
T
>
T
narrow
(
Object
narrowFrom
,
Class
<
T
>
narrowTo
)
{
ensureAvailable
();
return
proxy
.
narrow
(
narrowFrom
,
narrowTo
);
}
/**
* Makes a server object ready to receive remote calls
*/
public
static
void
exportObject
(
Remote
obj
)
throws
RemoteException
{
ensureAvailable
();
proxy
.
exportObject
(
obj
);
}
/**
* Deregisters a server object from the runtime.
*/
public
static
void
unexportObject
(
Remote
obj
)
throws
NoSuchObjectException
{
ensureAvailable
();
proxy
.
unexportObject
(
obj
);
}
/**
* Returns a stub for the given server object.
*/
public
static
Remote
toStub
(
Remote
obj
)
throws
NoSuchObjectException
{
ensureAvailable
();
return
proxy
.
toStub
(
obj
);
}
}
jdk/src/share/classes/com/sun/jmx/remote/internal/IIOPProxy.java
0 → 100644
浏览文件 @
60175fc8
/*
* Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
package
com.sun.jmx.remote.internal
;
import
java.util.Properties
;
import
java.rmi.Remote
;
import
java.rmi.RemoteException
;
import
java.rmi.NoSuchObjectException
;
/**
* An interface to a subset of the RMI-IIOP and CORBA APIs to avoid a
* static dependencies on the types defined by these APIs.
*/
public
interface
IIOPProxy
{
/**
* Returns true if the given object is a Stub.
*/
boolean
isStub
(
Object
obj
);
/**
* Returns the Delegate to which the given Stub delegates.
*/
Object
getDelegate
(
Object
stub
);
/**
* Sets the Delegate for a given Stub.
*/
void
setDelegate
(
Object
stub
,
Object
delegate
);
/**
* Returns the ORB associated with the given stub
*
* @throws UnsupportedOperationException
* if the object does not support the operation that
* was invoked
*/
Object
getOrb
(
Object
stub
);
/**
* Connects the Stub to the given ORB.
*/
void
connect
(
Object
stub
,
Object
orb
)
throws
RemoteException
;
/**
* Returns true if the given object is an ORB.
*/
boolean
isOrb
(
Object
obj
);
/**
* Creates, and returns, a new ORB instance.
*/
Object
createOrb
(
String
[]
args
,
Properties
props
);
/**
* Converts a string, produced by the object_to_string method, back
* to a CORBA object reference.
*/
Object
stringToObject
(
Object
orb
,
String
str
);
/**
* Converts the given CORBA object reference to a string.
*/
String
objectToString
(
Object
orb
,
Object
obj
);
/**
* Checks to ensure that an object of a remote or abstract interface
* type can be cast to a desired type.
*/
<
T
>
T
narrow
(
Object
narrowFrom
,
Class
<
T
>
narrowTo
);
/**
* Makes a server object ready to receive remote calls
*/
void
exportObject
(
Remote
obj
)
throws
RemoteException
;
/**
* Deregisters a server object from the runtime.
*/
void
unexportObject
(
Remote
obj
)
throws
NoSuchObjectException
;
/**
* Returns a stub for the given server object.
*/
Remote
toStub
(
Remote
obj
)
throws
NoSuchObjectException
;
}
jdk/src/share/classes/com/sun/jmx/remote/protocol/iiop/IIOPProxyImpl.java
0 → 100644
浏览文件 @
60175fc8
/*
* Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
package
com.sun.jmx.remote.protocol.iiop
;
import
org.omg.CORBA.ORB
;
import
org.omg.CORBA.portable.Delegate
;
import
javax.rmi.PortableRemoteObject
;
import
javax.rmi.CORBA.Stub
;
import
java.util.Properties
;
import
java.rmi.Remote
;
import
java.rmi.RemoteException
;
import
java.rmi.NoSuchObjectException
;
import
com.sun.jmx.remote.internal.IIOPProxy
;
/**
* An implementatin of IIOPProxy that simply delegates to the appropriate
* RMI-IIOP and CORBA APIs.
*/
public
class
IIOPProxyImpl
implements
IIOPProxy
{
public
IIOPProxyImpl
()
{
}
@Override
public
boolean
isStub
(
Object
obj
)
{
return
(
obj
instanceof
Stub
);
}
@Override
public
Object
getDelegate
(
Object
stub
)
{
return
((
Stub
)
stub
).
_get_delegate
();
}
@Override
public
void
setDelegate
(
Object
stub
,
Object
delegate
)
{
((
Stub
)
stub
).
_set_delegate
((
Delegate
)
delegate
);
}
@Override
public
Object
getOrb
(
Object
stub
)
{
try
{
return
((
Stub
)
stub
).
_orb
();
}
catch
(
org
.
omg
.
CORBA
.
BAD_OPERATION
x
)
{
throw
new
UnsupportedOperationException
(
x
);
}
}
@Override
public
void
connect
(
Object
stub
,
Object
orb
)
throws
RemoteException
{
((
Stub
)
stub
).
connect
((
ORB
)
orb
);
}
@Override
public
boolean
isOrb
(
Object
obj
)
{
return
(
obj
instanceof
ORB
);
}
@Override
public
Object
createOrb
(
String
[]
args
,
Properties
props
)
{
return
ORB
.
init
(
args
,
props
);
}
@Override
public
Object
stringToObject
(
Object
orb
,
String
str
)
{
return
((
ORB
)
orb
).
string_to_object
(
str
);
}
@Override
public
String
objectToString
(
Object
orb
,
Object
obj
)
{
return
((
ORB
)
orb
).
object_to_string
((
org
.
omg
.
CORBA
.
Object
)
obj
);
}
@Override
@SuppressWarnings
(
"unchecked"
)
public
<
T
>
T
narrow
(
Object
narrowFrom
,
Class
<
T
>
narrowTo
)
{
return
(
T
)
PortableRemoteObject
.
narrow
(
narrowFrom
,
narrowTo
);
}
@Override
public
void
exportObject
(
Remote
obj
)
throws
RemoteException
{
PortableRemoteObject
.
exportObject
(
obj
);
}
@Override
public
void
unexportObject
(
Remote
obj
)
throws
NoSuchObjectException
{
PortableRemoteObject
.
unexportObject
(
obj
);
}
@Override
public
Remote
toStub
(
Remote
obj
)
throws
NoSuchObjectException
{
return
PortableRemoteObject
.
toStub
(
obj
);
}
}
jdk/src/share/classes/com/sun/jmx/remote/
internal
/ProxyInputStream.java
→
jdk/src/share/classes/com/sun/jmx/remote/
protocol/iiop
/ProxyInputStream.java
浏览文件 @
60175fc8
...
...
@@ -23,7 +23,7 @@
* have any questions.
*/
package
com.sun.jmx.remote.
internal
;
package
com.sun.jmx.remote.
protocol.iiop
;
import
java.io.IOException
;
import
java.io.Serializable
;
...
...
jdk/src/share/classes/javax/management/remote/rmi/NoCallStackClassLoader.java
浏览文件 @
60175fc8
...
...
@@ -225,4 +225,72 @@ insert-buffer'd into a Java program."
(insert "\"")
(switch-to-buffer buf)))
Alternatively, the following class reads a class file and outputs a string
that can be used by the stringToBytes method above.
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
public class BytesToString {
public static void main(String[] args) throws IOException {
File f = new File(args[0]);
int len = (int)f.length();
byte[] classBytes = new byte[len];
FileInputStream in = new FileInputStream(args[0]);
try {
int pos = 0;
for (;;) {
int n = in.read(classBytes, pos, (len-pos));
if (n < 0)
throw new RuntimeException("class file changed??");
pos += n;
if (pos >= n)
break;
}
} finally {
in.close();
}
int pos = 0;
boolean lastWasOctal = false;
for (int i=0; i<len; i++) {
int value = classBytes[i];
if (value < 0)
value += 256;
String s = null;
if (value == '\\')
s = "\\\\";
else if (value == '\"')
s = "\\\"";
else {
if ((value >= 32 && value < 127) && ((!lastWasOctal ||
(value < '0' || value > '7')))) {
s = Character.toString((char)value);
}
}
if (s == null) {
s = "\\" + Integer.toString(value, 8);
lastWasOctal = true;
} else {
lastWasOctal = false;
}
if (pos > 61) {
System.out.print("\"");
if (i<len)
System.out.print("+");
System.out.println();
pos = 0;
}
if (pos == 0)
System.out.print(" \"");
System.out.print(s);
pos += s.length();
}
System.out.println("\"");
}
}
*/
jdk/src/share/classes/javax/management/remote/rmi/RMIConnector.java
浏览文件 @
60175fc8
...
...
@@ -29,8 +29,8 @@ import com.sun.jmx.mbeanserver.Util;
import
com.sun.jmx.remote.internal.ClientCommunicatorAdmin
;
import
com.sun.jmx.remote.internal.ClientListenerInfo
;
import
com.sun.jmx.remote.internal.ClientNotifForwarder
;
import
com.sun.jmx.remote.internal.ProxyInputStream
;
import
com.sun.jmx.remote.internal.ProxyRef
;
import
com.sun.jmx.remote.internal.IIOPHelper
;
import
com.sun.jmx.remote.util.ClassLogger
;
import
com.sun.jmx.remote.util.EnvHelp
;
import
java.io.ByteArrayInputStream
;
...
...
@@ -101,12 +101,8 @@ import javax.management.remote.NotificationResult;
import
javax.management.remote.JMXAddressable
;
import
javax.naming.InitialContext
;
import
javax.naming.NamingException
;
import
javax.rmi.CORBA.Stub
;
import
javax.rmi.PortableRemoteObject
;
import
javax.rmi.ssl.SslRMIClientSocketFactory
;
import
javax.security.auth.Subject
;
import
org.omg.CORBA.BAD_OPERATION
;
import
org.omg.CORBA.ORB
;
import
sun.rmi.server.UnicastRef2
;
import
sun.rmi.transport.LiveRef
;
...
...
@@ -1693,12 +1689,12 @@ public class RMIConnector implements JMXConnector, Serializable, JMXAddressable
static
RMIServer
connectStub
(
RMIServer
rmiServer
,
Map
<
String
,
?>
environment
)
throws
IOException
{
if
(
rmiServer
instanceof
javax
.
rmi
.
CORBA
.
Stub
)
{
javax
.
rmi
.
CORBA
.
Stub
stub
=
(
javax
.
rmi
.
CORBA
.
Stub
)
rmiServer
;
if
(
IIOPHelper
.
isStub
(
rmiServer
))
{
try
{
stub
.
_orb
();
}
catch
(
BAD_OPERATION
x
)
{
stub
.
connect
(
resolveOrb
(
environment
));
IIOPHelper
.
getOrb
(
rmiServer
);
}
catch
(
UnsupportedOperationException
x
)
{
// BAD_OPERATION
IIOPHelper
.
connect
(
rmiServer
,
resolveOrb
(
environment
));
}
}
return
rmiServer
;
...
...
@@ -1725,22 +1721,22 @@ public class RMIConnector implements JMXConnector, Serializable, JMXAddressable
* does not point to an {@link org.omg.CORBA.ORB ORB}.
* @exception IOException if the ORB initialization failed.
**/
static
O
RB
resolveOrb
(
Map
<
String
,
?>
environment
)
static
O
bject
resolveOrb
(
Map
<
String
,
?>
environment
)
throws
IOException
{
if
(
environment
!=
null
)
{
final
Object
orb
=
environment
.
get
(
EnvHelp
.
DEFAULT_ORB
);
if
(
orb
!=
null
&&
!(
orb
instanceof
ORB
))
if
(
orb
!=
null
&&
!(
IIOPHelper
.
isOrb
(
orb
)
))
throw
new
IllegalArgumentException
(
EnvHelp
.
DEFAULT_ORB
+
" must be an instance of org.omg.CORBA.ORB."
);
if
(
orb
!=
null
)
return
(
ORB
)
orb
;
if
(
orb
!=
null
)
return
orb
;
}
final
O
RB
orb
=
final
O
bject
orb
=
(
RMIConnector
.
orb
==
null
)?
null
:
RMIConnector
.
orb
.
get
();
if
(
orb
!=
null
)
return
orb
;
final
O
RB
newOrb
=
ORB
.
init
((
String
[])
null
,
(
Properties
)
null
);
RMIConnector
.
orb
=
new
WeakReference
<
O
RB
>(
newOrb
);
final
O
bject
newOrb
=
IIOPHelper
.
createOrb
((
String
[])
null
,
(
Properties
)
null
);
RMIConnector
.
orb
=
new
WeakReference
<
O
bject
>(
newOrb
);
return
newOrb
;
}
...
...
@@ -1878,9 +1874,11 @@ public class RMIConnector implements JMXConnector, Serializable, JMXAddressable
return
findRMIServerJNDI
(
path
.
substring
(
6
,
end
),
environment
,
isIiop
);
else
if
(
path
.
startsWith
(
"/stub/"
))
return
findRMIServerJRMP
(
path
.
substring
(
6
,
end
),
environment
,
isIiop
);
else
if
(
path
.
startsWith
(
"/ior/"
))
else
if
(
path
.
startsWith
(
"/ior/"
))
{
if
(!
IIOPHelper
.
isAvailable
())
throw
new
IOException
(
"iiop protocol not available"
);
return
findRMIServerIIOP
(
path
.
substring
(
5
,
end
),
environment
,
isIiop
);
else
{
}
else
{
final
String
msg
=
"URL path must begin with /jndi/ or /stub/ "
+
"or /ior/: "
+
path
;
throw
new
MalformedURLException
(
msg
);
...
...
@@ -1922,8 +1920,7 @@ public class RMIConnector implements JMXConnector, Serializable, JMXAddressable
private
static
RMIServer
narrowIIOPServer
(
Object
objref
)
{
try
{
return
(
RMIServer
)
PortableRemoteObject
.
narrow
(
objref
,
RMIServer
.
class
);
return
IIOPHelper
.
narrow
(
objref
,
RMIServer
.
class
);
}
catch
(
ClassCastException
e
)
{
if
(
logger
.
traceOn
())
logger
.
trace
(
"narrowIIOPServer"
,
"Failed to narrow objref="
+
...
...
@@ -1935,10 +1932,9 @@ public class RMIConnector implements JMXConnector, Serializable, JMXAddressable
private
RMIServer
findRMIServerIIOP
(
String
ior
,
Map
<
String
,
?>
env
,
boolean
isIiop
)
{
// could forbid "rmi:" URL here -- but do we need to?
final
ORB
orb
=
(
ORB
)
env
.
get
(
EnvHelp
.
DEFAULT_ORB
);
final
Object
stub
=
orb
.
string_to_object
(
ior
);
return
(
RMIServer
)
PortableRemoteObject
.
narrow
(
stub
,
RMIServer
.
class
);
final
Object
orb
=
env
.
get
(
EnvHelp
.
DEFAULT_ORB
);
final
Object
stub
=
IIOPHelper
.
stringToObject
(
orb
,
ior
);
return
IIOPHelper
.
narrow
(
stub
,
RMIServer
.
class
);
}
private
RMIServer
findRMIServerJRMP
(
String
base64
,
Map
<
String
,
?>
env
,
boolean
isIiop
)
...
...
@@ -1964,7 +1960,7 @@ public class RMIConnector implements JMXConnector, Serializable, JMXAddressable
}
catch
(
ClassNotFoundException
e
)
{
throw
new
MalformedURLException
(
"Class not found: "
+
e
);
}
return
(
RMIServer
)
PortableRemoteObject
.
narrow
(
stub
,
RMIServer
.
class
)
;
return
(
RMIServer
)
stub
;
}
private
static
final
class
ObjectInputStreamWithLoader
...
...
@@ -2205,9 +2201,9 @@ public class RMIConnector implements JMXConnector, Serializable, JMXAddressable
again, using reflection.
The strings below encode the following two Java classes,
compiled using
J2SE 1.4.2 with
javac -g:none.
compiled using javac -g:none.
package com.sun.jmx.remote.
internal
;
package com.sun.jmx.remote.
protocol.iiop
;
import org.omg.stub.javax.management.remote.rmi._RMIConnection_Stub;
...
...
@@ -2228,12 +2224,13 @@ public class RMIConnector implements JMXConnector, Serializable, JMXAddressable
}
public void _releaseReply(InputStream in) {
PInputStream pis = (PInputStream) in;
super._releaseReply(pis.getProxiedInputStream());
if (in != null)
in = ((PInputStream)in).getProxiedInputStream();
super._releaseReply(in);
}
}
package com.sun.jmx.remote.
internal
;
package com.sun.jmx.remote.
protocol.iiop
;
public class PInputStream extends ProxyInputStream {
public PInputStream(org.omg.CORBA.portable.InputStream in) {
...
...
@@ -2252,49 +2249,52 @@ public class RMIConnector implements JMXConnector, Serializable, JMXAddressable
*/
private
static
final
String
iiopConnectionStubClassName
=
"org.omg.stub.javax.management.remote.rmi._RMIConnection_Stub"
;
"org.omg.stub.javax.management.remote.rmi._RMIConnection_Stub"
;
private
static
final
String
proxyStubClassName
=
"com.sun.jmx.remote.internal.ProxyStub"
;
"com.sun.jmx.remote.protocol.iiop.ProxyStub"
;
private
static
final
String
ProxyInputStreamClassName
=
"com.sun.jmx.remote.protocol.iiop.ProxyInputStream"
;
private
static
final
String
pInputStreamClassName
=
"com.sun.jmx.remote.
internal
.PInputStream"
;
"com.sun.jmx.remote.
protocol.iiop
.PInputStream"
;
private
static
final
Class
<?>
proxyStubClass
;
static
{
final
String
proxyStubByteCodeString
=
"\312\376\272\276\0\0\0.\0)\12\0\14\0\26\7\0\27\12\0\14\0\30\12"
+
"\0\2\0\31\7\0\32\12\0\5\0\33\12\0\5\0\34\12\0\5\0\35\12\0\2\0"
+
"\36\12\0\14\0\37\7\0\40\7\0!\1\0\6<init>\1\0\3()V\1\0\4Code\1"
+
"\0\7_invoke\1\0K(Lorg/omg/CORBA/portable/OutputStream;)Lorg/o"
+
"mg/CORBA/portable/InputStream;\1\0\12Exceptions\7\0\"\1\0\15_"
+
"releaseReply\1\0'(Lorg/omg/CORBA/portable/InputStream;)V\14\0"
+
"\15\0\16\1\0(com/sun/jmx/remote/internal/PInputStream\14\0\20"
+
"\0\21\14\0\15\0\25\1\0+org/omg/CORBA/portable/ApplicationExce"
+
"ption\14\0#\0$\14\0%\0&\14\0\15\0'\14\0(\0$\14\0\24\0\25\1\0%"
+
"com/sun/jmx/remote/internal/ProxyStub\1\0<org/omg/stub/javax/"
+
"management/remote/rmi/_RMIConnection_Stub\1\0)org/omg/CORBA/p"
+
"ortable/RemarshalException\1\0\16getInputStream\1\0&()Lorg/om"
+
"g/CORBA/portable/InputStream;\1\0\5getId\1\0\24()Ljava/lang/S"
+
"tring;\1\09(Ljava/lang/String;Lorg/omg/CORBA/portable/InputSt"
+
"ream;)V\1\0\25getProxiedInputStream\0!\0\13\0\14\0\0\0\0\0\3\0"
+
"\1\0\15\0\16\0\1\0\17\0\0\0\21\0\1\0\1\0\0\0\5*\267\0\1\261\0"
+
"\0\0\0\0\1\0\20\0\21\0\2\0\17\0\0\0;\0\4\0\4\0\0\0'\273\0\2Y*"
+
"+\267\0\3\267\0\4\260M\273\0\2Y,\266\0\6\267\0\4N\273\0\5Y,\266"
+
"\0\7-\267\0\10\277\0\1\0\0\0\14\0\15\0\5\0\0\0\22\0\0\0\6\0\2"
+
"\0\5\0\23\0\1\0\24\0\25\0\1\0\17\0\0\0\36\0\2\0\2\0\0\0\22+\306"
+
"\0\13+\300\0\2\266\0\11L*+\267\0\12\261\0\0\0\0\0\0"
;
"\312\376\272\276\0\0\0\63\0+\12\0\14\0\30\7\0\31\12\0\14\0\32\12"
+
"\0\2\0\33\7\0\34\12\0\5\0\35\12\0\5\0\36\12\0\5\0\37\12\0\2\0 "
+
"\12\0\14\0!\7\0\"\7\0#\1\0\6<init>\1\0\3()V\1\0\4Code\1\0\7_in"
+
"voke\1\0K(Lorg/omg/CORBA/portable/OutputStream;)Lorg/omg/CORBA"
+
"/portable/InputStream;\1\0\15StackMapTable\7\0\34\1\0\12Except"
+
"ions\7\0$\1\0\15_releaseReply\1\0'(Lorg/omg/CORBA/portable/Inp"
+
"utStream;)V\14\0\15\0\16\1\0-com/sun/jmx/remote/protocol/iiop/"
+
"PInputStream\14\0\20\0\21\14\0\15\0\27\1\0+org/omg/CORBA/porta"
+
"ble/ApplicationException\14\0%\0&\14\0'\0(\14\0\15\0)\14\0*\0&"
+
"\14\0\26\0\27\1\0*com/sun/jmx/remote/protocol/iiop/ProxyStub\1"
+
"\0<org/omg/stub/javax/management/remote/rmi/_RMIConnection_Stu"
+
"b\1\0)org/omg/CORBA/portable/RemarshalException\1\0\16getInput"
+
"Stream\1\0&()Lorg/omg/CORBA/portable/InputStream;\1\0\5getId\1"
+
"\0\24()Ljava/lang/String;\1\09(Ljava/lang/String;Lorg/omg/CORB"
+
"A/portable/InputStream;)V\1\0\25getProxiedInputStream\0!\0\13\0"
+
"\14\0\0\0\0\0\3\0\1\0\15\0\16\0\1\0\17\0\0\0\21\0\1\0\1\0\0\0\5"
+
"*\267\0\1\261\0\0\0\0\0\1\0\20\0\21\0\2\0\17\0\0\0G\0\4\0\4\0\0"
+
"\0'\273\0\2Y*+\267\0\3\267\0\4\260M\273\0\2Y,\266\0\6\267\0\4N"
+
"\273\0\5Y,\266\0\7-\267\0\10\277\0\1\0\0\0\14\0\15\0\5\0\1\0\22"
+
"\0\0\0\6\0\1M\7\0\23\0\24\0\0\0\6\0\2\0\5\0\25\0\1\0\26\0\27\0"
+
"\1\0\17\0\0\0'\0\2\0\2\0\0\0\22+\306\0\13+\300\0\2\266\0\11L*+"
+
"\267\0\12\261\0\0\0\1\0\22\0\0\0\3\0\1\14\0\0"
;
final
String
pInputStreamByteCodeString
=
"\312\376\272\276\0\0\0
.\0\36\12\0\7\0\17\11\0\6\0\20\12\0\21\0
"
+
"\
22\12\0\6\0\23\12\0\24\0\25\7\0\26\7\0\27\1\0\6<init>\1\0'(L
"
+
"org/omg/CORBA/portable/InputStream;)V\1\0\4Code\1\0\10read_an"
+
"y\1\0\25()Lorg/omg/CORBA/Any;\1\0\12read_value\1\0)(Ljava/lan"
+
"
g/Class;)Ljava/io/Serializable;\14\0\10\0\11\14\0\30\0\31\7\0
"
+
"\
32\14\0\13\0\14\14\0\33\0\34\7\0\35\14\0\15\0\16\1\0(com/sun
"
+
"/
jmx/remote/internal/PInputStream\1\0,com/sun/jmx/remote/inte
"
+
"
rnal/ProxyInputStream\1\0\2in\1\0$Lorg/omg/CORBA/portable/Inp
"
+
"
utStream;\1\0\"org/omg/CORBA/portable/InputStream\1\0\6narrow
"
+
"
\1\0*()Lorg/omg/CORBA_2_3/portable/InputStream;\1\0&org/omg/C
"
+
"
ORBA_2_3/portable/InputStream\0!\0\6\0\7\0\0\0\0\0\3\0\1\0\1
0"
+
"\
0\11\0\1\0\12\0\0\0\22\0\2\0\2\0\0\0\6*+\267\0\1\261\0
\0\0\0"
+
"\0\1\0\13\0\14\0\1\0\12\0\0\0\24\0\1\0\1\0\0\0\10*\264\0\2\266"
+
"\312\376\272\276\0\0\0
\63\0\36\12\0\7\0\17\11\0\6\0\20\12\0\21
"
+
"\
0\22\12\0\6\0\23\12\0\24\0\25\7\0\26\7\0\27\1\0\6<init>\1\0'(
"
+
"
L
org/omg/CORBA/portable/InputStream;)V\1\0\4Code\1\0\10read_an"
+
"y\1\0\25()Lorg/omg/CORBA/Any;\1\0\12read_value\1\0)(Ljava/lan
g
"
+
"
/Class;)Ljava/io/Serializable;\14\0\10\0\11\14\0\30\0\31\7\0\32
"
+
"\
14\0\13\0\14\14\0\33\0\34\7\0\35\14\0\15\0\16\1\0-com/sun/jmx
"
+
"/
remote/protocol/iiop/PInputStream\1\0\61com/sun/jmx/remote/pr
"
+
"
otocol/iiop/ProxyInputStream\1\0\2in\1\0$Lorg/omg/CORBA/portab
"
+
"
le/InputStream;\1\0\"org/omg/CORBA/portable/InputStream\1\0\6n
"
+
"
arrow\1\0*()Lorg/omg/CORBA_2_3/portable/InputStream;\1\0&org/o
"
+
"
mg/CORBA_2_3/portable/InputStream\0!\0\6\0\7\0\0\0\0\0\3\0\1\
0"
+
"\
10\0\11\0\1\0\12\0\0\0\22\0\2\0\2\0\0\0\6*+\267\0\1\261
\0\0\0"
+
"\0\
0\
1\0\13\0\14\0\1\0\12\0\0\0\24\0\1\0\1\0\0\0\10*\264\0\2\266"
+
"\0\3\260\0\0\0\0\0\1\0\15\0\16\0\1\0\12\0\0\0\25\0\2\0\2\0\0\0"
+
"\11*\266\0\4+\266\0\5\260\0\0\0\0\0\0"
;
final
byte
[]
proxyStubByteCode
=
...
...
@@ -2305,12 +2305,12 @@ public class RMIConnector implements JMXConnector, Serializable, JMXAddressable
final
byte
[][]
byteCodes
=
{
proxyStubByteCode
,
pInputStreamByteCode
};
final
String
[]
otherClassNames
=
{
iiopConnectionStubClassName
,
ProxyInputStream
.
class
.
getName
()
,
ProxyInputStream
ClassName
,
};
PrivilegedExceptionAction
<
Class
<?>>
action
=
if
(
IIOPHelper
.
isAvailable
())
{
PrivilegedExceptionAction
<
Class
<?>>
action
=
new
PrivilegedExceptionAction
<
Class
<?>>()
{
public
Class
<?>
run
()
throws
Exception
{
public
Class
<?>
run
()
throws
Exception
{
Class
thisClass
=
RMIConnector
.
class
;
ClassLoader
thisLoader
=
thisClass
.
getClassLoader
();
ProtectionDomain
thisProtectionDomain
=
...
...
@@ -2322,24 +2322,27 @@ public class RMIConnector implements JMXConnector, Serializable, JMXAddressable
thisLoader
,
thisProtectionDomain
);
return
cl
.
loadClass
(
proxyStubClassName
);
}
};
Class
<?>
stubClass
;
try
{
stubClass
=
AccessController
.
doPrivileged
(
action
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"<clinit>"
,
"Unexpected exception making shadow IIOP stub class: "
+
e
);
logger
.
debug
(
"<clinit>"
,
e
);
stubClass
=
null
;
}
};
Class
<?>
stubClass
;
try
{
stubClass
=
AccessController
.
doPrivileged
(
action
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"<clinit>"
,
"Unexpected exception making shadow IIOP stub class: "
+
e
);
logger
.
debug
(
"<clinit>"
,
e
);
stubClass
=
null
;
proxyStubClass
=
stubClass
;
}
else
{
proxyStubClass
=
null
;
}
proxyStubClass
=
stubClass
;
}
private
static
RMIConnection
shadowIiopStub
(
Stub
stub
)
private
static
RMIConnection
shadowIiopStub
(
Object
stub
)
throws
InstantiationException
,
IllegalAccessException
{
Stub
proxyStub
=
(
Stub
)
proxyStubClass
.
newInstance
();
proxyStub
.
_set_delegate
(
stub
.
_get_delegate
(
));
Object
proxyStub
=
proxyStubClass
.
newInstance
();
IIOPHelper
.
setDelegate
(
proxyStub
,
IIOPHelper
.
getDelegate
(
stub
));
return
(
RMIConnection
)
proxyStub
;
}
...
...
@@ -2353,7 +2356,7 @@ public class RMIConnector implements JMXConnector, Serializable, JMXAddressable
if
(
c
.
getClass
()
==
rmiConnectionImplStubClass
)
return
shadowJrmpStub
((
RemoteObject
)
c
);
if
(
c
.
getClass
().
getName
().
equals
(
iiopConnectionStubClassName
))
return
shadowIiopStub
(
(
Stub
)
c
);
return
shadowIiopStub
(
c
);
logger
.
trace
(
"getConnection"
,
"Did not wrap "
+
c
.
getClass
()
+
" to foil "
+
"stack search for classes: class loading semantics "
+
...
...
@@ -2539,7 +2542,7 @@ public class RMIConnector implements JMXConnector, Serializable, JMXAddressable
* A static WeakReference to an {@link org.omg.CORBA.ORB ORB} to
* connect unconnected stubs.
**/
private
static
volatile
WeakReference
<
O
RB
>
orb
=
null
;
private
static
volatile
WeakReference
<
O
bject
>
orb
=
null
;
// TRACES & DEBUG
//---------------
...
...
jdk/src/share/classes/javax/management/remote/rmi/RMIConnectorServer.java
浏览文件 @
60175fc8
...
...
@@ -27,6 +27,7 @@ package javax.management.remote.rmi;
import
com.sun.jmx.remote.security.MBeanServerFileAccessController
;
import
com.sun.jmx.remote.internal.IIOPHelper
;
import
com.sun.jmx.remote.util.ClassLogger
;
import
com.sun.jmx.remote.util.EnvHelp
;
...
...
@@ -674,7 +675,7 @@ public class RMIConnectorServer extends JMXConnectorServer {
final
int
port
;
if
(
address
==
null
)
{
if
(
rmiServer
instanceof
javax
.
rmi
.
CORBA
.
Stub
)
if
(
IIOPHelper
.
isStub
(
rmiServer
)
)
protocol
=
"iiop"
;
else
protocol
=
"rmi"
;
...
...
@@ -712,7 +713,7 @@ public class RMIConnectorServer extends JMXConnectorServer {
**/
static
String
encodeStub
(
RMIServer
rmiServer
,
Map
<
String
,
?>
env
)
throws
IOException
{
if
(
rmiServer
instanceof
javax
.
rmi
.
CORBA
.
Stub
)
if
(
IIOPHelper
.
isStub
(
rmiServer
)
)
return
"/ior/"
+
encodeIIOPStub
(
rmiServer
,
env
);
else
return
"/stub/"
+
encodeJRMPStub
(
rmiServer
,
env
);
...
...
@@ -733,10 +734,9 @@ public class RMIConnectorServer extends JMXConnectorServer {
RMIServer
rmiServer
,
Map
<
String
,
?>
env
)
throws
IOException
{
try
{
javax
.
rmi
.
CORBA
.
Stub
stub
=
(
javax
.
rmi
.
CORBA
.
Stub
)
rmiServer
;
return
stub
.
_orb
().
object_to_string
(
stub
);
}
catch
(
org
.
omg
.
CORBA
.
BAD_OPERATION
x
)
{
Object
orb
=
IIOPHelper
.
getOrb
(
rmiServer
);
return
IIOPHelper
.
objectToString
(
orb
,
rmiServer
);
}
catch
(
RuntimeException
x
)
{
throw
newIOException
(
x
.
getMessage
(),
x
);
}
}
...
...
jdk/src/share/classes/javax/management/remote/rmi/RMIIIOPServerImpl.java
浏览文件 @
60175fc8
...
...
@@ -33,9 +33,10 @@ import java.security.PrivilegedActionException;
import
java.security.PrivilegedExceptionAction
;
import
java.util.Map
;
import
java.util.Collections
;
import
javax.rmi.PortableRemoteObject
;
import
javax.security.auth.Subject
;
import
com.sun.jmx.remote.internal.IIOPHelper
;
/**
* <p>An {@link RMIServerImpl} that is exported through IIOP and that
* creates client connections as RMI objects exported through IIOP.
...
...
@@ -65,7 +66,7 @@ public class RMIIIOPServerImpl extends RMIServerImpl {
}
protected
void
export
()
throws
IOException
{
PortableRemoteObject
.
exportObject
(
this
);
IIOPHelper
.
exportObject
(
this
);
}
protected
String
getProtocol
()
{
...
...
@@ -83,7 +84,7 @@ public class RMIIIOPServerImpl extends RMIServerImpl {
public
Remote
toStub
()
throws
IOException
{
// javax.rmi.CORBA.Stub stub =
// (javax.rmi.CORBA.Stub) PortableRemoteObject.toStub(this);
final
Remote
stub
=
PortableRemoteObject
.
toStub
(
this
);
final
Remote
stub
=
IIOPHelper
.
toStub
(
this
);
// java.lang.System.out.println("NON CONNECTED STUB " + stub);
// org.omg.CORBA.ORB orb =
// org.omg.CORBA.ORB.init((String[])null, (Properties)null);
...
...
@@ -117,12 +118,12 @@ public class RMIIIOPServerImpl extends RMIServerImpl {
RMIConnection
client
=
new
RMIConnectionImpl
(
this
,
connectionId
,
getDefaultClassLoader
(),
subject
,
env
);
PortableRemoteObject
.
exportObject
(
client
);
IIOPHelper
.
exportObject
(
client
);
return
client
;
}
protected
void
closeClient
(
RMIConnection
client
)
throws
IOException
{
PortableRemoteObject
.
unexportObject
(
client
);
IIOPHelper
.
unexportObject
(
client
);
}
/**
...
...
@@ -134,7 +135,7 @@ public class RMIIIOPServerImpl extends RMIServerImpl {
* server failed.
*/
protected
void
closeServer
()
throws
IOException
{
PortableRemoteObject
.
unexportObject
(
this
);
IIOPHelper
.
unexportObject
(
this
);
}
@Override
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录