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

improve integration doc #9322

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

NathanQingyangXu
Copy link
Contributor

Recently working on Hibernate Integration stuff in MongoDB. After carefully reading the excellent Integration doc, it seems there are some minor defects that could be fixed.

As normal, many might be false positives. I'll leave some comments to explain the reasons behind some changes.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license
and can be relicensed under the terms of the LGPL v2.1 license in the future at the maintainers' discretion.
For more information on licensing, please check here.


@hibernate-github-bot
Copy link

Thanks for your pull request!

This pull request does not follow the contribution rules. Could you have a look?

❌ All commit messages should start with a JIRA issue key matching pattern HHH-\d+
    ↳ Offending commits: [b9297d2]

› This message was automatically generated.

@@ -35,17 +35,15 @@ What's interesting is the `ServiceRegistry` and the pluggable swapping of the di
The basic requirement for a `Service` is to implement the marker interface `org.hibernate.service.Service`.
Hibernate uses this internally for some basic type safety.

The `Service` can also implement a number of optional life-cycle related contracts:
The `Service` can also implement a number of optional lifecycle related contracts:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

change this to maintain consistency. lifecycle is used elsewhere


`org.hibernate.service.spi.Startable`::
allows the `Service` impl to be notified that it is being started and about to be put into use.
`org.hibernate.service.spi.Stoppable`::
allows the `Service` impl to be notified that it is being stopped and will be removed from use.
`org.hibernate.service.spi.ServiceRegistryAwareService`::
allows the `Service` to be injected with a reference to the registry that is managing it. See <<services-dependencies>> for more details.
`org.hibernate.service.spi.Manageable`::
marks the `Service` as manageable in JMX provided the JMX integration is enabled. This feature is still incomplete.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The above stuff has been absent from the codebase

@@ -118,12 +116,12 @@ Each specific type of registry defines its own `ServiceInitiator` specialization
=== Types of ServiceRegistries

Currently Hibernate utilizes three different `ServiceRegistry` implementations forming a hierarchy.
Each type is a specialization for the purpose of type-safety, but they add no new functionality.
Each type is a specialization for the purpose of type safety, but they add no new functionality.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

for consistency reason. type safety is used more often elsewhere.

@@ -1,4 +1,4 @@
public interface EventPublishingService extends Service {

public void publish(Event theEvent);
void publish(Event theEvent);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe we don't need to specify public for interface method

.get( JMS_CONNECTION_FACTORY_NAME_SETTING );
this.destinationName = configurationValues
this.destinationName = (String) configurationValues
.get( JMS_DESTINATION_NAME_SETTING );
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added generics usage as much as possible in this PR for using Map alone seems sloppy

@@ -1,4 +1,4 @@
public class LatestAndGreatestConnectionProviderImplContributor1
public class LatestAndGreatestConnectionProviderImplContributor
implements ServiceContributor {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Originally the example code snippets were prepared for two flavours:

  • LatestAndGreatestConnectionProviderImplContributor1
  • LatestAndGreatestConnectionProviderImplContributor2

one of the reasons is two meta-inf files were provided so using number suffix to differentiate between them:

  • ex2-meta-inf
  • ex3-meta-inf

However, the ex3-meta-inf was not used at all so it is deleted in this PR. Then it seems no such confusing suffix is needed.

selector.registerStrategyImplementor(
ConnectionProvider.class,
"lag",
LatestAndGreatestConnectionProviderImpl.class
);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this code snippet is too sloppy

Copy link
Member

Choose a reason for hiding this comment

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

Probably should be requireService() instead of getService() if we're being picky.

+
By default, injected services are considered required, that is the start up will fail if a named dependent `Service` is missing.
If the `Service` to be injected is optional, the required attribute of the `@InjectService` annotation should be declared as `false` (default is `true`).
By default, injected services are considered required, that is the startup will fail if a named dependent `Service` is missing.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
By default, injected services are considered required, that is the startup will fail if a named dependent `Service` is missing.
By default, injected services are considered required, that is, the startup will fail if a named dependent `Service` is missing.

@@ -58,10 +56,10 @@ Services are allowed to declare dependencies on other services using either of t
Any method on the `Service` implementation class accepting a single parameter and annotated with `@InjectService` is considered requesting injection of another service.
+
By default, the type of the method parameter is expected to be the `Service` role to be injected.
If the parameter type is different than the `Service` role, the serviceRole attribute of the `@InjectService` annotation should be used to explicitly name the role.
If the parameter type is different than the `Service` role, the `serviceRole` attribute of the `@InjectService` annotation should be used to explicitly name the role.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
If the parameter type is different than the `Service` role, the `serviceRole` attribute of the `@InjectService` annotation should be used to explicitly name the role.
If the parameter type is different to the `Service` role, the `serviceRole` attribute of the `@InjectService` annotation should be used to explicitly name the role.


===== `IntegratorService`

The `Service` role for this `Service` is `org.hibernate.integrator.spi.IntegratorService.`
Applications, third-party integrators and others all need to integrate with Hibernate. Historically this used to require something (usually the application) to coordinate registering the pieces of each integration needed on behalf of each integration. The `org.hibernate.integrator.spi.Integrator` contract formalized this "integration SPI". The IntegratorService manages all known integrators.
Applications, third-party integrators and others all need to integrate with Hibernate. Historically this used to require something (usually the application) to coordinate registering the pieces of each integration needed on behalf of each integration. The `org.hibernate.integrator.spi.Integrator` contract formalized this "integration SPI". The `IntegratorService` manages all known integrators.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Applications, third-party integrators and others all need to integrate with Hibernate. Historically this used to require something (usually the application) to coordinate registering the pieces of each integration needed on behalf of each integration. The `org.hibernate.integrator.spi.Integrator` contract formalized this "integration SPI". The `IntegratorService` manages all known integrators.
Applications, third-party integrators, and others all need to integrate with Hibernate. Historically this used to require something (usually the application) to coordinate registering the pieces of each integration needed on behalf of each integration. The `org.hibernate.integrator.spi.Integrator` contract formalized this "integration SPI". The `IntegratorService` manages all known integrators.

Oxford comma.


// if we wanted to allow other strategies (e.g. a jms
// queue publisher) we might also register short names
// queue publisher) we might also register short-names
Copy link
Member

Choose a reason for hiding this comment

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

Hyphenating "short names" is just weird. You don't need a hyphen between an adjective and a noun.

A hyphen would be used if this were a compound adjective, but it's not. So if there are other occurrences of "short-name", they should be fixed by removing the hyphen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants