[jira] [Commented] (SLING-4327) ResourceResolver aware of any mappings
[ https://issues.apache.org/jira/browse/SLING-4327?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15473216#comment-15473216 ] Krystian Panek commented on SLING-4327: --- Maybe there are some volunteers that will move forward the issue? ;) It is quite often a heavy blocker while implementing business features and forces to have some hardcoded method which reflects mappings done by resolver. > ResourceResolver aware of any mappings > -- > > Key: SLING-4327 > URL: https://issues.apache.org/jira/browse/SLING-4327 > Project: Sling > Issue Type: Wish > Components: API >Reporter: Kamil Ciecierski > > Provide ability to create a ResourceResolver which is aware of any mappings, > for example by providing proper argument mappingPath. In case of AEM it would > be possible to use publish instance mapping present under etc/publish.map to > on author instance. > To achieve that the CommonResourceResolverFactoryImpl could be implementing > methods getResourceResolver() and getAdministrativeResourceResolver() with > additional argument defining the mapping location. The advantage of this > solution is that the created ResourceResolver can be used many times with the > same mappings. The drawback is that the mappings configuration will be found > and cached when they resourceresolver will be used for the first time - there > is no possibility to define the list of working mappings before. > The proposal of API extension: > {code} > ResourceResolver getResourceResolver(MapauthenticationInfo, > String customRootMap) throws LoginException; > > ResourceResolver getAdministrativeResourceResolver(Map > authenticationInfo, String customRootMap) throws LoginException; > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (SLING-4813) Support OSGi service mocked by e.g Mockito
[ https://issues.apache.org/jira/browse/SLING-4813?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14593877#comment-14593877 ] Krystian Panek commented on SLING-4813: --- no problem, also thanks :) Support OSGi service mocked by e.g Mockito -- Key: SLING-4813 URL: https://issues.apache.org/jira/browse/SLING-4813 Project: Sling Issue Type: Improvement Components: Testing Reporter: Krystian Panek Assignee: Robert Munteanu Fix For: Testing OSGi Mock 1.4.0 I'd like to use my existing service and mock one of its method (which is calling remote API). But I cannot do that becuase SCR service descriptor cannot be found for CGLIB enhanced class. {code}OsgiServiceUtil.injectServices(Mockito.spy(MyServiceImpl()), bundleContext){code} It would be great if in further release of mock-osgi such case will be supported. Thanks in advance! I have a hit that may work... I will create a PR in a few seconds for it... -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Created] (SLING-4813) Support OSGi service mocked by e.g Mockito
Krystian Panek created SLING-4813: - Summary: Support OSGi service mocked by e.g Mockito Key: SLING-4813 URL: https://issues.apache.org/jira/browse/SLING-4813 Project: Sling Issue Type: Improvement Components: Testing Reporter: Krystian Panek I'd like to use my existing service and mock one of its method (which is calling remote API). But I cannot do that becuase SCR service descriptor cannot be found for CGLIB enhanced class. {code}OsgiServiceUtil.injectServices(Mockito.spy(MyServiceImpl()), bundleContext){code} It would be great if in further release of mock-osgi such case will be supported. Thanks in advance! I have a hit that may work... I will create a PR in a few seconds for it... -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (SLING-4813) Support OSGi service mocked by e.g Mockito
[ https://issues.apache.org/jira/browse/SLING-4813?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14587901#comment-14587901 ] Krystian Panek commented on SLING-4813: --- https://github.com/apache/sling/pull/97 Support OSGi service mocked by e.g Mockito -- Key: SLING-4813 URL: https://issues.apache.org/jira/browse/SLING-4813 Project: Sling Issue Type: Improvement Components: Testing Reporter: Krystian Panek I'd like to use my existing service and mock one of its method (which is calling remote API). But I cannot do that becuase SCR service descriptor cannot be found for CGLIB enhanced class. {code}OsgiServiceUtil.injectServices(Mockito.spy(MyServiceImpl()), bundleContext){code} It would be great if in further release of mock-osgi such case will be supported. Thanks in advance! I have a hit that may work... I will create a PR in a few seconds for it... -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (SLING-2192) Support JAX-RS resource classes
[ https://issues.apache.org/jira/browse/SLING-2192?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14375729#comment-14375729 ] Krystian Panek commented on SLING-2192: --- +1 Support JAX-RS resource classes --- Key: SLING-2192 URL: https://issues.apache.org/jira/browse/SLING-2192 Project: Sling Issue Type: New Feature Reporter: Reto Gmür Attachments: SLING-2192-20110310.patch, SLING-2192-20111004.patch, SLING-2192-20111013.patch, SLING-2192-new-jax-rs-bundle.patch, SLING-2192-new-jax-rs-bundle.patch, SLING-2192-with-sling-style-style-registration.patch, SLING-2192-with-tests.patch, jaxrs-in-contrib.patch, slingr-on-wink-osgi.patch It should be possible to register jax resource classes and providers as services. As they don't implement a specific interface services that expose java.lang.Object should be considered as javx-rs services iff they have the service property javax.ws.rs set to true. -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (SLING-3704) Provide better examples/documentation on how to test an injector
[ https://issues.apache.org/jira/browse/SLING-3704?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14047428#comment-14047428 ] Krystian Panek commented on SLING-3704: --- Yes, now title better describes my issue. Provide better examples/documentation on how to test an injector Key: SLING-3704 URL: https://issues.apache.org/jira/browse/SLING-3704 Project: Sling Issue Type: Improvement Components: Extensions Affects Versions: Sling Models Implementation 1.0.6, Sling Models API 1.0.2 Reporter: Krystian Panek In the future, I plan to create a custom injector for Sling Models. It would be great if documentation will have some section which describes how do it in a most simple way. Also API / Impl could be improved for that perspective of usage. I would like to use in my package following snippet which I found in unit tests: {quote} factory = new ModelAdapterFactory(); factory.activate(componentCtx); factory.bindInjector(new MyCustomInjector(), new ServicePropertiesMap(1, 1)); {quote} But methods in factory have protected scope and I cannot use them directly in my package without using a reflection. I realize that maybe custom injectors are not planned in design but I hope that suggested improvement could make SM more extensible. -- This message was sent by Atlassian JIRA (v6.2#6252)
[jira] [Created] (SLING-3704) Custom injectors
Krystian Panek created SLING-3704: - Summary: Custom injectors Key: SLING-3704 URL: https://issues.apache.org/jira/browse/SLING-3704 Project: Sling Issue Type: Improvement Components: Extensions Affects Versions: Sling Models Implementation 1.0.6 Reporter: Krystian Panek In the future, I plan to create a custom injector for Sling Models. It would be great if documentation will have some section which describes how do it in a most simple way. Also API / Impl could be improved for that perspective of usage. I would like to use in my package following snippet which I found in unit tests: {quote} factory = new ModelAdapterFactory(); factory.activate(componentCtx); factory.bindInjector(new MyCustomInjector(), new ServicePropertiesMap(1, 1)); {quote} But methods in factory have protected scope and I cannot use them directly in my package without using a reflection. I realize that maybe custom injectors are not planned in design but I hope that suggested improvement could make SM more extensible. -- This message was sent by Atlassian JIRA (v6.2#6252)
[jira] [Updated] (SLING-3704) Custom injectors
[ https://issues.apache.org/jira/browse/SLING-3704?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Krystian Panek updated SLING-3704: -- Affects Version/s: Sling Models API 1.0.2 Custom injectors Key: SLING-3704 URL: https://issues.apache.org/jira/browse/SLING-3704 Project: Sling Issue Type: Improvement Components: Extensions Affects Versions: Sling Models Implementation 1.0.6, Sling Models API 1.0.2 Reporter: Krystian Panek In the future, I plan to create a custom injector for Sling Models. It would be great if documentation will have some section which describes how do it in a most simple way. Also API / Impl could be improved for that perspective of usage. I would like to use in my package following snippet which I found in unit tests: {quote} factory = new ModelAdapterFactory(); factory.activate(componentCtx); factory.bindInjector(new MyCustomInjector(), new ServicePropertiesMap(1, 1)); {quote} But methods in factory have protected scope and I cannot use them directly in my package without using a reflection. I realize that maybe custom injectors are not planned in design but I hope that suggested improvement could make SM more extensible. -- This message was sent by Atlassian JIRA (v6.2#6252)
[jira] [Commented] (SLING-3704) Custom injectors
[ https://issues.apache.org/jira/browse/SLING-3704?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14045706#comment-14045706 ] Krystian Panek commented on SLING-3704: --- Sorry for my oversight, only a few lines of docs. I just thought that I could test it using same code as in SM impl. Custom injectors Key: SLING-3704 URL: https://issues.apache.org/jira/browse/SLING-3704 Project: Sling Issue Type: Improvement Components: Extensions Affects Versions: Sling Models Implementation 1.0.6, Sling Models API 1.0.2 Reporter: Krystian Panek In the future, I plan to create a custom injector for Sling Models. It would be great if documentation will have some section which describes how do it in a most simple way. Also API / Impl could be improved for that perspective of usage. I would like to use in my package following snippet which I found in unit tests: {quote} factory = new ModelAdapterFactory(); factory.activate(componentCtx); factory.bindInjector(new MyCustomInjector(), new ServicePropertiesMap(1, 1)); {quote} But methods in factory have protected scope and I cannot use them directly in my package without using a reflection. I realize that maybe custom injectors are not planned in design but I hope that suggested improvement could make SM more extensible. -- This message was sent by Atlassian JIRA (v6.2#6252)
[jira] [Resolved] (SLING-3679) Required fields validation
[ https://issues.apache.org/jira/browse/SLING-3679?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Krystian Panek resolved SLING-3679. --- Resolution: Fixed Fix Version/s: Sling Models Implementation 1.0.6 Required fields validation -- Key: SLING-3679 URL: https://issues.apache.org/jira/browse/SLING-3679 Project: Sling Issue Type: Improvement Components: Extensions Affects Versions: Sling Models Implementation 1.0.4 Reporter: Krystian Panek Labels: models Fix For: Sling Models Implementation 1.0.6 Currently if some field cannot be injected (and it is not annotated with @Optional), model adapter factory returns null. However fact that some field has null and all other are properly injected is acceptable in my context. Proposal: * model adapter factory does not return null if not all required fields are injected, * result of requirement validation is serviced as for example: ** injecting it to some extra annotated field: @Valid boolean valid; (with default false), ** passing bool parameter in @PostConstruct callback, for example 'valid' (true if all required field are injected, false otherwise), * behave current behavior, new available only with extra model class annotation, for example @NotNull . -- This message was sent by Atlassian JIRA (v6.2#6252)
[jira] [Commented] (SLING-3679) Required fields validation
[ https://issues.apache.org/jira/browse/SLING-3679?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14041770#comment-14041770 ] Krystian Panek commented on SLING-3679: --- OK, so maybe in other words... My idea is to implement custom strategy of injecting (or even more) that tries to inject all annotated field as if all of them were optional (so in consequence model variable from taglib sling:adaptTo adaptable=${resource} adaptTo=... var=model/ never be a null - what I care most). Yes I understand that it is currently possible if I annotate all fields with @Optional, but I think that there could be a better way to do this :) Required fields validation -- Key: SLING-3679 URL: https://issues.apache.org/jira/browse/SLING-3679 Project: Sling Issue Type: Improvement Components: Extensions Affects Versions: Sling Models Implementation 1.0.4 Reporter: Krystian Panek Labels: models Currently if some field cannot be injected (and it is not annotated with @Optional), model adapter factory returns null. However fact that some field has null and all other are properly injected is acceptable in my context. Proposal: * model adapter factory does not return null if not all required fields are injected, * result of requirement validation is serviced as for example: ** injecting it to some extra annotated field: @Valid boolean valid; (with default false), ** passing bool parameter in @PostConstruct callback, for example 'valid' (true if all required field are injected, false otherwise), * behave current behavior, new available only with extra model class annotation, for example @NotNull . -- This message was sent by Atlassian JIRA (v6.2#6252)
[jira] [Comment Edited] (SLING-3679) Required fields validation
[ https://issues.apache.org/jira/browse/SLING-3679?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14041770#comment-14041770 ] Krystian Panek edited comment on SLING-3679 at 6/24/14 6:37 AM: OK, so maybe in other words... My idea is to implement custom strategy of injecting (or even more) that tries to inject all annotated field as if all of them were optional (so in consequence model variable from taglib sling:adaptTo var=model ... / never be a null - what I care most). Yes I understand that it is currently possible if I annotate all fields with @Optional, but I think that there could be a better way to do this :) was (Author: kpanek): OK, so maybe in other words... My idea is to implement custom strategy of injecting (or even more) that tries to inject all annotated field as if all of them were optional (so in consequence model variable from taglib sling:adaptTo adaptable=${resource} adaptTo=... var=model/ never be a null - what I care most). Yes I understand that it is currently possible if I annotate all fields with @Optional, but I think that there could be a better way to do this :) Required fields validation -- Key: SLING-3679 URL: https://issues.apache.org/jira/browse/SLING-3679 Project: Sling Issue Type: Improvement Components: Extensions Affects Versions: Sling Models Implementation 1.0.4 Reporter: Krystian Panek Labels: models Currently if some field cannot be injected (and it is not annotated with @Optional), model adapter factory returns null. However fact that some field has null and all other are properly injected is acceptable in my context. Proposal: * model adapter factory does not return null if not all required fields are injected, * result of requirement validation is serviced as for example: ** injecting it to some extra annotated field: @Valid boolean valid; (with default false), ** passing bool parameter in @PostConstruct callback, for example 'valid' (true if all required field are injected, false otherwise), * behave current behavior, new available only with extra model class annotation, for example @NotNull . -- This message was sent by Atlassian JIRA (v6.2#6252)
[jira] [Commented] (SLING-3679) Required fields validation
[ https://issues.apache.org/jira/browse/SLING-3679?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14038553#comment-14038553 ] Krystian Panek commented on SLING-3679: --- Consider situation that I would like to check whether my component model can be adopted in view. If not I want to display some placeholder instead of that component. I am afraid but this is currently not possible without getting warning: Required properties ... on model class class ... were not able to be injected.. In my context at the first time when I create a component model all fields are always null so I have to mark all of them as @Optional . I cannot change that mechanism, so proposed improvements are very important in my situation (and potentially for many other users who are using CQ/AEM). Required fields validation -- Key: SLING-3679 URL: https://issues.apache.org/jira/browse/SLING-3679 Project: Sling Issue Type: Improvement Components: Extensions Affects Versions: Sling Models Implementation 1.0.4 Reporter: Krystian Panek Labels: models Currently if some field cannot be injected (and it is not annotated with @Optional), model adapter factory returns null. However fact that some field has null and all other are properly injected is acceptable in my context. Proposal: * model adapter factory does not return null if not all required fields are injected, * result of requirement validation is serviced as for example: ** injecting it to some extra annotated field: @Valid boolean valid; (with default false), ** passing bool parameter in @PostConstruct callback, for example 'valid' (true if all required field are injected, false otherwise), * behave current behavior, new available only with extra model class annotation, for example @NotNull . -- This message was sent by Atlassian JIRA (v6.2#6252)
[jira] [Updated] (SLING-3677) Array to list conversion in ValueMap
[ https://issues.apache.org/jira/browse/SLING-3677?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Krystian Panek updated SLING-3677: -- Attachment: valuemap-injector-list-support.diff Array to list conversion in ValueMap Key: SLING-3677 URL: https://issues.apache.org/jira/browse/SLING-3677 Project: Sling Issue Type: Improvement Components: Extensions Affects Versions: Sling Models Implementation 1.0.4 Reporter: Krystian Panek Priority: Minor Labels: models Fix For: Sling Models Implementation 1.0.6 Attachments: valuemap-injector-list-support.diff I suppose that many people prefer lists more than arrays. Automatic conversion in value map would be useful. See attachment (svn diff this time as Justin asked). Only default value support is missing... -- This message was sent by Atlassian JIRA (v6.2#6252)
[jira] [Created] (SLING-3677) Array to list conversion in ValueMap
Krystian Panek created SLING-3677: - Summary: Array to list conversion in ValueMap Key: SLING-3677 URL: https://issues.apache.org/jira/browse/SLING-3677 Project: Sling Issue Type: Improvement Components: Extensions Affects Versions: Sling Models Implementation 1.0.4 Reporter: Krystian Panek Priority: Minor Fix For: Sling Models Implementation 1.0.6 Attachments: valuemap-injector-list-support.diff I suppose that many people prefer lists more than arrays. Automatic conversion in value map would be useful. See attachment (svn diff this time as Justin asked). Only default value support is missing... -- This message was sent by Atlassian JIRA (v6.2#6252)
[jira] [Created] (SLING-3679) Required fields validation
Krystian Panek created SLING-3679: - Summary: Required fields validation Key: SLING-3679 URL: https://issues.apache.org/jira/browse/SLING-3679 Project: Sling Issue Type: Improvement Components: Extensions Affects Versions: Sling Models Implementation 1.0.4 Reporter: Krystian Panek Fix For: Sling Models Implementation 1.0.6 Currently if some field cannot be injected (and it is not annotated with @Optional), model adapter factory returns null. However fact that some field has null and all other are properly injected is acceptable in my context. Proposal: * model adapter factory does not return null if not all required fields are injected, * result of requirement validation is serviced as for example: ** injecting it to some extra annotated field: @Valid boolean valid; (with default false), ** passing bool parameter in @PostConstruct callback, for example 'valid' (true if all required field are injected, false otherwise), * behave current behavior, new available only with extra model class annotation, for example @NotNull . -- This message was sent by Atlassian JIRA (v6.2#6252)
[jira] [Created] (SLING-3674) Array of wrappers to primitives conversion in Sling Models
Krystian Panek created SLING-3674: - Summary: Array of wrappers to primitives conversion in Sling Models Key: SLING-3674 URL: https://issues.apache.org/jira/browse/SLING-3674 Project: Sling Issue Type: Bug Components: Extensions Affects Versions: Sling Models Implementation 1.0.6 Reporter: Krystian Panek Fix For: Sling Models Implementation 1.0.6 Problem is related with: https://issues.apache.org/jira/browse/SLING-3547 Suppose that I have: {quote} @Inject private int[] scores; @Inject private Integer[] scores; {quote} For first declaration injection does not work, because in my environment ValueMap contains array of wrapped integers and type cast to array of primitives cannot be done. I noticed an exception: {quote} 27 [main] ERROR org.apache.sling.models.impl.ModelAdapterFactory - unable to create object java.lang.ClassCastException: [I cannot be cast to [Ljava.lang.Object; at org.apache.sling.api.wrappers.ValueMapDecorator.convertToArray(ValueMapDecorator.java:100) {quote} Second declaration seems to work but how to apply default value for it? According to Sling Models documentation, example with default value for array of integers currently it is not possible to get it working. Same error as for first declaration. I wrote unit test for it. I hope, useful for reproducing problem, see attachments. -- This message was sent by Atlassian JIRA (v6.2#6252)
[jira] [Updated] (SLING-3674) Array of wrappers to primitives conversion in Sling Models
[ https://issues.apache.org/jira/browse/SLING-3674?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Krystian Panek updated SLING-3674: -- Attachment: ArrayPrimitivesModel.java ResourceModelClassesTest.java Array of wrappers to primitives conversion in Sling Models -- Key: SLING-3674 URL: https://issues.apache.org/jira/browse/SLING-3674 Project: Sling Issue Type: Bug Components: Extensions Affects Versions: Sling Models Implementation 1.0.6 Reporter: Krystian Panek Labels: models Fix For: Sling Models Implementation 1.0.6 Attachments: ArrayPrimitivesModel.java, ResourceModelClassesTest.java Problem is related with: https://issues.apache.org/jira/browse/SLING-3547 Suppose that I have: {quote} @Inject private int[] scores; @Inject private Integer[] scores; {quote} For first declaration injection does not work, because in my environment ValueMap contains array of wrapped integers and type cast to array of primitives cannot be done. I noticed an exception: {quote} 27 [main] ERROR org.apache.sling.models.impl.ModelAdapterFactory - unable to create object java.lang.ClassCastException: [I cannot be cast to [Ljava.lang.Object; at org.apache.sling.api.wrappers.ValueMapDecorator.convertToArray(ValueMapDecorator.java:100) {quote} Second declaration seems to work but how to apply default value for it? According to Sling Models documentation, example with default value for array of integers currently it is not possible to get it working. Same error as for first declaration. I wrote unit test for it. I hope, useful for reproducing problem, see attachments. -- This message was sent by Atlassian JIRA (v6.2#6252)