{@inheritDoc}

@throws CDIException
424880
public ExtensionArchive getExtensionArchiveForBundle(Bundle bundle,
                                                         Set<String> extraClasses,
                                                         Set<String> extraAnnotations,
                                                         boolean applicationBDAsVisible,
                                                         boolean extClassesOnly) throws CDIException {

        ExtensionArchive extensionArchive = null;
        extensionArchive = extensionArchives.get(bundle);
        if (extensionArchive == null) {
            Container container = getContainerForBundle(bundle);
            //get hold of bundle classloader
            BundleWiring bundleWiring = bundle.adapt(BundleWiring.class);
            ClassLoader loader = bundleWiring.getClassLoader();
            if (container != null) {
                ExtensionContainerInfo containerInfo = new ExtensionContainerInfo(container, loader, CDIServiceUtils.getSymbolicNameWithoutMinorOrMicroVersionPart(bundle.getSymbolicName())
                                                                                                     + "_"
                                                                                                     + CDIServiceUtils.getOSGIVersionForBndName(bundle.getVersion()), extraClasses, extraAnnotations, applicationBDAsVisible, extClassesOnly);

                extensionArchive = new ExtensionArchiveImpl(containerInfo, this);
                ExtensionArchive oldExtensionArchive = extensionArchives.putIfAbsent(bundle, extensionArchive);
                if (oldExtensionArchive != null) {
                    extensionArchive = oldExtensionArchive;
                }
            }
        }
        return extensionArchive;
    }
94576
private WebSphereCDIDeployment createWebSphereCDIDeployment(Application application,
                                                                Set<ExtensionArchive> extensionArchives) throws CDIException {
        WebSphereCDIDeployment webSphereCDIDeployment = new WebSphereCDIDeploymentImpl(application, cdiRuntime);

        DiscoveredBdas discoveredBdas = new DiscoveredBdas(webSphereCDIDeployment);

        if (application.hasModules()) {

            Collection<CDIArchive> libraryArchives = application.getLibraryArchives();
            Collection<CDIArchive> moduleArchives = application.getModuleArchives();

            ClassLoader applicationClassLoader = application.getClassLoader();
            webSphereCDIDeployment.setClassLoader(applicationClassLoader);

            processLibraries(webSphereCDIDeployment,
                             discoveredBdas,
                             libraryArchives);

            processModules(webSphereCDIDeployment,
                           discoveredBdas,
                           moduleArchives);

            //discoveredBdas has the full map, let's go through them all to make sure the wire is complete
            discoveredBdas.makeCrossBoundaryWiring();

            //and finally the runtime extensions
            addRuntimeExtensions(webSphereCDIDeployment,
                                 discoveredBdas);
        }

        return webSphereCDIDeployment;
    }
1013783
public function init()
	{
		$this->_cache=Yii::app()->getComponent($this->cacheID);
		if(!($this->_cache instanceof ICache))
			throw new CException(Yii::t('yii','CCacheHttpSession.cacheID is invalid. Please make sure "{id}" refers to a valid cache application component.',
				array('{id}'=>$this->cacheID)));
		parent::init();
	}
1056393
final function InitFromReader(DBInterfaces\IDatabaseReader $reader)
    {
        $names = $reader->Names();
        foreach ($names as $name)
        {    
            $this->SetInternally($name, $reader->ByName($name));
        }
        $this->initialized = true;
    }
