Examples of ProtocolPolicy


Examples of org.apache.yoko.orb.OB.ProtocolPolicy

        }

        //
        // Get the protocol policy, if any
        //
        ProtocolPolicy protocolPolicy = null;
        for (int i = 0; i < policies.length; i++) {
            if (policies[i].policy_type() == PROTOCOL_POLICY_ID.value) {
                protocolPolicy = ProtocolPolicyHelper.narrow(policies[i]);
                break;
            }
        }

        //
        // check whether the BiDir policy is enabled
        //
        boolean enableBidir = false;
        for (int i = 0; i < policies.length; i++) {
            if (policies[i].policy_type() == org.omg.BiDirPolicy.BIDIRECTIONAL_POLICY_TYPE.value) {
                org.omg.BiDirPolicy.BidirectionalPolicy p = org.omg.BiDirPolicy.BidirectionalPolicyHelper
                        .narrow(policies[i]);
                if (p.value() == org.omg.BiDirPolicy.BOTH.value)
                    enableBidir = true;
            }
        }

        java.util.Vector pairs = new java.util.Vector();

        //
        // First try to create CollocatedClients
        //
        org.apache.yoko.orb.OBPortableServer.POAManagerFactory pmFactory = orbInstance_
                .getPOAManagerFactory();
        org.omg.PortableServer.POAManager[] managers = pmFactory.list();

        for (int i = 0; i < managers.length; i++) {
            try {
                org.apache.yoko.orb.OCI.Acceptor[] acceptors = ((org.apache.yoko.orb.OBPortableServer.POAManager) managers[i])
                        .get_acceptors();

                boolean local = false;
                for (int j = 0; j < acceptors.length && !local; j++) {
                    org.apache.yoko.orb.OCI.ProfileInfo[] localProfileInfos = acceptors[j]
                            .get_local_profiles(ior);
                    if (localProfileInfos.length > 0)
                        local = true;
                }

                if (local) {
                    //
                    // Retrieve the CollocatedServer from the POAManager
                    //
                    org.apache.yoko.orb.OBPortableServer.POAManager_impl manager = (org.apache.yoko.orb.OBPortableServer.POAManager_impl) managers[i];
                    CollocatedServer collocatedServer = manager
                            ._OB_getCollocatedServer();

                    //
                    // Create a new CollocatedClient and add the new client to
                    // both the list of all clients, and the list of clients
                    // that is returned
                    //
                    CodeConverters conv = new CodeConverters();
                    Client client = new CollocatedClient(collocatedServer,
                            concModel_, conv);
                    allClients_.addElement(client);

                    org.apache.yoko.orb.OCI.ProfileInfo[] profileInfos = client
                            .getUsableProfiles(ior, policies);
                    for (int j = 0; j < profileInfos.length; j++) {
                        ClientProfilePair pair = new ClientProfilePair();
                        pair.client = client;
                        pair.profile = profileInfos[j];
                        pairs.addElement(pair);
                    }

                    //
                    // TODO: Introduce reusable CollocatedClients?
                    //
                }
            } catch (org.omg.PortableServer.POAManagerPackage.AdapterInactive ex) {
                // Ignore
            }
        }

        //
        // If no private clients are requested, add all existing reusable
        // clients which are usable for the given IOR and policies
        //
        if (!privateClients) {
            for (int i = 0; i < reusableClients_.size(); i++) {
                Client reusableClient = (Client) reusableClients_.elementAt(i);

                //
                // Skip any client whose protocol is not present in the
                // protocol list
                //
                if (protocolPolicy != null) {
                    org.apache.yoko.orb.OCI.ConnectorInfo info = reusableClient
                            .connectorInfo();
                    if (info != null)
                        if (!protocolPolicy.contains(info.id()))
                            continue;
                }

                org.apache.yoko.orb.OCI.ProfileInfo[] profileInfos = reusableClient
                        .getUsableProfiles(ior, policies);
                for (int j = 0; j < profileInfos.length; j++) {
                    ClientProfilePair pair = new ClientProfilePair();
                    pair.client = reusableClient;
                    pair.profile = profileInfos[j];
                    pairs.addElement(pair);
                }
            }
        }

        //
        // Finally, create new GIOPClients for all connectors we can get
        //
        org.apache.yoko.orb.OCI.ConFactoryRegistry conFactoryRegistry = orbInstance_
                .getConFactoryRegistry();
        org.apache.yoko.orb.OCI.ConFactory[] factories = conFactoryRegistry
                .get_factories();
        for (int i = 0; i < factories.length; i++) {
            org.apache.yoko.orb.OCI.Connector[] connectors = factories[i]
                    .create_connectors(ior, policies);
            for (int j = 0; j < connectors.length; j++) {
                //
                // Skip any connector whose protocol is not present in the
                // protocol list
                //
                if (protocolPolicy != null)
                    if (!protocolPolicy.contains(connectors[j].id()))
                        continue;

                //
                // Get all usable profiles
                //
                org.apache.yoko.orb.OCI.ProfileInfo[] profileInfos = connectors[j]
                        .get_usable_profiles(ior, policies);
                Assert._OB_assert(profileInfos.length >= 1);

                //
                // Create a new GIOPClient for each usable profile, and set
                // the concurrency model and code converters. Filter out
                // clients that are equivalent to other clients we already
                // have.
                //
                for (int k = 0; k < profileInfos.length; k++) {
                    CodeConverters conv = CodeSetUtil.getCodeConverters(
                            orbInstance_, profileInfos[k]);

                    Client client = new GIOPClient(orbInstance_, connectors[j],
                            concModel_, conv, enableBidir);

                    if (!pairs.isEmpty()) {
                        int l;

                        for (l = 0; l < pairs.size(); l++) {
                            ClientProfilePair pair = (ClientProfilePair) pairs
                                    .elementAt(l);
                            if (pair.client.equal(client))
                                break;
                        }

                        if (l != pairs.size()) {
                            client.destroy(false);
                            continue;
                        }
                    }

                    //
                    // Add the new client to the list of all clients
                    //
                    allClients_.addElement(client);

                    //
                    // Add client/profile pairs
                    //
                    org.apache.yoko.orb.OCI.ProfileInfo[] clientProfileInfos = client
                            .getUsableProfiles(ior, policies);
                    for (int l = 0; l < clientProfileInfos.length; l++) {
                        ClientProfilePair pair = new ClientProfilePair();
                        pair.client = client;
                        pair.profile = clientProfileInfos[l];
                        pairs.addElement(pair);
                    }

                    //
                    // If no private clients have been requested, also add the
                    // client to the list of existing reusable clients
                    //
                    if (!privateClients)
                        reusableClients_.addElement(client);
                }
            }
        }

        //
        // If there is a protocol policy, then the client/profile pairs
        // have already been filtered. Now we need to sort the pairs in
        // the order specified by the policy. Note that clients which
        // do not have a ConnectorInfo are assumed to be local, and will
        // be ordered before the other clients.
        //
        if (!pairs.isEmpty() && protocolPolicy != null) {
            String[] protocols = protocolPolicy.value();

            java.util.Vector newPairs = new java.util.Vector();

            //
            // First, add any pairs whose clients do not have ConnectorInfo
View Full Code Here

Examples of org.apache.yoko.orb.OB.ProtocolPolicy

        }

        //
        // Get the protocol policy, if any
        //
        ProtocolPolicy protocolPolicy = null;
        for (int i = 0; i < policies.length; i++) {
            if (policies[i].policy_type() == PROTOCOL_POLICY_ID.value) {
                protocolPolicy = ProtocolPolicyHelper.narrow(policies[i]);
                break;
            }
        }

        //
        // check whether the BiDir policy is enabled
        //
        boolean enableBidir = false;
        for (int i = 0; i < policies.length; i++) {
            if (policies[i].policy_type() == org.omg.BiDirPolicy.BIDIRECTIONAL_POLICY_TYPE.value) {
                org.omg.BiDirPolicy.BidirectionalPolicy p = org.omg.BiDirPolicy.BidirectionalPolicyHelper
                        .narrow(policies[i]);
                if (p.value() == org.omg.BiDirPolicy.BOTH.value)
                    enableBidir = true;
            }
        }

        java.util.Vector pairs = new java.util.Vector();

        //
        // First try to create CollocatedClients
        //
        org.apache.yoko.orb.OBPortableServer.POAManagerFactory pmFactory = orbInstance_
                .getPOAManagerFactory();
        org.omg.PortableServer.POAManager[] managers = pmFactory.list();

        for (int i = 0; i < managers.length; i++) {
            try {
                org.apache.yoko.orb.OCI.Acceptor[] acceptors = ((org.apache.yoko.orb.OBPortableServer.POAManager) managers[i])
                        .get_acceptors();

                boolean local = false;
                for (int j = 0; j < acceptors.length && !local; j++) {
                    org.apache.yoko.orb.OCI.ProfileInfo[] localProfileInfos = acceptors[j]
                            .get_local_profiles(ior);
                    if (localProfileInfos.length > 0)
                        local = true;
                }

                if (local) {
                    //
                    // Retrieve the CollocatedServer from the POAManager
                    //
                    org.apache.yoko.orb.OBPortableServer.POAManager_impl manager = (org.apache.yoko.orb.OBPortableServer.POAManager_impl) managers[i];
                    CollocatedServer collocatedServer = manager
                            ._OB_getCollocatedServer();

                    //
                    // Create a new CollocatedClient and add the new client to
                    // both the list of all clients, and the list of clients
                    // that is returned
                    //
                    CodeConverters conv = new CodeConverters();
                    Client client = new CollocatedClient(collocatedServer,
                            concModel_, conv);
                    allClients_.addElement(client);

                    org.apache.yoko.orb.OCI.ProfileInfo[] profileInfos = client
                            .getUsableProfiles(ior, policies);
                    for (int j = 0; j < profileInfos.length; j++) {
                        ClientProfilePair pair = new ClientProfilePair();
                        pair.client = client;
                        pair.profile = profileInfos[j];
                        pairs.addElement(pair);
                    }

                    //
                    // TODO: Introduce reusable CollocatedClients?
                    //
                }
            } catch (org.omg.PortableServer.POAManagerPackage.AdapterInactive ex) {
                // Ignore
            }
        }

        //
        // If no private clients are requested, add all existing reusable
        // clients which are usable for the given IOR and policies
        //
        if (!privateClients) {
            for (int i = 0; i < reusableClients_.size(); i++) {
                Client reusableClient = (Client) reusableClients_.elementAt(i);

                //
                // Skip any client whose protocol is not present in the
                // protocol list
                //
                if (protocolPolicy != null) {
                    org.apache.yoko.orb.OCI.ConnectorInfo info = reusableClient
                            .connectorInfo();
                    if (info != null)
                        if (!protocolPolicy.contains(info.id()))
                            continue;
                }

                org.apache.yoko.orb.OCI.ProfileInfo[] profileInfos = reusableClient
                        .getUsableProfiles(ior, policies);
                for (int j = 0; j < profileInfos.length; j++) {
                    ClientProfilePair pair = new ClientProfilePair();
                    pair.client = reusableClient;
                    pair.profile = profileInfos[j];
                    pairs.addElement(pair);
                }
            }
        }

        //
        // Finally, create new GIOPClients for all connectors we can get
        //
        org.apache.yoko.orb.OCI.ConFactoryRegistry conFactoryRegistry = orbInstance_
                .getConFactoryRegistry();
        org.apache.yoko.orb.OCI.ConFactory[] factories = conFactoryRegistry
                .get_factories();
        for (int i = 0; i < factories.length; i++) {
            org.apache.yoko.orb.OCI.Connector[] connectors = factories[i]
                    .create_connectors(ior, policies);
            for (int j = 0; j < connectors.length; j++) {
                //
                // Skip any connector whose protocol is not present in the
                // protocol list
                //
                if (protocolPolicy != null)
                    if (!protocolPolicy.contains(connectors[j].id()))
                        continue;

                //
                // Get all usable profiles
                //
                org.apache.yoko.orb.OCI.ProfileInfo[] profileInfos = connectors[j]
                        .get_usable_profiles(ior, policies);
                Assert._OB_assert(profileInfos.length >= 1);

                //
                // Create a new GIOPClient for each usable profile, and set
                // the concurrency model and code converters. Filter out
                // clients that are equivalent to other clients we already
                // have.
                //
                for (int k = 0; k < profileInfos.length; k++) {
                    CodeConverters conv = CodeSetUtil.getCodeConverters(
                            orbInstance_, profileInfos[k]);

                    Client client = new GIOPClient(orbInstance_, connectors[j],
                            concModel_, conv, enableBidir);

                    if (!pairs.isEmpty()) {
                        int l;

                        for (l = 0; l < pairs.size(); l++) {
                            ClientProfilePair pair = (ClientProfilePair) pairs
                                    .elementAt(l);
                            if (pair.client.equal(client))
                                break;
                        }

                        if (l != pairs.size()) {
                            client.destroy(false);
                            continue;
                        }
                    }

                    //
                    // Add the new client to the list of all clients
                    //
                    allClients_.addElement(client);

                    //
                    // Add client/profile pairs
                    //
                    org.apache.yoko.orb.OCI.ProfileInfo[] clientProfileInfos = client
                            .getUsableProfiles(ior, policies);
                    for (int l = 0; l < clientProfileInfos.length; l++) {
                        ClientProfilePair pair = new ClientProfilePair();
                        pair.client = client;
                        pair.profile = clientProfileInfos[l];
                        pairs.addElement(pair);
                    }

                    //
                    // If no private clients have been requested, also add the
                    // client to the list of existing reusable clients
                    //
                    if (!privateClients)
                        reusableClients_.addElement(client);
                }
            }
        }

        //
        // If there is a protocol policy, then the client/profile pairs
        // have already been filtered. Now we need to sort the pairs in
        // the order specified by the policy. Note that clients which
        // do not have a ConnectorInfo are assumed to be local, and will
        // be ordered before the other clients.
        //
        if (!pairs.isEmpty() && protocolPolicy != null) {
            String[] protocols = protocolPolicy.value();

            java.util.Vector newPairs = new java.util.Vector();

            //
            // First, add any pairs whose clients do not have ConnectorInfo
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.