Example usage for javax.xml.registry ConnectionFactory createConnection

List of usage examples for javax.xml.registry ConnectionFactory createConnection

Introduction

In this page you can find the example usage for javax.xml.registry ConnectionFactory createConnection.

Prototype

public abstract Connection createConnection() throws JAXRException;

Source Link

Document

Create a named connection.

Usage

From source file:JAXRGetMyObjects.java

/**
     * Establishes a connection to a registry.
     *// w  w  w  .j a v  a  2s  .c om
     * @param queryUrl        the URL of the query registry
     * @param publishUrl        the URL of the publish registry
     */
    public void makeConnection(String queryUrl, String publishUrl) {
        /*
         * Specify proxy information in case you
         *  are going beyond your firewall.
         */
        ResourceBundle bundle = ResourceBundle.getBundle("JAXRExamples");
        String httpProxyHost = bundle.getString("http.proxyHost");
        String httpProxyPort = bundle.getString("http.proxyPort");
        String httpsProxyHost = bundle.getString("https.proxyHost");
        String httpsProxyPort = bundle.getString("https.proxyPort");

        /*
         * Define connection configuration properties.
         * For simple queries, you need the query URL.
         */
        Properties props = new Properties();
        props.setProperty("javax.xml.registry.queryManagerURL", queryUrl);
        props.setProperty("javax.xml.registry.lifeCycleManagerURL", publishUrl);
        props.setProperty("com.sun.xml.registry.http.proxyHost", httpProxyHost);
        props.setProperty("com.sun.xml.registry.http.proxyPort", httpProxyPort);
        props.setProperty("com.sun.xml.registry.https.proxyHost", httpsProxyHost);
        props.setProperty("com.sun.xml.registry.https.proxyPort", httpsProxyPort);

        try {
            // Create the connection, passing it the 
            // configuration properties
            ConnectionFactory factory = ConnectionFactory.newInstance();
            factory.setProperties(props);
            connection = factory.createConnection();
            System.out.println("Created connection to registry");
        } catch (Exception e) {
            e.printStackTrace();

            if (connection != null) {
                try {
                    connection.close();
                } catch (JAXRException je) {
                }
            }
        }
    }

From source file:JAXRPublishConcept.java

/**
     * Establishes a connection to a registry.
     */* w  ww  .  j  a v a 2 s .  c om*/
     * @param queryUrl        the URL of the query registry
     * @param publishUrl        the URL of the publish registry
     */
    public void makeConnection(String queryUrl, String publishUrl) {
        /*
         * Specify proxy information in case you
         *  are going beyond your firewall.
         */
        ResourceBundle bundle = ResourceBundle.getBundle("JAXRExamples");
        String httpProxyHost = bundle.getString("http.proxyHost");
        String httpProxyPort = bundle.getString("http.proxyPort");
        String httpsProxyHost = bundle.getString("https.proxyHost");
        String httpsProxyPort = bundle.getString("https.proxyPort");

        /*
         * Define connection configuration properties.
         * To publish, you need both the query URL and the
         * publish URL.
         */
        Properties props = new Properties();
        props.setProperty("javax.xml.registry.queryManagerURL", queryUrl);
        props.setProperty("javax.xml.registry.lifeCycleManagerURL", publishUrl);
        props.setProperty("com.sun.xml.registry.http.proxyHost", httpProxyHost);
        props.setProperty("com.sun.xml.registry.http.proxyPort", httpProxyPort);
        props.setProperty("com.sun.xml.registry.https.proxyHost", httpsProxyHost);
        props.setProperty("com.sun.xml.registry.https.proxyPort", httpsProxyPort);

        try {
            // Create the connection, passing it the 
            // configuration properties
            ConnectionFactory factory = ConnectionFactory.newInstance();
            factory.setProperties(props);
            connection = factory.createConnection();
            System.out.println("Created connection to registry");
        } catch (Exception e) {
            e.printStackTrace();

            if (connection != null) {
                try {
                    connection.close();
                } catch (JAXRException je) {
                }
            }
        }
    }

From source file:JAXRSaveClassificationScheme.java

/**
     * Establishes a connection to a registry.
     *//from w w w .  j a v a 2  s.c  o  m
     * @param queryUrl        the URL of the query registry
     * @param publishUrl        the URL of the publish registry
     */
    public void makeConnection(String queryUrl, String publishUrl) {
        /*
         * Specify proxy information in case you
         *  are going beyond your firewall.
         */
        ResourceBundle bundle = ResourceBundle.getBundle("JAXRExamples");
        String httpProxyHost = bundle.getString("http.proxyHost");
        String httpProxyPort = bundle.getString("http.proxyPort");
        String httpsProxyHost = bundle.getString("https.proxyHost");
        String httpsProxyPort = bundle.getString("https.proxyPort");

        /*
         * Define connection configuration properties.
         * To delete, you need both the query URL and the
         * publish URL.
         */
        Properties props = new Properties();
        props.setProperty("javax.xml.registry.queryManagerURL", queryUrl);
        props.setProperty("javax.xml.registry.lifeCycleManagerURL", publishUrl);
        props.setProperty("com.sun.xml.registry.http.proxyHost", httpProxyHost);
        props.setProperty("com.sun.xml.registry.http.proxyPort", httpProxyPort);
        props.setProperty("com.sun.xml.registry.https.proxyHost", httpsProxyHost);
        props.setProperty("com.sun.xml.registry.https.proxyPort", httpsProxyPort);

        try {
            // Create the connection, passing it the 
            // configuration properties
            ConnectionFactory factory = ConnectionFactory.newInstance();
            factory.setProperties(props);
            connection = factory.createConnection();
            System.out.println("Created connection to registry");
        } catch (Exception e) {
            e.printStackTrace();

            if (connection != null) {
                try {
                    connection.close();
                } catch (JAXRException je) {
                }
            }
        }
    }

From source file:JAXRQuery.java

/**
     * Establishes a connection to a registry.
     *//from  w w w .ja  v a2  s  . c  o m
     * @param queryUrl        the URL of the query registry
     * @param publishUrl        the URL of the publish registry
     */
    public void makeConnection(String queryUrl, String publishUrl) {
        /*
         * Specify proxy information in case you
         *  are going beyond your firewall.
         */
        ResourceBundle registryBundle = ResourceBundle.getBundle("JAXRExamples");
        String httpProxyHost = registryBundle.getString("http.proxyHost");
        String httpProxyPort = registryBundle.getString("http.proxyPort");

        /*
         * Define connection configuration properties.
         * For simple queries, you need the query URL.
         */
        Properties props = new Properties();
        props.setProperty("javax.xml.registry.queryManagerURL", queryUrl);
        props.setProperty("com.sun.xml.registry.http.proxyHost", httpProxyHost);
        props.setProperty("com.sun.xml.registry.http.proxyPort", httpProxyPort);

        try {
            // Create the connection, passing it the 
            // configuration properties
            ConnectionFactory factory = ConnectionFactory.newInstance();
            factory.setProperties(props);
            connection = factory.createConnection();
            System.out.println("Created connection to registry");
        } catch (Exception e) {
            e.printStackTrace();

            if (connection != null) {
                try {
                    connection.close();
                } catch (JAXRException je) {
                }
            }
        }
    }

From source file:JAXRQueryByNAICSClassification.java

/**
     * Establishes a connection to a registry.
     *//w  w w. j av  a2  s  .  com
     * @param queryUrl        the URL of the query registry
     * @param publishUrl        the URL of the publish registry
     */
    public void makeConnection(String queryUrl, String publishUrl) {
        /*
         * Specify proxy information in case you
         *  are going beyond your firewall.
         */
        ResourceBundle bundle = ResourceBundle.getBundle("JAXRExamples");
        String httpProxyHost = bundle.getString("http.proxyHost");
        String httpProxyPort = bundle.getString("http.proxyPort");
        String httpsProxyHost = bundle.getString("https.proxyHost");
        String httpsProxyPort = bundle.getString("https.proxyPort");

        /*
         * Define connection configuration properties.
         * For simple queries, you need the query URL.
         * To use a life cycle manager, you need the publish URL.
         */
        Properties props = new Properties();
        props.setProperty("javax.xml.registry.queryManagerURL", queryUrl);
        props.setProperty("javax.xml.registry.lifeCycleManagerURL", publishUrl);

        props.setProperty("com.sun.xml.registry.http.proxyHost", httpProxyHost);
        props.setProperty("com.sun.xml.registry.http.proxyPort", httpProxyPort);
        props.setProperty("com.sun.xml.registry.https.proxyHost", httpsProxyHost);
        props.setProperty("com.sun.xml.registry.https.proxyPort", httpsProxyPort);

        try {
            // Create the connection, passing it the 
            // configuration properties
            ConnectionFactory factory = ConnectionFactory.newInstance();
            factory.setProperties(props);
            connection = factory.createConnection();
            System.out.println("Created connection to registry");
        } catch (Exception e) {
            e.printStackTrace();

            if (connection != null) {
                try {
                    connection.close();
                } catch (JAXRException je) {
                }
            }
        }
    }

From source file:JAXRQueryByWSDLClassification.java

/**
     * Establishes a connection to a registry.
     */*w ww .  j a  v a 2  s. c  o m*/
     * @param queryUrl        the URL of the query registry
     * @param publishUrl        the URL of the publish registry
     */
    public void makeConnection(String queryUrl, String publishUrl) {
        /*
         * Specify proxy information in case you
         *  are going beyond your firewall.
         */
        ResourceBundle bundle = ResourceBundle.getBundle("JAXRExamples");
        String httpProxyHost = bundle.getString("http.proxyHost");
        String httpProxyPort = bundle.getString("http.proxyPort");
        String httpsProxyHost = bundle.getString("https.proxyHost");
        String httpsProxyPort = bundle.getString("https.proxyPort");

        /*
         * Define connection configuration properties.
         * For simple queries, you need the query URL.
         * To use a life cycle manager, you need the publish URL.
         */
        Properties props = new Properties();
        props.setProperty("javax.xml.registry.queryManagerURL", queryUrl);
        props.setProperty("javax.xml.registry.lifeCycleManagerURL", publishUrl);
        props.setProperty("com.sun.xml.registry.http.proxyHost", httpProxyHost);
        props.setProperty("com.sun.xml.registry.http.proxyPort", httpProxyPort);
        props.setProperty("com.sun.xml.registry.https.proxyHost", httpsProxyHost);
        props.setProperty("com.sun.xml.registry.https.proxyPort", httpsProxyPort);

        try {
            // Create the connection, passing it the 
            // configuration properties
            ConnectionFactory factory = ConnectionFactory.newInstance();
            factory.setProperties(props);
            connection = factory.createConnection();
            System.out.println("Created connection to registry");
        } catch (Exception e) {
            e.printStackTrace();

            if (connection != null) {
                try {
                    connection.close();
                } catch (JAXRException je) {
                }
            }
        }
    }

From source file:it.cnr.icar.eric.client.ui.swing.JAXRClient.java

/**
 * Makes a connection to a JAXR Registry.
 *
 * @param url The URL of the registry.//from w w  w. j  a v  a2  s .  c o  m
 * @return boolean true if connected, false otherwise.
 */
