From 17c9e91134fbc0f893e29c53fc0ceeaf4da243af Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Thu, 27 Aug 2015 14:14:31 +0200 Subject: [PATCH] =?utf8?q?Some=20changes:=20-=20Moved=20sessionId=20+=20se?= =?utf8?q?tter/getter=20to=20super=20class=20BaseFrameworkSystem=20-=20add?= =?utf8?q?ed=20method=20isBundledInitialized()=20-=20the=20data=20source?= =?utf8?q?=20identifier=20is=20now=20hard-coded=20Signed-off-by:Roland=20H?= =?utf8?q?=C3=A4der=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../mxchange/jcore/BaseFrameworkSystem.java | 37 ++++++++++++++++++- .../mxchange/jcore/FrameworkInterface.java | 12 ++++++ .../datasource/DataSourceDatabaseBackend.java | 14 +++---- 3 files changed, 55 insertions(+), 8 deletions(-) diff --git a/src/org/mxchange/jcore/BaseFrameworkSystem.java b/src/org/mxchange/jcore/BaseFrameworkSystem.java index 7a7fa0a..7677441 100644 --- a/src/org/mxchange/jcore/BaseFrameworkSystem.java +++ b/src/org/mxchange/jcore/BaseFrameworkSystem.java @@ -105,6 +105,11 @@ public class BaseFrameworkSystem implements FrameworkInterface { */ private DatabaseFrontend frontend; + /** + * Session id assigned with this basket, or any other unique identifier + */ + private String sessionId; + /** * Initialize object */ @@ -905,6 +910,36 @@ public class BaseFrameworkSystem implements FrameworkInterface { this.frontend = frontend; } + /** + * Setter for session id + * + * @param sessionId Session id + */ + @Override + public final void setSessionId (final String sessionId) { + this.sessionId = sessionId; + } + + /** + * Getter for session id + * + * @return Session id + */ + @Override + public final String getSessionId () { + return this.sessionId; + } + + /** + * Checks if the bundle is initialized + * + * @return Whether the bundle has been initialized + */ + protected boolean isBundledInitialized () { + // Check it + return (bundle instanceof ResourceBundle); + } + /** * Initializes i18n bundles */ @@ -913,7 +948,7 @@ public class BaseFrameworkSystem implements FrameworkInterface { this.getLogger().trace("CALLED!"); //NOI18N // Is the bundle set? - if (bundle instanceof ResourceBundle) { + if (this.isBundledInitialized()) { // Is already set throw new IllegalStateException("called twice"); //NOI18N } diff --git a/src/org/mxchange/jcore/FrameworkInterface.java b/src/org/mxchange/jcore/FrameworkInterface.java index bf9b1e8..222b09d 100644 --- a/src/org/mxchange/jcore/FrameworkInterface.java +++ b/src/org/mxchange/jcore/FrameworkInterface.java @@ -66,6 +66,18 @@ public interface FrameworkInterface { */ public Application getApplication (); + /** + * Session id + * @return the sessionId + */ + public String getSessionId (); + + /** + * Session id + * @param sessionId the sessionId to set + */ + public void setSessionId (final String sessionId); + /** * Getter for human-readable string from given key * diff --git a/src/org/mxchange/jcore/database/backend/datasource/DataSourceDatabaseBackend.java b/src/org/mxchange/jcore/database/backend/datasource/DataSourceDatabaseBackend.java index d5265d3..221ad86 100644 --- a/src/org/mxchange/jcore/database/backend/datasource/DataSourceDatabaseBackend.java +++ b/src/org/mxchange/jcore/database/backend/datasource/DataSourceDatabaseBackend.java @@ -79,7 +79,7 @@ public class DataSourceDatabaseBackend extends BaseDatabaseBackend implements Da @Override public void connectToDatabase () throws SQLException, NamingException { // Trace message - this.getLogger().trace("CALLED!"); + this.getLogger().trace("CALLED!"); //NOI18N // Is the connection given? if (null == connection) { @@ -87,16 +87,16 @@ public class DataSourceDatabaseBackend extends BaseDatabaseBackend implements Da Context context = new InitialContext(); // Get data source instance - DataSource source = (DataSource) context.lookup(this.getProperty("database.datasource.name")); + DataSource source = (DataSource) context.lookup("jdbc/pizza-service"); //NOI18N // Debug message - this.getLogger().debug(MessageFormat.format("source={0}", source)); + this.getLogger().debug(MessageFormat.format("source={0}", source)); //NOI18N // Now as all access data is stored in data source, get a connection from it connection = source.getConnection(); // Debug log - this.getLogger().debug(MessageFormat.format("connection={0}", connection)); + this.getLogger().debug(MessageFormat.format("connection={0}", connection)); //NOI18N } // Debug message @@ -106,17 +106,17 @@ public class DataSourceDatabaseBackend extends BaseDatabaseBackend implements Da this.totalRows = connection.prepareStatement(String.format("SELECT COUNT(`%s`) AS `cnt` FROM `%s` LIMIT 1", this.getFrontend().getIdName(), this.getTableName())); //NOI18N // Trace message - this.getLogger().trace("EXIT!"); + this.getLogger().trace("EXIT!"); //NOI18N } @Override public Result doInsertDataSet (final Map dataset) throws SQLException, IOException { - throw new UnsupportedOperationException("Not supported yet: dataset=" + dataset); //To change body of generated methods, choose Tools | Templates. + throw new UnsupportedOperationException(MessageFormat.format("Not supported yet: dataset={0}", dataset)); } @Override public Result doSelectByCriteria (final SearchableCriteria criteria) throws IOException, BadTokenException, CorruptedDatabaseFileException, SQLException, NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { - throw new UnsupportedOperationException("Not supported yet: criteria=" + criteria); //To change body of generated methods, choose Tools | Templates. + throw new UnsupportedOperationException(MessageFormat.format("Not supported yet: criteria={0}", criteria)); } @Override -- 2.39.5