本文整理匯總了Java中java.rmi.Naming.rebind方法的典型用法代碼示例。如果您正苦於以下問題:Java Naming.rebind方法的具體用法?Java Naming.rebind怎麽用?Java Naming.rebind使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.rmi.Naming
的用法示例。
在下文中一共展示了Naming.rebind方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: main
import java.rmi.Naming; //導入方法依賴的package包/類
public static void main(String[] args) throws UnknownHostException, RemoteException, MalformedURLException{
// System.setProperty("java.rmi.server.hostname", InetAddress.getLocalHost().toString());
// System.setProperty("java.rmi.server.hostname", "172.26.210.111");
// PaymentReceiptDataService data=new PaymentReceiptData();
AccountDataService accountData=new AccountData();
CollectionReceiptDataService collectionData=new CollectionReceiptData();
CostIncomeReceiptDataService costIncomeData=new CostIncomeReceiptData();
InitialStockDataService initData=new InitialStockData();
PaymentReceiptDataService paymentData=new PaymentReceiptData();
LocateRegistry.createRegistry(8800);
//// //綁定RMI名稱進行發布
Naming.rebind("rmi://localhost:8800/AccountDataService", accountData);
Naming.rebind("rmi://localhost:8800/CollectionReceiptDataService", collectionData);
Naming.rebind("rmi://localhost:8800/CostIncomeReceiptDataService", costIncomeData);
Naming.rebind("rmi://localhost:8800/InitialStockDataService", initData);
Naming.rebind("rmi://localhost:8800/PaymentReceiptDataService", paymentData);
System.out.println("Service start at 8800 !");
}
示例2: Server
import java.rmi.Naming; //導入方法依賴的package包/類
/**
* Register the sample company for remote invocation.
*/
public Server() {
try {
InetAddress addr = InetAddress.getLocalHost();
hostname = addr.getHostName();
} catch (UnknownHostException unknownHostException) {
System.err.println("Failure during host name resolution: " + unknownHostException);
}
try {
Naming.rebind("//" + hostname + "/meganalysis", mkSampleCompany());
} catch (RemoteException remoteException) {
System.err.println("Failure during name registration: " + remoteException);
} catch (MalformedURLException malformedException) {
System.err.println("Failure during name registration: " + malformedException);
}
}
示例3: main
import java.rmi.Naming; //導入方法依賴的package包/類
public static void main(String[] args) throws Throwable {
try {
int namingPort = Integer.getInteger(DUnitLauncher.RMI_PORT_PARAM).intValue();
int vmNum = Integer.getInteger(DUnitLauncher.VM_NUM_PARAM).intValue();
int pid = OSProcess.getId();
//logger.info("VM" + vmNum + " is launching" + (pid > 0? " with PID " + pid : ""));
DUnitLauncher.MasterRemote holder = (DUnitLauncher.MasterRemote) Naming.lookup("//localhost:" + namingPort + "/" + DUnitLauncher.MASTER_PARAM);
DUnitLauncher.init(holder);
DUnitLauncher.locatorPort = holder.getLocatorPort();
Naming.rebind("//localhost:" + namingPort + "/vm" + vmNum, new RemoteDUnitVM());
holder.signalVMReady();
//This loop is here so this VM will die even if the master is mean killed.
while(true) {
holder.ping();
Thread.sleep(1000);
}
} catch (Throwable t) {
t.printStackTrace();
System.exit(1);
}
}
示例4: create
import java.rmi.Naming; //導入方法依賴的package包/類
public static String create(final Service svc, final int port) {
String svcUri = null;
try {
synchronized(SVC_MAP) {
//ensureRmiUseFixedPort(port);
ensureRmiRegistryIsAvailableAt(port);
UnicastRemoteObject.exportObject(svc, port);
final String svcName = svc.getName();
svcUri = getLocalSvcUri(svcName, port).toString();
if(!SVC_MAP.containsKey(svcName + ":" + port)) {
Naming.rebind(svcUri, svc);
SVC_MAP.put(svcName + ":" + port, svc);
} else {
throw new AssertionError("Service already registered");
}
}
} catch(final IOException | URISyntaxException e) {
e.printStackTrace(System.err);
}
return svcUri;
}
示例5: main
import java.rmi.Naming; //導入方法依賴的package包/類
public static void main(String[] args) {
GumballMachineRemote remote = null;
int count = 0;
if(args.length < 2){
System.out.println("GumballMachine <name> <inventory>");
System.exit(1);
}
count = Integer.parseInt(args[1]);
try {
remote = new GumballMachine(args[0], count);
System.out.println("/"+args[0]+"/gumballmachine");
Naming.rebind("/"+args[0]+"/gumballmachine", remote);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
示例6: main
import java.rmi.Naming; //導入方法依賴的package包/類
public static void main(String[] args) {
// You may want a SecurityManager for downloading of classes:
// System.setSecurityManager(new RMISecurityManager());
try {
// Create an instance of the server object
RemoteDateImpl im = new RemoteDateImpl();
System.out.println("DateServer starting...");
// Publish it in the RMI registry.
// Of course you have to have rmiregistry or equivalent running!
Naming.rebind(RemoteDate.LOOKUPNAME, im);
System.out.println("DateServer ready.");
} catch (Exception e) {
System.err.println(e);
System.exit(1);
}
}
示例7: main
import java.rmi.Naming; //導入方法依賴的package包/類
public static void main(String[] args){
try{
System.setProperty("java.rmi.server.hostname", "172.25.132.40");
RepertoryDataService repertoryData = new RepertoryData();
LocateRegistry.createRegistry(6001);
//綁定RMI名稱進行發布
Naming.rebind("rmi://172.25.132.40:6001/RepertoryDataService", repertoryData);
System.out.println("Repertory Service start!");
ArrayList<RepertoryPO> repertoryList0 = repertoryData.showAllRepertorys();
for(RepertoryPO repertory:repertoryList0)
System.out.println("ID: "+repertory.getRepertoryID()+", Owner: "+repertory.getOwnerID());
RepertoryPO repertorypo = repertoryData.findRepertory("030-CK");
System.out.println("ID: "+repertorypo.getRepertoryID()+", Owner: "+repertorypo.getOwnerID());
}catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
示例8: main
import java.rmi.Naming; //導入方法依賴的package包/類
public static void main(String[] args){
try{
System.setProperty("java.rmi.server.hostname", "172.25.132.40");
CostDataService costData = new CostData();
LocateRegistry.createRegistry(6004);
//綁定RMI名稱進行發布
Naming.rebind("rmi://172.25.132.40:6004/CostDataService", costData);
System.out.println("Cost Service start!");
ArrayList<CostPO> costList0 = costData.showAllCosts();
for(CostPO cost:costList0)
System.out.println("ExpressType: "+cost.getExpressType()+", Cost: "+cost.getCost());
CostPO costpo = costData.findCost(ExpressType.FAST);
System.out.println("ExpressType: "+costpo.getExpressType()+", Cost: "+costpo.getCost());
}catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
示例9: main
import java.rmi.Naming; //導入方法依賴的package包/類
public static void main(String[] args){
try{
System.setProperty("java.rmi.server.hostname", "172.25.132.40");
BasicSalaryDataService basicSalaryData = new BasicSalaryData();
LocateRegistry.createRegistry(6003);
//綁定RMI名稱進行發布
Naming.rebind("rmi://172.25.132.40:6003/BasicSalaryDataService", basicSalaryData);
System.out.println("BasicSalary Service start!");
ArrayList<BasicSalaryPO> basicSalaryList0 = basicSalaryData.showAllBasicSalarys();
for(BasicSalaryPO basicSalary:basicSalaryList0)
System.out.println("Profession: "+basicSalary.getProfession()+", BasicSalary: "+basicSalary.getBasicSalary());
BasicSalaryPO basicSalarypo = basicSalaryData.findBasicSalary(ProfessionType.manager);
System.out.println("Profession: "+basicSalarypo.getProfession()+", BasicSalary: "+basicSalarypo.getBasicSalary());
}catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
示例10: main
import java.rmi.Naming; //導入方法依賴的package包/類
public static void main(String[] args){
try{
System.setProperty("java.rmi.server.hostname", "172.25.132.40");
PerWageDataService perWageData = new PerWageData();
LocateRegistry.createRegistry(6002);
//綁定RMI名稱進行發布
Naming.rebind("rmi://172.25.132.40:6002/PerWageDataService", perWageData);
System.out.println("PerWage Service start!");
ArrayList<PerWagePO> perWageList0 = perWageData.showAllPerWages();
for(PerWagePO perWage:perWageList0)
System.out.println("Profession: "+perWage.getProfession()+", PerWage: "+perWage.getPerWage());
PerWagePO perWagepo = perWageData.findPerWage(ProfessionType.driver);
System.out.println("Profession: "+perWagepo.getProfession()+", PerWage: "+perWagepo.getPerWage());
}catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
示例11: run
import java.rmi.Naming; //導入方法依賴的package包/類
/**
*
*/
@Override
public void run() {
try {
this.urna = this.prepararUrna();
LocateRegistry.createRegistry(1099);
Naming.rebind("rmi:///Urna", this.urna);
System.out.println("[email protected]$> Urna iniciada, pronta para receber votos!");
} catch (RemoteException | MalformedURLException ex) {
System.err.println(ex);
System.exit(1);
}
this.iniciarApurador();
this.escutarComandos();
}
示例12: createStatement
import java.rmi.Naming; //導入方法依賴的package包/類
public Statement createStatement() throws RemoteException {
try {
if (statement == null) {
//init connection
ConnectionConf connectionConf = sdbConf.getConnectionConf();
//create sdbStatement
LOG.info("Creating sdb statement");
SdbStatement sdbStatement = new SdbStatement(metaStore, serverConnection, serverDB, sdbConf.getServerConf());
serviceUrl = connectionConf.getSdbAddress() + ":"
+ connectionConf.getSdbPort() + "/" + SERVICE_NAME;
Naming.rebind(serviceUrl, sdbStatement);
}
statement = (Statement) Naming.lookup(serviceUrl);
} catch (RemoteException | NotBoundException | MalformedURLException e) {
e.printStackTrace();
}
return statement;
}
示例13: main
import java.rmi.Naming; //導入方法依賴的package包/類
public static void main(String[] args) {
if (args.length < 2) {
System.out.println("GumballMachine <name> <inventory>");
System.exit(1);
}
try {
int count = Integer.parseInt(args[1]);
GumballMachineRemote gumballMachine =
new GumballMachine(args[0], count);
Naming.rebind("//" + args[0] + "/gumballmachine", gumballMachine);
} catch (Exception e) {
e.printStackTrace();
}
}
示例14: main
import java.rmi.Naming; //導入方法依賴的package包/類
public static void main(String[] args) {
if(args.length != 1)
usage("Wrong number of arguments.");
NumberCruncherServer ncs;
PropertyConfigurator.configure(args[0]);
try {
ncs = new NumberCruncherServer();
Naming.rebind("Factor", ncs);
logger.info("NumberCruncherServer bound and ready to serve.");
}
catch(Exception e) {
logger.error("Could not bind NumberCruncherServer.", e);
return;
}
NumberCruncherClient.loop(ncs);
}
示例15: main
import java.rmi.Naming; //導入方法依賴的package包/類
public static void main(String[] args) throws RemoteException, MalformedURLException {
try {
Server server = new Server();
String location = "//localhost/service";
Naming.rebind(location, server);
} catch (MalformedURLException e) {
System.out.println("Error - Malformed URL: " + e.getMessage());
} catch (RemoteException ex) {
System.out.println("Error: " + ex.getMessage());
}
}