Adding a filter

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Adding a filter

Ben Short-4
Hi,

I'm trying to add a filter to my bundle I have the following at the
top of my class

/**
* @scr.component metatype="no" enabled="no"
* @scr.property name="service.description" value="Request Filter"
* @scr.property name="filter.scope" value="request" private="true"
* @scr.property name="filter.order" value="-2147483648" type="Integer"
private="true"
* @scr.service
*/

And my maven config is as follows

<plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <extensions>true</extensions>
                <configuration>
                    <instructions>

<Sling-Initial-Content>initial-content;overwrite:=true;uninstall=true</Sling-Initial-Content>
                        <Export-Package>
                            com.daisytechnologies.*;version=${pom.version}
                        </Export-Package>
                    </instructions>
                </configuration>
            </plugin>

I deploy the bundle but can't see that the filter is added or being used.

I have also set

* @scr.component metatype="no" enabled="no"

to

* @scr.component metatype="no" immediate="true"

but no joy.

Can anyone help me out?

Ben

Reply | Threaded
Open this post in threaded view
|

Re: Adding a filter

Felix Meschberger
Administrator
Hi Ben, I fear you are missing the maven-scr-plugin which converts the
JavaDoc tags into the Declarative Services descriptor used to register
the filter.

Also setting 'enabled="no"' actually per default disables the filter.
You should remove this setting unless you plan to manually enable the
filter.

I think that using the 'immediate="true"' flag makes sense since the
service will anyway immediately be picked up by the SlingMainServlet.

HTH

Regards
Felix

Ben Short schrieb:

> Hi,
>
> I'm trying to add a filter to my bundle I have the following at the
> top of my class
>
> /**
> * @scr.component metatype="no" enabled="no"
> * @scr.property name="service.description" value="Request Filter"
> * @scr.property name="filter.scope" value="request" private="true"
> * @scr.property name="filter.order" value="-2147483648" type="Integer"
> private="true"
> * @scr.service
> */
>
> And my maven config is as follows
>
> <plugin>
>                 <groupId>org.apache.felix</groupId>
>                 <artifactId>maven-bundle-plugin</artifactId>
>                 <extensions>true</extensions>
>                 <configuration>
>                     <instructions>
>
> <Sling-Initial-Content>initial-content;overwrite:=true;uninstall=true</Sling-Initial-Content>
>                         <Export-Package>
>                             com.daisytechnologies.*;version=${pom.version}
>                         </Export-Package>
>                     </instructions>
>                 </configuration>
>             </plugin>
>
> I deploy the bundle but can't see that the filter is added or being used.
>
> I have also set
>
> * @scr.component metatype="no" enabled="no"
>
> to
>
> * @scr.component metatype="no" immediate="true"
>
> but no joy.
>
> Can anyone help me out?
>
> Ben
>

Reply | Threaded
Open this post in threaded view
|

Re: Adding a filter

Ben Short-4
I have the following in my pom now and removed enabled='no' and added
immediate='true' but no luck

<plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-scr-plugin</artifactId>
                <!--<version>1.2.0</version>-->
            </plugin>
            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <extensions>true</extensions>
                <configuration>
                    <instructions>

<Sling-Initial-Content>initial-content;overwrite:=true;uninstall=true</Sling-Initial-Content>
                        <Export-Package>
                            com.daisytechnologies.*;version=${pom.version}
                        </Export-Package>
                        <Sling-Bundle-Resources>

/classes/com/daisytechnologies
                                                </Sling-Bundle-Resources>

                    </instructions>
                </configuration>
            </plugin>

2009/10/14 Felix Meschberger <[hidden email]>:

> Hi Ben, I fear you are missing the maven-scr-plugin which converts the
> JavaDoc tags into the Declarative Services descriptor used to register
> the filter.
>
> Also setting 'enabled="no"' actually per default disables the filter.
> You should remove this setting unless you plan to manually enable the
> filter.
>
> I think that using the 'immediate="true"' flag makes sense since the
> service will anyway immediately be picked up by the SlingMainServlet.
>
> HTH
>
> Regards
> Felix
>
> Ben Short schrieb:
>> Hi,
>>
>> I'm trying to add a filter to my bundle I have the following at the
>> top of my class
>>
>> /**
>> * @scr.component metatype="no" enabled="no"
>> * @scr.property name="service.description" value="Request Filter"
>> * @scr.property name="filter.scope" value="request" private="true"
>> * @scr.property name="filter.order" value="-2147483648" type="Integer"
>> private="true"
>> * @scr.service
>> */
>>
>> And my maven config is as follows
>>
>> <plugin>
>>                 <groupId>org.apache.felix</groupId>
>>                 <artifactId>maven-bundle-plugin</artifactId>
>>                 <extensions>true</extensions>
>>                 <configuration>
>>                     <instructions>
>>
>> <Sling-Initial-Content>initial-content;overwrite:=true;uninstall=true</Sling-Initial-Content>
>>                         <Export-Package>
>>                             com.daisytechnologies.*;version=${pom.version}
>>                         </Export-Package>
>>                     </instructions>
>>                 </configuration>
>>             </plugin>
>>
>> I deploy the bundle but can't see that the filter is added or being used.
>>
>> I have also set
>>
>> * @scr.component metatype="no" enabled="no"
>>
>> to
>>
>> * @scr.component metatype="no" immediate="true"
>>
>> but no joy.
>>
>> Can anyone help me out?
>>
>> Ben
>>
>

Reply | Threaded
Open this post in threaded view
|

Re: Adding a filter

Felix Meschberger-2
Hi,

Ben Short schrieb:
> I have the following in my pom now and removed enabled='no' and added
> immediate='true' but no luck
>
> <plugin>
>                 <groupId>org.apache.felix</groupId>
>                 <artifactId>maven-scr-plugin</artifactId>
>                 <!--<version>1.2.0</version>-->

This seems to be missing the <executions> element to actually run a
goal. I generally have this in the pluginmanagement section of the
parent pom

                <!-- Apache Felix SCR Plugin -->
                <plugin>
                    <groupId>org.apache.felix</groupId>
                    <artifactId>maven-scr-plugin</artifactId>
                    <version>1.4.0</version>
                    <executions>
                        <execution>
                            <id>generate-scr-scrdescriptor</id>
                            <goals>
                                <goal>scr</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>

And in the project extending from the parent POM I just refer to the
plugin inheriting the executions from the parent pom.

When running the maven build you should see something like

    [scr:scr]....

Regards
Felix


>             </plugin>
>             <plugin>
>                 <groupId>org.apache.felix</groupId>
>                 <artifactId>maven-bundle-plugin</artifactId>
>                 <extensions>true</extensions>
>                 <configuration>
>                     <instructions>
>
> <Sling-Initial-Content>initial-content;overwrite:=true;uninstall=true</Sling-Initial-Content>
>                         <Export-Package>
>                             com.daisytechnologies.*;version=${pom.version}
>                         </Export-Package>
>                         <Sling-Bundle-Resources>
>
> /classes/com/daisytechnologies
>                                                 </Sling-Bundle-Resources>
>
>                     </instructions>
>                 </configuration>
>             </plugin>
>
> 2009/10/14 Felix Meschberger <[hidden email]>:
>> Hi Ben, I fear you are missing the maven-scr-plugin which converts the
>> JavaDoc tags into the Declarative Services descriptor used to register
>> the filter.
>>
>> Also setting 'enabled="no"' actually per default disables the filter.
>> You should remove this setting unless you plan to manually enable the
>> filter.
>>
>> I think that using the 'immediate="true"' flag makes sense since the
>> service will anyway immediately be picked up by the SlingMainServlet.
>>
>> HTH
>>
>> Regards
>> Felix
>>
>> Ben Short schrieb:
>>> Hi,
>>>
>>> I'm trying to add a filter to my bundle I have the following at the
>>> top of my class
>>>
>>> /**
>>> * @scr.component metatype="no" enabled="no"
>>> * @scr.property name="service.description" value="Request Filter"
>>> * @scr.property name="filter.scope" value="request" private="true"
>>> * @scr.property name="filter.order" value="-2147483648" type="Integer"
>>> private="true"
>>> * @scr.service
>>> */
>>>
>>> And my maven config is as follows
>>>
>>> <plugin>
>>>                 <groupId>org.apache.felix</groupId>
>>>                 <artifactId>maven-bundle-plugin</artifactId>
>>>                 <extensions>true</extensions>
>>>                 <configuration>
>>>                     <instructions>
>>>
>>> <Sling-Initial-Content>initial-content;overwrite:=true;uninstall=true</Sling-Initial-Content>
>>>                         <Export-Package>
>>>                             com.daisytechnologies.*;version=${pom.version}
>>>                         </Export-Package>
>>>                     </instructions>
>>>                 </configuration>
>>>             </plugin>
>>>
>>> I deploy the bundle but can't see that the filter is added or being used.
>>>
>>> I have also set
>>>
>>> * @scr.component metatype="no" enabled="no"
>>>
>>> to
>>>
>>> * @scr.component metatype="no" immediate="true"
>>>
>>> but no joy.
>>>
>>> Can anyone help me out?
>>>
>>> Ben
>>>
>