Java 类java.rmi.AlreadyBoundException 实例源码

项目:JavaRushTasks    文件:Solution.java   
@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();
    }
}
项目:openNaEF    文件:MplsnmsTefService.java   
@Override protected void serviceStarted() {
    super.serviceStarted();

    String rmiServiceName = System.getProperty(PROPERTYNAME_RMISERVICENAME);
    if (rmiServiceName == null) {
        throw new IllegalStateException("system property '" + PROPERTYNAME_RMISERVICENAME+ "' を設定してください.");
    }
    try {
        TefService.instance().getRmiRegistry().bind(rmiServiceName, new MplsnmsRmiServiceAccessPoint.Impl());
    } catch (RemoteException re) {
        throw new RuntimeException(re);
    } catch (AlreadyBoundException abe) {
        throw new RuntimeException(abe);
    }

    NaefTefService.instance().getRmcServerService()
        .registerMethod(AllocateVlanIpsubnetaddr.Call.class, new AllocateVlanIpsubnetaddr.Exec());
}
项目:openNaEF    文件:DistributedTransactionService.java   
public static void main(String[] args)
        throws RemoteException, AlreadyBoundException {
    if (args.length != 3) {
        System.out.println
                ("args: [port] [service name]"
                        + " [acceptable tef service ids (comma separated)]");
        return;
    }

    String portStr = args[0];
    String serviceName = args[1];
    String[] acceptableTefServiceIds = args[2].split(",");

    int port;
    try {
        port = Integer.parseInt(portStr);
    } catch (NumberFormatException nfe) {
        throw new IllegalArgumentException("invalid number format: port");
    }

    new Impl(port, serviceName, acceptableTefServiceIds);
}
项目:CanReg5    文件:InstallNewSystemInternalFrame.java   
@Override
protected Object doInBackground() {
    // Your Task's code here.  This method runs
    // on a background thread, so don't reference
    // the Swing GUI from here...
    String result = "stopped";
    try {
        if (canreg.common.ServerLauncher.start(Globals.DEFAULT_SERVER_ADDRESS, systemDescription.getSystemCode(), Globals.DEFAULT_PORT)) {
            result = "started";
        }
    } catch (AlreadyBoundException ex) {
        result = "running";
        Logger.getLogger(InstallNewSystemInternalFrame.class.getName()).log(Level.INFO, null, ex);
    }
    // Return your result...
    return result;
}
项目:CanReg5    文件:LoginInternalFrame.java   
@Override
protected Object doInBackground() {
    // Your Task's code here.  This method runs
    // on a background thread, so don't reference
    // the Swing GUI from here...
    String result = "stopped";
    try {
        if (canreg.common.ServerLauncher.start(serverURLTextField.getText(), codeField.getText(), Integer.parseInt(portField.getText()))) {
            result = "started";
        } else {
            // if this fails, does that always mean this is running?
            result = "running";
        }
    } catch (AlreadyBoundException ex) {
        result = "running";
        Logger.getLogger(LoginInternalFrame.class.getName()).log(Level.INFO, null, ex);
    }
    // Return your result... 
    return result;
}
项目:jas    文件:ClusterImpl.java   
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();
    }
}
项目:cloudkeeper    文件:ITFileLockSyncContextFactory.java   
/**
 * Entry point for the JVM forked by {@link #testSeparateJVMs()}.
 */