565404
protected function execute(InputInterface $oInput, OutputInterface $oOutput)
    {
        parent::execute($oInput, $oOutput);

        $oOutput->writeln('');
        $oOutput->writeln('<info>--------------------</info>');
        $oOutput->writeln('<info>CDN Driver Migration</info>');
        $oOutput->writeln('<info>--------------------</info>');
        $oOutput->writeln('');

        $oStorageDriver = Factory::service('StorageDriver', 'nails/module-cdn');
        $sDriver        = $oInput->getArgument('driver');
        $bOverwrite     = $oInput->getOption('overwrite');
        $bRemove        = $oInput->getOption('remove-src');
        $aAllDrivers    = $oStorageDriver->getAll();

        //  Auto-detect the driver if not specified
        if (empty($sDriver)) {
            $oEnabledDriver = $oStorageDriver->getEnabled();
            if (empty($oEnabledDriver)) {
                throw new NailsException('No CDN drivers are enabled');
            } else {
                $sDriver = $oEnabledDriver->slug;
            }
        }

        //  Validate driver
        $aDrivers    = [];
        $aDriversOld = [];
        foreach ($aAllDrivers as $oDriver) {
            $aDrivers[$oDriver->slug] = $oDriver;
            if ($oDriver->slug != $sDriver) {
                $aDriversOld[$oDriver->slug] = $oDriver;
            }
        }

        if (!array_key_exists($sDriver, $aDrivers)) {
            throw new NailsException('"' . $sDriver . '" is not a valid storage driver.');
        }

        // --------------------------------------------------------------------------

        //  Work out what's going to happen
        $oObjectModel = Factory::model('Object', 'nails/module-cdn');

        //  How many objects are already migrated
        $iMigrated = $oObjectModel->countAll([
            'where' => [
                ['driver', $sDriver],
            ],
        ]);

        //  How many objects will be migrated
        $iToMigrate = $oObjectModel->countAll([
            'where_in' => [
                ['driver', array_keys($aDriversOld)],
            ],
        ]);

        //  How many objects which need to be migrated but won't be
        $iCannotMigrate = $oObjectModel->countAll([
            'where_not_in' => [
                ['driver', array_keys($aDrivers)],
            ],
        ]);

        //  Summarise for the user and seek confirmation
        $oOutput->writeln('');
        $oOutput->writeln('Migrate CDN objects to <info>' . $sDriver . '</info>');
        $oOutput->writeln('');
        if ($iToMigrate) {
            $oOutput->writeln('- <info>' . $iToMigrate . '</info> objects will be migrated');
            $oOutput->writeln('- <info>' . $iMigrated . '</info> objects already exist and will not be migrated');
            if (!empty($iCannotMigrate)) {
                $oOutput->writeln(
                    '- <info>' . $iCannotMigrate . '</info> objects cannot be migrated as their driver is not available'
                );
            }

            if ($bOverwrite) {
                $oOutput->writeln('- <fg=red;options=bold>Target overwriting is enabled</>');
            }

            if ($bRemove) {
                $oOutput->writeln('- <fg=red;options=bold>The original file will be deleted</>');
            }

            $oOutput->writeln('');
            if ($this->confirm('Continue?', true)) {
                $oOutput->writeln('<comment>Migrating...</comment>');
                $this->doMigrate($sDriver, $bOverwrite, $bRemove, $aDriversOld);
            } else {
                $oOutput->writeln('');
                $oOutput->writeln('Aborting Migration');
            }

        } else {
            $oOutput->writeln('There are no objects requiring migration.');
        }

        // --------------------------------------------------------------------------

        //  Cleaning up
        $oOutput->writeln('');
        $oOutput->writeln('<comment>Cleaning up...</comment>');

        //  And we're done!
        $oOutput->writeln('');
        $oOutput->writeln('Complete!');
    }
136108
private void processModules(WebSphereCDIDeployment applicationContext,
                                DiscoveredBdas discoveredBdas,
                                Collection<CDIArchive> moduleArchives) throws CDIException {

        List<WebSphereBeanDeploymentArchive> moduleBDAs = new ArrayList<WebSphereBeanDeploymentArchive>();

        for (CDIArchive archive : moduleArchives) {

            if (cdiRuntime.isClientProcess()) {
                // when on a client process, we only process client modules and ignore the others
                if (ArchiveType.CLIENT_MODULE != archive.getType()) {
                    continue;
                }
            } else {
                // when on a server process, we do not process client modules, just the others
                if (ArchiveType.CLIENT_MODULE == archive.getType()) {
                    continue;
                }
            }

            //if the app is not an EAR then there should be only one module and we can just use it's classloader
            if (applicationContext.getClassLoader() == null) {
                applicationContext.setClassLoader(archive.getClassLoader());
            }

            String archiveID = archive.getJ2EEName().toString();

            // we need to work our whether to create a bda or not
            if (cdiRuntime.skipCreatingBda(archive)) {
                continue;
            }

            WebSphereBeanDeploymentArchive moduleBda = BDAFactory.createBDA(applicationContext,
                                                                            archiveID,
                                                                            archive,
                                                                            cdiRuntime);
            discoveredBdas.addDiscoveredBda(archive.getType(), moduleBda);
            moduleBDAs.add(moduleBda);

        }

        // Having processed all the modules, we now process their libraries
        // We do it in this order in case one of the modules references another of the same type as a library
        for (WebSphereBeanDeploymentArchive bda : moduleBDAs) {
            processModuleLibraries(bda, discoveredBdas);
        }
    }
