tag:blogger.com,1999:blog-5778419059463879376.post1166745357133293150..comments2024-03-28T23:09:52.265-07:00Comments on Adobe CQ/Adobe AEM: How to work with Configurations in CQ Yogihttp://www.blogger.com/profile/13222275932054732457noreply@blogger.comBlogger29125tag:blogger.com,1999:blog-5778419059463879376.post-83946473132238364342016-02-25T12:04:02.022-08:002016-02-25T12:04:02.022-08:00###### Helper Service Interface #####
public inter...###### Helper Service Interface #####<br />public interface QueryFacetPredicateProvider {<br /><br /> List getFacetPredicates(String providerClassName);<br />}<br /><br />##### Helper Service Impl ######<br />@Component(label = "Query Facets Provider", description = "Provides query facets from the QueryFacetConfiguration", immediate = true, metatype = false, enabled = true)<br />@Service<br />@References({@Reference(referenceInterface = QueryFacetConfigurationFactory.class,<br /> cardinality = ReferenceCardinality.OPTIONAL_MULTIPLE,<br /> policy = ReferencePolicy.DYNAMIC, name = "FacetConfigurationFactory")})<br />public class QueryFacetPredicateProviderService implements QueryFacetPredicateProvider {<br /><br /> private static final Logger LOGGER = LoggerFactory.getLogger(QueryFacetPredicateProviderService.class);<br /><br /> private Map factoryConfigs;<br /><br /> protected synchronized void bindFacetConfigurationFactory(final QueryFacetConfigurationFactory config) {<br /> if (factoryConfigs == null) {<br /> factoryConfigs = new HashMap<>();<br /> }<br /><br /> LOGGER.debug("Adding facets configuration for provider " + config.getQueryClass());<br /><br /> factoryConfigs.put(config.getQueryClass(), config);<br /> }<br /><br /> protected synchronized void unbindFacetConfigurationFactory(final QueryFacetConfigurationFactory config) {<br /> LOGGER.debug("Removing facets configuration for provider " + config.getQueryClass());<br /> factoryConfigs.remove(config.getQueryClass());<br /> }<br /><br /> /**<br /> *<br /> * @param providerClassName<br /> * @return<br /> */<br /> public List getFacetPredicates(String providerClassName) {<br /><br /> String [] configuredFacets = factoryConfigs.get(providerClassName).getFacets();<br /> List facetPredicates = new ArrayList<>();<br /><br /> for(String facet : configuredFacets) {<br /><br /> if(facet.split("#").length > 1) {<br /> Predicate facetPredicate = new Predicate(facet.split("#")[0],facet.split("#")[1]);<br /> facetPredicate.set("property",facet.split("#")[2]);<br /> facetPredicates.add(facetPredicate);<br /> } else {<br /> LOGGER.debug("Configuration not properly set for facet {}",facet);<br /> }<br /> }<br /><br /> return facetPredicates;<br />}<br />}<br /><br /><br /><br />##### XML File name ####<br />net.cms.aem.search.sql2.core.facets.QueryFacetConfigurationFactoryService.Full-text-search.xml<br /><br />I have tried with net.cms.aem.search.sql2.core.facets.QueryFacetConfigurationFactory.Full-text-search.xml as well.<br /><br />Thanks in advance<br />AmeeshAmeeshThttps://www.blogger.com/profile/04150449351390419839noreply@blogger.comtag:blogger.com,1999:blog-5778419059463879376.post-14531264714874498302016-02-14T10:00:19.884-08:002016-02-14T10:00:19.884-08:00Hello Mohit,
Note that random PID value is someth...Hello Mohit,<br /><br />Note that random PID value is something AEM generated. If you have custom factory config. I would suggest to give some meaningful name to it, For example config.author/com.day.commons.datasource.jdbcpool.JdbcPoolService-MySQL.xml or config.author/com.day.commons.datasource.jdbcpool.JdbcPoolService-teradata.xml or config.author/com.day.commons.datasource.jdbcpool.JdbcPoolService-Oracle.xml<br /><br />They all should work. I would suggest to use felix console for randomly generated PID.<br /><br />YogeshYogihttps://www.blogger.com/profile/13222275932054732457noreply@blogger.comtag:blogger.com,1999:blog-5778419059463879376.post-66305112484771156932016-02-14T09:53:10.672-08:002016-02-14T09:53:10.672-08:00@ashtrick,
I think your approach of defining chan...@ashtrick,<br /><br />I think your approach of defining changeable property through @Property should work.<br /><br />YogeshYogihttps://www.blogger.com/profile/13222275932054732457noreply@blogger.comtag:blogger.com,1999:blog-5778419059463879376.post-38080071840468679602016-02-11T20:47:09.318-08:002016-02-11T20:47:09.318-08:00Hi Yogesh,
Is it possible to override the factory...Hi Yogesh,<br /><br />Is it possible to override the factory configuration PID from crxde using sling:osgiconfig type.<br /><br />Scenario is :-<br /><br />There is one manually authored configuration inside my factory configuration and its PID value is com.xperian.cms.base.swse.services.xperianswseconfiguration.6ad86ce9-752b-410d-8ada-23a06111e369<br /><br />6ad86ce9-752b-410d-8ada-23a06111e369 is appended bt cq. But when i want to made its osgi.config from crxde it is giving me an error.<br />"Could not save changes. Received 403 (Forbidden) for saving changes in workspace crx.default. Failed to resolve path com.xperian.cms.base.swse.services.xperianswseconfiguration.6ad86ce9-752b-410d-8ada-23a06111e369 relative to node /apps/xperian/configuration/config.author"<br /><br />Is there any way to override this values ?<br /><br />or we have to create the new one ?<br />Anonymoushttps://www.blogger.com/profile/03965198175539902501noreply@blogger.comtag:blogger.com,1999:blog-5778419059463879376.post-90053279639528627402015-03-27T04:39:53.258-07:002015-03-27T04:39:53.258-07:00Thanks for the response. Is it a best way to provi...Thanks for the response. Is it a best way to provide this as property that can be configured through Felix console? So, I have osgi:config node for the class for those parameters that will not change and as well as have the @Property configuration parameters in the class which can be managed through Felix console.<br />Thanksashtrickhttps://www.blogger.com/profile/14640005329457543552noreply@blogger.comtag:blogger.com,1999:blog-5778419059463879376.post-36123598272856536692015-03-25T09:40:29.287-07:002015-03-25T09:40:29.287-07:00If these property can be changed by author or admi...If these property can be changed by author or admin on regular basis and not during code deployment then I would suggest not to use osgi:config approach at all. Use some kind custom property that user can change through UI and then read it through code.Yogihttps://www.blogger.com/profile/13222275932054732457noreply@blogger.comtag:blogger.com,1999:blog-5778419059463879376.post-58435688089484683932015-03-24T04:40:31.275-07:002015-03-24T04:40:31.275-07:00Hi Yogesh,
Thanks for sharing.
I created configu...Hi Yogesh,<br /><br />Thanks for sharing.<br /><br />I created configurations by creating node sling:OsgiConfig. I have a property which is likely to change often, which I need to configure through felix console. How do I do that? Or is it not a good idea to keep these kind of properties in OsgiConfig node?<br />Thanksashtrickhttps://www.blogger.com/profile/14640005329457543552noreply@blogger.comtag:blogger.com,1999:blog-5778419059463879376.post-86388393450417612822014-11-17T03:06:28.475-08:002014-11-17T03:06:28.475-08:00Hi thanks for sharing!
I'm trying to create a ...Hi thanks for sharing!<br />I'm trying to create a Configuration factory. Anyway I can't understand how you can make it works.<br />In particular I get stuck with the bind method.<br />protected void bindMyCustomService(ServiceReference ref) {<br /> synchronized (this. myCustomServices) {<br /> String customKey = ref.getProperty(KEY);<br /> MyCustomServices operation = this.componentContext.locateService("MyCustomService",ref);<br />//Or you can use<br />//MyCustomServices operation = ref.getProperty("service.pid");<br /> if (operation != null) {<br /> myCustomServices.put(customKey,ref);<br /> }<br /> }<br />}<br />I get a compile-time error with your code due to the incompability of the ServiceReference object with the MyCustomService class of the map. If I try to do a cast before to put the object into the Map I get a CastException.<br /><br />Any advice about that? Thanks againAnonymoushttps://www.blogger.com/profile/10267242185945945417noreply@blogger.comtag:blogger.com,1999:blog-5778419059463879376.post-84603877929280049112014-10-08T23:59:27.631-07:002014-10-08T23:59:27.631-07:00Bingo -:) It worked.
Thanks Yogesh.... Bingo -:) It worked. <br />Thanks Yogesh.... Anonymoushttps://www.blogger.com/profile/16860584909147899760noreply@blogger.comtag:blogger.com,1999:blog-5778419059463879376.post-67808472257597131592014-10-08T17:36:54.401-07:002014-10-08T17:36:54.401-07:00Can you create a corresponding osgi config in repo...Can you create a corresponding osgi config in repository as well to test ? for example in your case you have to create com.cq.querybuilder.BaseConfig.xml under some /apps/config node and then set up property there.Yogihttps://www.blogger.com/profile/13222275932054732457noreply@blogger.comtag:blogger.com,1999:blog-5778419059463879376.post-3364009973660910812014-10-08T17:34:43.574-07:002014-10-08T17:34:43.574-07:00facade class is just a helper in case you want to ...facade class is just a helper in case you want to get particular service within factory service based on key. Yogihttps://www.blogger.com/profile/13222275932054732457noreply@blogger.comtag:blogger.com,1999:blog-5778419059463879376.post-29013205160994186662014-10-08T17:22:27.435-07:002014-10-08T17:22:27.435-07:00for config factory you can use friendly name after...for config factory you can use friendly name after pid .. some thing like com.mycompany.something-myfriendlyname1 com.mycompany.something-myfriendlyname2 so on.Yogihttps://www.blogger.com/profile/13222275932054732457noreply@blogger.comtag:blogger.com,1999:blog-5778419059463879376.post-54480154127912087082014-10-08T17:21:07.857-07:002014-10-08T17:21:07.857-07:00Run mode can not help in this case. As Run mode ar...Run mode can not help in this case. As Run mode are set during startup. You need to use if then condition for this to work and then use ConfigUtil service to read from different configurations.Yogihttps://www.blogger.com/profile/13222275932054732457noreply@blogger.comtag:blogger.com,1999:blog-5778419059463879376.post-57919497270477861852014-10-08T01:13:25.083-07:002014-10-08T01:13:25.083-07:00Hey Yogesh,
I was trying to create a property on ...Hey Yogesh,<br /><br />I was trying to create a property on a Service using the option#2, code way. I am seeing a strange behavior. The service will be "unbound" until it is SAVED at least once. When I tried to find on the net, I found a similar thread but can't make out what was the solution. (https://forums.adobe.com/thread/1088425).<br /><br />My code...<br />package com.cq.querybuilder;<br /><br />import org.apache.felix.scr.annotations.Component;<br />import org.apache.felix.scr.annotations.Properties;<br />import org.apache.felix.scr.annotations.Property;<br />import org.apache.felix.scr.annotations.PropertyUnbounded;<br />import org.apache.felix.scr.annotations.Service;<br /><br /><br />@Service(value=BaseConfig.class)<br />@Component(label = "com.cq.querybuilder.BaseConfig", description = "Place Holder for configurations", metatype = true, immediate=true)<br />@Properties({ @Property(name="service.description", value="My trial 001"),<br /> @Property(name="service.vendor", value="YEs !!!")})<br />public class BaseConfig {<br /><br /> /** The Constant PROPERTY_EMAIL_TITLE */<br /> @Property(<br /> label = "Property Title",<br /> description = "Title of the Property.",<br /> value = "Customer Input")<br /> private static final String PROPERTY_XYZ_TITLE = "propertyTilte";<br /><br />}<br /><br />Anonymoushttps://www.blogger.com/profile/16860584909147899760noreply@blogger.comtag:blogger.com,1999:blog-5778419059463879376.post-54288751777961840442014-05-14T11:45:50.045-07:002014-05-14T11:45:50.045-07:00Hi, for the Configuration of Factory items, how do...Hi, for the Configuration of Factory items, how do those get registered with the Facade class?<br />I see the bind and unbind, are those functions named by convention? Is there some piece missing? I have everything working except this last piece (Felix is registering the individual services but I can't seem to access them from the facade class functions)Anonymoushttps://www.blogger.com/profile/07007302420400429067noreply@blogger.comtag:blogger.com,1999:blog-5778419059463879376.post-32259321084768012702014-01-20T14:05:17.298-08:002014-01-20T14:05:17.298-08:00Hi Yogesh,
Is it possible to display a more user-...Hi Yogesh,<br /><br />Is it possible to display a more user-friendly name in Felix console for the config factory instance instead of the PID? Our customer would like to create multiple factory instances of the same service and be able to easily distinguish between all of the instances with a more user-friendly name.<br /><br />Thank you in advance.<br />GS Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-5778419059463879376.post-91633074643234363912013-11-27T06:39:30.146-08:002013-11-27T06:39:30.146-08:00Hi Yogesh,
CQ ConfigAdmin picks a folder based on...Hi Yogesh,<br /><br />CQ ConfigAdmin picks a folder based on the runmode like your example config.author.dev. I have a usecase where-in my custom service is supposed to use two different set of properties based on whether its day or night. I know we could have an if else in service itslef and taking a superset of all the parameters, so wondering if runmode can help me here. Like if I create two different folders say config.author.dev.day & config.author.dev.night and then creating under each of it osgi:config node same as PID of my service. This will make it more flexible but have not found a way to do the same so far. Can you help?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-5778419059463879376.post-51985485434220774112013-11-15T17:30:17.077-08:002013-11-15T17:30:17.077-08:00Vipul,
If it is static content then you can can u...Vipul,<br /><br />If it is static content then you can can use i18n feature http://www.wemblog.com/2011/12/how-to-use-multi-language-translation.html one with jcr:language=en and other with en_US. If it is read from dialog then in that case you have to implement some thing at code level.<br /><br />YogeshYogihttps://www.blogger.com/profile/13222275932054732457noreply@blogger.comtag:blogger.com,1999:blog-5778419059463879376.post-49876820426769332522013-11-15T03:16:08.151-08:002013-11-15T03:16:08.151-08:00If I have two sites in one CQ5 instance, for e.g e...If I have two sites in one CQ5 instance, for e.g en, en_US. How will I be able to configure different values for same property for both sites ?<br /><br />Thanks in advance,<br />VipulAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-5778419059463879376.post-41615351691499154752013-10-11T09:00:29.018-07:002013-10-11T09:00:29.018-07:00LM,
You should be able to access value using some...LM,<br /><br />You should be able to access value using something like<br />this. RESTEndPointUrl =OsgiUtil.toStringArray(properties.get(REST_SERVIVE_BY_ARL)); where this. RESTEndPointUrl is string array and REST_SERVIVE_BY_ARL is multivalue property. You can manually create configuration as well, for example in your case file name would be<br />/apps//config/.ConfigurationServiceImpl.xml and content would be<br /><br /><br /><jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"<br /> jcr:primaryType="sling:OsgiConfig"<br /> RESTEndPointUrl="[SOMETHING]"/<br /><br />YogeshYogihttps://www.blogger.com/profile/13222275932054732457noreply@blogger.comtag:blogger.com,1999:blog-5778419059463879376.post-59503168947976331682013-10-09T19:27:35.481-07:002013-10-09T19:27:35.481-07:00Hi,
I created config factory as below
import jav...Hi,<br /><br />I created config factory as below<br /><br />import java.util.Dictionary;<br />import org.apache.felix.scr.annotations.Component;<br />import org.apache.felix.scr.annotations.Properties;<br />import org.apache.felix.scr.annotations.Property;<br />import org.apache.felix.scr.annotations.Service;<br />import org.osgi.framework.Constants;<br />import org.osgi.service.component.ComponentContext;<br />import org.slf4j.Logger;<br />import org.slf4j.LoggerFactory;<br />@Component( immediate=true, label="Cache Clear Configuration Service", description = " Cache Clear Configuration Service", metatype=true )<br />@Service <br />@Properties({<br /> @Property(name = Constants.SERVICE_DESCRIPTION, value = "Cache Clear Configuration Service"),<br /> @Property(name = Constants.SERVICE_VENDOR, value = "XYZ")})<br /> public class ConfigurationServiceImpl implements ConfigurationService{<br /> private static final Logger log = LoggerFactory.getLogger(ConfigurationServiceImpl.class);<br /> @Property(label = "REST Service Url By ARL", value = "http://localhost:8080/abbc")<br /> public static final String REST_SERVIVE_BY_ARL= "RESTEndPointUrl";<br /> private String RESTEndPointUrl;<br /> protected void activate(ComponentContext context){<br /> try {<br /> log.info("activate method called");<br /> Dictionary props = context.getProperties();<br /> RESTEndPointUrl = (String) props.get(REST_SERVIVE_BY_ARL);<br /> } catch (Exception e){<br /> log.error(e.getMessage(), e);<br /> } }<br /> public String getRESTSericeUrlByARL() {<br /> return rESTEndPointUrl;<br /> }<br /> public void setRESTSericeUrlByARL(String rESTEndPointUrl) {<br /> this.akamaiRESTEndPointUrl = rESTEndPointUrl;<br /> }}<br /><br />I could see values stored under /apps/system/config/com......How I can access those array of values.Currently it is stored as binary data.<br /><br />Thanks<br />LM<br />Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-5778419059463879376.post-28056049545238337862013-10-08T13:13:49.326-07:002013-10-08T13:13:49.326-07:00Hello,
I am very sorry but do not have any specif...Hello,<br /><br />I am very sorry but do not have any specific package for this. But it should be very easy to implement this. Please let me know if you are getting any error while implementing this ?<br /><br />YogeshYogihttps://www.blogger.com/profile/13222275932054732457noreply@blogger.comtag:blogger.com,1999:blog-5778419059463879376.post-58400711479496703712013-10-07T21:59:39.373-07:002013-10-07T21:59:39.373-07:00As package can u pls upload it.As package can u pls upload it.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-5778419059463879376.post-11203554192380599792013-10-07T12:58:03.295-07:002013-10-07T12:58:03.295-07:00Hello example code if already there in post, Let m...Hello example code if already there in post, Let me know if you want any specific code.<br /><br />YogeshYogihttps://www.blogger.com/profile/13222275932054732457noreply@blogger.comtag:blogger.com,1999:blog-5778419059463879376.post-14546601053886978392013-10-07T00:58:11.822-07:002013-10-07T00:58:11.822-07:00Hi Yogesh,Can u pls share code base for this?Hi Yogesh,Can u pls share code base for this?Anonymousnoreply@blogger.com