After the Java RMI stub is deserialized, the dynamic proxy

Source: Internet
Author: User
Tags stub

Source file:

/**

*
* user:xingxiaobing
* DATE:2015-02-13
* Implementation of the remote interface
*/
public class Helloimpl extends UnicastRemoteObjectimplements Ihello{
/**
* Because the UnicastRemoteObject constructor throws a RemoteException exception, the default constructor here must be written and must declare a RemoteException exception to be thrown
*
* @throws RemoteException
*/
Public Helloimpl () throws RemoteException {
}


/**
* Simple return to "Hello world!" "Words
*
* @return return "Hello world! "Words
* @throws java.rmi.RemoteException
*/
Public StringHelloWorld ()Throws RemoteException {
Return "Hello world!";
}


/**
* A simple business method that returns the appropriate greeting according to the name of the incoming person
*
* @param somebodyname names
* @return return the appropriate greeting
* @throws java.rmi.RemoteException
*/
public string Sayhellotosomebody (String somebodyname) throws RemoteException {
Return "Hello," + Somebodyname + "!";
}

}


Using the Rmic command in the project Bin directory



After anti-compilation


Package RMI;


Import Java.lang.reflect.Method;
Import Java.rmi.Remote;
Import java.rmi.RemoteException;
Import java.rmi.UnexpectedException;
Import Java.rmi.server.RemoteObject;
Import Java.rmi.server.RemoteRef;
Import java.rmi.server.RemoteStub;

Implement the same interface as the real object

// RemoteStubclass is a public superclass of client stubs, providing a framework that supports a large number of remote reference semantics
Public final class Helloimpl_stub extends Remotestub
implements Ihello,Remote
{
Private static final long serialversionuid = 2L;
private static Method $method _helloworld_0;
private static Method $method _sayhellotosomebody_1;


Static
{
Try
{
$method _helloworld_0 = Remote.class.getMethod ("HelloWorld", new Class[0]);
$method _sayhellotosomebody_1 = Tmp50_47.getmethod ("Sayhellotosomebody", new class[] {string.class});
}
catch (Nosuchmethodexception localnosuchmethodexception)
{
throw New Nosuchmethoderror ("Stub class initialization failed");
}
}


Public helloimpl_stub (Remoteref paramremoteref)
{
Super (PARAMREMOTEREF);
}


Public StringHelloWorld ()
Throws RemoteException
{
Object Localobject;
Try
{

//Helloword method for invoking real objects
Localobject =This.ref.invoke (This, $method _helloworld_0, NULL, 32013462L);
Return ((String) localobject);
}
catch (RuntimeException localruntimeexception)
{
Throw localruntimeexception;
}
catch (RemoteException localremoteexception)
{
Throw localremoteexception;
}
catch (Exception localexception)
{
throw new Unexpectedexception ("Undeclared checked exception", localexception);
}
}


public string Sayhellotosomebody (string paramstring)
Throws RemoteException
{
Try
{
Object Localobject = This.ref.invoke (this, $method _sayhellotosomebody_1, new object[] {paramstring}, -1641805534l);
Return ((String) localobject);
}
catch (RuntimeException localruntimeexception)
{
Throw localruntimeexception;
}
catch (RemoteException localremoteexception)
{
Throw localremoteexception;
}
catch (Exception localexception)
{
throw new Unexpectedexception ("Undeclared checked exception", localexception);
}
}
}

Apparently Helloimpl_stub is an agent of Helloimpl.

The process of dynamically generating helloimpl_stub is the process of dynamically creating an agent.



After the Java RMI stub is deserialized, the dynamic proxy

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.