public static void main(String[] arguments) throws IOException, AlreadyBoundException, NotBoundException {
    LocalController localController = new LocalController();

    Registry registry = LocateRegistry.createRegistry(REGISTRY_PORT);
    Controller controller = (Controller) UnicastRemoteObject.exportObject(localController, 0);
    registry.bind(CONTROLLER, controller);

    Path lockFile = Paths.get(arguments[0]);
    RepositorySystemSession repositorySystemSession = Mockito.mock(RepositorySystemSession.class);
    try (FileLockSyncContextFactory syncContextFactory = new FileLockSyncContextFactory(lockFile)) {
        new SyncTask(syncContextFactory, localController, repositorySystemSession).run();
    }

    UnicastRemoteObject.unexportObject(localController, true);
    UnicastRemoteObject.unexportObject(registry, true);
}
项目:scheduling    文件:RMTHelper.java   
/**
 * 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;
}
项目:mlib    文件:RMITest.java   
@Test
public void server() throws RemoteException, AlreadyBoundException, InterruptedException {
    int port = 8030;
    Registry registry = LocateRegistry.createRegistry(port);

    RIImpl ro = new RIImpl();
    Remote expRO = UnicastRemoteObject.exportObject(ro, port + 1);
    registry.bind("ro", expRO);

    registry.bind("po", (PureObj) () -> {
        System.out.println("PureObj getValue");
        return 1;
    });

    int i = 1;
    while (true) {
        Thread.sleep(1_000);
        ro.v = i++;
    }
}
项目:cn1    文件:RegistryImpl.java   
/**
 * @see Registry.bind(String, Remote)
 */
public void bind(String name, Remote obj)
        throws RemoteException, AlreadyBoundException, AccessException {
    if (name == null) {
        // rmi.5D=name could not be null.
        throw new NullPointerException(Messages.getString("rmi.5D")); //$NON-NLS-1$
    }

    if (obj == null) {
        // rmi.5C=obj could not be null.
        throw new NullPointerException(Messages.getString("rmi.5C")); //$NON-NLS-1$
    }

    if (table.containsKey(name)) {
        // rmi.5E=There is already binding to the name {0}.
        throw new AlreadyBoundException(Messages.getString("rmi.5E", name)); //$NON-NLS-1$
    }
    checkAccess("RegistryImpl.bind"); //$NON-NLS-1$
    table.put(name, obj);
}
项目:libbluray    文件:IxcRegistryImpl.java   
public void bind(XletContext xc, String path, Remote obj)
    throws AlreadyBoundException {

    Debug("IxcRegistry.bind(" + xc + ", " + path + ", " + obj + ")");

    if (!(xc instanceof BDJXletContext) || (BDJXletContext)xc != BDJXletContext.getCurrentContext()) {
        Debug("bind(): xc not current BDJXletContext");
        throw new IllegalArgumentException("xc not current BDJXletContext");
    }
    if (((BDJXletContext)xc).isReleased()) {
        Debug("bind(): xc is destroyed");
        return;
    }

    synchronized (remoteObjects) {
        if (remoteObjects.containsKey(path))
            throw new AlreadyBoundException();
        remoteObjects.put(path, new WrappedRemoteObj(obj, (BDJXletContext)xc));
    }
}
项目:freeVM    文件:RegistryImpl.java   
/**
 * @see Registry.bind(String, Remote)
 */
public void bind(String name, Remote obj)
        throws RemoteException, AlreadyBoundException, AccessException {
    if (name == null) {
        // rmi.5D=name could not be null.
        throw new NullPointerException(Messages.getString("rmi.5D")); //$NON-NLS-1$
    }

    if (obj == null) {
        // rmi.5C=obj could not be null.
        throw new NullPointerException(Messages.getString("rmi.5C")); //$NON-NLS-1$
    }

    if (table.containsKey(name)) {
        // rmi.5E=There is already binding to the name {0}.
        throw new AlreadyBoundException(Messages.getString("rmi.5E", name)); //$NON-NLS-1$
    }
    checkAccess("RegistryImpl.bind"); //$NON-NLS-1$
    table.put(name, obj);
}
项目:freeVM    文件:RegistryImpl.java   
/**
 * @see Registry.bind(String, Remote)
 */
public void bind(String name, Remote obj)
        throws RemoteException, AlreadyBoundException, AccessException {
    if (name == null) {
        // rmi.5D=name could not be null.
        throw new NullPointerException(Messages.getString("rmi.5D")); //$NON-NLS-1$
    }

    if (obj == null) {
        // rmi.5C=obj could not be null.
        throw new NullPointerException(Messages.getString("rmi.5C")); //$NON-NLS-1$
    }

    if (table.containsKey(name)) {
        // rmi.5E=There is already binding to the name {0}.
        throw new AlreadyBoundException(Messages.getString("rmi.5E", name)); //$NON-NLS-1$
    }
    checkAccess("RegistryImpl.bind"); //$NON-NLS-1$
    table.put(name, obj);
}
项目:EXPERImonitor    文件:ExperimediaFactory.java   
/**
 * Creates an application including all the required EDMProv elements:
 * agent, entity and the activity of running the app, started by the
 * participant running it.
 *
 * @param participant the participant who runs the application
 * @param name the human readable name of the application
 * @param timestamp the time the application is started
 * @return the application
 */
