Thanks Andy, I've tried your approach, in my case the controller service is a DBCPConnectionPool and when I tried to get driver class name property through context.getProperty(DBCPConnectionPool.DB_DRIVERNAME).getValue(), but I the value is null. The AbstractControllerService class does have a method getConfigurationContext() to get configuration context, but the method is protected. So I still didn't find a feasible way to get the controller service's properties.
Regards, Ben 2017-08-10 12:18 GMT+08:00 Andy LoPresto <alopre...@apache.org>: > You can get the current property values of a controller service from the > processor by using the ProcessContext object. For example, in GetHTTP [1], > in the @OnScheduled method, you could do: > > context.getControllerServiceLookup().getControllerService("my- > controller-service-id”); > > context.getProperty("controller-service-property-name"); > context.getProperty(SomeControllerService.CONSTANT_PROPERTY_DESCRIPTOR); > > I forget if context.getProperty() will give the controller service > properties as well as the processor properties. If it doesn’t, you can cast > the retrieved ControllerService into AbstractControllerService or the > concrete class and access available properties directly from the > encapsulated ConfigurationContext. > > [1] https://github.com/apache/nifi/blob/master/nifi-nar- > bundles/nifi-standard-bundle/nifi-standard-processors/src/ > main/java/org/apache/nifi/processors/standard/GetHTTP.java#L295 > > Andy LoPresto > alopre...@apache.org > *alopresto.apa...@gmail.com <alopresto.apa...@gmail.com>* > PGP Fingerprint: 70EC B3E5 98A6 5A3F D3C4 BACE 3C6E F65B 2F7D EF69 > > On Aug 9, 2017, at 6:57 PM, 尹文才 <batman...@gmail.com> wrote: > > Thanks Koji, I checked the link you provided and I think getting a > DataSource is no different than getting the DBCP service(they could just > get the connection). Actually I was trying to get the configured driver > class to check the database type. > > Regards, > Ben > > 2017-08-10 9:29 GMT+08:00 Koji Kawamura <ijokaruma...@gmail.com>: > > Hi Ben, > > I'm not aware of ways to obtain configurations of a controller from a > processor. Those should be encapsulated inside a controller service. > If you'd like to create DataSource instance instead of just obtaining > a connection, this discussion might be helpful: > https://github.com/apache/nifi/pull/1417 > > Although I would not recommend, if you really need to obtain all > configurations, you can do so by calling NiFi REST API from your > processor. > > Thanks, > Koji > > On Thu, Aug 10, 2017 at 10:09 AM, 尹文才 <batman...@gmail.com> wrote: > > Hi guys, I have a customized processor with a DBCP controller service as > > a > > property. I could get the DBCP controller service in my code, but does > anyone know how to obtain all the configurations of the DBCP controller > service in java code(e.g. Database Connection URL, Database Driver > Location, etc) Thanks. > > Regards, > Ben > > > >