本文整理匯總了Java中java.rmi.Naming.bind方法的典型用法代碼示例。如果您正苦於以下問題:Java Naming.bind方法的具體用法?Java Naming.bind怎麽用?Java Naming.bind使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.rmi.Naming
的用法示例。
在下文中一共展示了Naming.bind方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: ClusterImpl
import java.rmi.Naming; //導入方法依賴的package包/類
public ClusterImpl(ActorSystem system, String host, String seedHost) throws RemoteException {
super();
this.system = (AbsActorSystem) system;
this.members = Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>());
this.seed = seedHost;
if (!host.equals(seedHost))
this.uuid = host + "/" + UUID.randomUUID().toString().replaceAll("-", "");
else this.uuid = host + "/master";
try {
Naming.bind("rmi://" + this.uuid, this);
join(this.uuid);
if (!host.equals(seedHost))
updateMembers(seedHost, this.uuid);
} catch (AlreadyBoundException | MalformedURLException e) {
e.printStackTrace();
}
}
示例2: 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();
LogWriter log = Log.createLogWriter("dunit-vm-" + vmNum, DUnitLauncher.LOG_LEVEL);
System.out.println("VM" + vmNum + " is launching");
DUnitLauncher.initSystemProperties(log);
MasterRemote holder = (MasterRemote) Naming.lookup("//localhost:" + namingPort + "/" + DUnitLauncher.MASTER_PARAM);
RemoteTestModule.Master = new FakeMaster();
DUnitLauncher.locatorPort = holder.getLocatorPort();
Naming.bind("//localhost:" + namingPort + "/vm" + vmNum, new FakeRemoteTestModule(log));
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);
}
}
示例3: Service
import java.rmi.Naming; //導入方法依賴的package包/類
public Service() {
File file = FileGetter.getFile("address");
try {
if (!file.exists()) {
JOptionPane.showMessageDialog(null, "IP地址文件不存在,將使用本地地址,請檢查Info目錄下的address是否丟失");
address = "localhost";
} else {
Scanner in = new Scanner(file);
address = in.nextLine();
in.close();
}
System.setProperty("java.rmi.server.hostname", address);
reg = LocateRegistry.createRegistry(8888);
test = new Test();
Naming.bind("rmi://" + address + ":8888/TestConnection", test);
} catch (Exception e) {
JOptionPane.showMessageDialog(null, "請勿重複啟動服務器", "", JOptionPane.ERROR_MESSAGE);
System.exit(0);
e.printStackTrace();
}
}
示例4: initialize
import java.rmi.Naming; //導入方法依賴的package包/類
private static synchronized void initialize() throws Exception {
if (blackboard == null) {
System.out.println(
DUnitLauncher.RMI_PORT_PARAM + "=" + System.getProperty(DUnitLauncher.RMI_PORT_PARAM));
int namingPort = Integer.getInteger(DUnitLauncher.RMI_PORT_PARAM).intValue();
String name = "//localhost:" + namingPort + "/" + "InternalBlackboard";
try {
blackboard = (InternalBlackboard) Naming.lookup(name);
} catch (NotBoundException e) {
// create the master blackboard in this VM
blackboard = new InternalBlackboardImpl();
Naming.bind(name, blackboard);
}
}
}
示例5: initialize
import java.rmi.Naming; //導入方法依賴的package包/類
private static synchronized void initialize() throws Exception {
if (blackboard == null) {
System.out.println(
DUnitLauncher.RMI_PORT_PARAM + "=" + System.getProperty(DUnitLauncher.RMI_PORT_PARAM));
int namingPort = Integer.getInteger(DUnitLauncher.RMI_PORT_PARAM).intValue();
String name = "//localhost:" + namingPort + "/" + "DistributedLockBlackboard";
try {
blackboard = (DistributedLockBlackboard) Naming.lookup(name);
} catch (NotBoundException e) {
// create the master blackboard in this VM
blackboard = new DistributedLockBlackboardImpl();
Naming.bind(name, blackboard);
}
}
}
示例6: AbsActorRef
import java.rmi.Naming; //導入方法依賴的package包/類
/**
* Public constructor, in case of an {@code ActorRef} of type
* {@code ActorMode.REMOTE} bind the name to the RMI registry.
*/
public AbsActorRef(ActorSystem system, ActorMode mode, String name) throws RemoteException {
super();
this.system = (AbsActorSystem) system;
this.name = name;
this.originalSender = this;
if (this.system.getSystemMode() == SystemMode.CLUSTER) {
try {
Naming.bind("rmi://" + name, this);
} catch (AlreadyBoundException | MalformedURLException e) {
e.printStackTrace();
}
}
}
示例7: setUp
import java.rmi.Naming; //導入方法依賴的package包/類
/**
* Initializes this test by binding an instance of
* <code>RemoteBlockingQueueImpl</code> into the RMI registry hosted
* in Hydra's master controller VM.
*/
public void setUp() throws Exception {
String queueName = this.getUniqueName();
Host host = Host.getHost(0);
this.queueURL = RmiRegistryHelper.getMasterRegistryURL() + queueName;
RemoteBlockingQueue queue =
new RemoteBlockingQueueImpl(QUEUE_CAPACITY);
DistributedTestCase.getLogWriter().info("Binding queue named \"" + this.queueURL
+ "\"");
Naming.bind(this.queueURL, queue);
}
示例8: main
import java.rmi.Naming; //導入方法依賴的package包/類
/**
* Initializes the Blunk environment, starts up a remote SQLDatabase instance and binds it to a RMI url.
*
* @param args arg0 = Path to blunk.properties (environment). arg1 = RMI url
*/
public static void main(String[] args)
{
try
{
// Initialize Environment with blunk.properties (arg0)
Environment.init(args[0]);
// Now create new instance!
SQLDatabase instance = new SQLDatabase();
// OK?
if (instance.prepare())
{
// And now bind the new instance of SQLDatabase to the RMI uri
// (arg1)
Naming.bind(args[1], instance);
// We are up and running!
Log.info("SQLDatabase instance up and running and bound to " + args[2]);
}
else
{
Log.error("Failed to start new SQLDatabase instance!");
}
}
catch (Exception ex)
{
Log.error("Failed to start new SQLDatabase instance!", ex);
Log.info("Start this class with 'java com.blunk.storage.sql.SQLDatabase [blunk.properties] [RMI url]");
}
}
示例9: main
import java.rmi.Naming; //導入方法依賴的package包/類
public static void main(String[] args) throws MalformedURLException, RemoteException, AlreadyBoundException {
XMathImpl ref = new XMathImpl();
Naming.bind("rmi://localhost/XMath",ref);
System.out.println("Server pronto");
}