public Application createApplication(Participant participant, String name, String timestamp) {
    Application app = new Application();
    String appName = name.trim().substring(0, 1).toUpperCase() + name.replace(" ", "").substring(1).toLowerCase();
    try {
        app.activity = participant.agent.startActivity("Using" + appName + "Activity_"
                + UUID.randomUUID(), "Using " + name + " activity", timestamp);
        app.entity = app.activity.generateEntity("app_entity_" + UUID.randomUUID(), name, timestamp);
        app.entity.addOwlClass(provFactory.getNamespaceForPrefix("eee") + "Application");
        app.agent = provFactory.createAgent("app_agent_" + UUID.randomUUID(), name);
        app.agent.addTriple(provFactory.getNamespaceForPrefix("owl") + "sameAs",
                app.entity.getIri(), EDMTriple.TRIPLE_TYPE.OBJECT_PROPERTY);
        app.agent.actOnBehalfOf(participant.agent);
        app.participant = participant;
    } catch (DataFormatException | DatatypeConfigurationException | AlreadyBoundException | NoSuchFieldException e) {
        logger.error("Error creating application", e);
        app = null;
    }
    return app;
}
项目:EXPERImonitor    文件:ExperimediaFactory.java   
/**
 * Make the participant use data on the client
 *
 * @param participant the participant
 * @param client the application which the participant is using
 * @param data the content which is used
 * @param dataName the name of the data to be used for labelling
 * @param timestamp the unix timestamp of this discrete useData (start=end)
 * @param duration in seconds
 * @return the useData of using the data
 */
public Activity useDataOnClient(Participant participant, Application client, Content data,
        String dataName, String timestamp, String duration) {

    Activity useData = new Activity();
    try {
        String dName = dataName.substring(0, 1).toUpperCase() + dataName.replaceAll(" ", "").substring(1);

        if (duration == null) {
            useData.activity = participant.agent.doDiscreteActivity("Use" + dName + "Activity_" + UUID.randomUUID(), "Use " + dataName, timestamp);
        } else {
            useData.activity = participant.agent.startActivity("Use" + dName + "Activity_" + UUID.randomUUID(), "Use " + dataName, timestamp);
            participant.agent.stopActivity(useData.activity, getEndTimestamp(timestamp, duration));
        }

        useData.activity.useEntity(data.entity);
        useData.activity.useEntity(client.entity);
    } catch (DataFormatException | DatatypeConfigurationException | AlreadyBoundException e) {
        logger.error("Error creating \"use data on client\" pattern", e);
    }
    return useData;
}
项目:EXPERImonitor    文件:ExperimediaFactory.java   
/**
 * Make a participant use a real world entity
 *
 * @param participant the participant
 * @param entity the entity to be used
 * @param timestamp the unix timestamp of this discrete useData (start=end)
 * @param duration in seconds
 *
 * @return the useData Activity of the agent using the entity
 */
public Activity useRealWorldEntity(Participant participant, Entity entity, String timestamp, String duration) {

    Activity useEntity = new Activity();
    try {

        if (duration == null) {
            useEntity.activity = participant.agent.doDiscreteActivity("UseActivity_"
                    + UUID.randomUUID(), "Use " + entity.entity.getFriendlyName(), timestamp);
        } else {
            useEntity.activity = participant.agent.startActivity("UseActivity_"
                    + UUID.randomUUID(), "Use " + entity.entity.getFriendlyName(), timestamp);
            participant.agent.stopActivity(useEntity.activity, getEndTimestamp(timestamp, duration));
        }

        useEntity.activity.useEntity(entity.entity);
    } catch (DataFormatException | DatatypeConfigurationException | AlreadyBoundException e) {
        logger.error("Error creating \"use entity\" pattern", e);
    }
    return useEntity;
}
项目:EXPERImonitor    文件:ExperimediaFactory.java   
/**
 * Make the participant navigate the client
 *
 * @param participant the participant
 * @param client the application which the participant is using
 * @param timestamp the unix timestamp of this discrete activity (start=end)
 * @param duration in seconds
 * @return the activity of navigating
 */
