Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JAMES-2886 Allow to load extensions in WebAdmin #2701

Closed
wants to merge 15 commits into from

Conversation

chibenwa
Copy link
Member

Next step of #2699 , this work enables one to add new custom routes within the WebAdmin protocol from the extensions-jars folder.

The example of the ApacheCon preparation can then be handled as completly indepandantly source code.

@chibenwa chibenwa added the contribution Contribution of a kind contributor - also applicable for community oriented efforts. label Sep 20, 2019
@chibenwa chibenwa added this to the Sprint 11 - Robusta beans milestone Sep 20, 2019
@chibenwa chibenwa force-pushed the webadmin-routes-extensions branch 2 times, most recently from d98291d to 2548fc9 Compare September 20, 2019 13:01
@mbaechler
Copy link

Could you please provide the documentation of how you use this feature?

@chibenwa
Copy link
Member Author

[2548fc9180ecba4bc19dd71fda109d9b6151032f] bloop 14:04:12.525 [ERROR] spark.Spark - ignite failed
[2548fc9180ecba4bc19dd71fda109d9b6151032f] java.net.BindException: Address already in use
[2548fc9180ecba4bc19dd71fda109d9b6151032f] 	at java.base/sun.nio.ch.Net.bind0(Native Method)
[2548fc9180ecba4bc19dd71fda109d9b6151032f] 	at java.base/sun.nio.ch.Net.bind(Net.java:461)
[2548fc9180ecba4bc19dd71fda109d9b6151032f] 	at java.base/sun.nio.ch.Net.bind(Net.java:453)
[2548fc9180ecba4bc19dd71fda109d9b6151032f] 	at java.base/sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:227)
[2548fc9180ecba4bc19dd71fda109d9b6151032f] 	at java.base/sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:80)
[2548fc9180ecba4bc19dd71fda109d9b6151032f] 	at org.eclipse.jetty.server.ServerConnector.openAcceptChannel(ServerConnector.java:342)
[2548fc9180ecba4bc19dd71fda109d9b6151032f] 	... 9 common frames omitted
[2548fc9180ecba4bc19dd71fda109d9b6151032f] Wrapped by: java.io.IOException: Failed to bind to /0.0.0.0:40261
[2548fc9180ecba4bc19dd71fda109d9b6151032f] 	at org.eclipse.jetty.server.ServerConnector.openAcceptChannel(ServerConnector.java:346)
[2548fc9180ecba4bc19dd71fda109d9b6151032f] 	at org.eclipse.jetty.server.ServerConnector.open(ServerConnector.java:308)
[2548fc9180ecba4bc19dd71fda109d9b6151032f] 	at org.eclipse.jetty.server.AbstractNetworkConnector.doStart(AbstractNetworkConnector.java:80)
[2548fc9180ecba4bc19dd71fda109d9b6151032f] 	at org.eclipse.jetty.server.ServerConnector.doStart(ServerConnector.java:236)
[2548fc9180ecba4bc19dd71fda109d9b6151032f] 	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
[2548fc9180ecba4bc19dd71fda109d9b6151032f] 	at org.eclipse.jetty.server.Server.doStart(Server.java:396)
[2548fc9180ecba4bc19dd71fda109d9b6151032f] 	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
[2548fc9180ecba4bc19dd71fda109d9b6151032f] 	at spark.embeddedserver.jetty.EmbeddedJettyServer.ignite(EmbeddedJettyServer.java:149)
[2548fc9180ecba4bc19dd71fda109d9b6151032f] 	at spark.Service.lambda$init$2(Service.java:574)
[2548fc9180ecba4bc19dd71fda109d9b6151032f] 	at java.base/java.lang.Thread.run(Thread.java:834)
[2548fc9180ecba4bc19dd71fda109d9b6151032f] [INFO] 

test this please

@mbaechler
Copy link

Thank you for the update on the webadmin configuration.
However, I would rather read a general "customization" or "extension" documentation explaining how to achieve that (how should I write my route? can I rely on guice? how to package the classes and their dependencies?)

Copy link

@rouazana rouazana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice, thanks!

src/site/xdoc/server/dev-extend.xml Outdated Show resolved Hide resolved
src/site/xdoc/server/dev-extend.xml Outdated Show resolved Hide resolved
src/site/xdoc/server/dev-extend.xml Show resolved Hide resolved
We demonstrate:
 - A previously defined route can not be overwritten
 - That public routes are applied after private routes, thus if a private
  route is already defined, the public route is ignored.
Note that route injection was revisited on this occasion:
 - Make WebAdmin server responsible of private/public triage. This avoids
 errors like the one with SwaggerRoutes where the developer forgets to
 declare his route as public upon injections. This also factorize the code
 between code & test (as a user might want to define custom public routes as
 well)
Your extension class-loader will be the modified one (James and extensions-jars content) but James class-loader
stays unmodified everywhere else.</p>

<p>Once done, you need to explicitly require James to load your extensions. This needs to be done in the following

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't we use an SPI for that? (https://docs.oracle.com/javase/tutorial/sound/SPI-intro.html)
It's the standard way of implementing extensions so why would we create a custom solution for that?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does SPI interacts with injection system?

Do you want the users extensions to fully rely on SPI for their dependency resolution?

I would consider this being a burdon...

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SPI is just a way to declare extension points so that people can put an extension on the classpath an get it loaded.

AFAIK, it doesn't mean that you can't use @Inject or any other DI system.

What it does mean is:

  • we define clearly with a standard how to extend James
  • we rely on a standard jar META-INF to declare extensions

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got with your link how as an extension writer I can declare the Services I implement,

I did not get how as an extension user how I select the Services implementations I want to use....

What if a Jat contains listenerA & listenerB & I only want listenerA?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should be in two different files then

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unless your jar parse some configuration by itself

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also does this mean a breaking change for already provided extensions (mailboxListeners?)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

src/site/xdoc/server/dev-extend.xml Outdated Show resolved Hide resolved
src/site/xdoc/server/dev-extend.xml Outdated Show resolved Hide resolved
@chibenwa
Copy link
Member Author

Merged

@chibenwa chibenwa closed this Oct 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution Contribution of a kind contributor - also applicable for community oriented efforts.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants