Registers the given {@code bundle} for the given {@code bundleInterface}.

@param bundleInterface is the interface of the {@link NlsBundle}.
@param bundle is the actual {@link NlsBundle} instance.
178490
protected void register(Class<? extends NlsBundle> bundleInterface, NlsBundle bundle) {

    NlsBundle old = this.bundleMap.put(bundleInterface, bundle);
    if (old != null) {
      throw new IllegalStateException("Duplicate bundle for " + bundleInterface);
    }
  }
385585
public static function registerPackage(PackageInterface $package, $target, AssetsInstallerInterface $installer = null)
    {
        $_this = self::getInstance($installer);
        $_this->addPackage($package, $target);
    }
943525
@Override
	public void writeBundleTo(String bundlePath, Writer writer) throws ResourceNotFoundException {

		Reader rd = null;

		try {

			// If debug mode is on, resources are retrieved one by one.
			if (config.isDebugModeOn()) {

				rd = resourceHandler.getResource(null, bundlePath);
			} else {

				for (String prefix : bundlePrefixes) {
					if (bundlePath.startsWith(prefix)) {
						bundlePath = bundlePath.substring(prefix.length());
						break;
					}
				}

				// Prefixes are used only in production mode
				String path = PathNormalizer.removeVariantPrefixFromPath(bundlePath);
				rd = resourceBundleHandler.getResourceBundleReader(path);
				if (liveProcessBundles.contains(path)) {
					rd = processInLive(rd);
				}
			}

			IOUtils.copy(rd, writer);
			writer.flush();
		} catch (IOException e) {
			throw new BundlingProcessException("Unexpected IOException writing bundle[" + bundlePath + "]", e);
		} finally {
			IOUtils.close(rd);
			IOUtils.close(writer);
		}
	}
548707
@Override
    public void start(BundleContext bc) throws Exception {
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "start", bc);
        }
    }
137073
@Route(method = HttpMethod.POST, uri = "")
    public Result installBundle(@FormParameter("bundle") final FileItem bundle,
                                @FormParameter("start") @DefaultValue("false") final boolean startIfNeeded) {
        if (bundle != null) {
            return async(new Callable<Result>() {
                @Override
                public Result call() throws Exception {
                    Bundle b;

                    try {
                        b = context.installBundle("file/temp/" + bundle.name(), bundle.stream());
                        logger().info("Bundle {} installed", b.getSymbolicName());
                    } catch (BundleException e) {
                        flash("error", "Cannot install bundle '" + bundle.name() + "' : "
                                + e.getMessage());
                        return bundle();
                    }

                    if (startIfNeeded  && ! isFragment(b)) {
                        try {
                            b.start();
                            flash("success", "Bundle '" + b.getSymbolicName() + "' installed and started");
                            return bundle();
                        } catch (BundleException e) {
                            flash("error", "Bundle '" + b.getSymbolicName() + "' installed but " +
                                    "failed to start: " + e.getMessage());
                            return bundle();
                        }
                    } else {
                        flash("success", "Bundle '" + b.getSymbolicName() + "' installed.");
                        return bundle();
                    }
                }
            });
        } else {
            logger().error("No bundle to install");
            flash("error", "Unable to install the bundle - no uploaded file");
            return bundle();
        }
    }
570870
protected final void addBundleToMap(String bundleId, String mapping) throws DuplicateBundlePathException {

		for (JoinableResourceBundle bundle : currentBundles) {
			if (bundleId.equals(bundle.getId()) || this.bundleMapping.containsKey(bundleId)) {
				Marker fatal = MarkerFactory.getMarker("FATAL");
				LOGGER.error(fatal, "Duplicate bundle id resulted from mapping:" + bundleId);
				throw new DuplicateBundlePathException(bundleId);
			}
		}

		bundleMapping.put(bundleId, mapping);
	}
156642
public void register() {
        if (registration != null) {
            throw new IllegalStateException("Webapplication is already registered.");
        }
        validateNotNull(applicationName, "applicationName");
        validateNotNull(mountPoint, "mountPoint");
        Hashtable<String, Object> props = new Hashtable<String, Object>();
        props.put(Constants.APPLICATION_NAME, applicationName);
        props.put(Constants.MOUNTPOINT, mountPoint);
        props.put(Constants.CONTEXT_PARAMS, contextParam);
        registration = bundleContext.registerService(WebApplicationFactory.class, this, props);
    }
433717
public void setBundleActivator(String bundleActivator) {
		String old = mainAttributes.get(BUNDLE_ACTIVATOR);
		if (!bundleActivator.equals(old)) {
			this.mainAttributes.put(BUNDLE_ACTIVATOR, bundleActivator);
			this.modified = true;
			this.bundleActivator = bundleActivator;
		}
	}
1197117
@Override
	public void storeJawrBundleMapping(Properties bundleMapping) {

		File bundleMappingFile = new File(tempDirPath, mappingFileName);
		OutputStream out = null;
		try {
			out = new FileOutputStream(bundleMappingFile);
			bundleMapping.store(out, "Jawr mapping");
		} catch (IOException e) {
			LOGGER.error("Unable to store the bundle mapping");
		} finally {
			IOUtils.close(out);
		}

	}
618129
public final void register() {
        synchronized (lock) {
            if (serviceRegistration == null) {
                BundleClassResolver resolver = new BundleClassResolver();
                serviceRegistration = bundleContext.registerService(SERVICE_NAMES, resolver, serviceProperties);
            }
        }
    }
513599
private static BundleContext checkBundleContext() {
        if (bundleContext == null) {
            if (tc.isDebugEnabled()) {
                Tr.debug(tc, "BundleContext is null and should not be");
            }
        }
        return bundleContext;
    }
874448
private void startBundle( final Bundle bundle )
        throws BundleException
    {
        // Don't start if bundle already active
        int bundleState = bundle.getState();
        if( bundleState == Bundle.ACTIVE )
        {
            return;
        }

        // Don't start if bundle is a fragment bundle
        Dictionary bundleHeaders = bundle.getHeaders();
        if( bundleHeaders.get( Constants.FRAGMENT_HOST ) != null )
        {
            return;
        }

        // Start bundle
        bundle.start();

        bundleState = bundle.getState();
        if( bundleState != Bundle.ACTIVE )
        {
            long bundleId = bundle.getBundleId();
            String bundleName = bundle.getSymbolicName();
            String bundleStateStr = bundleStateToString( bundleState );
            throw new BundleException(
                "Bundle (" + bundleId + ", " + bundleName + ") not started (still " + bundleStateStr + ")"
            );
        }
    }
1210270
protected void addBundle (HashIntMap<TileSet> idmap, HashMap<String, Integer> namemap,
                              TileSetBundle bundle)
    {
        IMImageProvider improv = (_imgr == null) ?
            null : new IMImageProvider(_imgr, bundle);

        // map all of the tilesets in this bundle
        for (IntMap.IntEntry<TileSet> entry : bundle.intEntrySet()) {
            Integer tsid = entry.getKey();
            TileSet tset = entry.getValue();
            tset.setImageProvider(improv);
            idmap.put(tsid.intValue(), tset);
            namemap.put(tset.getName(), tsid);
        }
    }
1082068
public void init(ResourceBundlesHandler bundler, Boolean useRandomParam) {

		this.bundler = bundler;
		if (useRandomParam == null) {
			this.useRandomParam = bundler.getConfig().isDebugUseRandomParam();
		} else {
			this.useRandomParam = useRandomParam;
		}
	}
503203
private void storeBundle(String bundleId, JoinableResourceBundleContent store) {

		stopProcessIfNeeded();

		if (bundleMustBeProcessedInLive(store.getContent().toString())) {
			liveProcessBundles.add(bundleId);
		}
		resourceBundleHandler.storeBundle(bundleId, store);
	}
1096193
private void register( final Bundle bundle )
    {
        LOG.debug( "Scanning bundle [" + bundle.getSymbolicName() + "]" );
        final List<T> resources = m_scanner.scan( bundle );
        m_mappings.put( bundle, resources );
        if( resources != null && resources.size() > 0 )
        {
            LOG.debug( "Found resources " + resources );
		            for( final BundleObserver<T> observer : m_observers )
		            {
		                try
		                {
		                	//here the executor service completes the job in an extra thread. 
		                	executorService.submit(new Runnable() {
		                		public void run() {
		                		    try 
		                		    {
		                		        observer.addingEntries( bundle, Collections.unmodifiableList( resources ) );
		                		    }
		                		    catch (Throwable t)
		                		    {
		                		        LOG.error( "Exception in executor thread", t );
		                		    }
		                		}
		                	});
		                }
		                catch( Throwable ignore )
		                {
		                    LOG.error( "Ignored exception during register", ignore );
		                }
		            }
        }
    }
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);
        }
    }