@see Command

@throws InvalidArgumentException When namespace doesn't end with Bundle
@throws RuntimeException When bundle can't be executed
763607
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $io = new SymfonyStyle($input, $output);

        if ($input->isInteractive() && !$io->confirm('Do you confirm generation?', true)) {
            $io->error('Command aborted');

            return 1;
        }

        foreach (['namespace', 'dir'] as $option) {
            if (null === $input->getOption($option)) {
                throw new RuntimeException(sprintf('The "%s" option must be provided.', $option));
            }
        }

        $namespace = Validators::validateBundleNamespace($input->getOption('namespace'));
        if (!$bundle = $input->getOption('module-name')) {
            $bundle = strtr($namespace, ['\\' => '']);
        }
        $bundle = Validators::validateBundleName($bundle);
        $dir = Validators::validateTargetDir($input->getOption('dir'), $bundle, $namespace);
        if (null === $input->getOption('format')) {
            $input->setOption('format', 'annotation');
        }
        $format = Validators::validateFormat($input->getOption('format'));

        $io->block('Module generation', null, 'bg=blue;fg=white', '  ', true);

        if (!$this->getContainer()->get('filesystem')->isAbsolutePath($dir)) {
            $dir = getcwd().'/'.$dir;
        }

        $io->text('Generating the module code...');
        $generator = $this->getGenerator();
        $generator->generate($namespace, $bundle, $dir, $format);
        $io->success('Code generated!');

        $io->block('You can now start using the generated code!', null, 'bg=blue;fg=white', '  ', true);

        return 0;
    }
734933
public void start(BundleContext context) throws Exception
    {
        this.log(context, LogService.LOG_INFO, "Starting and registering the (repository) " + this.getClass().getName() + " ClassService ");
        
        bundleContext = context;

        if (context != null)
            context.registerService(ClassFinder.class.getName(), this, null);	// Should be only one of these
    }
1150327
public static function loadAll(array $bundles)
    {
        foreach ($bundles as $bundle) {
            if (!$bundle instanceof BundleInterface) {
                throw new InvalidArgumentException('Bundle must be instance of "Rad\Core\BundleInterface".');
            }

            self::load($bundle);
        }
    }
298566
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $root = $this->getContainer()->getParameter('kernel.root_dir');
        chdir("$root/..");
        $bundle = $input->getArgument('bundle');
        $bundle = ltrim($bundle, '@');
        $bundleObj = $this->getContainer()->get('kernel')->getBundle($bundle);
        if (!$bundleObj) {
            throw new ResourceNotFoundException("Cannot load bundle resource '$bundle'");
        }
        $path = $bundleObj->getPath().'/Resources/gettext/messages.pot';
        $languages = $input->getArgument('languages');
        $results = $this->initializeFromTemplate($path, $languages);
        foreach ($results as $filename => $status) {
            $output->writeln("$status: $filename");
        }
    }
961500
protected void addBundle (HashIntMap<TileSet> idmap, HashMap<String, Integer> namemap,
        ResourceBundle bundle)
    {
        try {
            TileSetBundle tsb = BundleUtil.extractBundle(bundle);
            // initialize it and add it to the list
            tsb.init(bundle);
            addBundle(idmap, namemap, tsb);

        } catch (Exception e) {
            log.warning("Unable to load tileset bundle '" + BundleUtil.METADATA_PATH +
                        "' from resource bundle [rbundle=" + bundle + "].", e);
        }
    }
372804
public function locateResource($name, $dir = null, $first = true)
    {
        if ('@' !== $name[0]) {
            throw new \InvalidArgumentException(sprintf('A resource name must start with @ ("%s" given).', $name));
        }

        if (false !== strpos($name, '..')) {
            throw new \RuntimeException(sprintf('File name "%s" contains invalid characters (..).', $name));
        }

        $bundleName = substr($name, 1);
        $path = '';
        if (false !== strpos($bundleName, '/')) {
            list($bundleName, $path) = explode('/', $bundleName, 2);
        }

        $isResource = 0 === strpos($path, 'Resources') && null !== $dir;
        $overridePath = substr($path, 9);
        $bundle = $this->getBundle($bundleName);
        $files = [];

        if ($isResource && file_exists($file = $dir.'/'.$bundle->getName().$overridePath)) {
            $files[] = $file;
        }

        if (file_exists($file = $bundle->getPath().'/'.$path)) {
            if ($first && !$isResource) {
                return $file;
            }
            $files[] = $file;
        }

        if (\count($files) > 0) {
            return $first && $isResource ? $files[0] : $files;
        }

        throw new \InvalidArgumentException(sprintf('Unable to find file "%s".', $name));
    }
