當前位置: 首頁>>代碼示例>>Java>>正文


Java Naming類代碼示例

本文整理匯總了Java中java.rmi.Naming的典型用法代碼示例。如果您正苦於以下問題:Java Naming類的具體用法?Java Naming怎麽用?Java Naming使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Naming類屬於java.rmi包,在下文中一共展示了Naming類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: connectRemote

import java.rmi.Naming; //導入依賴的package包/類
private MplsnmsRmiServiceAccessPoint connectRemote(CoreConfiguration config) throws NotBoundException,
        MalformedURLException, RemoteException {
    if (this.ap != null) {
        try {
            this.ap.getServiceFacade();
            return this.ap;
        } catch (RemoteException e) {
            log.warn("got error from existing remote [MplsnmsRmiServiceAccessPoint].", e);
            this.ap = null;
        }
    }
    MplsnmsRmiServiceAccessPoint newAccessPoint = (MplsnmsRmiServiceAccessPoint) Naming.lookup(config.getDbServerUrl());
    if (newAccessPoint == null) {
        throw new IllegalStateException("inventory server not found on " + config.getDbServerUrl());
    }
    this.ap = newAccessPoint;
    registTriggers();
    return ap;
}
 
開發者ID:openNaEF,項目名稱:openNaEF,代碼行數:20,代碼來源:DefaultNaefBridge.java

示例2: main

import java.rmi.Naming; //導入依賴的package包/類
public static void main(String[] args) {
    if (args.length == 0) {
        System.err.println("usage: RegistryInspector [registry url]");
        System.exit(-1);
    }

    String registry = args[0];
    try {
        String[] names = Naming.list(registry);
        for (String name : names) {
            Remote remoteObject = Naming.lookup(name);
            if (remoteObject != null) {
                System.out.println("name[" + name + "] class=" + remoteObject.getClass().getCanonicalName());
            } else {
                System.out.println("name[" + name + "] is null.");
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
開發者ID:openNaEF,項目名稱:openNaEF,代碼行數:22,代碼來源:RegistryInspector.java

示例3: 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 !");

}
 
開發者ID:Disguiser-w,項目名稱:SE2,代碼行數:21,代碼來源:test.java

示例4: 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);
	}

}
 
開發者ID:amritbhat786,項目名稱:DocIT,代碼行數:22,代碼來源:Server.java

示例5: 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);
  }
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:22,代碼來源:ChildVM.java

示例6: 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();
    }
}
 
開發者ID:codepr,項目名稱:jas,代碼行數:18,代碼來源:ClusterImpl.java

示例7: actorOf

import java.rmi.Naming; //導入依賴的package包/類
/**
 * Create an instance of {@code actor} returning a {@link ActorRef reference}
 * to it using the given {@code mode} and a unique name inside the cluster.
 *
 * @param actor The type of actor that has to be created
 * @param mode The mode of the actor requested
 * @param name The name of the actor inside the cluster, must be unique
 *
 * @return A reference to the actor
 */
@Override
public ActorRef<? extends Message> actorOf(Class<? extends Actor> actor, ActorMode mode, String name) throws RemoteException {
    ActorRef<? extends Message> ref = null;
    switch (mode) {
    case LOCAL:
        ref = system.actorOf(actor, mode, name);
        synchronized(this) {
            updateRemoteActors(name, ref);
        }
        break;
    case REMOTE:
        String addr = name.split("/")[0];
        String memberName = (String)
            members.stream().filter(x -> x.startsWith(addr)).toArray()[0];
        try {
            Cluster remoteMember = (Cluster) Naming.lookup("rmi://" + memberName);
            ref = remoteMember.actorOf(actor, ActorMode.LOCAL, name);
        } catch (NotBoundException | MalformedURLException | RemoteException e) {
            e.printStackTrace();
        }
        break;
    }
    return ref;
}
 
開發者ID:codepr,項目名稱:jas,代碼行數:35,代碼來源:ClusterImpl.java

示例8: updateRemoteActors

import java.rmi.Naming; //導入依賴的package包/類
/**
 * Update new members' remote actors map so they can access to the actors
 * located on other {@code ActorSystem}.
 *
 * @param newMember The identifier name of the new member, in order to be
 * located across the cluster and be updated with remote actors table.
 */
@Override
public void updateRemoteActors(String newMember) throws RemoteException {
    system.getRemoteActors()
        .entrySet()
        .stream()
        .forEach(x -> {
                try {
                    final Cluster cluster =
                        (Cluster) Naming.lookup("rmi://" + newMember);
                    cluster.addRemoteRef(x.getKey(), x.getValue());
                } catch (RemoteException | MalformedURLException | NotBoundException e) {
                    e. printStackTrace();
                }
            });
}
 
