Thank you very much Karel.  This is the first time I have seen
PrototypeServiceFactory.  I did manage to get everything registered and it
seems to work but it is not very stable running on windows.  I get the
error message registered in SERVER runtime does not implement any provider
interfaces applicable in the SERVER runtime.  This error makes sense
because Jersey does not use servlet.Filter it uses ContainerRequestFilter
which does not inherit from filter.  Here was my end properties.  I think
based off the error though I can remove provider.  I am still trying to
play with things to make sure it runs smooth.

@Provider
@Component(service = {Filter.class},
    property = {
            HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_PATTERN + "=/",
            HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT +
                "=(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME
+ "=org.osgi.service.http)",
                "filter.init.map-name=my-sessions",
                "filter.init.sticky-session=false",
                "filter.init.cookie-name=aardvark",
                "filter.init.cookie-secure=false",
                "filter.init.cookie-http-only=false",
                "filter.init.debug=true",
                "filter.init.instance-name=default",
                "filter.init.use-client=true",
                "filter.init.shutdown-on-destroy=true"
            })
public class HazelcastSessionFilter implements Filter {

On Wed, Apr 27, 2016 at 1:21 PM, Karel Haeck <[email protected]> wrote:

>
>  Note that you can register your filter to both contexts by using a
> wildcard filter
>  "(osgi.http.whiteboard.context.name=*)" .  Your filter will both
>  be activated in the whiteboard (default) context and in the api context
> ("org.osgi.service.http").
>
>  In this case you probably want to register a
> PrototypeServiceFactory<Filter> to have a
>  separate Filter instance per context. Otherwise your init method will be
> called twice
>  on the same instance with two different FilterConfig arguments.
>
>
> On 25/04/2016 21:27, Bram Pouwelse wrote:
>
>> Hi David,
>>
>> I don't know the osgi-jax-rs-connector you're using but based on the
>> issues
>> I'd think it's using the HttpService (or Felix Whiteboard implementation).
>> In that case you need to add a servlet context select filter to you
>> servlet
>> to make it use the same servlet context as the jax-rs connector. The
>> required servlet context select filter value is mentioned in the Felix
>> issue "(osgi.http.whiteboard.context.name=org.osgi.service.http)".
>>
>> Regards,
>> Bram
>>
>> On Mon, Apr 25, 2016 at 9:03 PM David Daniel <[email protected]
>> >
>> wrote:
>>
>> I seem to be bumping into a different problem.  Similar to this
>>> https://github.com/hstaudacher/osgi-jax-rs-connector/issues/99 where an
>>> issue was opened here https://issues.apache.org/jira/browse/FELIX-4904
>>> but
>>> is closed for the version that I am using.  My filter is getting called
>>> when going to /test.html but not when going to /services/api which uses
>>> the
>>> jersey library linked above.  Is there a way to get my filter called for
>>> either.  Here is how I registered my filter
>>>
>>> @Component(service = {Filter.class},
>>>      property = HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_PATTERN +
>>> "=/*")
>>>
>>> On Mon, Apr 25, 2016 at 1:08 PM, David Daniel <
>>> [email protected]
>>> wrote:
>>>
>>> I found the issue.  It was in the context name.  It is working now.
>>>>
>>> Thank
>>>
>>>> you so much for pointing me in the right direction.
>>>>
>>>> On Mon, Apr 25, 2016 at 12:56 PM, David Daniel <
>>>> [email protected]> wrote:
>>>>
>>>> I think I see the pertinent error message.
>>>>>
>>>>> [main] DEBUG org.apache.felix.http.jetty - Ignoring unmatched Filter
>>>>> service [javax.servlet.Filter]
>>>>>
>>>>> Is it because I try to pick up / on my filter pattern.
>>>>>
>>>>> On Mon, Apr 25, 2016 at 12:47 PM, David Daniel <
>>>>> [email protected]> wrote:
>>>>>
>>>>> Carsten,
>>>>>>
>>>>>>   I tried to register as a whiteboard service for the filter like this
>>>>>>
>>>>>>          final HazelcastSessionFilter sessionFilter = new
>>>>>> HazelcastSessionFilter();
>>>>>>          final Dictionary<String, Object> filter1Props = new
>>>>>> Hashtable<String, Object>();
>>>>>>
>>>>>>
>>>>>>
>>> filter1Props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_PATTERN,
>>>
>>>> "/");
>>>>>>
>>>>>>
>>>>>>
>>> filter1Props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT,
>>>
>>>>                  "(" +
>>>>>> HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME +
>>>>>>
>>>>> "=sessionFilter)");
>>>
>>>>          bc.registerService(Filter.class, sessionFilter, filter1Props);
>>>>>>
>>>>>> this comes from the example here
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>> https://github.com/apache/felix/blob/trunk/http/samples/whiteboard/src/main/java/org/apache/felix/http/samples/whiteboard/Activator.java
>>>
>>>> The init function is never called.  Am I doing something wrong.  Here
>>>>>> are my log messages
>>>>>>
>>>>>> [INFO] Started Jetty 9.2.14.v20151106 at port(s) HTTP:8084 on context
>>>>>> path / [minThreads=8,maxThreads=200,acceptors=1,selectors=4]
>>>>>> [INFO] Detected extended HttpService. Filters enabled.
>>>>>> [INFO] Http service whiteboard started
>>>>>>
>>>>>>
>>> org.ops4j.pax.logging.pax-logging-api[org.ops4j.pax.logging.internal.Activator]
>>>
>>>> : Enabling SLF4J API support.
>>>>>>
>>>>>>
>>> org.ops4j.pax.logging.pax-logging-api[org.ops4j.pax.logging.internal.Activator]
>>>
>>>> : Enabling Jakarta Commons Logging API support.
>>>>>>
>>>>>>
>>> org.ops4j.pax.logging.pax-logging-api[org.ops4j.pax.logging.internal.Activator]
>>>
>>>> : Enabling Log4J API support.
>>>>>>
>>>>>>
>>> org.ops4j.pax.logging.pax-logging-api[org.ops4j.pax.logging.internal.Activator]
>>>
>>>> : Enabling Avalon Logger API support.
>>>>>>
>>>>>>
>>> org.ops4j.pax.logging.pax-logging-api[org.ops4j.pax.logging.internal.Activator]
>>>
>>>> : Enabling JULI Logger API support.
>>>>>>
>>>>>>
>>> org.ops4j.pax.logging.pax-logging-api[org.ops4j.pax.logging.internal.Activator]
>>>
>>>> : Enabling Log4J v2 API support. Ignored FQCN:
>>>>>> org.apache.logging.log4j.spi.AbstractLogger
>>>>>> [WARNING] Deprecation warning: Filter registered through Apache Felix
>>>>>> whiteboard service: [javax.servlet.Filter]. Please change your code to
>>>>>>
>>>>> the
>>>
>>>> OSGi Http Whiteboard Service.
>>>>>> [DEBUG] Reusing context with id []
>>>>>>
>>>>>> I am not sure if that filter registered is the correct filter or my
>>>>>>
>>>>> cors
>>>
>>>> filter but my assumption is that it is the session filter.
>>>>>>
>>>>>> On Sat, Apr 23, 2016 at 11:19 AM, Carsten Ziegeler <
>>>>>>
>>>>> [email protected]
>>>
>>>> wrote:
>>>>>>> David Daniel wrote
>>>>>>>
>>>>>>>> I noticed ExtHttpService is deprecated.  Is there a better way to
>>>>>>>>
>>>>>>> register
>>>>>>>
>>>>>>>> a filter now than the example here
>>>>>>>>
>>>>>>>>
>>> http://felix.apache.org/documentation/subprojects/apache-felix-http-service.html
>>>
>>>> Yes, the documentation is totally outdated. There is the Http
>>>>>>>
>>>>>> Whiteboard
>>>
>>>> Specification - it's part of the OSGi Compendium R6 and this is how
>>>>>>>
>>>>>> you
>>>
>>>> should do these things today.
>>>>>>>
>>>>>>> I think the examples in svn are updated. I'll probably update the
>>>>>>> docs
>>>>>>> in some weeks if no one beats me to it.
>>>>>>>
>>>>>>> Regards
>>>>>>> Carsten
>>>>>>> --
>>>>>>> Carsten Ziegeler
>>>>>>> Adobe Research Switzerland
>>>>>>> [email protected]
>>>>>>>
>>>>>>> ---------------------------------------------------------------------
>>>>>>> To unsubscribe, e-mail: [email protected]
>>>>>>> For additional commands, e-mail: [email protected]
>>>>>>>
>>>>>>>
>>>>>>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>

Reply via email to