633855
@Override
	public void start(BundleContext context) throws Exception {
		final String sourceMethod = "start"; //$NON-NLS-1$
		boolean isTraceLogging = log.isLoggable(Level.FINER);
		if (isTraceLogging) {
			log.entering(Activator.class.getName(), sourceMethod, new Object[]{context});
		}
		super.start(context);

		// Verify the bundle id.
		if (!context.getBundle().getSymbolicName().equals(BUNDLE_NAME)) {
			throw new IllegalStateException();
		}
		serviceRegistrations = new LinkedList<ServiceRegistration<?>>();
		Activator.context = context;
		Dictionary<String, String> dict = new Hashtable<String, String>();
		dict.put("name", BUNDLE_NAME); //$NON-NLS-1$

		ServiceRegistration<?> commandProviderReg = registerCommandProvider();
		if (commandProviderReg != null) {
			serviceRegistrations.add(commandProviderReg);
		}
		// Create the executors provider.  The executors provider is created by the
		// activator primarily to allow executors to be shared by all of the
		// aggregators created by this bundle.
		dict = new Hashtable<String, String>();
		dict.put("name", BUNDLE_NAME); //$NON-NLS-1$
		executors = newExecutors();
		serviceRegistrations.add(
				context.registerService(IExecutors.class.getName(), executors, dict));

		if (isTraceLogging) {
			log.exiting(Activator.class.getName(), sourceMethod);
		}
	}
639130
private function parseBundles(array $bundles, array &$configs): void
    {
        foreach ($bundles as $options) {
            // Only one value given, must be class name
            if (!\is_array($options)) {
                $options = ['bundle' => $options];
            }

            if (!isset($options['bundle'])) {
                throw new \RuntimeException(
                    sprintf('Missing class name for bundle config (%s)', json_encode($options))
                );
            }

            if (!empty($options['optional']) && !class_exists($options['bundle'])) {
                continue;
            }

            $config = new BundleConfig($options['bundle']);

            if (isset($options['replace'])) {
                $config->setReplace($options['replace']);
            }

            if (isset($options['development'])) {
                if (true === $options['development']) {
                    $config->setLoadInProduction(false);
                } elseif (false === $options['development']) {
                    $config->setLoadInDevelopment(false);
                }
            }

            if (isset($options['load-after'])) {
                $config->setLoadAfter($options['load-after']);
            }

            $configs[] = $config;
        }
    }
928967
public static void main(String[] args) throws Exception {
    Configuration conf = HBaseConfiguration.create();
    String[] otherArgs = new GenericOptionsParser(conf, args).getRemainingArgs();
    if (otherArgs.length < 2) {
      usage("Wrong number of arguments: " + otherArgs.length);
      System.exit(-1);
    }
    if (conf.get(BigtableOptionsFactory.PROJECT_ID_KEY) == null) {
      usage("Must specify the property " + BigtableOptionsFactory.PROJECT_ID_KEY);
      System.exit(-1);
    }
    if (conf.get(BigtableOptionsFactory.INSTANCE_ID_KEY) == null) {
      usage("Must specify the property" + BigtableOptionsFactory.INSTANCE_ID_KEY);
      System.exit(-1);
    }

    Job job = createSubmittableJob(conf, otherArgs);
    System.exit(job.waitForCompletion(true)? 0 : 1);
  }
