本文整理汇总了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");
}