-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Refactor shared package into the architecture #3523
Conversation
.putAllDBMSConnectionProperties(properties); | ||
DatabaseSynchronizer synchronizer = context.getDBMSSynchronizer(); | ||
if (synchronizer instanceof DBMSSynchronizer) { | ||
DatabaseConnectionProperties properties = ((DBMSSynchronizer) synchronizer).getDBProcessor() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you add getDBMSConnectionProperties
to the Synchronizer
interface, then you probably don't need the if statement and the explicit cast here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, nicely spotted! So far, I was focused on the refactoring only, but the code certainly has a lot of potential for improvements. Implementing your suggestion was fairly easy and I fixed this at a second position as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This refactoring is a nice step in the right direction. In the long term, I think we should refactor everything related to saving and opening databases to use a common interfaces regardless if the file is stored on the PC, in the cloud or somewhere else.
This refs #110. I am still planning to work on that as I want to provide our logic package as standalone library. |
@koppor Ah, I was looking for that issue :) Maybe we should re-open it, since we now have a tangible use case (the new Java module system). Once the model package is modularized, the logic package will not be far off. |
@JabRef/developers With another review, this could be merged. |
|
||
import org.apache.commons.logging.Log; | ||
import org.apache.commons.logging.LogFactory; | ||
|
||
/** | ||
* Keeps all essential data for establishing a new connection to a DBMS using {@link DBMSConnection}. | ||
*/ | ||
public class DBMSConnectionProperties { | ||
public class DBMSConnectionProperties implements DatabaseConnectionProperties { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I only don't get this, isn't this supposed to be same or are DataBaseConnectionProperties more general?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DBMSConnectionProperties
are the only implementation of DatabaseConnectionProperties
, they're essentially the same. The sole reason for the existence of the interface is that it breaks the dependency from model to elsewhere.
|
||
void registerListener(Object listener); | ||
|
||
void openSharedDatabase(DatabaseConnection connection) throws DatabaseNotSupportedException, SQLException; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would let this rather be more general, by not having the concrete SQLException here. I could implement this interface for my Sharelatex Connection.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I've inlined the SQLException
in favor of an IllegalStateException
.
* upstream/master: Refactor shared package into the architecture (#3523)
The new Java 9 module system brings us the possibility to actually modularize inside Java, i.e. to distribute our source code into multiple modules and specify dependencies and constraints among them, much in the way that we do it now with tests. But to extract modules, there can be no cyclic dependencies among them.
The
model
package is our best candidate for extracting a new module. Here the last dependency that coupled it to transitively to everything else was theshared
package. This PR refactors the shared package and puts most of it intologic
. I broke the dependency frommodel
by introducing a number of interface that thelogic
layer implements. These interfaces will have just one implementation now, but at least they break the dependency cycle.This is just a refactoring, so I think it should be merged after the release of 4.1
gradle localizationUpdate
?