257741
protected function execute(InputInterface $input, OutputInterface $output)
    {
        /**
         * GENERATE THE BUNDLEBUNDLE
         */
        $bundleBundleDir = sprintf(self::BUNDLE_NAME_MASK, 'Bundle');

        // GravitonDynBundleBundle
        $bundleName = str_replace('/', '', $bundleBundleDir);

        // bundlebundle stuff..
        $this->bundleBundleNamespace = $bundleBundleDir;
        $this->bundleBundleDir = $input->getOption('srcDir') . $bundleBundleDir;
        $this->bundleBundleClassname = $bundleName;
        $this->bundleBundleClassfile = $this->bundleBundleDir . '/' . $this->bundleBundleClassname . '.php';

        $filesToWorkOn = $this->definitionLoader->load($input->getOption('json'));

        if (count($filesToWorkOn) < 1) {
            throw new \LogicException("Could not find any usable JSON files.");
        }

        $templateHash = $this->getTemplateHash();
        $existingBundles = $this->getExistingBundleHashes($input->getOption('srcDir'));

        /**
         * GENERATE THE BUNDLE(S)
         */
        foreach ($filesToWorkOn as $jsonDef) {
            $thisIdName = $jsonDef->getId();
            $namespace = sprintf(self::BUNDLE_NAME_MASK, $thisIdName);

            // make sure bundle is in bundlebundle
            $this->bundleBundleList[] = $namespace;

            $jsonDef->setNamespace($namespace);

            $bundleName = str_replace('/', '', $namespace);
            $bundleDir = $input->getOption('srcDir').$namespace;
            $bundleNamespace = str_replace('/', '\\', $namespace).'\\';

            try {
                $thisHash = sha1($templateHash.PATH_SEPARATOR.serialize($jsonDef));

                $needsGeneration = true;
                if (isset($existingBundles[$bundleDir])) {
                    if ($existingBundles[$bundleDir] == $thisHash) {
                        $needsGeneration = false;
                    }
                    unset($existingBundles[$bundleDir]);
                }

                if ($needsGeneration) {
                    $this->generateBundle($bundleNamespace, $bundleName, $input->getOption('srcDir'));
                    $this->generateGenerationHashFile($bundleDir, $thisHash);
                }

                if ($needsGeneration) {
                    $this->generateResources(
                        $jsonDef,
                        $bundleName,
                        $bundleDir,
                        $bundleNamespace
                    );

                    $output->write(
                        PHP_EOL.
                        sprintf('<info>Generated "%s" from definition %s</info>', $bundleName, $jsonDef->getId()).
                        PHP_EOL
                    );
                } else {
                    $output->write(
                        PHP_EOL.
                        sprintf('<info>Using pre-existing "%s"</info>', $bundleName).
                        PHP_EOL
                    );
                }
            } catch (\Exception $e) {
                $output->writeln(
                    sprintf('<error>%s</error>', $e->getMessage())
                );

                // remove failed bundle from list
                array_pop($this->bundleBundleList);
            }
        }

        // whatever is left in $existingBundles is not defined anymore and needs to be deleted..
        foreach ($existingBundles as $dirName => $hash) {
            $fileInfo = new \SplFileInfo($dirName);
            $bundleClassName = $this->getBundleClassnameFromFolder($fileInfo->getFilename());

            // remove from bundlebundle list
            unset($this->bundleBundleList[array_search($bundleClassName, $this->bundleBundleList)]);

            $this->fs->remove($dirName);

            $output->write(
                PHP_EOL.
                sprintf('<info>Deleted obsolete bundle "%s"</info>', $dirName).
                PHP_EOL
            );
        }

        // generate bundlebundle
        $this->generateBundleBundleClass();
    }
534168
public static Bundle installBundle(BundleContext context, Resource bundle, boolean checkExistence) throws IOException, BundleException {
	if (checkExistence) {
	    BundleFile bf = new BundleFile(bundle);
	    if (!bf.isBundle()) throw new BundleException(bundle + " is not a valid bundle!");

	    Bundle existing = loadBundleFromLocal(context, bf.getSymbolicName(), bf.getVersion(), false, null);
	    if (existing != null) return existing;
	}

	return _loadBundle(context, bundle.getAbsolutePath(), bundle.getInputStream(), true);
    }
737187
public static function load(BundleInterface $bundle)
    {
        if (is_dir($bundle->getPath())) {
            self::$bundlesLoaded[$bundle->getName()] = [
                'namespace' => $bundle->getNamespace(),
                'path' => $bundle->getPath()
            ];

            if (!self::$classLoader) {
                self::$classLoader = new ClassLoader();
            }

            self::$classLoader->addPsr4($bundle->getNamespace(), $bundle->getPath());
            self::$classLoader->register();
        } else {
            throw new MissingBundleException(sprintf('Bundle "%s" could not be found.', $bundle->getName()));
        }
    }
1213155
private void validateBundleId(ResourceBundleDefinition definition) {
		String bundleId = definition.getBundleId();
		if (bundleId != null) {
			if (!bundleId.endsWith(fileExtension)) {
				throw new BundlingProcessException("The extension of the bundle " + definition.getBundleName() + " - "
						+ bundleId + " doesn't match the allowed extension : '" + fileExtension
						+ "'. Please update your bundle definition.");
			} else if (bundleId.startsWith(JawrConstant.WEB_INF_DIR_PREFIX)
					|| bundleId.startsWith(JawrConstant.META_INF_DIR_PREFIX)) {
				throw new BundlingProcessException("For the bundle " + definition.getBundleName() + ", the bundle id '"
						+ bundleId
						+ "' is not allowed because it starts with \"/WEB-INF/\". Please update your bundle definition.");
			}
		}
	}
833317
public function run(): void
    {
        if ('' === (string)$this->catName) {
            throw new \RuntimeException('You must call setCatName before running this action');
        }
        if ('' === (string)$this->name) {
            throw new \RuntimeException('You must call setName before running this action');
        }
        $this->fakerDataCreator->setCatName($this->catName)->setName($this->name)->createTargetFileObject()->write();
        $this->interfaceCreator->setCatName($this->catName)->setName($this->name)->createTargetFileObject()->write();
        $this->hasInterfaceCreator->setCatName($this->catName)->setName($this->name)->createTargetFileObject()->write();
        $this->embeddableCreator->setCatName($this->catName)->setName($this->name)->createTargetFileObject()->write();
        $this->hasCreator->setCatName($this->catName)->setName($this->name)->createTargetFileObject()->write();
    }
340888
private function initBundleExposedActions()
    {
        if (true === $this->isEnabled()) {
            $container = $this->getApplication()->getContainer();
            foreach ((array) $this->getProperty('exposed_actions') as $controllerId => $actions) {
                if (false === $container->has($controllerId)) {
                    throw new \InvalidArgumentException(
                        "Exposed controller with id `$controllerId` not found for ".$this->getId()
                    );
                }

                $controller = $container->get($controllerId);
                $this->formatAndInjectExposedAction($controller, $actions);
            }
        }
    }
39186
public function generate($namespace, $bundle, $dir)
    {
        $dir .= '/' . strtr($namespace, '\\', '/');
        if (file_exists($dir)) {
            throw new \RuntimeException(sprintf('Unable to generate the bundle as the target directory "%s" is not empty.', realpath($dir)));
        }

        $basename = substr($bundle, 0, -6);
        $parameters = array(
            'namespace' => $namespace,
            'bundle' => $bundle,
            'bundle_basename' => $basename,
            'extension_alias' => Container::underscore($basename),
        );

        $this->renderFile('/bundle/Bundle.php', $dir . '/' . $bundle . '.php', $parameters);
        $this->renderFile('/bundle/Extension.php', $dir . '/DependencyInjection/' . $basename . 'Extension.php', $parameters);
        $this->renderFile('/bundle/Configuration.php', $dir . '/DependencyInjection/Configuration.php', $parameters);
        $this->renderFile('/bundle/DefaultController.php', $dir . '/Controller/DefaultController.php', $parameters);
        $this->renderFile('/bundle/index.html.twig', $dir . '/Resources/views/Default/index.html.twig', $parameters);

        $this->renderFile('/bundle/services.yml', $dir . '/Resources/config/services.yml', $parameters);
        $this->renderFile('/bundle/routing.yml', $dir . '/Resources/config/routing.yml', $parameters);
    }
1026963
@Override
	public void streamBundleTo(String bundlePath, OutputStream out) throws ResourceNotFoundException {

		try {
			// byte[] gzip = gzipCache.get(bundlePath);
			byte[] gzip = (byte[]) cacheMgr.get(ZIP_CACHE_PREFIX + bundlePath);
			// If it's not cached yet
			if (null == gzip) {
				// Stream the stored data
				ByteArrayOutputStream baOs = new ByteArrayOutputStream();
				BufferedOutputStream bfOs = new BufferedOutputStream(baOs);
				rsHandler.streamBundleTo(bundlePath, bfOs);

				// Copy the data into the ByteBuffer
				bfOs.close();
				gzip = baOs.toByteArray();

				// Cache the byte array
				cacheMgr.put(ZIP_CACHE_PREFIX + bundlePath, gzip);
			}

			// Write bytes to the outputstream
			IOUtils.write(gzip, out);

		} catch (IOException e) {
			throw new BundlingProcessException("Unexpected IOException writing bundle[" + bundlePath + "]", e);
		}

	}