You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@nifi.apache.org by Mark Payne <ma...@hotmail.com> on 2016/04/11 16:11:32 UTC
Re: Controller service reference another service
Vincent,
I moved users@nifi to the BCC and instead am redirecting this to the dev@nifi mailing list,
as this is developer question moreso than a user question.
Certainly, you can reference one controller service from another. Generally, controller services
are referenced by using a PropertyDescriptor that identifies the controller service. For example:
public static final PropertyDescriptor SSL_CONTEXT_SERVICE = new PropertyDescriptor.Builder()
.name("SSL Context Service")
.description("The Controller Service to use in order to obtain an SSL Context")
.required(false)
.identifiesControllerService(SSLContextService.class)
.build();
This allows the user to choose the appropriate Controller Service. Node the 'identifiesControllerService' call.
The service itself is then obtained by calling 'asControllerService' on a PropertyValue object:
SSLContextService sslContextService = context.getProperty(SSL_CONTEXT_SERVICE).asControllerService(SSLContextService.class);
Does this give you what you need?
Thanks
-Mark
> On Apr 11, 2016, at 10:04 AM, Vincent Russell <vi...@gmail.com> wrote:
>
> Is it possible to user one controller service inside of another service? Can it be brought in from the ControllerServiceInitializationContext?
>
> If so, how is this done?
>
> Thank you,
> Vincent
Re: Controller service reference another service
Posted by Vincent Russell <vi...@gmail.com>.
Yes. Thank you.
On Mon, Apr 11, 2016 at 11:11 AM, Mark Payne <ma...@hotmail.com> wrote:
> D'oh! Sorry. You don't have a ProcessContext for Controller Services.
> Controller Services' lifecycles are a bit different than
> Processors and Reporting Tasks. For a Controller Service, you would
> want to use the @OnEnabled annotation and then use the provided
> ConfigurationContext:
>
>
>
> private volatile SSLContextService sslContextService;
>
> @OnEnabled
> public void obtainControllerService(ConfigurationContext context) {
> sslContextService =
> context.getProperty(SSL_CONTEXT_SERVICE).asControllerService(SSLContextService.class);
> }
>
>
> Then you should be able to reference the sslContextService member variable
> from whatever method that you need.
>
> Does this make sense.
>
> Thanks
> -Mark
>
>
> > On Apr 11, 2016, at 10:53 AM, Vincent Russell <vi...@gmail.com>
> wrote:
> >
> > Thank you for the response.
> >
> > Where can I make the SSLContextService sslContextService = context
> > .getProperty(SSL_CONTEXT_SERVICE).asControllerService(SSLContextService.
> > class); call?
> >
> > Where do I have access to the context within a ControllerService?
> >
> > Thanks,
> >
> > On Mon, Apr 11, 2016 at 10:11 AM, Mark Payne <ma...@hotmail.com>
> wrote:
> >
> >> Vincent,
> >>
> >> I moved users@nifi to the BCC and instead am redirecting this to the
> >> dev@nifi mailing list,
> >> as this is developer question moreso than a user question.
> >>
> >> Certainly, you can reference one controller service from another.
> >> Generally, controller services
> >> are referenced by using a PropertyDescriptor that identifies the
> >> controller service. For example:
> >>
> >> public static final PropertyDescriptor SSL_CONTEXT_SERVICE = new
> >> PropertyDescriptor.Builder()
> >> .name("SSL Context Service")
> >> .description("The Controller Service to use in order to
> >> obtain an SSL Context")
> >> .required(false)
> >> .identifiesControllerService(SSLContextService.class)
> >> .build();
> >>
> >> This allows the user to choose the appropriate Controller Service. Node
> >> the 'identifiesControllerService' call.
> >> The service itself is then obtained by calling 'asControllerService' on
> a
> >> PropertyValue object:
> >>
> >> SSLContextService sslContextService = context.getProperty(
> >> SSL_CONTEXT_SERVICE).asControllerService(SSLContextService.class);
> >>
> >> Does this give you what you need?
> >>
> >> Thanks
> >> -Mark
> >>
> >>
> >> On Apr 11, 2016, at 10:04 AM, Vincent Russell <
> vincent.russell@gmail.com>
> >> wrote:
> >>
> >> Is it possible to user one controller service inside of another service?
> >> Can it be brought in from the ControllerServiceInitializationContext?
> >>
> >> If so, how is this done?
> >>
> >> Thank you,
> >> Vincent
> >>
> >>
> >>
>
>
Re: Controller service reference another service
Posted by Mark Payne <ma...@hotmail.com>.
D'oh! Sorry. You don't have a ProcessContext for Controller Services. Controller Services' lifecycles are a bit different than
Processors and Reporting Tasks. For a Controller Service, you would
want to use the @OnEnabled annotation and then use the provided ConfigurationContext:
private volatile SSLContextService sslContextService;
@OnEnabled
public void obtainControllerService(ConfigurationContext context) {
sslContextService = context.getProperty(SSL_CONTEXT_SERVICE).asControllerService(SSLContextService.class);
}
Then you should be able to reference the sslContextService member variable from whatever method that you need.
Does this make sense.
Thanks
-Mark
> On Apr 11, 2016, at 10:53 AM, Vincent Russell <vi...@gmail.com> wrote:
>
> Thank you for the response.
>
> Where can I make the SSLContextService sslContextService = context
> .getProperty(SSL_CONTEXT_SERVICE).asControllerService(SSLContextService.
> class); call?
>
> Where do I have access to the context within a ControllerService?
>
> Thanks,
>
> On Mon, Apr 11, 2016 at 10:11 AM, Mark Payne <ma...@hotmail.com> wrote:
>
>> Vincent,
>>
>> I moved users@nifi to the BCC and instead am redirecting this to the
>> dev@nifi mailing list,
>> as this is developer question moreso than a user question.
>>
>> Certainly, you can reference one controller service from another.
>> Generally, controller services
>> are referenced by using a PropertyDescriptor that identifies the
>> controller service. For example:
>>
>> public static final PropertyDescriptor SSL_CONTEXT_SERVICE = new
>> PropertyDescriptor.Builder()
>> .name("SSL Context Service")
>> .description("The Controller Service to use in order to
>> obtain an SSL Context")
>> .required(false)
>> .identifiesControllerService(SSLContextService.class)
>> .build();
>>
>> This allows the user to choose the appropriate Controller Service. Node
>> the 'identifiesControllerService' call.
>> The service itself is then obtained by calling 'asControllerService' on a
>> PropertyValue object:
>>
>> SSLContextService sslContextService = context.getProperty(
>> SSL_CONTEXT_SERVICE).asControllerService(SSLContextService.class);
>>
>> Does this give you what you need?
>>
>> Thanks
>> -Mark
>>
>>
>> On Apr 11, 2016, at 10:04 AM, Vincent Russell <vi...@gmail.com>
>> wrote:
>>
>> Is it possible to user one controller service inside of another service?
>> Can it be brought in from the ControllerServiceInitializationContext?
>>
>> If so, how is this done?
>>
>> Thank you,
>> Vincent
>>
>>
>>
Re: Controller service reference another service
Posted by Vincent Russell <vi...@gmail.com>.
Thank you for the response.
Where can I make the SSLContextService sslContextService = context
.getProperty(SSL_CONTEXT_SERVICE).asControllerService(SSLContextService.
class); call?
Where do I have access to the context within a ControllerService?
Thanks,
On Mon, Apr 11, 2016 at 10:11 AM, Mark Payne <ma...@hotmail.com> wrote:
> Vincent,
>
> I moved users@nifi to the BCC and instead am redirecting this to the
> dev@nifi mailing list,
> as this is developer question moreso than a user question.
>
> Certainly, you can reference one controller service from another.
> Generally, controller services
> are referenced by using a PropertyDescriptor that identifies the
> controller service. For example:
>
> public static final PropertyDescriptor SSL_CONTEXT_SERVICE = new
> PropertyDescriptor.Builder()
> .name("SSL Context Service")
> .description("The Controller Service to use in order to
> obtain an SSL Context")
> .required(false)
> .identifiesControllerService(SSLContextService.class)
> .build();
>
> This allows the user to choose the appropriate Controller Service. Node
> the 'identifiesControllerService' call.
> The service itself is then obtained by calling 'asControllerService' on a
> PropertyValue object:
>
> SSLContextService sslContextService = context.getProperty(
> SSL_CONTEXT_SERVICE).asControllerService(SSLContextService.class);
>
> Does this give you what you need?
>
> Thanks
> -Mark
>
>
> On Apr 11, 2016, at 10:04 AM, Vincent Russell <vi...@gmail.com>
> wrote:
>
> Is it possible to user one controller service inside of another service?
> Can it be brought in from the ControllerServiceInitializationContext?
>
> If so, how is this done?
>
> Thank you,
> Vincent
>
>
>