開發者ID:codepr,項目名稱:jas,代碼行數:23,代碼來源:ClusterImpl.java

示例9: stop

import java.rmi.Naming; //導入依賴的package包/類
/**
 * Stops {@code actor} inside the cluster.
 *
 * @param actor The actor to be stopped
 */
@Override
public synchronized void stop(ActorRef<? extends Message> actorRef) throws RemoteException {
    AbsActorSystem abSystem = (AbsActorSystem) system;
    if (!abSystem.contains(actorRef)) {
        String destName = actorRef.getName();
        if (abSystem.containsRemote(destName)) {
            try {
                String addr = destName.split("/")[0];
                String memberName = (String)
                    members.stream().filter(x -> x.startsWith(addr)).toArray()[0];
                Cluster clusterMember = (Cluster) Naming.lookup("rmi://" + memberName);
                clusterMember.stop(actorRef);
            } catch (NotBoundException | MalformedURLException e) {
                e.printStackTrace();
            }
        } else throw new NoSuchActorException();
    } else {
        system.stop(actorRef);
    }
}
 
開發者ID:codepr,項目名稱:jas,代碼行數:26,代碼來源:ClusterImpl.java

示例10: 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);
  }
}
 
開發者ID:gemxd,項目名稱:gemfirexd-oss,代碼行數:23,代碼來源:ChildVM.java

示例11: getPi2GoLiteLocat

import java.rmi.Naming; //導入依賴的package包/類
public final synchronized static Pi2GoLite getPi2GoLiteLocat(String rmiServerUrl) 
           throws NotBoundException, 
                  MalformedURLException, 
                  RemoteException 
   {
       
// Assign security manager
       if (System.getSecurityManager() == null)
       {
               System.setSecurityManager
               (new SecurityManager());
       }

       // Call registry for PowerService
       Pi2GoLiteRemote piRemote = (Pi2GoLiteRemote) Naming.lookup
               ("rmi://" + rmiServerUrl + "/Pi2GoLiteRemoteImpl");
               //("rmi://" +"raspi-pi2go.homenet.telecomitalia.it" + "/Pi2GoLiteRemote");

       Pi2GoLite piLocal = new Pi2GoLiteLocal (piRemote);
       
       return piLocal;
   }
 
開發者ID:fustinoni-net,項目名稱:PiRobotPlatform,代碼行數:23,代碼來源:Pi2GoLiteLocal.java

示例12: 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;
}
 
開發者ID:emc-mongoose,項目名稱:mongoose-base,代碼行數:22,代碼來源:ServiceUtil.java

示例13: close

import java.rmi.Naming; //導入依賴的package包/類
public static String close(final Service svc)
throws RemoteException, MalformedURLException {
	final String svcName = svc.getName();
	String svcUri = null;
	try {
		UnicastRemoteObject.unexportObject(svc, true);
	} finally {
		try {
			svcUri = getLocalSvcUri(svcName, svc.getRegistryPort()).toString();
			Naming.unbind(svcUri);
			synchronized(SVC_MAP) {
				if(null == SVC_MAP.remove(svcName + ":" + svc.getRegistryPort())) {
					System.err.println(
						"Failed to remove the service \"" + svcName + "\""
					);
				}
			}
		} catch(final NotBoundException | URISyntaxException e) {
			e.printStackTrace(System.err);
		}
	}
	return svcUri;
}
 
開發者ID:emc-mongoose,項目名稱:mongoose-base,代碼行數:24,代碼來源:ServiceUtil.java

示例14: main

import java.rmi.Naming; //導入依賴的package包/類
public static void main(String[] args) {
	String location [] = {
			"rmi://127.0.0.1/seattle.mig.com/gumballmachine"
	};
	
	GumballMonitor [] monitors = new GumballMonitor[location.length];
	for(int i = 0 ; i < location.length ; i ++){
		try{
			GumballMachineRemote remote = (GumballMachineRemote) Naming.lookup(location[i]);
			monitors[i] = new GumballMonitor(remote);
			System.out.println(monitors[i]);
		}catch(Exception e){
			e.printStackTrace();
		}
	}
	
	for(int i = 0 ; i < location.length ; i ++){
		monitors[i].report();
	}
}
 
開發者ID:KWSStudy,項目名稱:DesignPartterns,代碼行數:21,代碼來源:GumballMonitorTestDrive.java

示例15: 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();
}
 }
 
開發者ID:KWSStudy,項目名稱:DesignPartterns,代碼行數:20,代碼來源:GumballMachineTestDrive.java


注:本文中的java.rmi.Naming類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。