]> git.mxchange.org Git - jcore.git/commitdiff
Some changes:
authorRoland Haeder <roland@mxchange.org>
Thu, 27 Aug 2015 12:14:31 +0000 (14:14 +0200)
committerRoland Haeder <roland@mxchange.org>
Thu, 27 Aug 2015 12:14:31 +0000 (14:14 +0200)
- 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 <roland@mxchange.org>

src/org/mxchange/jcore/BaseFrameworkSystem.java
src/org/mxchange/jcore/FrameworkInterface.java
src/org/mxchange/jcore/database/backend/datasource/DataSourceDatabaseBackend.java

index 7a7fa0a2f649d78393104fc6fcc78430acf076b7..7677441e843cfd34c919784c007e6b0ee0eeb5c6 100644 (file)
@@ -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
                }
index bf9b1e8f7ca8fa144c6c63504817f87b7b928730..222b09d7fafd9e6bd1cac2da8e6e2134f5716ffa 100644 (file)
@@ -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
         *
index d5265d37b4abe052b95767cd1c5f4399b31d6031..221ad86bdad7098fd495a1f8f5bbccaca4b92d44 100644 (file)
@@ -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<? extends Storeable> doInsertDataSet (final Map<String, Object> 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<? extends Storeable> 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