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

Provide Project via injection #672

Merged
merged 12 commits into from
Nov 7, 2017
Merged

Provide Project via injection #672

merged 12 commits into from
Nov 7, 2017

Conversation

lauraluiz
Copy link
Contributor

@lauraluiz lauraluiz commented Sep 22, 2017

So as the name explains, the main objective was to extract the Project fetching from the ProjectContext and grant it its own Provider and Module (which is then enabled in reference.conf on Sunrise framework level). And provide the new configuration structure.

To make tests work, other injection modules had to be created as well (localization, sphereclient and template).

@zonorti zonorti temporarily deployed to ct-sunrise-stage-pr-672 September 22, 2017 12:21 Inactive
@lauraluiz lauraluiz temporarily deployed to ct-sunrise-stage-pr-672 September 22, 2017 12:25 Inactive
bind(CurrencyUnit.class)
.toProvider(CurrencyFromCountryProvider.class)
.in(RequestScoped.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.

Removed from Module.java, because this file belongs to Starter Project and is therefore never updated with new releases, what makes migration more difficult. Now moved to LocalizationModule, which is enabled by default on reference.conf (default configuration), and can be disabled via configuration as explained in #671 in order to bind your own implementations.

@lauraluiz lauraluiz requested a review from katmatt October 26, 2017 13:06
Copy link
Contributor

@katmatt katmatt left a comment

Choose a reason for hiding this comment

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

Cool 😎 , I like the new modular modules a lot 👍 😄 I just have some questions and suggestions. And I'm looking forward to discuss them with you.

@@ -64,4 +69,8 @@ default boolean isCountrySupported(final CountryCode countryCode) {
default boolean isCurrencySupported(final CurrencyUnit currency) {
return currencies().contains(currency);
}

static ProjectContext of(final Configuration globalConfig, final String configPath, final Project project) {
Copy link
Contributor

Choose a reason for hiding this comment

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

To me it looks like this method isn't used or do you plan to use it in tests?


import javax.inject.Singleton;

public final class ProjectModule extends AbstractModule {
Copy link
Contributor

Choose a reason for hiding this comment

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

The name clearly states that it provides a project, but as an user you have to look at the source code to see what this module provides. What do you think about adding some javadoc here?


import static io.sphere.sdk.client.SphereClientUtils.blockingWait;

public final class ProjectProvider implements Provider<Project> {
Copy link
Contributor

Choose a reason for hiding this comment

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

We now could even remove the public modifier from this class. WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, I would like to let developers to bind using this provider, in case they need to override some parts of an injection module and reuse others.

@@ -13,7 +14,7 @@
private final CountryInSession countryInSession;

@Inject
public CountryFromSessionProvider(final ProjectContext projectContext, final CountryInSession countryInSession) {
CountryFromSessionProvider(final ProjectContext projectContext, final CountryInSession countryInSession) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice that you removed the public modifier here. And we now could remove the public modifier from this class too.

import javax.money.CurrencyUnit;
import java.util.Locale;

public final class LocalizationModule extends AbstractModule {
Copy link
Contributor

Choose a reason for hiding this comment

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

As above: Would be nice to add some javadoc here.


import javax.inject.Singleton;

public final class TemplateModule extends AbstractModule {
Copy link
Contributor

Choose a reason for hiding this comment

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

As above: Would be nice to add some javadoc here.

@lauraluiz
Copy link
Contributor Author

@katmatt applied the changes you requested and some more documentation :)

@katmatt
Copy link
Contributor

katmatt commented Nov 6, 2017

Looks very good to me 👍

@lauraluiz lauraluiz merged commit 924e28f into master Nov 7, 2017
@lauraluiz lauraluiz deleted the provide-project branch November 7, 2017 09:47
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.

3 participants