public synchronized boolean createConnection(String url) {
    try {
        if (!RegistryBrowser.localCall) {
            (new URL(url)).openStream().read();
        }

        Thread.currentThread().setContextClassLoader(RegistryBrowser.getInstance().classLoader);

        ProviderProperties.getInstance().put("javax.xml.registry.queryManagerURL", url);

        ConnectionFactory connFactory = JAXRUtility.getConnectionFactory();

        connection = (it.cnr.icar.eric.client.xml.registry.ConnectionImpl) connFactory.createConnection();
        RegistryService service = connection.getRegistryService();
        bqm = service.getBusinessQueryManager();
        dqm = (it.cnr.icar.eric.client.xml.registry.DeclarativeQueryManagerImpl) service
                .getDeclarativeQueryManager();
        lcm = (it.cnr.icar.eric.client.xml.registry.BusinessLifeCycleManagerImpl) service
                .getBusinessLifeCycleManager();

        lmm = connection.getLoginModuleManager();
        lmm.setParentFrame(RegistryBrowser.getInstance());
        connected = true;
    } catch (final JAXRException e) {
        connected = false;
        String msg = JavaUIResourceBundle.getInstance().getString("message.error.failedConnecting",
                new String[] { url, e.getLocalizedMessage() });
        log.error(msg, e);
        RegistryBrowser.displayError(msg, e);
    } catch (MalformedURLException e) {
        connected = false;
        String msg = JavaUIResourceBundle.getInstance().getString("message.error.failedConnecting",
                new String[] { url, e.getLocalizedMessage() });
        log.error(msg, e);
        RegistryBrowser.displayError(msg, e);
    } catch (IOException e) {
        connected = false;
        String msg = JavaUIResourceBundle.getInstance().getString("message.error.failedConnecting",
                new String[] { url, e.getLocalizedMessage() });
        log.error(msg, e);
        RegistryBrowser.displayError(msg, e);
    }
    return connected;
}

From source file:JAXRQueryPostal.java

/**
     * Establishes a connection to a registry.
     *//  w w w . ja v  a2s. co m
     * @param queryUrl        the URL of the query registry
     * @param publishUrl        the URL of the publish registry
     * @param uuidString        the UUID string of the postal address scheme
     */
    public void makeConnection(String queryUrl, String publishUrl, String uuidString) {
        /*
         * Specify proxy information in case you
         *  are going beyond your firewall.
         */
        ResourceBundle bundle = ResourceBundle.getBundle("JAXRExamples");
        String httpProxyHost = bundle.getString("http.proxyHost");
        String httpProxyPort = bundle.getString("http.proxyPort");
        String userTaxonomyFilenames = bundle.getString("postal.taxonomy.filenames");

        /*
         * Define connection configuration properties.
         * For simple queries, you need the query URL.
         */
        Properties props = new Properties();
        props.setProperty("javax.xml.registry.queryManagerURL", queryUrl);
        props.setProperty("com.sun.xml.registry.http.proxyHost", httpProxyHost);
        props.setProperty("com.sun.xml.registry.http.proxyPort", httpProxyPort);

        // Define the taxonomy XML file (postalconcepts.xml)
        props.setProperty("com.sun.xml.registry.userTaxonomyFilenames", userTaxonomyFilenames);

        // Set properties for postal address mapping: postal address
        //  classification scheme and mapping to JAXR scheme
        props.setProperty("javax.xml.registry.postalAddressScheme", uuidString);
        props.setProperty("javax.xml.registry.semanticEquivalences",
                "urn:uuid:PostalAddressAttributes/StreetNumber," + "urn:" + uuidString + "/MyStreetNumber|"
                        + "urn:uuid:PostalAddressAttributes/Street," + "urn:" + uuidString + "/MyStreet|"
                        + "urn:uuid:PostalAddressAttributes/City," + "urn:" + uuidString + "/MyCity|"
                        + "urn:uuid:PostalAddressAttributes/State," + "urn:" + uuidString + "/MyState|"
                        + "urn:uuid:PostalAddressAttributes/PostalCode," + "urn:" + uuidString + "/MyPostalCode|"
                        + "urn:uuid:PostalAddressAttributes/Country," + "urn:" + uuidString + "/MyCountry");

        try {
            // Create the connection, passing it the 
            // configuration properties
            ConnectionFactory factory = ConnectionFactory.newInstance();
            factory.setProperties(props);
            connection = factory.createConnection();
            System.out.println("Created connection to registry");
        } catch (Exception e) {
            e.printStackTrace();

            if (connection != null) {
                try {
                    connection.close();
                } catch (JAXRException je) {
                }
            }
        }
    }

From source file:JAXRPublishPostal.java