public Activity navigateClient(Participant participant, Application client, String timestamp, String duration) {

    Activity navigate = new Activity();
    try {

        if (duration == null) {
            navigate.activity = participant.agent.doDiscreteActivity("NavigateClientActitivy_"
                    + UUID.randomUUID(), "Navigate " + client.entity.getFriendlyName(), timestamp);
        } else {
            navigate.activity = participant.agent.startActivity("NavigateClientActitivy_"
                    + UUID.randomUUID(), "Navigate " + client.entity.getFriendlyName(), timestamp);
            participant.agent.stopActivity(navigate.activity, getEndTimestamp(timestamp, duration));
        }

        navigate.activity.useEntity(client.entity);
    } catch (DataFormatException | DatatypeConfigurationException | AlreadyBoundException e) {
        logger.error("Error creating \"navigate client\" pattern", e);
    }
    return navigate;
}
项目:proactive-component-monitoring    文件:PADeployment.java   
/**
 * Registers locally the given VirtualNode in a registry such RMIRegistry or HTTP registry.
 * The VirtualNode to register must exist on the local runtime. This is done when using XML Deployment Descriptors
 * @param virtualNode the VirtualNode to register.
 * @param registrationProtocol The protocol used for registration or null in order to use the protocol used to start the jvm.
 * At this time RMI, HTTP, IBIS are supported. If set to null, the registration protocol will be set to the system property:
 * proactive.communication.protocol
 * @param replacePreviousBinding
 * @throws ProActiveException If the VirtualNode with the given name has not been yet activated or does not exist on the local runtime
 */
public static void registerVirtualNode(VirtualNode virtualNode, String registrationProtocol,
        boolean replacePreviousBinding) throws ProActiveException, AlreadyBoundException {
    if (!(virtualNode instanceof VirtualNodeImpl)) {
        throw new ProActiveException("Cannot register such virtualNode since it results from a lookup!");
    }
    if (registrationProtocol == null) {
        registrationProtocol = CentralPAPropertyRepository.PA_COMMUNICATION_PROTOCOL.getValue();
    }
    String virtualnodeName = virtualNode.getName();
    ProActiveRuntime part = RuntimeFactory.getProtocolSpecificRuntime(registrationProtocol);
    VirtualNodeInternal vn = part.getVirtualNode(virtualnodeName);
    if (vn == null) {
        throw new ProActiveException("VirtualNode " + virtualnodeName +
            " has not been yet activated or does not exist! Try to activate it first !");
    }
    part.registerVirtualNode(URIBuilder.appendVnSuffix(virtualnodeName), replacePreviousBinding);
}
项目:proactive-component-monitoring    文件:NodeFactory.java   
/** Creates a new node on the local ProActive runtime.
 * 
 * @param nodeName 
 *          name of the node to create. It musts comply to the following regular expression: "[a-zA-Z0-9_-]+"
 * @param replacePreviousBinding
 *          Should an already existing node with the same name be replaced or not           
 * @param psm
 *          A {@link ProActiveSecurityManager} or null
 * @param vnname
 *          A Virtual Node name or null
 * @return  the newly created node on the local JVM
 * @exception NodeException 
 *          if the node cannot be created or if the nodeName is invalid
 */
