Package com.volantis.mcs.repository

Examples of com.volantis.mcs.repository.LocalRepository


            assetTranscoder =
                new PluggableAssetTranscoderManager(assetTranscoderConfig);


            LocalRepository xmlRepository = null;
            LocalRepository jdbcRepository = null;

            // Resolve all datasources
            if (logger.isDebugEnabled()) {
                logger.debug("Resolving DataSources");
            }

            mcsConfiguration = new MCSConfiguration(marinerConfig);
            mcsConfiguration.resolveDataSources();

            // Determine whether the default project should preload its
            // policies.
            ProjectsConfiguration projects = marinerConfig.getProjects();

            RepositoryConnectionType deviceConnectionType =
                    getDRepositoryConnectionType();

            // Configure an XML repository if one is configured or required
            // by the device repository; if not required this will be ignored.
            if (marinerConfig.getLocalRepository().
                    getXmlRepository() != null ||
                    (deviceConnectionType ==
                     RepositoryConnectionType.XML_REPOSITORY_CONNECTION)) {

                XMLRepositoryFactory factory =
                        XMLRepositoryFactory.getDefaultInstance();

                // todo: later: refactor this config object using factory pattern
                XMLRepositoryConfiguration xmlRepositoryConfiguration =
                        (XMLRepositoryConfiguration)
                        factory.createXMLRepositoryConfiguration();

                xmlRepository =
                        factory.createXMLRepository(xmlRepositoryConfiguration);
            }

            // Create a JDBC repository if one has been configured.

            // todo Should we try and get the data source from the
            // todo AppServerInterfaceManager like we used to.
            DataSource dataSource = getLocalRepositoryJDBCDataSource();

            if (dataSource != null ||
                    (deviceConnectionType ==
                     RepositoryConnectionType.JDBC_REPOSITORY_CONNECTION)) {

                JDBCRepositoryFactory factory =
                        JDBCRepositoryFactory.getDefaultInstance();

                // todo: later: refactor this config object using factory pattern
                com.volantis.mcs.repository.jdbc.JDBCRepositoryConfiguration configuration =
                        factory.createJDBCRepositoryConfiguration();
                configuration.setDataSource(dataSource);
                configuration.setReleaseConnectionsImmediately(true);
                configuration.setShortNames(getJDBCRepositoryUsesShortNames());
                configuration.setAnonymous(true);

                jdbcRepository = (LocalRepository)
                        factory.createJDBCRepository(configuration);
            } else {
                // Until datasource configuration is implemented, log a warning
                // about not being able to create a JDBC repository.
                logger.warn("local-repository-type-unknown");
            }

            // Determine the repository to use to access the device.
            DeviceRepositoryLocation deviceRepositoryLocation =
                    getDeviceRepositoryLocation(configContext);
            if (deviceConnectionType == RepositoryConnectionType.JDBC_REPOSITORY_CONNECTION) {
                deviceRepository = jdbcRepository;
            } else if (deviceConnectionType == RepositoryConnectionType.XML_REPOSITORY_CONNECTION) {
                deviceRepository = xmlRepository;
            } else {
                throw new IllegalStateException("Unknown device repository type " + deviceConnectionType);
            }

            if (logger.isDebugEnabled()) {
                logger.debug("Creating remote repository");
            }

            boolean IMDRepositoryEnabled =
                    marinerConfig.getImdRepositoryEnabled() == Boolean.TRUE;

            if (IMDRepositoryEnabled) {
                logger.info("using-imd-repository");
            }

            CacheControlConstraints defaultRemoteCacheControlConstraints =
                    createRemoteCacheControlConstraints();

            // Create the policy cache.
            PolicyCache policyCache = createPolicyCache(
                    defaultRemoteCacheControlConstraints);

            RemoteReadersFactory remoteReadersFactory =
                    createRemoteReadersFactory();

            // Create the ProjectManager.
            ProjectLoader projectLoader = createProjectLoader();

            RepositoryContainer repositoryContainer =
                    new RepositoryContainer(jdbcRepository, xmlRepository);

            // Create the remote project specific constraints.
            CacheControlConstraintsMap defaultRemoteCacheControlConstraintsMap
                    = createRemoteCacheControlConstraintsMap(
                            defaultRemoteCacheControlConstraints);

            // Create the local project specific constraints.
            CacheControlConstraintsMap defaultLocalCacheControlConstraintsMap
                    = createLocalCacheControlConstraintsMap();

            PopulatableProjectManager projectManager =
                    new ProjectManagerImpl(projectLoader,
                            new RuntimeProjectConfiguratorImpl(
                                    defaultLocalCacheControlConstraintsMap,
                                    defaultRemoteCacheControlConstraintsMap,
                                    pathURLMapper, policyCache),
                            repositoryContainer,
                            remoteReadersFactory);

            // Create the activator.
            PolicyReferenceFactory referenceFactory =
                    new PolicyReferenceFactoryImpl(projectManager);

            PolicyActivator policyActivator =
                    initializeRepositoryObjectActivators(referenceFactory);

            // Create the retriever to use to retrieve activated policies from
            // any source.
            RuntimePolicyFactory runtimePolicyFactory =
                    RuntimePolicyFactory.getDefaultInstance();

            ActivatedPolicyRetriever activatedPolicyRetriever =
                    runtimePolicyFactory.createCachingRetriever(
                            policyActivator, projectManager, policyCache);

            policyFetcher = new PolicyFetcherImpl(activatedPolicyRetriever);

            // Initialize the projects

            projectManager.createPredefinedProjects(projects, configContext,
                    defaultLocalCacheControlConstraintsMap,
                    policyCache.getLocalDefaultGroup());
            RuntimeProject defaultProject = projectManager.getDefaultProject();

            // Determine the repository within which the default project
            // resides.
            LocalRepository defaultRepository;

            PolicySource defaultPolicySource = defaultProject.getPolicySource();
            if (defaultPolicySource instanceof JDBCPolicySource) {
                defaultRepository = jdbcRepository;
            } else if (defaultPolicySource instanceof XMLPolicySource) {
View Full Code Here


    protected AbstractDeviceRepositoryAccessor createAccessor(
            final File file) {
        final XMLRepositoryConfiguration configuration =
            REPOSITORY_FACTORY.createXMLRepositoryConfiguration();
        try {
            final LocalRepository xmlRepository =
                REPOSITORY_FACTORY.createXMLRepository(configuration);
            return new JiBXDeviceRepositoryAccessor(xmlRepository,
                    new DeviceRepositoryLocationImpl(file.getPath()));
        } catch (RepositoryException e) {
            throw new UndeclaredThrowableException(e);
View Full Code Here

TOP

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

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.