/**
     * Establishes a connection to a registry.
     */*ww w.jav  a 2s. co m*/
     * @param queryUrl        the URL of the query registry
     * @param publishUrl        the URL of the publish registry
     */
    public void makeConnection(String queryUrl, String publishUrl, String uuidString) {
        /*
         * Specify proxy information in case you
         *  are going beyond your firewall.
         */
        ResourceBundle bundle = ResourceBundle.getBundle("JAXRExamples");
        String httpProxyHost = bundle.getString("http.proxyHost");
        String httpProxyPort = bundle.getString("http.proxyPort");
        String httpsProxyHost = bundle.getString("https.proxyHost");
        String httpsProxyPort = bundle.getString("https.proxyPort");
        String userTaxonomyFilenames = bundle.getString("postal.taxonomy.filenames");

        /*
         * Define connection configuration properties.
         * To publish, you need both the query URL and the
         * publish URL.
         */
        Properties props = new Properties();
        props.setProperty("javax.xml.registry.queryManagerURL", queryUrl);
        props.setProperty("javax.xml.registry.lifeCycleManagerURL", publishUrl);
        props.setProperty("com.sun.xml.registry.http.proxyHost", httpProxyHost);
        props.setProperty("com.sun.xml.registry.http.proxyPort", httpProxyPort);
        props.setProperty("com.sun.xml.registry.https.proxyHost", httpsProxyHost);
        props.setProperty("com.sun.xml.registry.https.proxyPort", httpsProxyPort);

        // Define the taxonomy XML file (postalconcepts.xml)
        props.setProperty("com.sun.xml.registry.userTaxonomyFilenames", userTaxonomyFilenames);

        // Set properties for postal address mapping using my scheme
        props.setProperty("javax.xml.registry.postalAddressScheme", uuidString);
        props.setProperty("javax.xml.registry.semanticEquivalences",
                "urn:uuid:PostalAddressAttributes/StreetNumber," + "urn:" + uuidString + "/MyStreetNumber|"
                        + "urn:uuid:PostalAddressAttributes/Street," + "urn:" + uuidString + "/MyStreet|"
                        + "urn:uuid:PostalAddressAttributes/City," + "urn:" + uuidString + "/MyCity|"
                        + "urn:uuid:PostalAddressAttributes/State," + "urn:" + uuidString + "/MyState|"
                        + "urn:uuid:PostalAddressAttributes/PostalCode," + "urn:" + uuidString + "/MyPostalCode|"
                        + "urn:uuid:PostalAddressAttributes/Country," + "urn:" + uuidString + "/MyCountry");

        try {
            // Create the connection, passing it the 
            // configuration properties
            ConnectionFactory factory = ConnectionFactory.newInstance();
            factory.setProperties(props);
            connection = factory.createConnection();
            System.out.println("Created connection to registry");
        } catch (Exception e) {
            e.printStackTrace();

            if (connection != null) {
                try {
                    connection.close();
                } catch (JAXRException je) {
                }
            }
        }
    }

From source file:it.cnr.icar.eric.client.xml.registry.RegistryFacadeImpl.java

private void createConnection(String qmEndpoint, String lcmEndpoint) throws JAXRException {
    ConnectionFactory connFactory = JAXRUtility.getConnectionFactory();

    Properties props = new Properties();

    if (qmEndpoint == null) {
        throw new JAXRException("QueryManager endpoint MUST not be null");
    }//from  ww  w  .  j a  va 2s .com
    props.put("javax.xml.registry.queryManagerURL", qmEndpoint);
    if (lcmEndpoint != null) {
        props.put("javax.xml.registry.lifeCycleManagerURL", qmEndpoint);
    }
    connFactory.setProperties(props);
    connection = connFactory.createConnection();

    service = getConnection().getRegistryService();
    bqm = (BusinessQueryManagerImpl) getService().getBusinessQueryManager();
    lcm = (BusinessLifeCycleManagerImpl) getService().getBusinessLifeCycleManager();
    dqm = (DeclarativeQueryManagerImpl) getService().getDeclarativeQueryManager();
}