diff options
Diffstat (limited to 'plugins/org.eclipse.net4j.jms.server.jdbc/src/org/eclipse/net4j/jms/server/internal/jdbc')
4 files changed, 347 insertions, 347 deletions
diff --git a/plugins/org.eclipse.net4j.jms.server.jdbc/src/org/eclipse/net4j/jms/server/internal/jdbc/JDBCStore.java b/plugins/org.eclipse.net4j.jms.server.jdbc/src/org/eclipse/net4j/jms/server/internal/jdbc/JDBCStore.java index 35d4b7a63f..d340b5909b 100644 --- a/plugins/org.eclipse.net4j.jms.server.jdbc/src/org/eclipse/net4j/jms/server/internal/jdbc/JDBCStore.java +++ b/plugins/org.eclipse.net4j.jms.server.jdbc/src/org/eclipse/net4j/jms/server/internal/jdbc/JDBCStore.java @@ -1,128 +1,128 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.net4j.jms.server.internal.jdbc;
-
-import org.eclipse.net4j.db.IDBAdapter;
-import org.eclipse.net4j.jms.internal.server.store.AbstractStore;
-import org.eclipse.net4j.jms.internal.server.store.StoreException;
-import org.eclipse.net4j.jms.server.IStoreTransaction;
-
-import javax.sql.DataSource;
-
-import java.sql.Connection;
-import java.sql.SQLException;
-
-/**
- * @author Eike Stepper
- */
-public class JDBCStore extends AbstractStore
-{
- private static final String STORE_TYPE = "JDBC"; //$NON-NLS-1$
-
- private IDBAdapter dbAdapter;
-
- private DataSource dataSource;
-
- public JDBCStore(IDBAdapter dbAdapter, DataSource dataSource)
- {
- super(STORE_TYPE);
- if (dbAdapter == null)
- {
- throw new IllegalArgumentException("dbAdapter == null"); //$NON-NLS-1$
- }
-
- if (dataSource == null)
- {
- throw new IllegalArgumentException("dataSource == null"); //$NON-NLS-1$
- }
-
- this.dbAdapter = dbAdapter;
- this.dataSource = dataSource;
- }
-
- public IDBAdapter getDBAdapter()
- {
- return dbAdapter;
- }
-
- public DataSource getDataSource()
- {
- return dataSource;
- }
-
- public Connection getConnection()
- {
- try
- {
- return dataSource.getConnection();
- }
- catch (SQLException ex)
- {
- throw new StoreException(ex);
- }
- }
-
- public void initDatabase(String instanceID)
- {
- JMSSchema.INSTANCE.create(dbAdapter, dataSource);
- // TODO Store instanceID
- }
-
- public IStoreTransaction startTransaction()
- {
- try
- {
- Connection connection = getConnection();
- connection.setAutoCommit(false);
- return new JDBCTransaction(this, connection);
- }
- catch (SQLException ex)
- {
- throw new StoreException(ex);
- }
- }
-
- public void commitTransaction(IStoreTransaction transaction)
- {
- JDBCTransaction jdbcTransaction = (JDBCTransaction)transaction;
- try
- {
- Connection connection = jdbcTransaction.getConnection();
- connection.commit();
- }
- catch (SQLException ex)
- {
- throw new StoreException(ex);
- }
- finally
- {
- jdbcTransaction.dispose();
- }
- }
-
- public void rollbackTransaction(IStoreTransaction transaction)
- {
- JDBCTransaction jdbcTransaction = (JDBCTransaction)transaction;
- try
- {
- Connection connection = jdbcTransaction.getConnection();
- connection.rollback();
- }
- catch (SQLException ex)
- {
- throw new StoreException(ex);
- }
- finally
- {
- jdbcTransaction.dispose();
- }
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.net4j.jms.server.internal.jdbc; + +import org.eclipse.net4j.db.IDBAdapter; +import org.eclipse.net4j.jms.internal.server.store.AbstractStore; +import org.eclipse.net4j.jms.internal.server.store.StoreException; +import org.eclipse.net4j.jms.server.IStoreTransaction; + +import javax.sql.DataSource; + +import java.sql.Connection; +import java.sql.SQLException; + +/** + * @author Eike Stepper + */ +public class JDBCStore extends AbstractStore +{ + private static final String STORE_TYPE = "JDBC"; //$NON-NLS-1$ + + private IDBAdapter dbAdapter; + + private DataSource dataSource; + + public JDBCStore(IDBAdapter dbAdapter, DataSource dataSource) + { + super(STORE_TYPE); + if (dbAdapter == null) + { + throw new IllegalArgumentException("dbAdapter == null"); //$NON-NLS-1$ + } + + if (dataSource == null) + { + throw new IllegalArgumentException("dataSource == null"); //$NON-NLS-1$ + } + + this.dbAdapter = dbAdapter; + this.dataSource = dataSource; + } + + public IDBAdapter getDBAdapter() + { + return dbAdapter; + } + + public DataSource getDataSource() + { + return dataSource; + } + + public Connection getConnection() + { + try + { + return dataSource.getConnection(); + } + catch (SQLException ex) + { + throw new StoreException(ex); + } + } + + public void initDatabase(String instanceID) + { + JMSSchema.INSTANCE.create(dbAdapter, dataSource); + // TODO Store instanceID + } + + public IStoreTransaction startTransaction() + { + try + { + Connection connection = getConnection(); + connection.setAutoCommit(false); + return new JDBCTransaction(this, connection); + } + catch (SQLException ex) + { + throw new StoreException(ex); + } + } + + public void commitTransaction(IStoreTransaction transaction) + { + JDBCTransaction jdbcTransaction = (JDBCTransaction)transaction; + try + { + Connection connection = jdbcTransaction.getConnection(); + connection.commit(); + } + catch (SQLException ex) + { + throw new StoreException(ex); + } + finally + { + jdbcTransaction.dispose(); + } + } + + public void rollbackTransaction(IStoreTransaction transaction) + { + JDBCTransaction jdbcTransaction = (JDBCTransaction)transaction; + try + { + Connection connection = jdbcTransaction.getConnection(); + connection.rollback(); + } + catch (SQLException ex) + { + throw new StoreException(ex); + } + finally + { + jdbcTransaction.dispose(); + } + } +} diff --git a/plugins/org.eclipse.net4j.jms.server.jdbc/src/org/eclipse/net4j/jms/server/internal/jdbc/JDBCTransaction.java b/plugins/org.eclipse.net4j.jms.server.jdbc/src/org/eclipse/net4j/jms/server/internal/jdbc/JDBCTransaction.java index 6ca1f24729..6857c0c34a 100644 --- a/plugins/org.eclipse.net4j.jms.server.jdbc/src/org/eclipse/net4j/jms/server/internal/jdbc/JDBCTransaction.java +++ b/plugins/org.eclipse.net4j.jms.server.jdbc/src/org/eclipse/net4j/jms/server/internal/jdbc/JDBCTransaction.java @@ -1,102 +1,102 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.net4j.jms.server.internal.jdbc;
-
-import org.eclipse.net4j.internal.jms.MessageImpl;
-import org.eclipse.net4j.jms.internal.server.ServerConsumer;
-import org.eclipse.net4j.jms.internal.server.ServerDestination;
-import org.eclipse.net4j.jms.internal.server.store.AbstractStore;
-import org.eclipse.net4j.jms.internal.server.store.AbstractTransaction;
-
-import java.sql.Connection;
-
-/**
- * @author Eike Stepper
- */
-public class JDBCTransaction extends AbstractTransaction
-{
- private Connection connection;
-
- public JDBCTransaction(AbstractStore store, Connection connection)
- {
- super(store);
- this.connection = connection;
- }
-
- public Connection getConnection()
- {
- return connection;
- }
-
- public void dispose()
- {
- connection = null;
- }
-
- @Override
- protected String[] doGetDestinationNames()
- {
- return NO_DESTINATION_NAMES;
- }
-
- @Override
- protected ServerDestination doGetDestination(String name)
- {
- return null;
- }
-
- @Override
- protected long[] doGetConsumerIDs()
- {
- return NO_CONSUMER_IDS;
- }
-
- @Override
- protected ServerConsumer doGetConsumer(long id)
- {
- return null;
- }
-
- @Override
- protected void doDestinationAdded(ServerDestination destination)
- {
- }
-
- @Override
- protected void doDestinationRemoved(ServerDestination destination)
- {
- }
-
- @Override
- protected void doConsumerAdded(ServerConsumer consumer)
- {
- }
-
- @Override
- protected void doConsumerRemoved(ServerConsumer consumer)
- {
- }
-
- @Override
- protected void doMessageReceived(MessageImpl message)
- {
- }
-
- @Override
- protected void doMessageSent(MessageImpl message, long consumerID)
- {
- }
-
- @Override
- protected void doMessageAcknowledged(MessageImpl message, long consumerID)
- {
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.net4j.jms.server.internal.jdbc; + +import org.eclipse.net4j.internal.jms.MessageImpl; +import org.eclipse.net4j.jms.internal.server.ServerConsumer; +import org.eclipse.net4j.jms.internal.server.ServerDestination; +import org.eclipse.net4j.jms.internal.server.store.AbstractStore; +import org.eclipse.net4j.jms.internal.server.store.AbstractTransaction; + +import java.sql.Connection; + +/** + * @author Eike Stepper + */ +public class JDBCTransaction extends AbstractTransaction +{ + private Connection connection; + + public JDBCTransaction(AbstractStore store, Connection connection) + { + super(store); + this.connection = connection; + } + + public Connection getConnection() + { + return connection; + } + + public void dispose() + { + connection = null; + } + + @Override + protected String[] doGetDestinationNames() + { + return NO_DESTINATION_NAMES; + } + + @Override + protected ServerDestination doGetDestination(String name) + { + return null; + } + + @Override + protected long[] doGetConsumerIDs() + { + return NO_CONSUMER_IDS; + } + + @Override + protected ServerConsumer doGetConsumer(long id) + { + return null; + } + + @Override + protected void doDestinationAdded(ServerDestination destination) + { + } + + @Override + protected void doDestinationRemoved(ServerDestination destination) + { + } + + @Override + protected void doConsumerAdded(ServerConsumer consumer) + { + } + + @Override + protected void doConsumerRemoved(ServerConsumer consumer) + { + } + + @Override + protected void doMessageReceived(MessageImpl message) + { + } + + @Override + protected void doMessageSent(MessageImpl message, long consumerID) + { + } + + @Override + protected void doMessageAcknowledged(MessageImpl message, long consumerID) + { + } +} diff --git a/plugins/org.eclipse.net4j.jms.server.jdbc/src/org/eclipse/net4j/jms/server/internal/jdbc/JMSSchema.java b/plugins/org.eclipse.net4j.jms.server.jdbc/src/org/eclipse/net4j/jms/server/internal/jdbc/JMSSchema.java index bef5537836..75fb324616 100644 --- a/plugins/org.eclipse.net4j.jms.server.jdbc/src/org/eclipse/net4j/jms/server/internal/jdbc/JMSSchema.java +++ b/plugins/org.eclipse.net4j.jms.server.jdbc/src/org/eclipse/net4j/jms/server/internal/jdbc/JMSSchema.java @@ -1,73 +1,73 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.net4j.jms.server.internal.jdbc;
-
-import org.eclipse.net4j.db.DBType;
-import org.eclipse.net4j.db.ddl.IDBField;
-import org.eclipse.net4j.db.ddl.IDBIndex;
-import org.eclipse.net4j.db.ddl.IDBTable;
-import org.eclipse.net4j.spi.db.DBSchema;
-
-/**
- * @author Eike Stepper
- */
-public class JMSSchema extends DBSchema
-{
- public static final JMSSchema INSTANCE = new JMSSchema();
-
- /**
- * DBTable Destinations
- */
- public static final IDBTable DESTINATIONS = INSTANCE.addTable("destinations"); //$NON-NLS-1$
-
- public static final IDBField DESTINATIONS_NAME = //
- DESTINATIONS.addField("name", DBType.VARCHAR, 255); //$NON-NLS-1$
-
- public static final IDBField DESTINATIONS_TYPE = //
- DESTINATIONS.addField("type", DBType.INTEGER); //$NON-NLS-1$
-
- public static final IDBIndex INDEX_DESTINATIONS_PK = //
- DESTINATIONS.addIndex(IDBIndex.Type.PRIMARY_KEY, DESTINATIONS_NAME);
-
- /**
- * DBTable Messages
- */
- public static final IDBTable MESSAGES = INSTANCE.addTable("messages"); //$NON-NLS-1$
-
- public static final IDBField MESSAGES_ID = //
- MESSAGES.addField("id", DBType.VARCHAR); //$NON-NLS-1$
-
- public static final IDBField MESSAGES_DESTINATION = //
- MESSAGES.addField("destination", DBType.VARCHAR); //$NON-NLS-1$
-
- public static final IDBField MESSAGES_PRIORITY = //
- MESSAGES.addField("priority", DBType.INTEGER); //$NON-NLS-1$
-
- public static final IDBIndex INDEX_MESSAGES_PK = //
- MESSAGES.addIndex(IDBIndex.Type.PRIMARY_KEY, MESSAGES_ID);
-
- /**
- * Queries
- */
- public static final String QUERY = "SELECT " + DESTINATIONS_TYPE + ", " + MESSAGES_ID + ", " + MESSAGES_PRIORITY //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- + " FROM " + DESTINATIONS + ", " + MESSAGES + " WHERE " + DESTINATIONS_NAME + "=" + MESSAGES_DESTINATION //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- + " AND " + DESTINATIONS_NAME + "=?"; //$NON-NLS-1$ //$NON-NLS-2$
-
- private JMSSchema()
- {
- super("JMS"); //$NON-NLS-1$
- }
-
- static
- {
- INSTANCE.lock();
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.net4j.jms.server.internal.jdbc; + +import org.eclipse.net4j.db.DBType; +import org.eclipse.net4j.db.ddl.IDBField; +import org.eclipse.net4j.db.ddl.IDBIndex; +import org.eclipse.net4j.db.ddl.IDBTable; +import org.eclipse.net4j.spi.db.DBSchema; + +/** + * @author Eike Stepper + */ +public class JMSSchema extends DBSchema +{ + public static final JMSSchema INSTANCE = new JMSSchema(); + + /** + * DBTable Destinations + */ + public static final IDBTable DESTINATIONS = INSTANCE.addTable("destinations"); //$NON-NLS-1$ + + public static final IDBField DESTINATIONS_NAME = // + DESTINATIONS.addField("name", DBType.VARCHAR, 255); //$NON-NLS-1$ + + public static final IDBField DESTINATIONS_TYPE = // + DESTINATIONS.addField("type", DBType.INTEGER); //$NON-NLS-1$ + + public static final IDBIndex INDEX_DESTINATIONS_PK = // + DESTINATIONS.addIndex(IDBIndex.Type.PRIMARY_KEY, DESTINATIONS_NAME); + + /** + * DBTable Messages + */ + public static final IDBTable MESSAGES = INSTANCE.addTable("messages"); //$NON-NLS-1$ + + public static final IDBField MESSAGES_ID = // + MESSAGES.addField("id", DBType.VARCHAR); //$NON-NLS-1$ + + public static final IDBField MESSAGES_DESTINATION = // + MESSAGES.addField("destination", DBType.VARCHAR); //$NON-NLS-1$ + + public static final IDBField MESSAGES_PRIORITY = // + MESSAGES.addField("priority", DBType.INTEGER); //$NON-NLS-1$ + + public static final IDBIndex INDEX_MESSAGES_PK = // + MESSAGES.addIndex(IDBIndex.Type.PRIMARY_KEY, MESSAGES_ID); + + /** + * Queries + */ + public static final String QUERY = "SELECT " + DESTINATIONS_TYPE + ", " + MESSAGES_ID + ", " + MESSAGES_PRIORITY //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + + " FROM " + DESTINATIONS + ", " + MESSAGES + " WHERE " + DESTINATIONS_NAME + "=" + MESSAGES_DESTINATION //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + + " AND " + DESTINATIONS_NAME + "=?"; //$NON-NLS-1$ //$NON-NLS-2$ + + private JMSSchema() + { + super("JMS"); //$NON-NLS-1$ + } + + static + { + INSTANCE.lock(); + } +} diff --git a/plugins/org.eclipse.net4j.jms.server.jdbc/src/org/eclipse/net4j/jms/server/internal/jdbc/bundle/OM.java b/plugins/org.eclipse.net4j.jms.server.jdbc/src/org/eclipse/net4j/jms/server/internal/jdbc/bundle/OM.java index 99465707cc..ddd0ad9f94 100644 --- a/plugins/org.eclipse.net4j.jms.server.jdbc/src/org/eclipse/net4j/jms/server/internal/jdbc/bundle/OM.java +++ b/plugins/org.eclipse.net4j.jms.server.jdbc/src/org/eclipse/net4j/jms/server/internal/jdbc/bundle/OM.java @@ -1,44 +1,44 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.net4j.jms.server.internal.jdbc.bundle;
-
-import org.eclipse.net4j.util.om.OMBundle;
-import org.eclipse.net4j.util.om.OMPlatform;
-import org.eclipse.net4j.util.om.OSGiActivator;
-import org.eclipse.net4j.util.om.log.OMLogger;
-import org.eclipse.net4j.util.om.trace.OMTracer;
-
-/**
- * The <em>Operations & Maintenance</em> class of this bundle.
- *
- * @author Eike Stepper
- */
-public abstract class OM
-{
- public static final String BUNDLE_ID = "org.eclipse.net4j.jms.server.jdbc"; //$NON-NLS-1$
-
- public static final OMBundle BUNDLE = OMPlatform.INSTANCE.bundle(BUNDLE_ID, OM.class);
-
- public static final OMTracer DEBUG = BUNDLE.tracer("debug"); //$NON-NLS-1$
-
- public static final OMLogger LOG = BUNDLE.logger();
-
- /**
- * @author Eike Stepper
- */
- public static final class Activator extends OSGiActivator
- {
- public Activator()
- {
- super(BUNDLE);
- }
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.net4j.jms.server.internal.jdbc.bundle; + +import org.eclipse.net4j.util.om.OMBundle; +import org.eclipse.net4j.util.om.OMPlatform; +import org.eclipse.net4j.util.om.OSGiActivator; +import org.eclipse.net4j.util.om.log.OMLogger; +import org.eclipse.net4j.util.om.trace.OMTracer; + +/** + * The <em>Operations & Maintenance</em> class of this bundle. + * + * @author Eike Stepper + */ +public abstract class OM +{ + public static final String BUNDLE_ID = "org.eclipse.net4j.jms.server.jdbc"; //$NON-NLS-1$ + + public static final OMBundle BUNDLE = OMPlatform.INSTANCE.bundle(BUNDLE_ID, OM.class); + + public static final OMTracer DEBUG = BUNDLE.tracer("debug"); //$NON-NLS-1$ + + public static final OMLogger LOG = BUNDLE.logger(); + + /** + * @author Eike Stepper + */ + public static final class Activator extends OSGiActivator + { + public Activator() + { + super(BUNDLE); + } + } +} |