850387
@Override
	public void init() throws TransactionException {
		systemConfig = getJsonConfig();

		// Load the storage plugin
		String storageId = systemConfig.getString("file-system", "storage",
				"type");
		if (storageId == null) {
			throw new TransactionException("No Storage ID provided");
		}
		storage = PluginManager.getStorage(storageId);
		if (storage == null) {
			throw new TransactionException("Unable to load Storage '"
					+ storageId + "'");
		}
		try {
			storage.init(systemConfig.toString());
		} catch (PluginException ex) {
			log.error("Unable to initialise storage layer!", ex);
			throw new TransactionException(ex);
		}

		// Load the indexer plugin
		String indexerId = systemConfig.getString("solr", "indexer", "type");
		if (indexerId == null) {
			throw new TransactionException("No Indexer ID provided");
		}
		indexer = PluginManager.getIndexer(indexerId);
		if (indexer == null) {
			throw new TransactionException("Unable to load Indexer '"
					+ indexerId + "'");
		}
		try {
			indexer.init(systemConfig.toString());
		} catch (PluginException ex) {
			log.error("Unable to initialise indexer!", ex);
			throw new TransactionException(ex);
		}

		// External facing URL
		urlBase = systemConfig.getString(null, "urlBase");
		if (urlBase == null) {
			throw new TransactionException("URL Base in config cannot be null");
		}

		// Where should emails be sent?
		emailAddress = systemConfig.getString(null, "curation",
				"curationEmailAddress");
		if (emailAddress == null) {
			throw new TransactionException("An admin email is required!");
		}

		// Where are PIDs stored?
		pidProperty = systemConfig.getString(null, "curation", "pidProperty");
		if (pidProperty == null) {
			throw new TransactionException("An admin email is required!");
		}

		// Do admin staff want to confirm each curation?
		manualConfirmation = systemConfig.getBoolean(false, "curation",
				"curationRequiresConfirmation");

		// Find the address of our broker
		brokerUrl = systemConfig.getString(null, "messaging", "url");
		if (brokerUrl == null) {
			throw new TransactionException("Cannot find the message broker.");
		}

		// We also need Mint's AMQ url
		mintBroker = systemConfig.getString(null, "curation", "mintBroker");
		if (mintBroker == null) {
			throw new TransactionException("Cannot find Mint's message broker.");
		}

		/** Relationship mapping */
		relationFields = systemConfig.getJsonSimpleMap("curation", "relations");
		if (relationFields == null) {
			log.warn("Curation configuration has no relationships");
			relationFields = new HashMap<String, JsonSimple>();
		}
	}
191778
public function initialize()
    {
        if ($this->initialized) {
            throw new Exception('The Reflection Service can only be initialized once.', 1232044696);
        }
        $frameworkConfiguration = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
        $this->cacheIdentifier = 'ReflectionData_' . $frameworkConfiguration['extensionName'];
        $this->loadFromCache();
        $this->initialized = true;
    }
355281
@Override
  public final synchronized void init() throws Exception {
    FactoryBldAccServices<ResultSet> factoryBldAccServices =
      new FactoryBldAccServices<ResultSet>();
    factoryBldAccServices.setFactoryAppBeans(this);
    setFactoryBldServices(factoryBldAccServices);
    FactoryAccServices<ResultSet> factoryAccServices =
      new FactoryAccServices<ResultSet>();
    factoryAccServices.setFactoryAppBeans(this);
    factoryAccServices.setFactoryBldAccServices(factoryBldAccServices);
    factoryBldAccServices.setFactoryAccServices(factoryAccServices);
    setFactoryOverBeans(factoryAccServices);
    FactoryAccReplicatorXmlHttps<ResultSet> factoryReplicatorXmlHttps =
      new FactoryAccReplicatorXmlHttps<ResultSet>();
    factoryReplicatorXmlHttps.setFactoryAppBeans(this);
    setFactoryReplicatorXmlHttps(factoryReplicatorXmlHttps);
    FactoryAccDatabaseWriterXml<ResultSet> factoryDatabaseWriterXml =
      new FactoryAccDatabaseWriterXml<ResultSet>();
    factoryDatabaseWriterXml.setFactoryAppBeans(this);
    setFactoryDatabaseWriterXml(factoryDatabaseWriterXml);
  }
