cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gaygeek <jme...@gmail.com>
Subject Re: Custom interceptors with DOSGi
Date Tue, 17 Jan 2012 19:00:30 GMT
I tried out the DOSGI change and it will work very well--the only thing
missing is the ability to specify in.fault and out.fault interceptors to
cover all interceptor lifecycles. Also, I have a suggestion on the
implementation--in ClassUtils, I think the loadProviderClasses should also
check the serviceProviders class to see if it is a String for non-arrays as
well as arrays (as it does already) so you could provide a single bean
reference without having to create an array if you only have one
interceptor... so instead of (using spring-dm for activator creation):

            <entry key="org.apache.cxf.ws.out.interceptors">
                <array>
                    <ref bean="exampleInterceptor"/>
                </array>
            </entry>

it could be specified as:
            <entry key="org.apache.cxf.ws.out.interceptors"
value-ref="exampleInterceptor"/>

This, of course, is not a big deal, but it was my first intuition to try it
the second way.

My suggested code change is:

public static List<Object> loadProviderClasses(BundleContext
callingContext, Map sd, String propName) {

    Object serviceProviders = sd.get(propName);
        if (serviceProviders != null) {
            if (serviceProviders.getClass().isArray()) {
                if (serviceProviders.getClass().getComponentType() ==
String.class) {
                return loadProviders(callingContext,
(String[])serviceProviders);
                } else {
                    return Arrays.asList((Object[])serviceProviders);
                }
            } else {
                if (serviceProviders.getClass() == String.class) {
                    String[] classNames =
serviceProviders.toString().split(",");
                    return loadProviders(callingContext, classNames);
                } else {
                    return Arrays.asList(serviceProviders);
                }
            }
        } else {
        return Collections.emptyList();
        }
    }

-Jeff


On Tue, Jan 17, 2012 at 10:07 AM, Jeff Melby <jmelby@gmail.com> wrote:

