Re: Can I add properties to the properties file

59 views
Skip to first unread message

Decebal Suiu

unread,
Jan 16, 2019, 1:45:00 AM1/16/19
to Zaca, pf4j
Can you add more details, please?
Do you have a property file per plugin or you have a property file per applicatin? Do you want to use properties in plugin or application?

On Wed, Jan 16, 2019 at 8:31 AM Zaca <zaca...@infosis.com.ar> wrote:
Is it posible to add properties to the properties file and use them from the plugin?

My scenario is a communication platform and aI want to configure in the properties file origin and destination of the plugin's messages.

--
You received this message because you are subscribed to the Google Groups "pf4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pf4j+uns...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Message has been deleted

Decebal Suiu

unread,
Jan 19, 2019, 6:34:39 AM1/19/19
to Zaca, pf4j
You have a lot of flexibility with PF4J.
In many cases the solution is to create your version of PluginManager (AcmePluginManager) and Plugin (AcmePlugin) and to push your business in these classes.
For example, in AcmePluginManager you can add some business methods or inject resources that can be used by all your plugins.
AcmePlugin will be the root of all your plugins (each plugin from your project must extends AcmePlugin and not directly Plugin). Here you have access to AcmePluginManager via getPluginManager method and in this mode you can make available some resources from AcmePluginManager.

In the past, I wrote in a post (I don't remember were) that the hard part of modularization is the planning phase (define the plugins, extension points and extension).
In your concrete case, I don't understand why you declare the plugin attributes (sendTopic and receiveTopics) in plugin descriptor and not in AcmePlugin (the root of all your plugins).
If you put these information in each plugin descriptor means that these information is immutable (static/fixed) for each plugin. So, why not

class abstract AcmePlugin extends Plugin {
    abstract String getSendTopic();
    abstract List<String> getReceiveTopic();
}

and each plugin will extends AcmePlugin?



On Fri, Jan 18, 2019 at 11:55 AM Zaca <zaca...@infosis.com.ar> wrote:
I need to add two properties for every plugin in my application. That means, in the plugin initialization I need to set two properties for a messaging functionality between plugins in my application. 

I solved creating a new PluginDescriptorFinder which reads these properties and extending PluginDescriptor. I also override 

protected ExtensionFactory createExtensionFactory() and protected PluginDescriptorFinder createPluginDescriptorFinder()  in the DefaultPluginManager 


Example code: 

https://github.com/InfosisARG/platform-iot/blob/master/platform-iot-main-app/src/main/java/com/infosisarg/PluginManagerHolder.java


Do you think it could be useful to have a FlexiblePluginDescriptor to have dynamic load of properties?. It would use a Map to store properties and could set default properties as it is doing now and extra properties in the Map.


It could be a 

    ExtendedPluginDescriptor with the methods getProperty(String key) setProperty(String key, Object value)

and a ExtendedPluginDescriptorFinder to set it.

Reply all
Reply to author
Forward
0 new messages