java.rmi.AlreadyBoundException Java Examples

The following examples show how to use java.rmi.AlreadyBoundException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RmiServer.java    From JavaTutorial with Apache License 2.0 6 votes vote down vote up
/**
 * @param args [0]:绑定端口
 * @throws RemoteException 
 */
public static void main(String[] args) throws RemoteException {
    int port = Integer.parseInt(args[0]);
    UserService userService = new UserServiceImpl();
    Registry registry = createRegistry(port);
    if (null == registry) {
        System.exit(0);
    }
    
    String bindName = "UserService";
    try {
        registry.bind(bindName, userService);
    } catch (AlreadyBoundException e) {
        _logger.info("服务{}已经绑定过", bindName);
    }
    
    _logger.info("RMI Server started, listen port:{}", port);
}
 
Example #2
Source File: RMTHelper.java    From scheduling with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Create several nodes on the same JVMProcess
 */
public static List<TestNode> createNodes(final String nodeName, int number)
        throws IOException, NodeException, ExecutionException, InterruptedException, AlreadyBoundException {
    if (number == 0) {
        throw new IllegalArgumentException("" + number);
    }

    ArrayList<TestNode> nodes = new ArrayList<>(number);
    // Start the JVMProcess and create the first node
    TestNode node0 = createNode(nodeName + 0, findFreePort());
    nodes.add(0, node0);

    // create all subsequent nodes remotely
    for (int i = 1; i < number; i++) {
        Node nodei = node0.getNode().getProActiveRuntime().createLocalNode(nodeName + i, false, null);
        nodes.add(new TestNode(node0.getNodeProcess(), nodei));
    }

    return nodes;
}
 
Example #3
Source File: Solution.java    From JavaRushTasks with MIT License 6 votes vote down vote up
@Override
public void run() {
    //напишите тут ваш код
    try {
        //создание объекта для удаленного доступа
        final Animal cat = new Cat("Barsik");
        final Animal dog = new Dog("Palkan");

        //создание реестра расшареных объетов
        registry = LocateRegistry.createRegistry(2099);

        //создание "заглушки" – приемника удаленных вызовов
        Remote stubCat = UnicastRemoteObject.exportObject(cat, 0);
        Remote stubDog = UnicastRemoteObject.exportObject(dog, 0);

        //регистрация "заглушки" в реесте
        registry.bind(BINDING_NAME1, stubCat);
        registry.bind(BINDING_NAME2, stubDog);

    } catch (RemoteException | AlreadyBoundException e) {
        e.printStackTrace();
    }
}
 
Example #4
Source File: DUnitLauncher.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
private static void launch() throws URISyntaxException, AlreadyBoundException, IOException, InterruptedException, NotBoundException  {
//    initialize the log writer that hydra uses
    LogWriter log = Log.createLogWriter( "dunit-master", LOG_LEVEL );

    locatorPort = AvailablePortHelper.getRandomAvailableTCPPort();
     
    //create an RMI registry and add an object to share our tests config
    int namingPort = AvailablePortHelper.getRandomAvailableTCPPort();
    Registry registry = LocateRegistry.createRegistry(namingPort);
    Master master = new Master();
    registry.bind(MASTER_PARAM, master);

    final ProcessManager processManager = new ProcessManager(NUM_VMS + 1, namingPort);

    Runtime.getRuntime().addShutdownHook(new Thread() {
      public void run() {
        processManager.killVMs();
      }
    });
    
    //launch the remote VMS
    processManager.launchVMs();
    
    //wait for the VMS to start up
    if(!master.waitForVMs(STARTUP_TIMEOUT)) {
      throw new RuntimeException("VMs did not start up with 30 seconds");
    }
    
    //populate the Host class with our stubs. The tests use this host class
    EclipseDUnitHost host = new EclipseDUnitHost(InetAddress.getLocalHost().getCanonicalHostName(), NUM_VMS);
    host.init(registry);

    initSystemProperties(log);
    
    startLocator(registry);
  }
 
Example #5
Source File: Activation.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public void bind(String name, Remote obj)
    throws RemoteException, AlreadyBoundException, AccessException
{
    if (name.equals(NAME)) {
        throw new AccessException(
            "binding ActivationSystem is disallowed");
    } else {
        super.bind(name, obj);
    }
}
 
Example #6
Source File: RegistryFilterTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void simpleRejectableClass() throws RemoteException, AlreadyBoundException, NotBoundException {
    RejectableClass r1 = null;
    try {
        String name = "reject1";
        r1 = new RejectableClass();
        registry.bind(name, r1);
        registry.unbind(name);
        Assert.assertNull(registryFilter, "Registry filter should have rejected");
    } catch (Exception rex) {
        Assert.assertNotNull(registryFilter, "Registry filter should not have rejected");
    }
}
 