public static Node createLocalNode(String nodeName, boolean replacePreviousBinding,
        ProActiveSecurityManager psm, String vnname) throws NodeException, AlreadyBoundException {
    ProActiveRuntime proActiveRuntime;

    // Throws an Exception is the name is invalid
    checkNodeName(nodeName);

    if (logger.isDebugEnabled()) {
        logger.debug("NodeFactory: createNode(" + nodeName + ")");
    }

    if (vnname == null) {
        vnname = DEFAULT_VIRTUAL_NODE_NAME;
    }

    //NodeFactory factory = getFactory(protocol);
    //then create a node
    try {
        proActiveRuntime = RuntimeFactory.getDefaultRuntime();
        return proActiveRuntime.createLocalNode(nodeName, replacePreviousBinding, psm, vnname);
    } catch (Exception e) {
        throw new NodeException("Failed to create a local node. name=" + nodeName, e);
    }
}
项目:BaRMIe    文件:IllegalRegistryBind.java   
/*******************
 * Check if the given endpoint can be attacked.
 * 
 * This check is performed by executing a dummy attack against the
 * endpoint and observing the resulting exception.
 * 
 * @param ep An enumerated RMI endpoint.
 * @return True if we can attack it.
 ******************/
public boolean canAttackEndpoint(RMIEndpoint ep) {
    RMIBindExploitProxy proxy = null;
    Registry reg;

    //Execute a dummy attack
    try {
        //Start a bind exploit proxy
        proxy = new RMIBindExploitProxy(InetAddress.getByName(ep.getEndpoint().getHost()), ep.getEndpoint().getPort(), this._options, this._dummyPayload);
        proxy.startProxy();

        //Get a proxied RMI registry reference
        reg = LocateRegistry.getRegistry(proxy.getServerListenAddress().getHostAddress(), proxy.getServerListenPort());

        //Bind a dummy object in an attempt to trigger the vulnerability
        reg.bind(this.generateRandomString(), new BaRMIeBindExploit());
    } catch(BaRMIeException | UnknownHostException | RemoteException | AlreadyBoundException ex) {
        //An up to date RMI registry will, by default, reject the dummy object
        if(ex instanceof ServerException && ex.getCause() != null && ex.getCause() instanceof UnmarshalException && ex.getCause().getCause() != null && ex.getCause().getCause() instanceof InvalidClassException) {
            //Check for "filter status: REJECTED"
            if(ex.getCause().getCause().toString().contains("filter status: REJECTED")) {
                //Test payload was filtered, likely this attack isn't possible
                return false;
            }
        }
    } finally {
        //Stop the proxy
        if(proxy != null) {
            proxy.stopProxy(true);
        }
    }

    //In all other cases we should be able to attack the registry
    return true;
}
项目:OpenJSharp    文件:Activation.java   
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);
    }
}
项目:jdk8u-jdk    文件:Activation.java   
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);
    }
}
项目:jdk8u-jdk    文件:RegistryFilterTest.java   
@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");
    }
}
项目:jdk8u-jdk    文件:RegistryFilterTest.java   
@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");
    }
}
项目:openjdk-jdk10    文件:Activation.java   
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);
    }
}
项目:openjdk-jdk10    文件:RegistryFilterTest.java   
@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");
    }
}
项目:openjdk-jdk10    文件:RegistryFilterTest.java   
@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");
    }
}
项目:openjdk-jdk10    文件:RegistryFilterTest.java   
@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);
    }
}
项目:openjdk-jdk10    文件:RegistryFilterTest.java   
@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
    }
}
项目:openNaEF    文件:DistributedTransactionService.java   
Impl(int port, String serviceName, String[] acceptableTefServiceIds)
        throws RemoteException, AlreadyBoundException {
    synchronized (Impl.class) {
        if (instance__ != null) {
            throw new IllegalStateException();
        } else {
            instance__ = this;
        }
    }

    Logs logs = new Logs(System.currentTimeMillis(), new File("."), "logs");
    transactionCoordinationLogger_ = logs.createLogger("distributed-transactions");

    tefServices_ = new HashMap<String, TefServiceProxy>();
    for (String acceptableTefServiceId : acceptableTefServiceIds) {
        tefServices_.put(acceptableTefServiceId, null);
    }

    tefServiceIndexes_ = new HashMap<String, Integer>();
    for (int i = 0; i < acceptableTefServiceIds.length; i++) {
        tefServiceIndexes_.put(acceptableTefServiceIds[i], new Integer(i));
    }

    try {
        history_
                = restoreTxHistory(transactionCoordinationLogger_.getFile().getParentFile());
    } catch (IOException ioe) {
        throw new RuntimeException(ioe);
    }

    System.out.println("restored: " + history_.size());
    System.gc();
    long memoryUsage
            = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
    System.out.println("memory: " + NumberFormat.getInstance().format(memoryUsage));

    Registry registry = LocateRegistry.createRegistry(port);
    registry.bind(serviceName, this);
}
项目:openjdk9    文件:Activation.java   
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);
    }
}
项目:topicrawler    文件:AbstractStringProvider.java   
public Registry publish(Registry registry, String identifier, int port) throws RemoteException, AccessException, AlreadyBoundException {
    final StringProviderMXBean stub = (StringProviderMXBean) UnicastRemoteObject.exportObject(this, port);
    // RemoteServer.setLog(System.out);
    // Bind the remote object's stub in the registry
    registry.bind(identifier, stub);
    LOG.info("Stringprovider service '{}' published on port {}.", identifier, port);
    return registry;
}
项目:topicrawler    文件:LanguageModelServer.java   
public void publish(Registry registry, String identifier, int port) throws RemoteException, AlreadyBoundException {
    LOG.info("Trying to publish Language model service '{}' on port {}.", identifier, port);
    @SuppressWarnings("unchecked")
    final LanguageModelServerMBean<String> stub = (LanguageModelServerMBean<String>) UnicastRemoteObject.exportObject(this, port);
    // RemoteServer.setLog(System.out);
    // Bind the remote object's stub in the registry
    registry.bind(identifier, stub);
    LOG.info("Language model service '{}' published on port {}.", identifier, port);
}
项目:CanReg5    文件:ServerLauncher.java   
/**
 * 
 * @param args
 */
