?? helloworldimpl.java
字號:
/*
* Copyright 1999 by dreamBean Software,
* All rights reserved.
*/
package masteringrmi.helloactivate.server;
import java.rmi.Remote;
import java.rmi.MarshalledObject;
import java.rmi.RemoteException;
import java.rmi.ServerException;
import java.rmi.activation.Activatable;
import java.rmi.activation.ActivationID;
import java.util.Properties;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import masteringrmi.helloactivate.interfaces.HelloWorld;
/**
* This is a remote activatable object that implements the remote interface.
*
* It has a special constructor that is invoked when the object is activated.
* This constructor will export the object and bind it in JNDI.
*
* @see HelloWorld
* @author Rickard 謆erg (rickard@dreambean.com)
* @version $Revision:$
*/
public class HelloWorldImpl
implements HelloWorld
{
// Constructors --------------------------------------------------
public HelloWorldImpl(ActivationID id, MarshalledObject data)
throws RemoteException
{
Remote stub = Activatable.exportObject(this, id, 0);
try
{
Properties cfg = new Properties();
cfg.load(this.getClass().getResourceAsStream("/jndi.properties"));
new InitialContext(cfg).rebind(HelloWorld.NAME, stub);
} catch (Exception e)
{
throw new ServerException("Could not bind server", e);
}
System.out.println("Hello created");
}
// Public --------------------------------------------------------
// HelloWorld implementation -------------------------------------
/**
* Create a greeting.
*
* @param name a name
* @return a name including the name
*/
public String helloWorld(String name)
{
System.out.println("Hello called");
return "Hello " + name +"!";
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -