protected void activate(final ComponentContext context) { final Hashtable<String, String> dict = new Hashtable<String, String>(); dict.put(URLConstants.URL_HANDLER_PROTOCOL, "httppgp"); context.getBundleContext().registerService(URLStreamHandlerService.class.getName(), this, dict); }
@Activate @SuppressWarnings("unchecked") protected void activate(ComponentContext componentContext) { initDimensionMap(); modified((Map<String, Object>) componentContext.getProperties()); this.resourceBundleTracker = new ResourceBundleTracker(componentContext.getBundleContext(), this); this.resourceBundleTracker.open(); }
@Activate protected void activate(ComponentContext ctx) throws ConfigurationException { Object value =ctx.getProperties().get(PROEPRTY_INDENT); if(value instanceof Number){ indent = ((Number)value).intValue(); } else if(value != null){ try { indent = Integer.parseInt(value.toString()); } catch(NumberFormatException e){ throw new ConfigurationException(PROEPRTY_INDENT, "The parsed indent MUST BE an Integer number (values <= 0 " + "will deactivate pretty format)"); } } else { indent = DEFAULT_INDENT; } } @Deactivate
@Activate protected final void activate(ComponentContext context) throws Exception { Dictionary<?, ?> properties = context.getProperties(); doActivate(context); String[] filters = PropertiesUtil.toStringArray(properties.get(PROP_FILTER_PATTERN)); if (filters == null || filters.length == 0) { throw new ConfigurationException(PROP_FILTER_PATTERN, "At least one filter pattern must be specified."); } for (String pattern : filters) { Dictionary<String, String> filterProps = new Hashtable<String, String>(); log.debug("Adding filter ({}) to pattern: {}", this.toString(), pattern); filterProps.put("pattern", pattern); ServiceRegistration filterReg = context.getBundleContext().registerService(Filter.class.getName(), this, filterProps); filterRegistrations.add(filterReg); } }
protected static String lookup(ComponentContext context, String property) { //Prefer property from BundleContext first if (context.getBundleContext().getProperty(property) != null) { return context.getBundleContext().getProperty(property); } if (context.getProperties().get(property) != null) { return context.getProperties().get(property).toString(); } return null; }
@Activate public void activate(ComponentContext context) { this.path = (String) context.getProperties().get(ReasoningService.SERVICE_PATH); } }
@SuppressWarnings("squid:S1149") protected final void registerAsSlingFilter(ComponentContext ctx, int ranking, String pattern) { Dictionary<String, String> filterProps = new Hashtable<String, String>(); filterProps.put("service.ranking", String.valueOf(ranking)); filterProps.put("sling.filter.scope", "REQUEST"); filterProps.put("sling.filter.pattern", StringUtils.defaultIfEmpty(pattern, ".*")); filterRegistration = ctx.getBundleContext().registerService(Filter.class.getName(), this, filterProps); }
/** * Check the existence of the given dictionary. Throw an exception if null. */ public static void checkDictionary(Dictionary properties, ComponentContext componentContext) throws ConfigurationException { if (properties == null) { String dicName = componentContext.getProperties().get("service.pid").toString(); throw new ConfigurationException("*", "Dictionary for " + dicName + " does not exist"); } }
/** * This service is being activated so setup it: * <ul> * <li>Create and open the {@link MetadataDependencyRegistryTracker}.</li> * </ul> */ protected void activate(final ComponentContext componentContext) { this.registryTracker = new MetadataDependencyRegistryTracker(componentContext.getBundleContext(), this); this.registryTracker.open(); for (final Bundle b : componentContext.getBundleContext().getBundles()) { if (!MY_BUNDLE_SYMBOLIC_NAME.equals(b.getSymbolicName())) { continue; } final Object v = b.getHeaders().get("Bundle-Version"); if (v != null) { final String version = v.toString(); bundleVersionInfo = extractVersionInfoFromString(version); } break; } }
@Activate public void activate(ComponentContext ctx) { URL url = ctx.getBundleContext().getBundle().getResource(TEMPLATE_FILENAME); if (url == null) { LOG.error("File " + TEMPLATE_FILENAME + " not found in bundle."); return; } readTemplateFromUrl(url); }
@Activate protected void activate(final ComponentContext context) { resourceProvidingBundles = new HashSet<Bundle>(); path2Bundle = new HashMap<String, Bundle>(); final Bundle[] registeredBundles = context.getBundleContext().getBundles(); for (int i = 0; i < registeredBundles.length; i++) { if (registeredBundles[i].getState() == Bundle.ACTIVE) { registerResources(registeredBundles[i]); } } context.getBundleContext().addBundleListener(this); }
protected void activate(final ComponentContext componentContext) { componentContext.getBundleContext().addBundleListener(this); weight = (Integer) componentContext.getProperties().get("weight"); registerExistingDocumentations(componentContext); createUnionGraph(); }
@Activate void activate(ComponentContext componentContext) throws IOException, BundleException { // Use system bundle' bundle context to avoid running into // "Invalid BundleContext" exceptions when updating bundles BundleContext bundleContext = componentContext.getBundleContext().getBundle(0).getBundleContext(); File karafHome = new File(bundleContext.getProperty("karaf.home")); helper = new OSGiPatchHelper(karafHome, bundleContext); }
/** * This service is being activated so setup it: * <ul> * <li>Create and open the {@link MetadataDependencyRegistryTracker}</li> * <li>Registers {@link RooJavaType#ROO_CONFIGURABLE} as additional * JavaType that will trigger metadata registration.</li> * </ul> */ @Override protected void activate(final ComponentContext cContext) { context = cContext.getBundleContext(); this.registryTracker = new MetadataDependencyRegistryTracker(context, null, PhysicalTypeIdentifier.getMetadataIdentiferType(), getProvidesType()); this.registryTracker.open(); addMetadataTrigger(ROO_CONFIGURABLE); }
@Activate protected void activate(ComponentContext ctx) { BundleContext bundleContext = ctx.getBundleContext(); // this is less than ideal, but there's no better way to get to the fs classloader's data directory for (Bundle bundle : bundleContext.getBundles()) { if (bundle.getSymbolicName().equals("org.apache.sling.commons.fsclassloader")) { this.fileRoot = new File(slingSettingsService.getSlingHomePath(), "launchpad/felix/bundle"+bundle.getBundleId()+"/data/classes"); break; } } } }
/** * Returns the Roo working directory for the given OSGi component context * * @param componentContext the component context (required) * @return the path of the Roo working directory * @since 1.2.0 */ public static String getRooWorkingDirectory(final ComponentContext componentContext) { return componentContext.getBundleContext().getProperty(ROO_WORKING_DIRECTORY_PROPERTY); }
protected void activate(final ComponentContext context) { this.context = context.getBundleContext(); final Thread thread = new Thread(this, "Spring Roo JLine Shell"); thread.start(); }
final Bundle[] bundles = context.getBundleContext().getBundles(); if (bundles != null) { for (final Bundle bundle : bundles) {
@Activate protected void activate(ComponentContext ctx) throws InvalidSyntaxException { BundleContext bundleContext = ctx.getBundleContext(); StringBuilder builder = new StringBuilder(); builder.append("(&("); builder.append(Constants.OBJECTCLASS).append("=").append(Importer.SERVICE_NAME).append(")"); builder.append("(displayName=*))"); Filter filter = bundleContext.createFilter(builder.toString()); this.tracker = new ServiceTracker(bundleContext, filter, null); this.tracker.open(); }
@Activate protected void activate(ComponentContext ctx) throws ConfigurationException { String folderName = requireProperty(ctx.getProperties(), DATA_FILES_FOLDER_PROP, String.class); dataFilesFolder = new File(folderName); if(!dataFilesFolder.exists()){ if(!dataFilesFolder.mkdirs()){ throw new ConfigurationException(DATA_FILES_FOLDER_PROP, "Unable to create the configured Directory "+dataFilesFolder); } } else if(!dataFilesFolder.isDirectory()){ throw new ConfigurationException(DATA_FILES_FOLDER_PROP, "The configured DataFile directory "+dataFilesFolder+" does already exists but is not a directory!"); } //else exists and is a directory! }