Skip to content
Snippets Groups Projects
Commit 3069eee1 authored by Eirik Steira's avatar Eirik Steira
Browse files

Add c3po connection pooling and close outgoing requests when exiting the map

parent 3c9d73b1
No related branches found
No related tags found
2 merge requests!219Add c3po connection pooling and close outgoing requests when exiting the map,!206Extraordinary push to master - project final stages
Pipeline #82910 passed
......@@ -62,6 +62,7 @@ public class Map extends NavBarController implements Initializable, MapComponent
private GoogleMap googleMap;
private GeoApiContext geoApiContext;
private StringProperty address = new SimpleStringProperty();
private EntityManager entityManager;
private ImageService imageService;
private AlbumService albumService;
private ExecutorService executorService = Executors.newCachedThreadPool();
......@@ -72,11 +73,19 @@ public class Map extends NavBarController implements Initializable, MapComponent
*/
public Map() {
App.ex.newPage("map");
EntityManager entityManager = App.ex.getEntityManager();
entityManager = App.ex.getEntityManager();
imageService = new ImageService(entityManager);
albumService = new AlbumService(entityManager);
}
/**
* Close outgoing requests when exiting the page.
*/
@Override
public void doBeforePageExit() {
entityManager.close();
}
/**
* Initialize {@link GoogleMapView} and {@link GeoApiContext} with required API key.
* Also add listener for map initialization and bind the address text field to a {@link SimpleStringProperty}.
......
......@@ -33,6 +33,8 @@ public class NavBarController {
* @throws IOException
*/
public void switchToMain(MouseEvent mouseEvent) throws IOException {
doBeforePageExit();
App.ex.setChosenAlbumId(null);
App.setRoot("main");
}
......@@ -44,10 +46,12 @@ public class NavBarController {
* @throws IOException
*/
public void goToPrevious(ActionEvent actionEvent) throws IOException {
doBeforePageExit();
String previousPage = App.ex.previousPage();
if (previousPage != null){
if (previousPage != null)
App.setRoot(previousPage);
}
}
/**
......@@ -57,9 +61,12 @@ public class NavBarController {
* @throws IOException
*/
public void switchToSearch(ActionEvent actionEvent) throws IOException {
if (!navBarSearch.getText().isEmpty()){
doBeforePageExit();
if (!navBarSearch.getText().isEmpty())
App.ex.setSearchField(navBarSearch.getText());
}
App.ex.setChosenAlbumId(null);
App.setRoot("search");
}
......@@ -70,6 +77,8 @@ public class NavBarController {
* @throws IOException
*/
public void switchToExplore(ActionEvent actionEvent) throws IOException {
doBeforePageExit();
App.ex.setChosenAlbumId(null);
App.setRoot("explore");
}
......@@ -80,6 +89,8 @@ public class NavBarController {
* @throws IOException
*/
public void switchToAlbums(ActionEvent actionEvent) throws IOException {
doBeforePageExit();
App.ex.setChosenAlbumId(null);
App.setRoot("explore_albums");
}
......@@ -90,6 +101,8 @@ public class NavBarController {
* @throws IOException
*/
public void switchToMap(ActionEvent actionEvent) throws IOException {
doBeforePageExit();
App.ex.setChosenAlbumId(null);
App.setRoot("map");
}
......@@ -100,6 +113,8 @@ public class NavBarController {
* @throws IOException
*/
public void switchToUpload(ActionEvent actionEvent) throws IOException {
doBeforePageExit();
App.ex.setChosenAlbumId(null);
App.setRoot("upload");
}
......@@ -111,9 +126,19 @@ public class NavBarController {
* @throws IOException
*/
public void logOut(ActionEvent actionEvent) throws IOException {
doBeforePageExit();
App.ex.emptyPageLog();
UserService.logOut();
App.ex.setChosenAlbumId(null);
App.setRoot("login");
}
/**
* Actions to perform when exiting the page.
* Can be implemented by subclasses to define custom actions on page exit.
*/
public void doBeforePageExit(){
};
}
......@@ -19,7 +19,11 @@
<properties>
<!-- Hibernate properties -->
<property name="hibernate.connection.pool_size" value="50"/>
<property name="hibernate.c3p0.min_size" value="5"/>
<property name="hibernate.c3p0.max_size" value="50"/>
<property name="hibernate.c3p0.timeout" value="1800"/>
<property name="hibernate.c3p0.max_statements" value="1800"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQL8Dialect"/>
<property name="hibernate.temp.use_jdbc_metadata_defaults" value="false"/>
<property name="hibernate.format_sql" value="true"/>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment