There are some usecases where this can be required, but they are usually along the lines of: you have a resource provider and a resource consumer, and they are in different components.
For example, I have a database component for my application which manages the database itself and I have another component that uses the database. They both have a need to access the database and they both need credentials to do so.
Another complication to this scenario is that these kinds of situations you often want different values for the properties in one or more environments. This limits us immediately to the environment or resource properties.
If I use a component environment property definition, they are only in scope for the component that defines the property. So how can I share the value? I don’t want to have to define the property in several places, I would then have to remember where all the copies were. If say the database password had to be changed I’d then have to try and find all the copies to update them or risk a deployment failure.
As a general rule and best practice, it’s best to define something only once, and use it in many places. So, if I was writing code, I’d have the database component retrieve its credentials from wherever they are stored and then provide an interface to let others a means to retrieve them in some form.
How can we do this with UCD?
I’m sure there are going to be other solutions to this problem, some of which may have a process change the value of another property on-the-fly. But this means that the number of versions of your property sheet is going to skyrocket and it’s also going to provide some ‘interesting’ challenges with snapshots.
Well, that is along the lines of the solution I’ll present here, but what I use are process properties. Yes, that’s right, processes have properties too. First, I would decide on what component owns the property. Usually, this is logically the resource provider. This component is where I define my component environment properties and then I have a component process that is always run, from the application process; something like an operational process with no version. This process then uses a step from the UrbanCode Deploy Processes plugin to create each property I want to share on the parent application process so that now all components can see the properties you expose.