[ 
https://issues.apache.org/jira/browse/CAMEL-26927?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Work on CAMEL-26927 started by Claus Ibsen.
-------------------------------------------
> camel-wordpress - each endpoint should use its own site URL and credentials
> ---------------------------------------------------------------------------
>
>                 Key: CAMEL-26927
>                 URL: https://issues.apache.org/jira/browse/CAMEL-26927
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-wordpress
>            Reporter: Claus Ibsen
>            Assignee: Claus Ibsen
>            Priority: Minor
>             Fix For: 4.18.6, 4.22.3, 4.24.0
>
>
> The WordPress client of camel-wordpress is held in one static 
> {{WordpressServiceProvider}} for the whole application instead of on the 
> endpoint. With more than one wordpress endpoint in the same application, all 
> of them end up sharing the settings of one endpoint.
> h3. Today
> * {{WordpressEndpoint.configureProperties(...)}} calls 
> {{WordpressServiceProvider.getInstance().init(apiConfiguration)}}, which 
> replaces the services of the static singleton with ones built from this 
> endpoint's {{url}}, {{apiVersion}}, {{user}} and {{password}}.
> * The producers ({{AbstractWordpressProducer}}, {{WordpressPostProducer}}, 
> {{WordpressUserProducer}}) and consumers ({{WordpressPostConsumer}}, 
> {{WordpressUserConsumer}}) read their services and {{hasAuthentication()}} 
> from that singleton in their constructors, which run after all endpoints of 
> the routes are configured.
> * So every wordpress producer and consumer uses the site {{url}}, {{user}} 
> and {{password}} of the endpoint that was configured last. For example, a 
> consumer without {{user}}/{{password}} next to a producer with them (the 
> example in the component docs) polls with the producer's credentials, or the 
> producer is rejected for missing credentials, depending on which endpoint was 
> configured last. Two endpoints for two sites both talk to one site.
> h3. After the change
> Each endpoint owns its own {{WordpressServiceProvider}}:
> * {{WordpressServiceProvider}} gets a public way to build a provider for one 
> {{WordpressAPIConfiguration}} (for example a static 
> {{create(WordpressAPIConfiguration)}} factory), with final fields.
> * {{WordpressEndpoint}} builds its provider in {{doInit()}} (or lazily, so 
> endpoints configured with setters also work), holds it in a field, and 
> exposes {{getService(Class)}} and {{hasAuthentication()}}. It no longer calls 
> {{WordpressServiceProvider.getInstance().init(...)}}.
> * Producers and consumers take their services and {{hasAuthentication()}} 
> from {{getEndpoint()}}, preferably in {{doStart()}}, instead of from 
> {{WordpressServiceProvider.getInstance()}}.
> * {{getInstance()}} and {{init(...)}} stay for API compatibility (the service 
> adapter tests and possibly user code use them); on main they are marked 
> {{@Deprecated}}.
> * No cache of providers keyed on {{WordpressAPIConfiguration.equals}}.
> h3. Tests
> * {{WordpressEndpointsUseTheirOwnSiteTest}}: two endpoints pointing at two 
> local mock servers (free ports via {{AvailablePortFinder}}, not the fixed 
> 9009 server of {{WordpressMockServerTestSupport}}) with different users. A 
> producer of each endpoint creates a post; assert that each server received 
> only its own endpoint's request with its own {{Authorization}} header. Run 
> both orders of endpoint creation.
> * Consumer variant: polling each endpoint reads only from its own server.
> * An endpoint without {{user}} sends no {{Authorization}} header, also when 
> an endpoint with {{user}}/{{password}} is created after it.
> * The existing {{WordpressComponentTest}}, {{WordpressPostOperationTest}}, 
> {{WordpressUserOperationTest}}, {{WordpressAPIConfigurationTest}} and the 
> service adapter tests keep passing.
> h3. Upgrade guide
> A note in the upgrade guides (4.24, and the 4.22.3 and 4.18.6 sections, all 
> on main): camel-wordpress endpoints no longer initialise 
> {{WordpressServiceProvider.getInstance()}}; each endpoint uses its own 
> client. Code that read services from the singleton after creating an endpoint 
> must call {{init(...)}} itself.
> No endpoint options are added or removed.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to