| Method from org.jboss.invocation.jrmp.server.JRMPInvoker Detail: |
public void create() throws Exception {
support.create();
}
|
protected Invoker createDelegateInvoker() {
return new JRMPInvokerProxy(this);
}
|
public void destroy() {
support.destroy();
}
|
protected void destroyService() throws Exception {
// Export references to the bean
Registry.unbind(support.getServiceName());
}
|
protected void exportCI() throws Exception {
this.invokerStub = (RemoteStub) UnicastRemoteObject.exportObject
(this, rmiPort, clientSocketFactory, serverSocketFactory);
}
|
public int getBacklog() {
return backlog;
}
|
public boolean getEnableClassCaching() {
return enableClassCaching;
}
|
public String getName() {
return support.getName();
}
|
public String getRMIClientSocketFactory() {
return clientSocketFactoryName;
}
|
public RMIClientSocketFactory getRMIClientSocketFactoryBean() {
return clientSocketFactory;
}
|
public int getRMIObjectPort() {
return rmiPort;
}
|
public String getRMIServerSocketFactory() {
return serverSocketFactoryName;
}
|
public RMIServerSocketFactory getRMIServerSocketFactoryBean() {
return serverSocketFactory;
}
|
public String getSecurityDomain() {
return sslDomain;
}
|
public MBeanServer getServer() {
return support.getServer();
}
|
public String getServerAddress() {
return serverAddress;
}
|
public String getServerHostName() {
try
{
return InetAddress.getLocalHost().getHostName();
}
catch (Exception ignored)
{
return null;
}
}
|
public int getState() {
return support.getState();
}
|
public String getStateString() {
return support.getStateString();
}
|
public Serializable getStub() {
return this.invokerStub;
}
|
protected Transaction importTPC(Object tpc) {
if (tpc != null)
return TransactionPropagationContextUtil.importTPC(tpc);
return null;
}
Import a transaction propagation context into the local VM, and
return the corresponding Transaction. |
public Object invoke(Invocation invocation) throws Exception {
ClassLoader oldCl = TCLAction.UTIL.getContextClassLoader();
ObjectName mbean = null;
try
{
// Deserialize the transaction if it is there
MarshalledInvocation mi = (MarshalledInvocation) invocation;
invocation.setTransaction(importTPC(mi.getTransactionPropagationContext()));
mbean = (ObjectName) Registry.lookup(invocation.getObjectName());
// The cl on the thread should be set in another interceptor
Object obj = serverAction.invoke(mbean,
"invoke",
new Object[]{invocation},
Invocation.INVOKE_SIGNATURE);
return new MarshalledObject(obj);
}
catch (Exception e)
{
Throwable th = JMXExceptionDecoder.decode(e);
if (log.isTraceEnabled())
log.trace("Failed to invoke on mbean: " + mbean, th);
if (th instanceof Exception)
e = (Exception) th;
throw e;
}
finally
{
TCLAction.UTIL.setContextClassLoader(oldCl);
Thread.interrupted(); // clear interruption because this thread may be pooled.
}
}
Invoke a Remote interface method. |
public void jbossInternalLifecycle(String method) throws Exception {
support.jbossInternalLifecycle(method);
}
|
protected void loadCustomSocketFactories() {
ClassLoader loader = TCLAction.UTIL.getContextClassLoader();
if( clientSocketFactory == null )
{
try
{
if (clientSocketFactoryName != null)
{
Class csfClass = loader.loadClass(clientSocketFactoryName);
clientSocketFactory = (RMIClientSocketFactory) csfClass.newInstance();
}
}
catch (Exception e)
{
log.error("Failed to load client socket factory", e);
clientSocketFactory = null;
}
}
if( serverSocketFactory == null )
{
try
{
if (serverSocketFactoryName != null)
{
Class ssfClass = loader.loadClass(serverSocketFactoryName);
serverSocketFactory = (RMIServerSocketFactory) ssfClass.newInstance();
if (serverAddress != null)
{
// See if the server socket supports setBindAddress(String)
try
{
Class[] parameterTypes = {String.class};
Method m = ssfClass.getMethod("setBindAddress", parameterTypes);
Object[] args = {serverAddress};
m.invoke(serverSocketFactory, args);
}
catch (NoSuchMethodException e)
{
log.warn("Socket factory does not support setBindAddress(String)");
// Go with default address
}
catch (Exception e)
{
log.warn("Failed to setBindAddress=" + serverAddress + " on socket factory", e);
// Go with default address
}
}
/* See if the server socket supports setSecurityDomain(SecurityDomain)
if an sslDomain was specified
*/
if (sslDomain != null)
{
try
{
InitialContext ctx = new InitialContext();
SecurityDomain domain = (SecurityDomain) ctx.lookup(sslDomain);
Class[] parameterTypes = {SecurityDomain.class};
Method m = ssfClass.getMethod("setSecurityDomain", parameterTypes);
Object[] args = {domain};
m.invoke(serverSocketFactory, args);
}
catch (NoSuchMethodException e)
{
log.error("Socket factory does not support setSecurityDomain(SecurityDomain)");
}
catch (Exception e)
{
log.error("Failed to setSecurityDomain=" + sslDomain + " on socket factory", e);
}
}
}
// If a bind address was specified create a DefaultSocketFactory
else if (serverAddress != null)
{
DefaultSocketFactory defaultFactory = new DefaultSocketFactory(backlog);
serverSocketFactory = defaultFactory;
try
{
defaultFactory.setBindAddress(serverAddress);
}
catch (UnknownHostException e)
{
log.error("Failed to setBindAddress=" + serverAddress + " on socket factory", e);
}
}
}
catch (Exception e)
{
log.error("operation failed", e);
serverSocketFactory = null;
}
}
}
Load and instantiate the clientSocketFactory, serverSocketFactory using
the TCL and set the bind address and SSL domain if the serverSocketFactory
supports it. |
public void postDeregister() {
support.postDeregister();
}
|
public void postRegister(Boolean registrationDone) {
support.postRegister(registrationDone);
}
|
public void preDeregister() throws Exception {
support.preDeregister();
}
|
public ObjectName preRegister(MBeanServer server,
ObjectName name) throws Exception {
return support.preRegister(server, name);
}
|
protected void rebind(Context ctx,
String name,
Object val) throws NamingException {
// Bind val to name in ctx, and make sure that all
// intermediate contexts exist
Name n = ctx.getNameParser("").parse(name);
while (n.size() > 1)
{
String ctxName = n.get(0);
try
{
ctx = (Context) ctx.lookup(ctxName);
}
catch (NameNotFoundException e)
{
ctx = ctx.createSubcontext(ctxName);
}
n = n.getSuffix(1);
}
ctx.rebind(n.get(0), val);
}
|
public void setBacklog(int back) {
backlog = back;
}
|
public void setEnableClassCaching(boolean flag) {
enableClassCaching = flag;
MarshalledValueInputStream.useClassCache(enableClassCaching);
}
|
public void setRMIClientSocketFactory(String name) {
clientSocketFactoryName = name;
}
|
public void setRMIClientSocketFactoryBean(RMIClientSocketFactory bean) {
clientSocketFactory = bean;
}
|
public void setRMIObjectPort(int rmiPort) {
this.rmiPort = rmiPort;
}
|
public void setRMIServerSocketFactory(String name) {
serverSocketFactoryName = name;
}
|
public void setRMIServerSocketFactoryBean(RMIServerSocketFactory bean) {
serverSocketFactory = bean;
}
|
public void setSecurityDomain(String domainName) {
this.sslDomain = domainName;
}
|
public void setServerAddress(String address) {
serverAddress = address;
}
|
public void start() throws Exception {
support.start();
}
|
protected void startService() throws Exception {
loadCustomSocketFactories();
log.debug("RMI Port='" +
(rmiPort == ANONYMOUS_PORT ? "Anonymous" :
Integer.toString(rmiPort)) + "'");
log.debug("Client SocketFactory='" +
(clientSocketFactory == null ? "Default" :
clientSocketFactory.toString()) + "'");
log.debug("Server SocketFactory='" +
(serverSocketFactory == null ? "Default" :
serverSocketFactory.toString()) + "'");
log.debug("Server SocketAddr='" +
(serverAddress == null ? "Default" :
serverAddress) + "'");
log.debug("SecurityDomain='" +
(sslDomain == null ? "Default" :
sslDomain) + "'");
InitialContext ctx = new InitialContext();
// Validate that there is a TransactionPropagationContextImporter
// bound in JNDI
TransactionPropagationContextUtil.getTPCImporter();
// Set the transaction manager and transaction propagation
// context factory of the GenericProxy class
Invoker delegateInvoker = createDelegateInvoker();
// Make the remote invoker proxy available for use by the proxy factory
Registry.bind(support.getServiceName(), delegateInvoker);
// Export CI
exportCI();
log.debug("Bound JRMP invoker for JMX node");
ctx.close();
}
|
public void stop() {
support.stop();
}
|
protected void stopService() throws Exception {
InitialContext ctx = new InitialContext();
try
{
unexportCI();
}
finally
{
ctx.close();
}
this.clientSocketFactory = null;
this.serverSocketFactory = null;
this.invokerStub = null;
}
|
protected void unexportCI() throws Exception {
UnicastRemoteObject.unexportObject(this, true);
}
|