[
https://issues.apache.org/jira/browse/SLING-4154?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14208491#comment-14208491
]
Marius Petria commented on SLING-4154:
--------------------------------------
As [~teofili] said the solution is not perfect, but it was we ended up with by
trying to resolve the constraints.
I will comment a bit on [~tripod]'s proposal to address the point of having an
endpoint to configure everything in one go. We can try to imagine what the
proposal looks like:
- we will have separate osgi factories for each component
- we will have a servlet let's say that receives a json like in [1] and tries
to create 7 osgi configs
- hence we will need code that does that parses the json, depending on the
component types it selects the appropriate osgi factory ids and then creates
the configs in ConfigAdmin.
- note that such a code will look 90% as the current
DefaultDistributionComponentFactory [2]. The only difference will be that
instead of creating objects with new there will be an osgi config created. For
example instead of new RemoteDistributionPackageImporter will have
configurationAdmin.createFactoryConfiguration(".....RemoteDistributionPackageImporterFactory");
So, the code is mostly the same. It is more standard as we are going through
osgi configs, but it is also more error prone as the caller does not have any
feedback if the creation of the agent failed (the config factories are executed
asynchronously).
We also need to have code that gathers all configs related to an agent and
assembles a json. Such code starts from a osgi config for the agent and should
follow the target references to find out which subcomponents are linked. That
works only if there is a convention that target references are only of form
"(name=componentName)".
[1]
https://github.com/apache/sling/blob/37d51791611f20aa7c4e927fd3eaefc499ff8215/contrib/extensions/distribution/sample/src/main/resources/SLING-CONTENT/libs/sling/distribution/jcrsettings/agents/jpublish.json
[2]
https://github.com/apache/sling/blob/37d51791611f20aa7c4e927fd3eaefc499ff8215/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/component/impl/DefaultDistributionComponentFactory.java
> Discuss distribution components creation and configuration
> -----------------------------------------------------------
>
> Key: SLING-4154
> URL: https://issues.apache.org/jira/browse/SLING-4154
> Project: Sling
> Issue Type: Task
> Components: Distribution
> Reporter: Marius Petria
> Fix For: Content Distribution 0.2.0
>
>
> Distribution has one main component (agent) and several secondary components
> (triggers, exporters and importers).
> These can be created as java objects using a DistributionComponentFactory.
> The core framework provides a DefaultDistributionComponentFactory that will
> create the components implemented in the core but a client can define its own
> components and factory and the default component factory will use those to
> create a component it does not know of.
> The core framework also provides two ways of registering such a java object
> as an OSGI service:
> 1. using osgi configs, the osgi properties are parsed and passed to the
> factory, a component is created and registered
> (GenericDistributionComponentFactory)
> 2. resource configs, the properties of a resource are parsed and passed to
> the factory, a component is created and registered
> (ResourceBasedDistributionComponentFactory)
> Components registered as OSGI services are available as resources via
> OsgiServicePropertiesResourceProvider.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)