Package com.volantis.mcs.repository

Examples of com.volantis.mcs.repository.RepositoryConnection


            // check if it's been cached
            descriptor = (CategoryDescriptor) nameToDescriptor.get(categoryName);
            if (descriptor == null) {
                // if not go to the repository and load it
                try {
                    RepositoryConnection connection = repository.connect();
                    try {
                        descriptor = accessor.retrieveCategoryDescriptor(
                                connection, categoryName, locale);
                        nameToDescriptor.put(categoryName, descriptor);
                    } finally {


            throws DeviceRepositoryException {

        DefaultDevice device = null;
        if (headers != null) {
            try {
                RepositoryConnection connection = repository.connect();
                try {
                    final DeviceIdentificationResult identificationResult =
                        DevicesHelper.getDevice(
                            connection, headers, accessor, unknownDevicesLogger, defaultDeviceName);
                    device = identificationResult.getDevice();

    public List getChildrenDeviceNames(final String deviceName)
            throws DeviceRepositoryException {

        final List names = new LinkedList();
        try {
            final RepositoryConnection connection = repository.connect();
            try {
                final RepositoryEnumeration e = accessor.enumerateDevicesChildren(
                        connection, deviceName);
                try {
                    while (e.hasNext()) {

     */
    private Set calculateAccessiblePolicyNames() throws RepositoryException {

        Set result = new HashSet();

        RepositoryConnection connection = repository.connect();
        try {
            RepositoryEnumeration policyNames =
                    accessor.enumeratePolicyNames(connection);
            try {
                while (policyNames.hasNext()) {

            logger.debug("Terminating all connections");
        }

        // Copy the connections collections so that closeConnection() can
        // change it without causeing a ConcurrentModificationException.
        RepositoryConnection connectionsArray [] = new RepositoryConnection[0];
        connectionsArray = (RepositoryConnection[])
                connections.toArray(connectionsArray);
        for (int i = 0; i < connectionsArray.length; i++) {
            RepositoryConnection connection = connectionsArray[i];

            try {
                if (logger.isDebugEnabled()) {
                    logger.debug("Disconnecting " + connection);
                }

     * @return a RepositoryConnection Object.
     */
    protected RepositoryConnection openConnection()
            throws RepositoryException {

        RepositoryConnection connection =
                new JDBCRepositoryConnectionImpl(this, anonymous, username, password,
                        allowImmediateConnectionRelease);

        return connection;
    }

     * Adds all the descendant devices of the devices in the exclusion list.
     * @throws RepositoryException if there is a problem acessing the device
     * repository
     */
    private void addDescendantDevices() throws RepositoryException {
        RepositoryConnection connection = null;
        try {
            Volantis volantis =
                    ApplicationInternals.getVolantisBean(application);
            connection = volantis.getDeviceConnection();

            // Create a copy of the list to iterate over. This must be done
            // because child devices are added to the original list during
            // iteration.
            List excCopy = new ArrayList(excludedDevices);

            if (logger.isDebugEnabled()) {
                Iterator it = excludedDevices.iterator();
                while (it.hasNext()) {
                    logger.debug("Added parent device for exclusion: " +
                            it.next());
                }
            }

            Iterator it = excCopy.iterator();
            while (it.hasNext()) {
                // Determine the children of the current device.
                String deviceName = (String) it.next();
                List children = enumerateAllDevicesChildren(
                        deviceName, connection);
                // Add the children to the exclusion list.
                excludedDevices.addAll(children);
            }
        } finally {
            connection.disconnect();
        }
    }

    public void testRemoveConnection() throws RepositoryException {
        JDBCRepositoryImpl repository =
                (JDBCRepositoryImpl) createTestableRepository();
        Collection connections = repository.connections;
        connections.clear();
        RepositoryConnection connection = repository.openConnection();
        connections.add(connection);
        assertEquals("The connections collection should contain 1 connection",
                     1, connections.size());
        repository.removeConnection(connection);
        assertEquals("The connections collection should contain 0 connections",

     *
     */
    private void loadDevicePatterns() {

        try {
            RepositoryConnection connection = null;
            try {
                connection = getDeviceConnection();
                deviceRepositoryAccessor.initializeDevicePatternCache(connection);
            } finally {
                freeConnection(connection);

                AbstractDeviceRepositoryAccessor accessor =
                        createAccessor(deviceRepositoryFile);

                // Create a test connection
                RepositoryConnection connection = createConnection();

                RepositoryEnumeration enumeration = accessor.enumeratePolicyNames(connection);

                // Check successful operation of the enumeration
                assertNotNull("Enumeration over retrieved items should exist", enumeration);

TOP

Related Classes of com.volantis.mcs.repository.RepositoryConnection

Copyright © 2018 www.massapicom. 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.