612229
private void populateQueryResultsInCDC(Map<String, QueryResult> queryResults, QueryResult queryResult) {
        if (queryResult != null) {
            List<? extends IEntity> entities = queryResult.getEntities();
            if (entities != null && !entities.isEmpty()) {
                IEntity entity = entities.get(0);
                String entityName = entity.getClass().getSimpleName();
                queryResults.put(entityName, queryResult);
            }
        }
    }
212210
public void execute() throws XDocletException
    {
        if (getJspversion().equals(JspVersionTypes.VERSION_1_1)) {
            setPublicId(TLD_PUBLICID_1_1);
            setSystemId(TLD_SYSTEMID_1_1);
            setDtdURL(getClass().getResource(TLD_DTD_FILE_NAME_1_1));
        }
        else {
            setPublicId(TLD_PUBLICID_1_2);
            setSystemId(TLD_SYSTEMID_1_2);
            setDtdURL(getClass().getResource(TLD_DTD_FILE_NAME_1_2));
        }

        startProcess();
    }
115479
public static function map(CommandInterface $command) {
        $mapper = new static();
        $mapper->setCommand($command);
        if ($mapper->save() === false) {
            throw new YiiException('Unable to save an instance of \jlorente\command\db\CommandMapper. Errors: [' . Json::encode($mapper->getErrors()) . ']');
        }
    }
458784
@Override
    @FFDCIgnore({ ClassNotFoundException.class })
    public void validateEjbInjection(EJB ejb, CDIArchive injectionArchive, Class<?> injectionType) throws ClassCastException, CDIException {

        Collection<CDIArchive> moduleArchives = injectionArchive.getApplication().getModuleArchives();
        String applicationName = injectionArchive.getApplication().getName();
        String moduleName = injectionArchive.getName();

        for (CDIArchive archive : moduleArchives) {
            try {

                EJBEndpoint endpoint = findEJBEndpoint(archive, ejb, injectionType, applicationName, moduleName);

                if (endpoint != null) {
                    // Found it!
                    return;
                }
            } catch (ClassNotFoundException e) {
                // Could not find the class, even though it should be in this module
                // Give up looking but don't fail validation
                return;
            } catch (ClassCastException e) {
                // Found the EJB and it's the wrong type
                // Throw on this exception to be handled by the caller
                throw e;
            }

            //TODO what happens if the endpoint is not found in any of the archives??
        }
    }
1256620
protected function execute(InputInterface $input, OutputInterface $output): void
    {
        $output->writeln([
            '----------------',
            'Domain entity generator',
            '----------------',
            ''
        ]);

        $helper      = $this->getHelper('question');
        $questionSet = $this->createQuestionSet();
        $entityName  = $helper->ask($input, $output, $questionSet['entityName']);

        do {
            $propertyNames[] = $helper->ask($input, $output, $questionSet['propertyName']);
            $propertyTypes[] = $helper->ask($input, $output, $questionSet['propertyType']);
        } while ($helper->ask($input, $output, $questionSet['continue']));

        $properties = array_combine($propertyNames, $propertyTypes);

        $configuration   = $this->appConfiguration->getConfiguration();
        $entityNamespace = $configuration['framework']['root_namespace'] . 'Domain\Entity';

        $entityData = [
            'namespace'  => $entityNamespace,
            'class'      => $entityName,
            'properties' => $properties
        ];

        (new EntityGenerator($entityData))->generate();

        $output->writeln('Entity generated successfully!');
    }
712135
public function objectDelete($iObjectId)
    {
        $oDb = Factory::service('Database');

        try {

            $object = $this->getObject($iObjectId);
            if (empty($object)) {
                throw new CdnException('Not a valid object');
            }

            // --------------------------------------------------------------------------

            $aObjectData = [
                'id'               => $object->id,
                'bucket_id'        => $object->bucket->id,
                'filename'         => $object->file->name->disk,
                'filename_display' => $object->file->name->human,
                'mime'             => $object->file->mime,
                'filesize'         => $object->file->size->bytes,
                'img_width'        => $object->img_width,
                'img_height'       => $object->img_height,
                'img_orientation'  => $object->img_orientation,
                'is_animated'      => $object->is_animated,
                'serves'           => $object->serves,
                'downloads'        => $object->downloads,
                'thumbs'           => $object->thumbs,
                'scales'           => $object->scales,
                'driver'           => $object->driver,
                'created'          => $object->created,
                'created_by'       => $object->created_by,
                'modified'         => $object->modified,
                'modified_by'      => $object->modified_by,
            ];

            $oDb->set($aObjectData);
            $oDb->set('trashed', 'NOW()', false);

            if (isLoggedIn()) {
                $oDb->set('trashed_by', activeUser('id'));
            }

            //  Start transaction
            $oDb->trans_begin();

            //  Create trash object
            if (!$oDb->insert(NAILS_DB_PREFIX . 'cdn_object_trash')) {
                throw new CdnException('Failed to create the trash object.');
            }

            //  Remove original object
            $oDb->where('id', $object->id);
            if (!$oDb->delete(NAILS_DB_PREFIX . 'cdn_object')) {
                throw new CdnException('Failed to remove original object.');
            }

            $oDb->trans_commit();

            //  Clear caches
            $this->unsetCacheObject($object);

            return true;

        } catch (\Exception $e) {

            $oDb->trans_rollback();
            $this->setError($e->getMessage());

            return false;
        }
    }
1210544
@Override
    public <T> List<InjectionPoint> getJEEComponentInjectionPoints(Class<T> clazz) throws CDIException {
        InjectionTarget<T> injectionTarget = getJEEComponentInjectionTarget(clazz);
        List<InjectionPoint> injectionPoints = null;

        if (injectionTarget != null) {
            injectionPoints = new ArrayList<InjectionPoint>();
            Set<InjectionPoint> jeeClassInjectionPoints = injectionTarget.getInjectionPoints();
            if (jeeClassInjectionPoints != null && jeeClassInjectionPoints.size() > 0) {
                injectionPoints.addAll(jeeClassInjectionPoints);
            }

            String mainClassName = archive.getClientModuleMainClass();

            if (mainClassName != null) {
                if (clazz.getName().equals(mainClassName)) {
                    List<InjectionPoint> staticInjectionPoints = this.staticInjectionPoints.get(clazz);
                    if (staticInjectionPoints != null) {
                        injectionPoints.addAll(staticInjectionPoints);
                    }
                }
            }
        }

        return injectionPoints;
    }
518753
private function executeConnect(ContainerInterface $container, IoInterface $inOut): void
    {
        assert($container->has(CommandStorageInterface::class));
        /** @var CommandStorageInterface $commandStorage */
        $commandStorage = $container->get(CommandStorageInterface::class);

        $commandClasses = [];
        foreach ($commandStorage->getAll() as $commandClass) {
            if (class_exists($commandClass) === false ||
                array_key_exists(CommandInterface::class, class_implements($commandClass)) === false
            ) {
                $inOut->writeWarning("Class `$commandClass` either do not exist or not a command class." . PHP_EOL);
                continue;
            }

            $inOut->writeInfo("Found command class `$commandClass`." . PHP_EOL, IoInterface::VERBOSITY_VERBOSE);

            $commandClasses[] = $this->commandClassToArray($commandClass);
        }

        if (empty($commandClasses) === false) {
            $now           = date(DATE_RFC2822);
            $data          = var_export($commandClasses, true);
            $content       = <<<EOT
<?php

// THIS FILE IS AUTO GENERATED. DO NOT EDIT IT MANUALLY.
// Generated at: $now

    return $data;

EOT;
            $cacheFilePath = $this->getCommandsCacheFilePath($this->getComposer());
            if (empty($cacheFilePath) === true) {
                $inOut->writeError("Commands cache file path is not set. Check your `Application` settings." . PHP_EOL);

                return;
            }

            $this->getFileSystem($container)->write($cacheFilePath, $content);

            $inOut->writeInfo('Commands connected.' . PHP_EOL);

            return;
        }

        $inOut->writeWarning('No commands found.' . PHP_EOL);
    }