You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by kupkaj <ju...@gmail.com> on 2015/10/21 13:36:11 UTC

WSRM changing default sequence id generator

Hello,

I would like to use custom id generator instead of default
RMManager$DefaultSequenceIdentifierGenerator.
The question is - how to configure (using spring) RM feature to use my class
instead of the default one?

Ideally, this configuration should take place on endpoint interceptor
provider level (if that does not make sense - I want to replace id generator
for specific service endpoint; currently I'm not configuring bus), or, if
that's not possible, on bus configuration.
Thanks for any advice.



--
View this message in context: http://cxf.547215.n5.nabble.com/WSRM-changing-default-sequence-id-generator-tp5762033.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: WSRM changing default sequence id generator

Posted by kupkaj <ju...@gmail.com>.
Sorry, I should've mentioned what version of framework I'm using. It's
2.7.10.
I checked version 3.0.2 and now I see that the method which is causing me
problems has been rewritten.
New version is working as expected.
Thanks.





--
View this message in context: http://cxf.547215.n5.nabble.com/WSRM-changing-default-sequence-id-generator-tp5762033p5762232.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: WSRM changing default sequence id generator

Posted by Aki Yoshida <el...@gmail.com>.
without looking at your code entirely, i don't know what is happening.

i just created one simple sample based on cxf's ws-rm sample.

https://www.dropbox.com/s/8fg7bnbwsib95ke/cxf-sample-wsrm-custom-id.tar.gz?dl=0

this file contains
sample-wsrm-custom-id.diff
 - the patch file (the diff to the cxf master)

sample-wsrm-custom-id-transcript.txt
- the transcription at the server showing the use of the custom id generator




2015-10-22 14:55 GMT+02:00 kupkaj <ju...@gmail.com>:
> Yes, posted configuration is the same I've tested - using only default bus.
> I did some debugging; the probem originates in RMFeature:initializeProvider
> method.
> bus.getExtension(RMManager.class) eventually invokes
> org.apache.cxf.bus.spring.SpringBeanLocator:getBeansOfType(RMManager.class)
> and the code in there creates two instances of the type:
>
> Set<String> s = new
> LinkedHashSet<String>(Arrays.asList(context.getBeanNamesForType(type,
>
> false,
>
> false)));
> s.removeAll(passThroughs);
> List<T> lst = new LinkedList<T>();
> for (String n : s) {
>     lst.add(type.cast(context.getBean(n, type))); // --> creates instance of
> spring-configured RMManager
> }
> lst.addAll(orig.getBeansOfType(type)); // --> creates second instance with
> default generator
> if (lst.isEmpty()) {
>     tryOSGI(lst, type);
> }
>
> the latter then replaces first one in bus extensions.
>
>
>
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/WSRM-changing-default-sequence-id-generator-tp5762033p5762131.html
> Sent from the cxf-user mailing list archive at Nabble.com.

Re: WSRM changing default sequence id generator

Posted by kupkaj <ju...@gmail.com>.
Yes, posted configuration is the same I've tested - using only default bus.
I did some debugging; the probem originates in RMFeature:initializeProvider
method.
bus.getExtension(RMManager.class) eventually invokes
org.apache.cxf.bus.spring.SpringBeanLocator:getBeansOfType(RMManager.class)
and the code in there creates two instances of the type:

Set<String> s = new
LinkedHashSet<String>(Arrays.asList(context.getBeanNamesForType(type,
                                                                                           
false,
                                                                                           
false)));
s.removeAll(passThroughs);
List<T> lst = new LinkedList<T>();
for (String n : s) {
    lst.add(type.cast(context.getBean(n, type))); // --> creates instance of
spring-configured RMManager
}
lst.addAll(orig.getBeansOfType(type)); // --> creates second instance with
default generator
if (lst.isEmpty()) {
    tryOSGI(lst, type);
}

the latter then replaces first one in bus extensions.




--
View this message in context: http://cxf.547215.n5.nabble.com/WSRM-changing-default-sequence-id-generator-tp5762033p5762131.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: WSRM changing default sequence id generator

Posted by Aki Yoshida <el...@gmail.com>.
Is this exactly showing your spring configuration with regard to the
bus setting?

I think if you have the bus configured exactly in that way, the bus
will be used as the default cxf bus and it should be injected to your
rmManager instance and subsequently the RMFeature should find this
rmManager. If you have several buses, you will need to assign the
particular bus an explicit reference so that the two things can be
wired.
e.g.
<wsrm-mgr:rmManager xmlns:wsrm-mgr="http://cxf.apache.org/ws/rm/manager">
      <property name="bus" ref="bus"/>
      ...
</wsrm-mgr:rmManager>
<cxf:bus bus="bus">
...
</cxf:bus>

2015-10-22 7:33 GMT+02:00 kupkaj <ju...@gmail.com>:
> Yes, this part is pretty straightforward, but I don't know how to configure
> RM feature to use my RMManager.
>
> So far I came up with this configuration
>
>     <cxf:bus>
>         <cxf:features>
>             <cxf:logging/>
>             <wsa:addressing/>
>             <wsrm-mgr:reliableMessaging/>
>         </cxf:features>
>
>     </cxf:bus>
>
>         <wsrm-mgr:rmManager xmlns:wsrm-mgr="http://cxf.apache.org/ws/rm/manager">
>       <wsrm-policy:RMAssertion>
>           <wsrm-policy:BaseRetransmissionInterval Milliseconds="4000"/>
>           <wsrm-policy:AcknowledgementInterval Milliseconds="2000"/>
>       </wsrm-policy:RMAssertion>
>             <wsrm-mgr:sourcePolicy>
>                 <wsrm-mgr:sequenceTerminationPolicy maxLength="5"/>
>             </wsrm-mgr:sourcePolicy>
>             <property name="idGenerator" ref="idGenerator"/>
>         </wsrm-mgr:rmManager>
>
>     <bean id="idGenerator" class="demo.wsrm.SequenceIdGenerator"/>
>
> but it's not working. It creates instance of RMManager that uses my
> generator and stores in on bus, but initialization of RM feature replaces
> this instance with new one, which uses default generator.
>
>
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/WSRM-changing-default-sequence-id-generator-tp5762033p5762118.html
> Sent from the cxf-user mailing list archive at Nabble.com.

Re: WSRM changing default sequence id generator

Posted by kupkaj <ju...@gmail.com>.
Yes, this part is pretty straightforward, but I don't know how to configure
RM feature to use my RMManager.

So far I came up with this configuration

    <cxf:bus>
        <cxf:features>
            <cxf:logging/>
            <wsa:addressing/>
            <wsrm-mgr:reliableMessaging/>
        </cxf:features>

    </cxf:bus>
    
	<wsrm-mgr:rmManager xmlns:wsrm-mgr="http://cxf.apache.org/ws/rm/manager">
      <wsrm-policy:RMAssertion>
          <wsrm-policy:BaseRetransmissionInterval Milliseconds="4000"/>           
          <wsrm-policy:AcknowledgementInterval Milliseconds="2000"/>          
      </wsrm-policy:RMAssertion>
	    <wsrm-mgr:sourcePolicy>
	        <wsrm-mgr:sequenceTerminationPolicy maxLength="5"/>                    
	    </wsrm-mgr:sourcePolicy>
	    <property name="idGenerator" ref="idGenerator"/>
	</wsrm-mgr:rmManager>
  
    <bean id="idGenerator" class="demo.wsrm.SequenceIdGenerator"/>

but it's not working. It creates instance of RMManager that uses my
generator and stores in on bus, but initialization of RM feature replaces
this instance with new one, which uses default generator.



--
View this message in context: http://cxf.547215.n5.nabble.com/WSRM-changing-default-sequence-id-generator-tp5762033p5762118.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: WSRM changing default sequence id generator

Posted by Aki Yoshida <el...@gmail.com>.
I think you need to instantiate RMManager and set your custom
generator there to have it picked up by the cxf bus.
something like
    <bean id="customIdGenerator" class="..."/>

    <bean id="rmManager" class="org.apache.cxf.ws.rm.RMManager">
        <property name="idGenerator" ref="customIdGenerator"/>
    </bean>


2015-10-21 13:36 GMT+02:00 kupkaj <ju...@gmail.com>:
> Hello,
>
> I would like to use custom id generator instead of default
> RMManager$DefaultSequenceIdentifierGenerator.
> The question is - how to configure (using spring) RM feature to use my class
> instead of the default one?
>
> Ideally, this configuration should take place on endpoint interceptor
> provider level (if that does not make sense - I want to replace id generator
> for specific service endpoint; currently I'm not configuring bus), or, if
> that's not possible, on bus configuration.
> Thanks for any advice.
>
>
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/WSRM-changing-default-sequence-id-generator-tp5762033.html
> Sent from the cxf-user mailing list archive at Nabble.com.