Sharing code between multiple micro-services [closed] - java

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 3 years ago.
Improve this question
I am developing three micro-services
View offers
Add offers(for administrator)
Opt offers
View offers is used to show offers to customer and Add offer used by service admins to link offer to customer and if offer is linked to customer, view offer will return that offer in response. Opt offers is used by customer to avail the offer.
While designing, I realized that all 3 services share same functionality, but also have their own logic.
Should I use shared code while developing these API or each API must have its own code base?

If you are using maven then you can use Maven Modules. This basically means you can extract the service code into separate module and include that module as a pom dependency in all 3 microservices.
Here's an example of how to do it using Spring. If you are not using Spring then you can have a look at another example here.

Related

Multi module java app project structure [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I am getting task(for learning new technologies) to create a facebook like project with
1. Auth (Spring Boot,Spring security, MySQL, ember.js)
2. Messaging (Spring Boot, Kafka,Cassandra, ember.js)
3. Member (Spring Boot, ember.js)
4. Reporting (Kafka, Spark, ember.js)
functional.
I need to get help for project structure. Should I have four separated modules (like auth, message, member, report) + core module. And what I should put in core module(entity beans, helpers, utils...)?
Thanks in advance.
Keeping code organized on huge projects is important, making each functionality into it's own module is desired.
But only if you are experienced enough should you begin with that. It might be better to start off in one module and expand later into separate modules.
In the core you construct tests that determine if the application as a whole is functional, etc. Core could also include the REST for everything else than the modules you already said.
Or do you plan to make the front with react?

Whats the right way to separate model and logic [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
Hi I'm setting up a new project and was struggeling with Java Annotations.
Are they related to Logic / API or Model
In Detail:
I have a started a multi maven module for example:
project-parent
project-model
project-persist
project-logic1
I separated model from every other module simple POJOs with JPA.
To use them with different frontends or REST etc.
Now I wanna use annotations from project-logic1 in the model.
Now i'm confused with the seperation.
Should I make an own API module (project-API) for this and similar annotation / interfaces
Should I simply add the annotation in the project-model
Should I add the dependency of project-logic1 into the project-model POM
I think the first one is correctly but I'm not sure.
From what I understand, you shouldn't use your model objects (with the JPA annotations) as DTO in your project.
You should have your model within the logic project, so DB related items are un the same place, and you create and API project with only POJO, not related to your DB, so you can use this API for REST services' answers and keep your implementation hidden.
If you have common code, I would suggest to wrap it into a dedicated module, so I would agree with your "API"-Approach (although the label "API" might be too much here).
Do not cross-reference your modules, dependencies must always go one way. And: Never repeat yourself, so c/p-ing your annotations is fundamentally wrong ;)

Proper organisation of packages in java standard crud application [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I'm trying to make a small crud application using swing, with Authentication features and GUI.
Can you give me the right organization and naming of my packages ??
There's no hard and fast rule, but the rule of thumb is to start with your company's domain name in reverse:
com.mycompany
Then add on the project:
com.mycompany.project
This ensures you're unlikely to have clashes between your classes and those from the libraries you depend on.
Then personally I try break things down by their functional groups, for example
com.mycompany.project.domain // contains the business domain classes
com.mycompany.project.io // contains the classes that deal with network or file-system
com.mycompany.project.persistence // contains the classes that handle persistence of the business domain classes
com.mycompany.project.ui // contains the user interface related classes
Within those packages, I might have further group but that would be very specific to the project.
The important thing is to be consistent across your project.
Short answer: One package per module/feature, possibly with sub-packages. Put closely related things together in the same package. Avoid circular dependencies between packages.
Long answer: I agree with most of this article

Modularity - design patterns - Architecture [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I'm trying to implement modularity system (J2EE) to allow changes of the type modules/plugins/add ons.
I want to know how to start, what approach I should follow.
Are there any new design patterns for this type of system ?
or do I need a new technology (message bus, osgi) ?
Thanks in advance
Mhadjis
Spring would be a good starting point. Spring context files let you specify most of the architecture in XML and the replace them later. This makes for a very modular architecture. Now in terms of being able to write "plugins" like where a user can provide a jar file and it hooks into the app dynamically that is something you'd have to roll yourself. However, Spring could help you there again by providing a lot of tools for abstracting out the configuration of plugins and loading them (loading them as Spring contexts).

How to document Java Web service API [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 years ago.
Improve this question
I have a Java web service and want to document the public API so the documentation is able to be browsed from the web from the same URL as the web service. How is this usually done?
There is wsdldocumentation tag:
<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">Your Documentation</wsdl:documentation>
There is no standard way of doing so. The WSDL is not humanly readable, and the page listing - if any - the possible WSDL's is automatically generated.
You will need to investigate how the web service layer you have chosen, do it, and see if there is any way to "hook into" that mechanism.
You can also use a documentation tool like iDocIt! to add documentation to the WSDL. It is an Open Source Eclipse Plugin for documenting APIs. http://code.google.com/p/idocit

Categories

Resources