> Great--I see on the trunk code you have added the below for in and out
> interceptors, but how about in.fault and out.fault interceptors? I'll be
> trying this out today--thanks again for looking into this issue so quickly.
>
> -Jeff
>
>
> On Tue, Jan 17, 2012 at 7:55 AM, Sergey Beryozkin-5 [via CXF] <
> ml-node+s547215n5151623h80@n5.nabble.com> wrote:
>
>> Hi
>> On 17/01/12 13:47, gaygeek wrote:
>> > Sergey-
>> >
>> > Can you explain how this will work for already-instantiated
>> interceptors
>> > from DOSGi? I realized that there are some interceptors where I may
>> want to
>> > inject spring beans, so the annotation approach won't work for those.
>> Will
>> > there be a way to reference a spring-instantiated bean as the
>> interceptor?
>> >
>>
>> for WS, you'd need to to register a List of Interceptor (or Feature)
>> instances as a service property, from the bundle Activator, example,
>>
>> props.put("org.apache.cxf.ws.in.interceptors", listOfInInterceptors);
>> props.put("org.apache.cxf.ws.out.interceptors", listOfInInterceptors);
>> props.put("org.apache.cxf.ws.features", listOfFeatures);
>>
>> and the context properties:
>>
>> props.put("org.apache.cxf.ws.context.properties", mapOfProps);
>>
>> and then pass them during the registration/lookup.
>> Same for RS;
>>
>> For RS, it is also possible to register JAX-RS providers as OSGI
>> services but I thought having the same supported for CXF
>> interceptors/features is a bit early
>>
>> Cheers, Sergey
>>
>> > Thanks,
>> > Jeff
>> >
>> > On Mon, Jan 16, 2012 at 5:22 PM, Sergey Beryozkin-5 [via CXF]<
>> > [hidden email] <http://user/SendEmail.jtp?type=node&node=5151623&i=0>>
>>  wrote:
>> >
>> >> Dan, thanks for the fix/enhancement, I also updated DOSGi
>> >> to check for custom interceptors&  features passed along during the
>> >> registration/lookup, possibly already instantiated, and also from
>> >> Declarative Services...for WS&  RS
>> >>
>> >> Just stopped short of also starting the trackers, may be later :-)
>> >>
>> >> Sergey
>> >> On 16/01/12 16:03, Daniel Kulp wrote:
>> >>
>> >>> On Monday, January 16, 2012 7:33:45 AM gaygeek wrote:
>> >>>> Yes--as you said, the export is there in my custom bundle, but the
>> cxf
>> >>>> bundle has no way to import it to create the interceptor instance.
>> >>>>
>> >>>> Are you saying there is currently a way to do this, or that DOSGi
>> will
>> >> need
>> >>>> to be modified to allow custom interceptors? I think you are saying
>> it
>> >> is
>> >>>> not available currently, but that it would probably need to be a
>> >> property
>> >>>> on the osgi service export configuration.
>> >>>
>> >>> One thing we COULD try doing is updating the Annotations we have to
>> >> actually
>> >>> support using Class objects.  Right now, we have:
>> >>>
>> >>> public @interface InInterceptors {
>> >>>       String[] interceptors();
>> >>> }
>> >>>
>> >>> which means we need to do Class.forName things.   We could expand
>> this
>> >> to:
>> >>>
>> >>> public @interface InInterceptors {
>> >>>       String[] interceptors();
>> >>>       Class<? extends Interceptor>[]  classes();
>> >>> }
>> >>>
>> >>> or similar so that you could annotate with the actual class objects
>> and
>> >> not
>> >>> have to deal with the classloaders in OSGi.
>> >>>
>> >>> Dan
>> >>>
>> >>>
>> >>>
>> >>>>
>> >>>> Thanks,
>> >>>> Jeff
>> >>>>
>> >>>> On Mon, Jan 16, 2012 at 8:37 AM, Sergey Beryozkin-5 [via CXF]<
>> >>>>
>> >>>> [hidden email]<http://user/SendEmail.jtp?type=node&node=5150169&i=0>>
>>
>> >>   wrote:
>> >>>>> Ignore that please, keeping forgetting the cxf bundle does not
>> import
>> >>>>> custom classes/
>> >>>>>
>> >>>>> I think in DOSGi case, a new property would have to be introduced
>> in
>> >>>>> time for custom CXF interceptors be picked up
>> >>>>>
>> >>>>> Cheers, Sergey
>> >>>>>
>> >>>>> On 16/01/12 12:25, Sergey Beryozkin wrote:
>> >>>>>> Does the custom bundle export "com.uhg.upm.webservice.interceptor"
>> ?
>> >>>>>>
>> >>>>>> Sergey
>> >>>>>>
>> >>>>>> On 13/01/12 22:36, gaygeek wrote:
>> >>>>>>> I am trying to configure a custom interceptor for a
web service
>> >>>>>>> I'm
>> >>>>>>> exposing
>> >>>>>>> with DOSGi. However, it seems that the interceptor cannot
be
>> >>>>>>> initialized via
>> >>>>>>> annotation, as the org.apache.cxf.bundle-minimal does
not have
>> >>>>>>> access
>> >>>>>>> to my
>> >>>>>>> custom interceptor class from its bundle classloader.
I get the
>> >>>>>
>> >>>>> following
>> >>>>>
>> >>>>>>> error when starting my bundle with the service in it
(which DOES
>> >>>>>>> have
>> >>>>>>> access
>> >>>>>>> to the package that my SoapFaultInterceptor is in).
It seems like
>> >>>>>>> the
>> >>>>>>> only
>> >>>>>>> way to make it work would be to hack the MANIFEST.MF
for the
>> >>>>>>> org.apache.cxf.bundle-minimal to import my bundle with
the custom
>> >>>>>>> interceptor.
>> >>>>>>>
>> >>>>>>> Is there a different way to configure custom interceptors
with
>> >>>>>>> DOSGi?
>> >>>>>>> Or am
>> >>>>>>> I missing something in order to allow the annotations
to work?
>> >>>>>>>
>> >>>>>>> Annotations for the WebService interface:
>> >>>>>>> @WebService(name = "HelloService", targetNamespace =
>> >>>>>>> "http://upm.uhc.com/example/hello")
>> >>>>>>> @OutFaultInterceptors(interceptors =
>> >>>>>>> {"com.uhg.upm.webservice.interceptor.SoapFaultInterceptor"})
>> >>>>>>> public interface HelloService
>> >>>>>>>
>> >>>>>>> Exception when starting my bundle with the HelloService
in it:
>> >>>>>>> Exception in thread "pool-1-thread-4"
>> >>>>>>> org.apache.cxf.interceptor.Fault: Could not create annotation
>> >>>>>>> object:
>> >>>>>>> com.uhg.upm.webservice.interceptor.SoapFaultInterceptor
>> >>>>>>> at
>> >>>>>
>> >>>>>
>> >>
>> org.apache.cxf.interceptor.AnnotationInterceptors.initializeAnnotationOb
>> >>>>> jects(AnnotationInterceptors.java:79)>
>> >>>>>>> at
>> >>>>>
>> >>>>>
>> >>
>> org.apache.cxf.interceptor.AnnotationInterceptors.getAnnotationObject(An
>> >>>>> notationInterceptors.java:48)>
>> >>>>>>> at
>> >>>>>
>> >>>>>
>> >>
>> org.apache.cxf.interceptor.AnnotationInterceptors.getAnnotationIntercept
>> >>>>> orList(AnnotationInterceptors.java:102)>
>> >>>>>>> at
>> >>>>>
>> >>>>>
>> >>
>> org.apache.cxf.interceptor.AnnotationInterceptors.getOutFaultInterceptor
>> >>>>> s(AnnotationInterceptors.java:122)>
>> >>>>>>> ...
>> >>>>>>> Caused by: java.lang.ClassNotFoundException:
>> >>>>>>> com.uhg.upm.webservice.interceptor.SoapFaultInterceptor
not found
>> >>>>>>> by
>> >>>>>>> org.apache.cxf.bundle-minimal [57]
>> >>>>>>> at
>> >>>>>
>> >>>>>
>> >>
>> org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(Mo
>> >>>>> duleImpl.java:812)>
>> >>>>>>> at
>> >>>>>>> org.apache.felix.framework.ModuleImpl.access$400(ModuleImpl.java:
>> >>>>>>> 72)
>> >>>>>>>
>> >>>>>>> Thank you for any insight into this issue.
>> >>>>>>>
>> >>>>>>> -Jeff
>> >>>>>>>
>> >>>>>>> --
>> >>>>>
>> >>>>>>> View this message in context:
>> >>>>>
>> >>
>> http://cxf.547215.n5.nabble.com/Custom-interceptors-with-DOSGi-tp5143924
>> >>>>> p5143924.html>
>> >>>>>>> Sent from the cxf-user mailing list archive at Nabble.com.
>> >>>>>
>> >>>>> --
>> >>>>> Sergey Beryozkin
>> >>>>>
>> >>>>> Talend Community Coders
>> >>>>> http://coders.talend.com/
>> >>>>>
>> >>>>> Blog: http://sberyozkin.blogspot.com
>> >>>>>
>> >>>>>
>> >>>>> ------------------------------
>> >>>>>
>> >>>>>    If you reply to this email, your message will be added to
the
>> >>>>>    discussion
>> >>>>>
>> >>>>> below:
>> >>>>>
>> >>>>>
>> >>
>> http://cxf.547215.n5.nabble.com/Custom-interceptors-with-DOSGi-tp5143924
>> >>>>> p5148873.html>
>> >>>>>    To unsubscribe from Custom interceptors with DOSGi, click
>> >>>>>    here<
>> >> http://cxf.547215.n5.nabble.com/template/NamlServlet.jtp?macro=u
>> >>>>>
>> >> nsubscribe_by_code&node=5143924&code=am1lbGJ5QGdtYWlsLmNvbXw1MTQzOTI0f
>> >>>>>    C02NTQzMjczNTA=>>
>> >>>>> .
>> >>>>> NAML<
>> >> http://cxf.547215.n5.nabble.com/template/NamlServlet.jtp?macro=macr
>> >>>>>
>> >>
>> o_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespac
>> >>>>>
>> >>
>> es.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.w
>> >>>>>
>> >>
>> eb.template.InstantMailNamespace&breadcrumbs=instant+emails%21nabble%3Ae
>> >>>>>
>> >>
>> mail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabb
>> >>>>> le%3Aemail.naml>
>> >>>> --
>> >>>> View this message in context:
>> >>>>
>> >>
>> http://cxf.547215.n5.nabble.com/Custom-interceptors-with-DOSGi-tp5143924p51
>> >>>> 49014.html Sent from the cxf-user mailing list archive at
>> Nabble.com.
>> >>
>> >>
>> >> --
>> >> Sergey Beryozkin
>> >>
>> >> Talend Community Coders
>> >> http://coders.talend.com/
>> >>
>> >> Blog: http://sberyozkin.blogspot.com
>> >>
>> >>
>> >> ------------------------------
>> >>   If you reply to this email, your message will be added to the
>> discussion
>> >> below:
>> >>
>> >>
>>
>> >> .
>> >> NAML<
>> http://cxf.547215.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.InstantMailNamespace&breadcrumbs=instant+emails%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>>
>> >>
>> >
>> >
>> > --
>> > View this message in context:
>> http://cxf.547215.n5.nabble.com/Custom-interceptors-with-DOSGi-tp5143924p5151596.html
>>
>> > Sent from the cxf-user mailing list archive at Nabble.com.
>>
>>
>> --
>> Sergey Beryozkin
>>
>> Talend Community Coders
>> http://coders.talend.com/
>>
>> Blog: http://sberyozkin.blogspot.com
>>
>>
>> ------------------------------
>>  If you reply to this email, your message will be added to the
>> discussion below:
>>
>> http://cxf.547215.n5.nabble.com/Custom-interceptors-with-DOSGi-tp5143924p5151623.html
>>  To unsubscribe from Custom interceptors with DOSGi, click here<http://cxf.547215.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5143924&code=am1lbGJ5QGdtYWlsLmNvbXw1MTQzOTI0fC02NTQzMjczNTA=>
>> .
>> NAML<http://cxf.547215.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.InstantMailNamespace&breadcrumbs=instant+emails%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>>
>
>


--
View this message in context: http://cxf.547215.n5.nabble.com/Custom-interceptors-with-DOSGi-tp5143924p5152563.html
Sent from the cxf-user mailing list archive at Nabble.com.

Mime
View raw message