Example #7
Source File: RegistryFilterTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void simpleDepthBuiltinNonRejectable() throws RemoteException, AlreadyBoundException, NotBoundException {
    int depthOverride = Integer.getInteger("test.maxdepth", REGISTRY_MAX_DEPTH);
    depthOverride = Math.min(depthOverride, REGISTRY_MAX_DEPTH);
    System.out.printf("overrideDepth: %d, filter: %s%n", depthOverride, registryFilter);
    try {
        String name = "reject2";
        DepthRejectableClass r1 = DepthRejectableClass.create(depthOverride);
        registry.bind(name, r1);
        registry.unbind(name);
    } catch (Exception rex) {
        Assert.fail("Registry filter should not have rejected depth: "
                        + depthOverride);
    }
}
 
Example #8
Source File: RegistryFilterTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void simpleDepthRejectable() throws RemoteException, AlreadyBoundException, NotBoundException {
    int depthOverride = Integer.getInteger("test.maxdepth", REGISTRY_MAX_DEPTH);
    depthOverride = Math.min(depthOverride, REGISTRY_MAX_DEPTH);
    System.out.printf("overrideDepth: %d, filter: %s%n", depthOverride, registryFilter);
    try {
        String name = "reject3";
        DepthRejectableClass r1 = DepthRejectableClass.create(depthOverride + 1);
        registry.bind(name, r1);
        Assert.fail("Registry filter should have rejected depth: " + depthOverride + 1);
    } catch (Exception rex) {
        // Rejection expected
    }
}
 
Example #9
Source File: Activation.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public void bind(String name, Remote obj)
    throws RemoteException, AlreadyBoundException, AccessException
{
    if (name.equals(NAME)) {
        throw new AccessException(
            "binding ActivationSystem is disallowed");
    } else {
        RegistryImpl.checkAccess("ActivationSystem.bind");
        super.bind(name, obj);
    }
}
 
Example #10
Source File: RegistryFilterTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void simpleRejectableClass() throws RemoteException, AlreadyBoundException, NotBoundException {
    RejectableClass r1 = null;
    try {
        String name = "reject1";
        r1 = new RejectableClass();
        registry.bind(name, r1);
        registry.unbind(name);
        Assert.assertNull(registryFilter, "Registry filter should have rejected");
    } catch (Exception rex) {
        Assert.assertNotNull(registryFilter, "Registry filter should not have rejected");
    }
}
 
Example #11
Source File: RegistryFilterTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void simpleDepthBuiltinNonRejectable() throws RemoteException, AlreadyBoundException, NotBoundException {
    int depthOverride = Integer.getInteger("test.maxdepth", REGISTRY_MAX_DEPTH);
    depthOverride = Math.min(depthOverride, REGISTRY_MAX_DEPTH);
    System.out.printf("overrideDepth: %d, filter: %s%n", depthOverride, registryFilter);
    try {
        String name = "reject2";
        DepthRejectableClass r1 = DepthRejectableClass.create(depthOverride);
        registry.bind(name, r1);
        registry.unbind(name);
    } catch (Exception rex) {
        Assert.fail("Registry filter should not have rejected depth: "
                        + depthOverride);
    }
}
 
Example #12
Source File: RegistryFilterTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void simpleDepthRejectable() throws RemoteException, AlreadyBoundException, NotBoundException {
    int depthOverride = Integer.getInteger("test.maxdepth", REGISTRY_MAX_DEPTH);
    depthOverride = Math.min(depthOverride, REGISTRY_MAX_DEPTH);
    System.out.printf("overrideDepth: %d, filter: %s%n", depthOverride, registryFilter);
    try {
        String name = "reject3";
        DepthRejectableClass r1 = DepthRejectableClass.create(depthOverride + 1);
        registry.bind(name, r1);
        Assert.fail("Registry filter should have rejected depth: " + depthOverride + 1);
    } catch (Exception rex) {
        // Rejection expected
    }
}
 
Example #13
Source File: Activation.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public void bind(String name, Remote obj)
    throws RemoteException, AlreadyBoundException, AccessException
{
    if (name.equals(NAME)) {
        throw new AccessException(
            "binding ActivationSystem is disallowed");
    } else {
        super.bind(name, obj);
    }
}
 
Example #14
Source File: RegistryFilterTest.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Test(dataProvider="bindData")
public void simpleBind(String name, Remote obj, boolean blacklisted) throws RemoteException, AlreadyBoundException, NotBoundException {
    try {
        registry.bind(name, obj);
        Assert.assertFalse(blacklisted, "Registry filter did not reject (but should have) ");
        registry.unbind(name);
    } catch (Exception rex) {
        Assert.assertTrue(blacklisted, "Registry filter should not have rejected");
    }
}
 
Example #15
Source File: RegistryFilterTest.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void simpleRejectableClass() throws RemoteException, AlreadyBoundException, NotBoundException {
    RejectableClass r1 = null;
    try {
        String name = "reject1";
        r1 = new RejectableClass();
        registry.bind(name, r1);
        registry.unbind(name);
        Assert.assertNull(registryFilter, "Registry filter should not have rejected");
    } catch (Exception rex) {
        Assert.assertNotNull(registryFilter, "Registry filter should have rejected");
    }
}
 
Example #16
Source File: Activation.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public void bind(String name, Remote obj)
    throws RemoteException, AlreadyBoundException, AccessException
{
    if (name.equals(NAME)) {
        throw new AccessException(
            "binding ActivationSystem is disallowed");
    } else {
        super.bind(name, obj);
    }
}
 
Example #17
Source File: Activation.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public void bind(String name, Remote obj)
    throws RemoteException, AlreadyBoundException, AccessException
{
    if (name.equals(NAME)) {
        throw new AccessException(
            "binding ActivationSystem is disallowed");
    } else {
        super.bind(name, obj);
    }
}
 
Example #18
Source File: RegistryFilterTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Test(dataProvider="bindData")
public void simpleBind(String name, Remote obj, boolean blacklisted) throws RemoteException, AlreadyBoundException, NotBoundException {
    try {
        registry.bind(name, obj);
        Assert.assertFalse(blacklisted, "Registry filter did not reject (but should have) ");
        registry.unbind(name);
    } catch (Exception rex) {
        Assert.assertTrue(blacklisted, "Registry filter should not have rejected");
    }
}
 
Example #19
Source File: Activation.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public void bind(String name, Remote obj)
    throws RemoteException, AlreadyBoundException, AccessException
{
    if (name.equals(NAME)) {
        throw new AccessException(
            "binding ActivationSystem is disallowed");
    } else {
        super.bind(name, obj);
    }
}
 
Example #20
Source File: Activation.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
public void bind(String name, Remote obj)
    throws RemoteException, AlreadyBoundException, AccessException
{
    if (name.equals(NAME)) {
        throw new AccessException(
            "binding ActivationSystem is disallowed");
    } else {
        RegistryImpl.checkAccess("ActivationSystem.bind");
        super.bind(name, obj);
    }
}
 
Example #21
Source File: RegistryFilterTest.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Test(dataProvider="bindData")
public void simpleBind(String name, Remote obj, boolean blacklisted) throws RemoteException, AlreadyBoundException, NotBoundException {
    try {
        registry.bind(name, obj);
        Assert.assertFalse(blacklisted, "Registry filter did not reject (but should have) ");
        registry.unbind(name);
    } catch (Exception rex) {
        Assert.assertTrue(blacklisted, "Registry filter should not have rejected");
    }
}
 
Example #22
Source File: RegistryFilterTest.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void simpleRejectableClass() throws RemoteException, AlreadyBoundException, NotBoundException {
    RejectableClass r1 = null;
    try {
        String name = "reject1";
        r1 = new RejectableClass();
        registry.bind(name, r1);
        registry.unbind(name);
        Assert.assertNull(registryFilter, "Registry filter should have rejected");
    } catch (Exception rex) {
        Assert.assertNotNull(registryFilter, "Registry filter should not have rejected");
    }
}
 
Example #23
Source File: RegistryFilterTest.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void simpleDepthBuiltinNonRejectable() throws RemoteException, AlreadyBoundException, NotBoundException {
    int depthOverride = Integer.getInteger("test.maxdepth", REGISTRY_MAX_DEPTH);
    depthOverride = Math.min(depthOverride, REGISTRY_MAX_DEPTH);
    System.out.printf("overrideDepth: %d, filter: %s%n", depthOverride, registryFilter);
    try {
        String name = "reject2";
        DepthRejectableClass r1 = DepthRejectableClass.create(depthOverride);
        registry.bind(name, r1);
        registry.unbind(name);
    } catch (Exception rex) {
        Assert.fail("Registry filter should not have rejected depth: "
                        + depthOverride);
    }
}
 
Example #24
Source File: RegistryFilterTest.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void simpleDepthRejectable() throws RemoteException, AlreadyBoundException, NotBoundException {
    int depthOverride = Integer.getInteger("test.maxdepth", REGISTRY_MAX_DEPTH);
    depthOverride = Math.min(depthOverride, REGISTRY_MAX_DEPTH);
    System.out.printf("overrideDepth: %d, filter: %s%n", depthOverride, registryFilter);
    try {
        String name = "reject3";
        DepthRejectableClass r1 = DepthRejectableClass.create(depthOverride + 1);
        registry.bind(name, r1);
        Assert.fail("Registry filter should have rejected depth: " + depthOverride + 1);
    } catch (Exception rex) {
        // Rejection expected
    }
}
 
Example #25
Source File: DUnitLauncher.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
private static void launch() throws URISyntaxException, AlreadyBoundException, IOException, InterruptedException, NotBoundException  {
//    initialize the log writer that hydra uses
    LogWriter log = Log.createLogWriter( "dunit-master", LOG_LEVEL );

    locatorPort = AvailablePortHelper.getRandomAvailableTCPPort();
     
    //create an RMI registry and add an object to share our tests config
    int namingPort = AvailablePortHelper.getRandomAvailableTCPPort();
    Registry registry = LocateRegistry.createRegistry(namingPort);
    Master master = new Master();
    registry.bind(MASTER_PARAM, master);

    final ProcessManager processManager = new ProcessManager(NUM_VMS + 1, namingPort);

    Runtime.getRuntime().addShutdownHook(new Thread() {
      public void run() {
        processManager.killVMs();
      }
    });
    
    //launch the remote VMS
    processManager.launchVMs();
    
    //wait for the VMS to start up
    if(!master.waitForVMs(STARTUP_TIMEOUT)) {
      throw new RuntimeException("VMs did not start up with 30 seconds");
    }
    
    //populate the Host class with our stubs. The tests use this host class
    EclipseDUnitHost host = new EclipseDUnitHost(InetAddress.getLocalHost().getCanonicalHostName(), NUM_VMS);
    host.init(registry);

    initSystemProperties(log);
    
    startLocator(registry);
  }
 
Example #26
Source File: SchedulerStarter.java    From scheduling with GNU Affero General Public License v3.0 5 votes vote down vote up
private static void startResourceManager(final int numberLocalNodes, final int nodeTimeoutValue) {
    final Thread rmStarter = new Thread() {
        public void run() {
            try {
                //Starting a local RM using default deployment descriptor
                RMFactory.setOsJavaProperty();
                LOGGER.info("Starting the resource manager...");
                RMAuthentication rmAuth = RMFactory.startLocal();

                if (numberLocalNodes > 0) {
                    addLocalNodes(rmAuth, numberLocalNodes, nodeTimeoutValue);
                }

                LOGGER.info("The resource manager with " + numberLocalNodes + " local nodes created on " +
                            rmAuth.getHostURL());
            } catch (AlreadyBoundException abe) {
                LOGGER.error("The resource manager already exists on local host", abe);
                System.exit(4);
            } catch (Exception aoce) {
                LOGGER.error("Unable to create local resource manager", aoce);
                System.exit(5);
            }
        }
    };

    rmStarter.start();
}
 
Example #27
Source File: Activation.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public void bind(String name, Remote obj)
    throws RemoteException, AlreadyBoundException, AccessException
{
    if (name.equals(NAME)) {
        throw new AccessException(
            "binding ActivationSystem is disallowed");
    } else {
        super.bind(name, obj);
    }
}
 
Example #28
Source File: Activation.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
public void bind(String name, Remote obj)
    throws RemoteException, AlreadyBoundException, AccessException
{
    if (name.equals(NAME)) {
        throw new AccessException(
            "binding ActivationSystem is disallowed");
    } else {
        super.bind(name, obj);
    }
}
 
Example #29
Source File: Coordinator.java    From hazelcast-simulator with Apache License 2.0 5 votes vote down vote up
private void initCoordinatorRemote() throws RemoteException, AlreadyBoundException {
    int remotePort = properties.getCoordinatorPort();
    if (remotePort != 0) {
        java.rmi.registry.Registry rmiRegistry = LocateRegistry.createRegistry(remotePort);
        coordinatorRemote = new CoordinatorRemoteImpl(this);
        Remote stub = UnicastRemoteObject.exportObject(coordinatorRemote, 0);

        // Bind the remote object's stub in the registry
        rmiRegistry.bind("CoordinatorRemote", stub);
    }
}
 
Example #30
Source File: DummyRegistry.java    From jdal with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public void bind(String name, Remote obj) throws RemoteException, AlreadyBoundException, AccessException {
	if (registry.containsKey(name))
		throw new AlreadyBoundException(name);
	
	registry.put(name, obj);
}