{"id":20885651,"url":"https://github.com/pf4j/pf4j-wicket","last_synced_at":"2025-05-12T19:31:13.768Z","repository":{"id":5016138,"uuid":"6174721","full_name":"pf4j/pf4j-wicket","owner":"pf4j","description":"Plugin Framework for Wicket (PF4J - Wicket integration)","archived":false,"fork":false,"pushed_at":"2022-07-07T21:09:37.000Z","size":222,"stargazers_count":32,"open_issues_count":6,"forks_count":15,"subscribers_count":11,"default_branch":"master","last_synced_at":"2024-05-02T01:18:40.093Z","etag":null,"topics":["java","modularity","pf4j","plugins","wicket"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pf4j.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-10-11T13:59:02.000Z","updated_at":"2024-03-07T00:38:17.000Z","dependencies_parsed_at":"2022-08-25T20:41:01.205Z","dependency_job_id":null,"html_url":"https://github.com/pf4j/pf4j-wicket","commit_stats":null,"previous_names":["decebals/wicket-plugin"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pf4j%2Fpf4j-wicket","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pf4j%2Fpf4j-wicket/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pf4j%2Fpf4j-wicket/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pf4j%2Fpf4j-wicket/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pf4j","download_url":"https://codeload.github.com/pf4j/pf4j-wicket/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225148852,"owners_count":17428430,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["java","modularity","pf4j","plugins","wicket"],"created_at":"2024-11-18T08:14:07.578Z","updated_at":"2024-11-18T08:14:08.161Z","avatar_url":"https://github.com/pf4j.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"PF4J - Wicket integration\n=====================\n[![Travis CI Build Status](https://travis-ci.org/pf4j/pf4j-wicket.png)](https://travis-ci.org/pf4j/pf4j-wicket)\n[![Maven Central](http://img.shields.io/maven-central/v/org.pf4j/pf4j-wicket.svg)](http://search.maven.org/#search|ga|1|pf4j-wicket)\n\nA simple plugin framework for wicket based on [PF4J](https://github.com/pf4j/pf4j). You can view pf4j-wicket as a wrapper over PF4J (that is more general and can be used to create a modular Swing application for example).  \n\nFeatures/Benefits\n-------------------\nThis framework is lightweight (around 10KB) with minimal dependencies (only PF4J).  \n\nThe beauty of this framework is that you can start with a monolithic application and as the application grows in complexity you can split the code (without modifications) in multiple plugins.  \nFirst create a package for each future plugin in your monolithic application. After this move each package in a plugin structure. You can play in each plugin with `PackageResoure`, `PackageResourceReference`, ... \nfrom wicket without be aware that your code is located in a plugin.\n\nComponents\n-------------------\n- **WicketPlugin** is a Plugin that implements IInitializer (hook for init/destroy application).\n- **PluginManagerInitializer** creates the plugin manager and register the created plugin manager in application using `MetaDataKey`.\nThis class load, init, start, stop and destroy plugins (using the plugin manager object).\n- **PluginComponentInjector** scans the wicket component class for fields annotated by `@javax.inject.Inject`, \nlooks up extensions of the required type for the given field from the plugin manager, and injects the extensions.\n\nUsing Maven\n-------------------\nIn your pom.xml you must define the dependencies to wicket plugin artifacts with:\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003eorg.pf4j\u003c/groupId\u003e\n    \u003cartifactId\u003epf4j-wicket\u003c/artifactId\u003e\n    \u003cversion\u003e${pf4j-wicket.version}\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\nwhere ${pf4j-wicket.version} is the last wicket plugin version.\n\nYou may want to check for the latest released version using [Maven Search](http://search.maven.org/#search%7Cga%7C1%7Cpf4j-wicket)\n\nHow to use\n-------------------\nIt's very easy to use pf4j-wicket. All you need to do is to add a dependency to pf4j-wicket in your pom.xml.\nThe main challenge for you to transform a monolithic wicket application in a modular wicket application is to identify what's your extension points and \nto write extensions for these extension point in your plugins.\n\nThe plugins are stored in a folder. You can specify the plugins folder in many way:\n- set `pf4j.pluginsDir` system property\n- servlet \\\u003ccontext-param\u003e with name `pluginsDir` (in your web.xml file)\n- filter \\\u003cinit-param\u003e with name `pluginsDir` (in your web.xml file)   \n\nThe default value for plugins folder is 'plugins'.\n\nYou can define an extension point in your application using **ExtensionPoint** interface marker.\n\n```java\npublic abstract class Section extends AbstractImageTab implements ExtensionPoint {\n\n    public Section(IModel\u003cString\u003e title) {\n        super(title);\n    }\n\n}\n```\n\nIn below code I supply an extension for the `Section` extension point.\n\n```java\npublic class WelcomePlugin extends WicketPlugin {\n\n    private static WelcomePlugin instance;\n    \n    public WelcomePlugin(PluginWrapper wrapper) {\n        super(wrapper);\n        \n        instance = this;\n    }\n\n    public static WelcomePlugin get() { // for a quick access to this plugin (it's optional)\n        return instance;\n    }\n    \n    @Extension\n    public static class WelcomeSection extends SimpleSection {\n\n        public WelcomeSection() {\n            super(Model.of(\"Welcome Plugin\"));\n        }\n\n        @Override\n        public ResourceReference getImage() {\n            return new PackageResourceReference(WelcomePlugin.class, \"res/datasource.png\");\n        }\n\n        @Override\n        public WebMarkupContainer getPanel(String panelId) {\n            return new WelcomePanel(panelId, Model.of(\"This plugin contributes with a css file to the head of page.\"));\n        }\n\n    }\n\n}\n\npublic class WelcomePanel extends SimplePanel {\n    \n    public WelcomePanel(String id, IModel\u003cString\u003e model) {\n        super(id, model);\n        \n        messageLabel.add(AttributeModifier.append(\"class\", \"welcome\"));\n    }\n\n    @Override\n    public void renderHead(IHeaderResponse response) {\n        super.renderHead(response);\n        \n        response.render(CssHeaderItem.forReference(new PackageResourceReference(WelcomePanel.class, \"res/welcome.css\")));\n    }\n\n}\n```\n\t\nYou can use **@Inject** to retrieve all extensions for `Section` extension point (see demo/app/.../HomePage.java).\n\n```java\npublic class HomePage extends WebPage {\n\n    @Inject\n    private List\u003cSection\u003e sectionExtensions; // this field is populate by pf4j-wicket\n\n    public HomePage() {     \n        ...\n\n        // add section extensions\n        sections.addAll(sectionExtensions);\n\n        // add tabbed panel to page\n        add(new ImageTabbedPanel\u003cSection\u003e(\"tabs\", sections));        \n    }\n    \n}\n```\n\nAnother option (without annotation) to retrieves all extensions for an extension point is **pluginManager.getExtensions(Section.class)**.   \nFor example:\n\t\n```java\nPluginManager pluginManager = Application.get().getMetaData(PluginManagerInitializer.PLUGIN_MANAGER_KEY);\nList\u003cSection\u003e sectionExtensions = pluginManager.getExtensions(Section.class);\n```\n\nIf you want to supply a custom `PluginManager` than your `Application` must implements `PluginManagerFactory`.\n\nFor more information please see the demo sources.\n\nDemo\n-------------------\nI have a tiny demo application. The demo application is in demo folder.\nIn `demo/api` folder I declared an extension point (_Section_) that is a tab in a wicket TabbedPanel.\nEach section has an title, an icon and a content (a simple text message in my demo).\nIn `demo/plugins/*` I implemented two plugins: plugin1, plugin2 (each plugin adds an extension for _Section_).\n\nThe first plugin contributes with some JavaScript files to the head of page and the second plugin contributes with a Css file to the head of page.  \n\nTo run the demo application use:  \n\n```bash \n./run-demo.sh\n```\n    \nIn the internet browser type http://localhost:8081/.\n\nMailing list\n--------------\n\nMuch of the conversation between developers and users is managed through [mailing list] (http://groups.google.com/group/wicket-plugin).\n\nVersioning\n------------\nThis project will be maintained under the Semantic Versioning guidelines as much as possible.\n\nReleases will be numbered with the follow format:\n\n`\u003cmajor\u003e.\u003cminor\u003e.\u003cpatch\u003e`\n\nAnd constructed with the following guidelines:\n\n* Breaking backward compatibility bumps the major\n* New additions without breaking backward compatibility bumps the minor\n* Bug fixes and misc changes bump the patch\n\nFor more information on SemVer, please visit http://semver.org/.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpf4j%2Fpf4j-wicket","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpf4j%2Fpf4j-wicket","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpf4j%2Fpf4j-wicket/lists"}