public static void main(String[] args) {
    try {
        if (args.length >= 1) {
            start("localhost", args[0], 1199);
        }
    } catch (AlreadyBoundException ex) {
        Logger.getLogger(ServerLauncher.class.getName()).log(Level.SEVERE, null, ex);
    }
}
项目:jas    文件:AbsActorRef.java   
/**
 * 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();
        }
    }
}
项目:gemfirexd-oss    文件:DUnitLauncher.java   
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);
  }
项目:jdk8u_jdk    文件:Activation.java   
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);
    }
}
项目:jdk8u_jdk    文件:RegistryFilterTest.java   
@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");
    }
}
项目:jdk8u_jdk    文件:RegistryFilterTest.java   
@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");
    }
}
项目:SilverKing    文件:DHTRingMaster.java   
public DHTRingMaster(ZooKeeperConfig zkConfig, String dhtName, 
                      long intervalMillis, Mode mode, boolean enableLogging) throws IOException, KeeperException, AlreadyBoundException {
    mc = new MetaClient(dhtName, zkConfig);
    convergenceControllers = new ConcurrentHashMap<>();
    this.intervalMillis = intervalMillis;
    this.mode = mode;
    mp = mc.getMetaPaths();
    this.zkConfig = zkConfig;
    convergenceLock = new ReentrantLock();
    /*
     * The below VersionWatcher watches the DHTConfiguration for changes. Whenever a new DHTConfiguration
     * is observed, a new RingConfigWatcher is started.
     */
    dhtConfigWatcher = new DHTConfigurationWatcher(zkConfig, dhtName, intervalMillis, enableLogging);
    this.enableLogging = enableLogging;

    dhtRingCurTargetZK = new DHTRingCurTargetZK(mc, dhtConfig);

    ringChangedWorker = new RingChangedWorker();
    recoverDataWorker = new RecoverDataWorker();

    dhtMetaReader = new DHTMetaReader(zkConfig, dhtName, enableLogging);

    mgBase = new MessageGroupBase(mgBasePort, this, SystemTimeUtil.systemTimeSource, null, 
                                  queueLimit, numSelectorControllers, selectorControllerClass);
    mode = Mode.Automatic;
    new RingMasterControlImpl(this);
}