From: Roland Haeder Date: Thu, 27 Aug 2015 12:14:31 +0000 (+0200) Subject: Some changes: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=17c9e91134fbc0f893e29c53fc0ceeaf4da243af;p=jcore.git Some changes: - Moved sessionId + setter/getter to super class BaseFrameworkSystem - added method isBundledInitialized() - the data source identifier is now hard-coded Signed-off-by:Roland Häder --- 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