diff options
| author | Alex Rudyy <orudyy@apache.org> | 2015-04-15 09:47:28 +0000 |
|---|---|---|
| committer | Alex Rudyy <orudyy@apache.org> | 2015-04-15 09:47:28 +0000 |
| commit | 0a0baee45ebcff44635907d457c4ff6810b09c87 (patch) | |
| tree | 8bfb0f9eddbc23cff88af69be80ab3ce7d47011c /qpid/java/broker-plugins/jdbc-store/src | |
| parent | 54aa3d7070da16ce55c28ccad3f7d0871479e461 (diff) | |
| download | qpid-python-0a0baee45ebcff44635907d457c4ff6810b09c87.tar.gz | |
QPID-6481: Move java source tree to top level
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1673693 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/broker-plugins/jdbc-store/src')
31 files changed, 0 insertions, 2812 deletions
diff --git a/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/DefaultConnectionProvider.java b/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/DefaultConnectionProvider.java deleted file mode 100644 index a96d46af18..0000000000 --- a/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/DefaultConnectionProvider.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.server.store.jdbc; - -import java.sql.Connection; -import java.sql.DriverManager; -import java.sql.SQLException; - -class DefaultConnectionProvider implements ConnectionProvider -{ - private final String _connectionUrl; - private final String _username; - private final String _password; - - public DefaultConnectionProvider(String connectionUrl, String username, String password) - { - _connectionUrl = connectionUrl; - _username = username; - _password = password; - } - - @Override - public Connection getConnection() throws SQLException - { - if (_username == null) - { - return DriverManager.getConnection(_connectionUrl); - } - else - { - return DriverManager.getConnection(_connectionUrl, _username, _password); - } - } - - @Override - public void close() throws SQLException - { - } -} diff --git a/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/DefaultConnectionProviderFactory.java b/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/DefaultConnectionProviderFactory.java deleted file mode 100644 index 0a829696f0..0000000000 --- a/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/DefaultConnectionProviderFactory.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.server.store.jdbc; - -import org.apache.qpid.server.plugin.JDBCConnectionProviderFactory; -import org.apache.qpid.server.plugin.PluggableService; - -import java.util.Collections; -import java.util.Map; -import java.util.Set; - -@PluggableService -public class DefaultConnectionProviderFactory implements JDBCConnectionProviderFactory -{ - public static final String TYPE = "NONE"; - - @Override - public String getType() - { - return TYPE; - } - - @Override - public ConnectionProvider getConnectionProvider(String connectionUrl, String username, String password, Map<String, String> providerAttributes) - { - return new DefaultConnectionProvider(connectionUrl, username, password); - } - - @Override - public Set<String> getProviderAttributeNames() - { - return Collections.emptySet(); - } - -} diff --git a/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/GenericAbstractJDBCMessageStore.java b/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/GenericAbstractJDBCMessageStore.java deleted file mode 100644 index e062af45a7..0000000000 --- a/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/GenericAbstractJDBCMessageStore.java +++ /dev/null @@ -1,160 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.qpid.server.store.jdbc; - - -import java.util.List; -import java.util.concurrent.CopyOnWriteArrayList; -import java.util.concurrent.atomic.AtomicBoolean; - -import org.apache.qpid.server.model.ConfiguredObject; -import org.apache.qpid.server.store.StoreException; -import org.apache.qpid.server.util.FutureResult; -import org.apache.qpid.server.store.Transaction; - -public abstract class GenericAbstractJDBCMessageStore extends org.apache.qpid.server.store.AbstractJDBCMessageStore -{ - private final AtomicBoolean _messageStoreOpen = new AtomicBoolean(false); - private final List<RecordedJDBCTransaction> _transactions = new CopyOnWriteArrayList<>(); - - private ConfiguredObject<?> _parent; - - @Override - public final void openMessageStore(ConfiguredObject<?> parent) - { - if (_messageStoreOpen.compareAndSet(false, true)) - { - _parent = parent; - - doOpen(parent); - - createOrOpenMessageStoreDatabase(); - setMaximumMessageId(); - } - } - - protected abstract void doOpen(final ConfiguredObject<?> parent) - throws StoreException; - - @Override - public final void upgradeStoreStructure() throws StoreException - { - checkMessageStoreOpen(); - - upgrade(_parent); - } - - @Override - public final void closeMessageStore() - { - if (_messageStoreOpen.compareAndSet(true, false)) - { - try - { - while(!_transactions.isEmpty()) - { - RecordedJDBCTransaction txn = _transactions.get(0); - txn.abortTran(); - } - } - finally - { - doClose(); - super.closeMessageStore(); - } - - } - } - - protected abstract void doClose(); - - protected boolean isMessageStoreOpen() - { - return _messageStoreOpen.get(); - } - - @Override - protected void checkMessageStoreOpen() - { - if (!_messageStoreOpen.get()) - { - throw new IllegalStateException("Message store is not open"); - } - } - - @Override - protected void storedSizeChange(int contentSize) - { - } - - @Override - public Transaction newTransaction() - { - return new RecordedJDBCTransaction(); - } - - - private class RecordedJDBCTransaction extends JDBCTransaction - { - private RecordedJDBCTransaction() - { - super(); - GenericAbstractJDBCMessageStore.this._transactions.add(this); - } - - @Override - public void commitTran() - { - try - { - super.commitTran(); - } - finally - { - GenericAbstractJDBCMessageStore.this._transactions.remove(this); - } - } - - @Override - public FutureResult commitTranAsync() - { - try - { - return super.commitTranAsync(); - } - finally - { - GenericAbstractJDBCMessageStore.this._transactions.remove(this); - } - } - - @Override - public void abortTran() - { - try - { - super.abortTran(); - } - finally - { - GenericAbstractJDBCMessageStore.this._transactions.remove(this); - } - } - } -} diff --git a/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/GenericJDBCConfigurationStore.java b/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/GenericJDBCConfigurationStore.java deleted file mode 100644 index cd6ca85ee5..0000000000 --- a/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/GenericJDBCConfigurationStore.java +++ /dev/null @@ -1,329 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.qpid.server.store.jdbc; - - -import java.io.File; -import java.nio.charset.Charset; -import java.security.PrivilegedAction; -import java.sql.Blob; -import java.sql.Connection; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.atomic.AtomicBoolean; - -import javax.security.auth.Subject; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import org.apache.qpid.server.model.ConfiguredObject; -import org.apache.qpid.server.plugin.JDBCConnectionProviderFactory; -import org.apache.qpid.server.security.SecurityManager; -import org.apache.qpid.server.store.AbstractJDBCConfigurationStore; -import org.apache.qpid.server.store.ConfiguredObjectRecord; -import org.apache.qpid.server.store.MessageStore; -import org.apache.qpid.server.store.MessageStoreProvider; -import org.apache.qpid.server.store.StoreException; - -/** - * Implementation of a DurableConfigurationStore backed by Generic JDBC Database - * that also provides a MessageStore. - */ -public class GenericJDBCConfigurationStore extends AbstractJDBCConfigurationStore implements MessageStoreProvider -{ - private static final Charset UTF8_CHARSET = Charset.forName("UTF-8"); - - private static final Logger LOGGER = LoggerFactory.getLogger(GenericJDBCConfigurationStore.class); - - private final AtomicBoolean _configurationStoreOpen = new AtomicBoolean(); - private final MessageStore _providedMessageStore = new ProvidedMessageStore(); - - private String _connectionURL; - private ConnectionProvider _connectionProvider; - - private String _blobType; - private String _varBinaryType; - private String _bigIntType; - private boolean _useBytesMethodsForBlob; - - private ConfiguredObject<?> _parent; - private final Class<? extends ConfiguredObject> _rootClass; - - public GenericJDBCConfigurationStore(final Class<? extends ConfiguredObject> rootClass) - { - _rootClass = rootClass; - } - - @Override - public void openConfigurationStore(ConfiguredObject<?> parent, - final boolean overwrite, - final ConfiguredObjectRecord... initialRecords) - throws StoreException - { - if (_configurationStoreOpen.compareAndSet(false, true)) - { - _parent = parent; - - JDBCSettings settings = (JDBCSettings)parent; - _connectionURL = settings.getConnectionUrl(); - - JDBCDetails details = JDBCDetails.getDetailsForJdbcUrl(_connectionURL, parent); - - if (!details.isKnownVendor() && getLogger().isInfoEnabled()) - { - getLogger().info("Do not recognize vendor from connection URL: " + _connectionURL - + " Using fallback settings " + details); - } - if (details.isOverridden() && getLogger().isInfoEnabled()) - { - getLogger().info("One or more JDBC details were overridden from context. " - + " Using settings : " + details); - } - - String connectionPoolType = settings.getConnectionPoolType() == null ? DefaultConnectionProviderFactory.TYPE : settings.getConnectionPoolType(); - - JDBCConnectionProviderFactory connectionProviderFactory = - JDBCConnectionProviderFactory.FACTORIES.get(connectionPoolType); - if(connectionProviderFactory == null) - { - LOGGER.warn("Unknown connection pool type: " - + connectionPoolType - + ". no connection pooling will be used"); - connectionProviderFactory = new DefaultConnectionProviderFactory(); - } - - try - { - Map<String, String> providerAttributes = new HashMap<>(); - Set<String> providerAttributeNames = new HashSet<String>(connectionProviderFactory.getProviderAttributeNames()); - providerAttributeNames.retainAll(parent.getContextKeys(false)); - for(String attr : providerAttributeNames) - { - providerAttributes.put(attr, parent.getContextValue(String.class, attr)); - } - - _connectionProvider = connectionProviderFactory.getConnectionProvider(_connectionURL, - settings.getUsername(), - getPlainTextPassword(settings), - providerAttributes); - } - catch (SQLException e) - { - throw new StoreException("Failed to create connection provider for connectionUrl: " + _connectionURL + - " and username: " + settings.getUsername(), e); - } - _blobType = details.getBlobType(); - _varBinaryType = details.getVarBinaryType(); - _useBytesMethodsForBlob = details.isUseBytesMethodsForBlob(); - _bigIntType = details.getBigintType(); - - createOrOpenConfigurationStoreDatabase(overwrite); - if(hasNoConfigurationEntries()) - { - update(true, initialRecords); - } - } - } - - @Override - public void upgradeStoreStructure() throws StoreException - { - checkConfigurationStoreOpen(); - upgradeIfNecessary(_parent); - } - - @Override - protected Connection getConnection() throws SQLException - { - return _connectionProvider.getConnection(); - } - - @Override - public void closeConfigurationStore() throws StoreException - { - if (_configurationStoreOpen.compareAndSet(true, false)) - { - try - { - _connectionProvider.close(); - } - catch (SQLException e) - { - throw new StoreException("Unable to close connection provider ", e); - } - } - } - - @Override - protected String getSqlBlobType() - { - return _blobType; - } - - @Override - protected String getSqlVarBinaryType(int size) - { - return String.format(_varBinaryType, size); - } - - @Override - public String getSqlBigIntType() - { - return _bigIntType; - } - - @Override - protected String getBlobAsString(ResultSet rs, int col) throws SQLException - { - byte[] bytes; - if(_useBytesMethodsForBlob) - { - bytes = rs.getBytes(col); - return new String(bytes,UTF8_CHARSET); - } - else - { - Blob blob = rs.getBlob(col); - if(blob == null) - { - return null; - } - bytes = blob.getBytes(1, (int)blob.length()); - } - return new String(bytes, UTF8_CHARSET); - - } - - protected byte[] getBlobAsBytes(ResultSet rs, int col) throws SQLException - { - if(_useBytesMethodsForBlob) - { - return rs.getBytes(col); - } - else - { - Blob dataAsBlob = rs.getBlob(col); - return dataAsBlob.getBytes(1,(int) dataAsBlob.length()); - - } - } - - @Override - protected void checkConfigurationStoreOpen() - { - if (!_configurationStoreOpen.get()) - { - throw new IllegalStateException("Configuration store is not open"); - } - } - - @Override - protected Logger getLogger() - { - return LOGGER; - } - - @Override - public MessageStore getMessageStore() - { - return _providedMessageStore; - } - - protected String getPlainTextPassword(final JDBCSettings settings) - { - return Subject.doAs(SecurityManager.getSubjectWithAddedSystemRights(), new PrivilegedAction<String>() - { - @Override - public String run() - { - return settings.getPassword(); - } - }); - } - - private class ProvidedMessageStore extends GenericAbstractJDBCMessageStore - { - @Override - protected void doOpen(final ConfiguredObject<?> parent) - { - // Nothing to do, store provided by DerbyConfigurationStore - } - - @Override - protected Connection getConnection() throws SQLException - { - return GenericJDBCConfigurationStore.this.getConnection(); - } - - @Override - protected void doClose() - { - // Nothing to do, store provided by DerbyConfigurationStore - } - - @Override - public String getStoreLocation() - { - return GenericJDBCConfigurationStore.this._connectionURL; - } - - @Override - public File getStoreLocationAsFile() - { - return null; - } - - @Override - protected Logger getLogger() - { - return GenericJDBCConfigurationStore.this.getLogger(); - } - - @Override - protected String getSqlBlobType() - { - return GenericJDBCConfigurationStore.this.getSqlBlobType(); - } - - @Override - protected String getSqlVarBinaryType(int size) - { - return GenericJDBCConfigurationStore.this.getSqlVarBinaryType(size); - } - - @Override - protected String getSqlBigIntType() - { - return GenericJDBCConfigurationStore.this.getSqlBigIntType(); - } - - @Override - protected byte[] getBlobAsBytes(final ResultSet rs, final int col) throws SQLException - { - return GenericJDBCConfigurationStore.this.getBlobAsBytes(rs, col); - } - } - - -} diff --git a/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/GenericJDBCMessageStore.java b/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/GenericJDBCMessageStore.java deleted file mode 100644 index 32ddd89833..0000000000 --- a/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/GenericJDBCMessageStore.java +++ /dev/null @@ -1,199 +0,0 @@ -/* -* -* Licensed to the Apache Software Foundation (ASF) under one -* or more contributor license agreements. See the NOTICE file -* distributed with this work for additional information -* regarding copyright ownership. The ASF licenses this file -* to you under the Apache License, Version 2.0 (the -* "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, -* software distributed under the License is distributed on an -* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -* KIND, either express or implied. See the License for the -* specific language governing permissions and limitations -* under the License. -* -*/ -package org.apache.qpid.server.store.jdbc; - - -import java.io.File; -import java.security.PrivilegedAction; -import java.sql.Blob; -import java.sql.Connection; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import javax.security.auth.Subject; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import org.apache.qpid.server.model.ConfiguredObject; -import org.apache.qpid.server.plugin.JDBCConnectionProviderFactory; -import org.apache.qpid.server.security.SecurityManager; -import org.apache.qpid.server.store.StoreException; - -/** - * Implementation of a MessageStore backed by a Generic JDBC Database. - */ -public class GenericJDBCMessageStore extends GenericAbstractJDBCMessageStore -{ - - private static final Logger _logger = LoggerFactory.getLogger(GenericJDBCMessageStore.class); - - protected String _connectionURL; - private ConnectionProvider _connectionProvider; - - private String _blobType; - private String _varBinaryType; - private String _bigIntType; - private boolean _useBytesMethodsForBlob; - - @Override - protected void doOpen(final ConfiguredObject<?> parent) throws StoreException - { - JDBCSettings settings = (JDBCSettings)parent; - _connectionURL = settings.getConnectionUrl(); - - JDBCDetails details = JDBCDetails.getDetailsForJdbcUrl(_connectionURL, parent); - - if (!details.isKnownVendor() && getLogger().isInfoEnabled()) - { - getLogger().info("Do not recognize vendor from connection URL: " + _connectionURL - + " Using fallback settings " + details); - } - if (details.isOverridden() && getLogger().isInfoEnabled()) - { - getLogger().info("One or more JDBC details were overridden from context. " - + " Using settings : " + details); - } - - _blobType = details.getBlobType(); - _varBinaryType = details.getVarBinaryType(); - _useBytesMethodsForBlob = details.isUseBytesMethodsForBlob(); - _bigIntType = details.getBigintType(); - - String connectionPoolType = settings.getConnectionPoolType() == null ? DefaultConnectionProviderFactory.TYPE : settings.getConnectionPoolType(); - - JDBCConnectionProviderFactory connectionProviderFactory = - JDBCConnectionProviderFactory.FACTORIES.get(connectionPoolType); - if(connectionProviderFactory == null) - { - _logger.warn("Unknown connection pool type: " + connectionPoolType + ". No connection pooling will be used"); - connectionProviderFactory = new DefaultConnectionProviderFactory(); - } - - try - { - Map<String, String> providerAttributes = new HashMap<>(); - Set<String> providerAttributeNames = new HashSet<String>(connectionProviderFactory.getProviderAttributeNames()); - providerAttributeNames.retainAll(parent.getContextKeys(false)); - for(String attr : providerAttributeNames) - { - providerAttributes.put(attr, parent.getContextValue(String.class, attr)); - } - - _connectionProvider = connectionProviderFactory.getConnectionProvider(_connectionURL, - settings.getUsername(), - getPlainTextPassword(settings), - providerAttributes); - } - catch (SQLException e) - { - throw new StoreException("Failed to create connection provider for connectionUrl: " + _connectionURL + - " and username: " + settings.getUsername()); - } - - } - - @Override - protected Connection getConnection() throws SQLException - { - return _connectionProvider.getConnection(); - } - - protected void doClose() - { - try - { - _connectionProvider.close(); - } - catch (SQLException e) - { - throw new StoreException("Unable to close connection provider ", e); - } - } - - - @Override - protected Logger getLogger() - { - return _logger; - } - - @Override - protected String getSqlBlobType() - { - return _blobType; - } - - @Override - protected String getSqlVarBinaryType(int size) - { - return String.format(_varBinaryType, size); - } - - @Override - protected byte[] getBlobAsBytes(ResultSet rs, int col) throws SQLException - { - if(_useBytesMethodsForBlob) - { - return rs.getBytes(col); - } - else - { - Blob dataAsBlob = rs.getBlob(col); - return dataAsBlob.getBytes(1,(int) dataAsBlob.length()); - - } - } - - @Override - public String getSqlBigIntType() - { - return _bigIntType; - } - - @Override - public String getStoreLocation() - { - return _connectionURL; - } - - @Override - public File getStoreLocationAsFile() - { - return null; - } - - protected String getPlainTextPassword(final JDBCSettings settings) - { - return Subject.doAs(SecurityManager.getSubjectWithAddedSystemRights(), new PrivilegedAction<String>() - { - @Override - public String run() - { - return settings.getPassword(); - } - }); - } -} diff --git a/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/JDBCDetails.java b/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/JDBCDetails.java deleted file mode 100644 index eec2d49a80..0000000000 --- a/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/JDBCDetails.java +++ /dev/null @@ -1,370 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.qpid.server.store.jdbc; - -import java.util.AbstractMap; -import java.util.AbstractSet; -import java.util.Collections; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; - -import org.apache.qpid.server.model.ConfiguredObject; - -public abstract class JDBCDetails -{ - public static final String CONTEXT_JDBCSTORE_BIGINTTYPE = "qpid.jdbcstore.bigIntType"; - public static final String CONTEXT_JDBCSTORE_VARBINARYTYPE = "qpid.jdbcstore.varBinaryType"; - public static final String CONTEXT_JDBCSTORE_BLOBTYPE = "qpid.jdbcstore.blobType"; - public static final String CONTEXT_JDBCSTORE_USEBYTESFORBLOB = "qpid.jdbcstore.useBytesForBlob"; - - public abstract String getVendor(); - - public abstract String getBlobType(); - - public abstract String getVarBinaryType(); - - public abstract String getBigintType(); - - public abstract boolean isUseBytesMethodsForBlob(); - - public abstract boolean isKnownVendor(); - - public abstract boolean isOverridden(); - - static class KnownJDBCDetails extends JDBCDetails - { - private static final JDBCDetails FALLBACK = new KnownJDBCDetails("fallback", "blob", "varchar(%d) for bit data", "bigint", false, - false); - private static final JDBCDetails ORACLE = new KnownJDBCDetails("oracle", "blob", "raw(%d)", "number", false, - true); - private static final JDBCDetails SYBASE = new KnownJDBCDetails("sybase", "image", "varbinary(%d)", "bigint", false, - true); - private static final JDBCDetails POSTGRES = new KnownJDBCDetails("postgresql", "bytea", "bytea", "bigint", true, - true); - private static final JDBCDetails DERBY = new KnownJDBCDetails("derby", "blob", "varchar(%d) for bit data", "bigint", false, - true); - - static - { - Map<String, JDBCDetails> map = new HashMap<>(); - - try - { - map.put(ORACLE.getVendor(), ORACLE); - map.put(SYBASE.getVendor(), SYBASE); - map.put(POSTGRES.getVendor(), POSTGRES); - map.put(DERBY.getVendor(), DERBY); - map.put(FALLBACK.getVendor(), FALLBACK); - } - finally - { - VENDOR_DETAILS = Collections.unmodifiableMap(map); - } - } - - private final static Map<String, JDBCDetails> VENDOR_DETAILS; - - private final String _vendor; - private final String _blobType; - private final String _varBinaryType; - private final String _bigintType; - private final boolean _useBytesMethodsForBlob; - private final boolean _isKnownVendor; - - KnownJDBCDetails(String vendor, - String blobType, - String varBinaryType, - String bigIntType, - boolean useBytesMethodsForBlob, - boolean knownVendor) - { - _vendor = vendor; - _blobType = blobType; - _varBinaryType = varBinaryType; - _bigintType = bigIntType; - _useBytesMethodsForBlob = useBytesMethodsForBlob; - _isKnownVendor = knownVendor; - } - - @Override - public String getVendor() - { - return _vendor; - } - - @Override - public String getBlobType() - { - return _blobType; - } - - @Override - public String getVarBinaryType() - { - return _varBinaryType; - } - - @Override - public boolean isUseBytesMethodsForBlob() - { - return _useBytesMethodsForBlob; - } - - @Override - public String getBigintType() - { - return _bigintType; - } - - @Override - public boolean isKnownVendor() - { - return _isKnownVendor; - } - - @Override - public boolean isOverridden() - { - return false; - } - - } - - @Override - public String toString() - { - return "JDBCDetails{" + - "vendor='" + getVendor() + '\'' + - ", blobType='" + getBlobType() + '\'' + - ", varBinaryType='" + getVarBinaryType() + '\'' + - ", bigIntType='" + getBigintType() + '\'' + - ", useBytesMethodsForBlob=" + isUseBytesMethodsForBlob() + - ", knownVendor=" + isKnownVendor() + - ", overridden=" + isOverridden() + - '}'; - } - - @Override - public boolean equals(final Object o) - { - if (this == o) - { - return true; - } - if (o == null || getClass() != o.getClass()) - { - return false; - } - - final JDBCDetails that = (JDBCDetails) o; - - if (isKnownVendor() != that.isKnownVendor()) - { - return false; - } - if (isOverridden() != that.isOverridden()) - { - return false; - } - if (isUseBytesMethodsForBlob() != that.isUseBytesMethodsForBlob()) - { - return false; - } - if (getBigintType() != null ? !getBigintType().equals(that.getBigintType()) : that.getBigintType() != null) - { - return false; - } - if (getBlobType() != null ? !getBlobType().equals(that.getBlobType()) : that.getBlobType() != null) - { - return false; - } - if (getVarBinaryType() != null ? !getVarBinaryType().equals(that.getVarBinaryType()) : that.getVarBinaryType() != null) - { - return false; - } - if (getVendor() != null ? !getVendor().equals(that.getVendor()) : that.getVendor() != null) - { - return false; - } - - return true; - } - - @Override - public int hashCode() - { - int result = getVendor() != null ? getVendor().hashCode() : 0; - result = 31 * result + (getBlobType() != null ? getBlobType().hashCode() : 0); - result = 31 * result + (getVarBinaryType() != null ? getVarBinaryType().hashCode() : 0); - result = 31 * result + (getBigintType() != null ? getBigintType().hashCode() : 0); - result = 31 * result + (isUseBytesMethodsForBlob() ? 1 : 0); - result = 31 * result + (isKnownVendor() ? 1 : 0); - result = 31 * result + (isOverridden() ? 1 : 0); - return result; - } - - public static JDBCDetails getDetailsForJdbcUrl(String jdbcUrl, final ConfiguredObject<?> object) - { - final Set<String> contextKeys = object.getContextKeys(false); - Map<String,String> mapConversion = new AbstractMap<String, String>() - { - @Override - public Set<Entry<String, String>> entrySet() - { - return new AbstractSet<Entry<String, String>>() - { - @Override - public Iterator<Entry<String, String>> iterator() - { - final Iterator<String> underlying = contextKeys.iterator(); - return new Iterator<Entry<String, String>>() - { - @Override - public boolean hasNext() - { - return underlying.hasNext(); - } - - @Override - public Entry<String, String> next() - { - final String key = underlying.next(); - final String value = object.getContextValue(String.class, key); - return new Entry<String,String>() - { - - @Override - public String getKey() - { - return key; - } - - @Override - public String getValue() - { - return value; - } - - @Override - public String setValue(final String value) - { - throw new UnsupportedOperationException(); - } - }; - - } - - @Override - public void remove() - { - throw new UnsupportedOperationException(); - } - }; - } - - @Override - public int size() - { - return contextKeys.size(); - } - }; - } - }; - return getDetailsForJdbcUrl(jdbcUrl, mapConversion); - } - public static JDBCDetails getDetailsForJdbcUrl(String jdbcUrl, final Map<String, String> contextMap) - { - String[] components = jdbcUrl.split(":", 3); - final JDBCDetails details; - if(components.length >= 2) - { - String vendor = components[1]; - if (KnownJDBCDetails.VENDOR_DETAILS.containsKey(vendor)) - { - details = KnownJDBCDetails.VENDOR_DETAILS.get(vendor); - } - else - { - details = KnownJDBCDetails.FALLBACK; - } - } - else - { - details = KnownJDBCDetails.FALLBACK; - } - - - return new JDBCDetails() - { - @Override - public String getVendor() - { - return details.getVendor(); - } - - @Override - public String getBlobType() - { - return contextMap.containsKey(CONTEXT_JDBCSTORE_BLOBTYPE) - ? String.valueOf(contextMap.get(CONTEXT_JDBCSTORE_BLOBTYPE)) : details.getBlobType(); - } - - @Override - public String getVarBinaryType() - { - return contextMap.containsKey(CONTEXT_JDBCSTORE_VARBINARYTYPE) - ? String.valueOf(contextMap.get(CONTEXT_JDBCSTORE_VARBINARYTYPE)) : details.getVarBinaryType(); - } - - @Override - public String getBigintType() - { - return contextMap.containsKey(CONTEXT_JDBCSTORE_BIGINTTYPE) - ? String.valueOf(contextMap.get(CONTEXT_JDBCSTORE_BIGINTTYPE)) : details.getBigintType(); - } - - @Override - public boolean isUseBytesMethodsForBlob() - { - return contextMap.containsKey(CONTEXT_JDBCSTORE_USEBYTESFORBLOB) - ? Boolean.parseBoolean(contextMap.get(CONTEXT_JDBCSTORE_USEBYTESFORBLOB)) : details.isUseBytesMethodsForBlob(); - } - - @Override - public boolean isKnownVendor() - { - return details.isKnownVendor(); - } - - @Override - public boolean isOverridden() - { - return contextMap.containsKey(CONTEXT_JDBCSTORE_USEBYTESFORBLOB) - || contextMap.containsKey(CONTEXT_JDBCSTORE_BIGINTTYPE) - || contextMap.containsKey(CONTEXT_JDBCSTORE_VARBINARYTYPE) - || contextMap.containsKey(CONTEXT_JDBCSTORE_BLOBTYPE); - } - }; - - } - -} diff --git a/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/JDBCSettings.java b/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/JDBCSettings.java deleted file mode 100644 index d784ece0e4..0000000000 --- a/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/JDBCSettings.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.qpid.server.store.jdbc; - -import org.apache.qpid.server.store.Settings; - -public interface JDBCSettings extends Settings -{ - String getConnectionUrl(); - - String getConnectionPoolType(); - - String getUsername(); - - String getPassword(); -} diff --git a/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/JDBCSystemConfig.java b/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/JDBCSystemConfig.java deleted file mode 100644 index 9fe64577bb..0000000000 --- a/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/JDBCSystemConfig.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.server.store.jdbc; - -import org.apache.qpid.server.model.ManagedAttribute; -import org.apache.qpid.server.model.SystemConfig; - -public interface JDBCSystemConfig<X extends JDBCSystemConfig<X>> extends SystemConfig<X>, JDBCSettings -{ - @ManagedAttribute(mandatory=true, defaultValue = "${systemConfig.connectionUrl}") - String getConnectionUrl(); - - @ManagedAttribute(defaultValue=DefaultConnectionProviderFactory.TYPE) - String getConnectionPoolType(); - - @ManagedAttribute(defaultValue = "${systemConfig.username}") - String getUsername(); - - @ManagedAttribute(secure=true, defaultValue = "${systemConfig.password}") - String getPassword(); -} diff --git a/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/JDBCSystemConfigImpl.java b/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/JDBCSystemConfigImpl.java deleted file mode 100644 index 9c3d33fc04..0000000000 --- a/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/JDBCSystemConfigImpl.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.server.store.jdbc; - -import java.util.Map; - -import org.apache.qpid.server.configuration.updater.TaskExecutor; -import org.apache.qpid.server.logging.EventLogger; -import org.apache.qpid.server.logging.LogRecorder; -import org.apache.qpid.server.model.AbstractSystemConfig; -import org.apache.qpid.server.model.Broker; -import org.apache.qpid.server.model.BrokerShutdownProvider; -import org.apache.qpid.server.model.ManagedAttributeField; -import org.apache.qpid.server.model.ManagedObject; -import org.apache.qpid.server.model.SystemConfigFactoryConstructor; -import org.apache.qpid.server.store.DurableConfigurationStore; - -@ManagedObject( category = false, type = JDBCSystemConfigImpl.SYSTEM_CONFIG_TYPE) -public class JDBCSystemConfigImpl extends AbstractSystemConfig<JDBCSystemConfigImpl> implements JDBCSystemConfig<JDBCSystemConfigImpl> -{ - public static final String SYSTEM_CONFIG_TYPE = "JDBC"; - - @ManagedAttributeField - private String _connectionUrl; - @ManagedAttributeField - private String _connectionPoolType; - @ManagedAttributeField - private String _username; - @ManagedAttributeField - private String _password; - - @SystemConfigFactoryConstructor - public JDBCSystemConfigImpl(final TaskExecutor taskExecutor, - final EventLogger eventLogger, - final LogRecorder logRecorder, - final Map<String,Object> attributes, - final BrokerShutdownProvider brokerShutdownProvider) - { - super(taskExecutor, eventLogger, logRecorder, attributes, brokerShutdownProvider); - } - - @Override - protected DurableConfigurationStore createStoreObject() - { - return new GenericJDBCConfigurationStore(Broker.class); - } - - @Override - public String getConnectionUrl() - { - return _connectionUrl; - } - - @Override - public String getConnectionPoolType() - { - return _connectionPoolType; - } - - @Override - public String getUsername() - { - return _username; - } - - @Override - public String getPassword() - { - return _password; - } -} diff --git a/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/virtualhost/jdbc/JDBCVirtualHost.java b/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/virtualhost/jdbc/JDBCVirtualHost.java deleted file mode 100644 index 8608848d98..0000000000 --- a/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/virtualhost/jdbc/JDBCVirtualHost.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.qpid.server.virtualhost.jdbc; - -import org.apache.qpid.server.exchange.ExchangeImpl; -import org.apache.qpid.server.model.ManagedAttribute; -import org.apache.qpid.server.queue.AMQQueue; -import org.apache.qpid.server.store.jdbc.DefaultConnectionProviderFactory; -import org.apache.qpid.server.store.jdbc.JDBCSettings; -import org.apache.qpid.server.virtualhost.VirtualHostImpl; - -public interface JDBCVirtualHost<X extends JDBCVirtualHost<X>> extends VirtualHostImpl<X, AMQQueue<?>, ExchangeImpl<?>>, - JDBCSettings -{ - @ManagedAttribute(mandatory=true) - String getConnectionUrl(); - - @ManagedAttribute(defaultValue=DefaultConnectionProviderFactory.TYPE) - String getConnectionPoolType(); - - @ManagedAttribute - String getUsername(); - - @ManagedAttribute(secure=true) - String getPassword(); -} diff --git a/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/virtualhost/jdbc/JDBCVirtualHostImpl.java b/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/virtualhost/jdbc/JDBCVirtualHostImpl.java deleted file mode 100644 index 434e887596..0000000000 --- a/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/virtualhost/jdbc/JDBCVirtualHostImpl.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.server.virtualhost.jdbc; - -import org.apache.qpid.server.model.ManagedAttributeField; -import org.apache.qpid.server.model.ManagedObject; -import org.apache.qpid.server.model.ManagedObjectFactoryConstructor; -import org.apache.qpid.server.model.VirtualHostNode; -import org.apache.qpid.server.store.MessageStore; -import org.apache.qpid.server.store.jdbc.GenericJDBCMessageStore; -import org.apache.qpid.server.virtualhost.AbstractVirtualHost; - -import java.util.Map; - -@ManagedObject(category = false, type = JDBCVirtualHostImpl.VIRTUAL_HOST_TYPE) -public class JDBCVirtualHostImpl extends AbstractVirtualHost<JDBCVirtualHostImpl> implements JDBCVirtualHost<JDBCVirtualHostImpl> -{ - public static final String VIRTUAL_HOST_TYPE = "JDBC"; - - @ManagedAttributeField - private String _connectionUrl; - - @ManagedAttributeField - private String _connectionPoolType; - - @ManagedAttributeField - private String _username; - - @ManagedAttributeField - private String _password; - - @ManagedObjectFactoryConstructor - public JDBCVirtualHostImpl(final Map<String, Object> attributes, - final VirtualHostNode<?> virtualHostNode) - { - super(attributes, virtualHostNode); - } - - @Override - protected MessageStore createMessageStore() - { - return new GenericJDBCMessageStore(); - } - - @Override - public String getConnectionUrl() - { - return _connectionUrl; - } - - @Override - public String getConnectionPoolType() - { - return _connectionPoolType; - } - - @Override - public String getUsername() - { - return _username; - } - - @Override - public String getPassword() - { - return _password; - } - - @Override - public String toString() - { - return getClass().getSimpleName() + " [id=" + getId() + ", name=" + getName() + - ", connectionUrl=" + getConnectionUrl() + - ", connectionPoolType=" + getConnectionPoolType() + - ", username=" + getUsername() + "]"; - } -} diff --git a/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/virtualhostnode/jdbc/JDBCVirtualHostNode.java b/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/virtualhostnode/jdbc/JDBCVirtualHostNode.java deleted file mode 100644 index 0ac75b3877..0000000000 --- a/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/virtualhostnode/jdbc/JDBCVirtualHostNode.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.server.virtualhostnode.jdbc; - -import org.apache.qpid.server.model.ManagedAttribute; -import org.apache.qpid.server.model.VirtualHostNode; -import org.apache.qpid.server.store.jdbc.DefaultConnectionProviderFactory; -import org.apache.qpid.server.store.jdbc.JDBCSettings; - -public interface JDBCVirtualHostNode<X extends JDBCVirtualHostNode<X>> extends VirtualHostNode<X>, JDBCSettings -{ - @ManagedAttribute(mandatory=true) - String getConnectionUrl(); - - @ManagedAttribute(defaultValue=DefaultConnectionProviderFactory.TYPE) - String getConnectionPoolType(); - - @ManagedAttribute - String getUsername(); - - @ManagedAttribute(secure=true) - String getPassword(); -} diff --git a/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/virtualhostnode/jdbc/JDBCVirtualHostNodeImpl.java b/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/virtualhostnode/jdbc/JDBCVirtualHostNodeImpl.java deleted file mode 100644 index cb20549b80..0000000000 --- a/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/virtualhostnode/jdbc/JDBCVirtualHostNodeImpl.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.server.virtualhostnode.jdbc; - -import java.util.Collection; -import java.util.Collections; -import java.util.Map; - -import org.apache.qpid.server.model.Broker; -import org.apache.qpid.server.model.ManagedAttributeField; -import org.apache.qpid.server.model.ManagedObject; -import org.apache.qpid.server.model.ManagedObjectFactoryConstructor; -import org.apache.qpid.server.model.VirtualHost; -import org.apache.qpid.server.store.DurableConfigurationStore; -import org.apache.qpid.server.store.jdbc.GenericJDBCConfigurationStore; -import org.apache.qpid.server.virtualhostnode.AbstractStandardVirtualHostNode; - -@ManagedObject(type = JDBCVirtualHostNodeImpl.VIRTUAL_HOST_NODE_TYPE, category = false , - validChildTypes = "org.apache.qpid.server.virtualhostnode.jdbc.JDBCVirtualHostNodeImpl#getSupportedChildTypes()") -public class JDBCVirtualHostNodeImpl extends AbstractStandardVirtualHostNode<JDBCVirtualHostNodeImpl> implements JDBCVirtualHostNode<JDBCVirtualHostNodeImpl> -{ - public static final String VIRTUAL_HOST_NODE_TYPE = "JDBC"; - - @ManagedAttributeField - private String _connectionUrl; - - @ManagedAttributeField - private String _connectionPoolType; - - @ManagedAttributeField - private String _username; - - @ManagedAttributeField - private String _password; - - @ManagedObjectFactoryConstructor - public JDBCVirtualHostNodeImpl(Map<String, Object> attributes, Broker<?> parent) - { - super(attributes, parent); - } - - @Override - protected void writeLocationEventLog() - { - } - - @Override - protected DurableConfigurationStore createConfigurationStore() - { - return new GenericJDBCConfigurationStore(VirtualHost.class); - } - - @Override - public String getConnectionUrl() - { - return _connectionUrl; - } - - @Override - public String getConnectionPoolType() - { - return _connectionPoolType; - } - - @Override - public String getUsername() - { - return _username; - } - - @Override - public String getPassword() - { - return _password; - } - - @Override - public String toString() - { - return getClass().getSimpleName() + " [id=" + getId() + ", name=" + getName() + - ", connectionUrl=" + getConnectionUrl() + - ", connectionPoolType=" + getConnectionPoolType() + - ", username=" + getUsername() + "]"; - } - - - public static Map<String, Collection<String>> getSupportedChildTypes() - { - return Collections.singletonMap(VirtualHost.class.getSimpleName(), getSupportedVirtualHostTypes(true)); - } -} diff --git a/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/js/qpid/management/store/pool/none/add.js b/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/js/qpid/management/store/pool/none/add.js deleted file mode 100644 index 44405c610b..0000000000 --- a/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/js/qpid/management/store/pool/none/add.js +++ /dev/null @@ -1,41 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -define(["dojo/_base/xhr", - "dojo/dom", - "dojo/dom-construct", - "dojo/_base/window", - "dijit/registry", - "dojo/parser", - "dojo/_base/array", - "dojo/_base/event", - "dojo/_base/json", - "dojo/string", - "dojo/store/Memory", - "dijit/form/FilteringSelect", - "dojo/domReady!"], - function (xhr, dom, construct, win, registry, parser, array, event, json, string, Memory, FilteringSelect) { - return { - show: function(data) - { - data.context.removeDynamicallyAddedInheritedContext(); - } - }; - }); diff --git a/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/js/qpid/management/store/pool/none/edit.js b/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/js/qpid/management/store/pool/none/edit.js deleted file mode 100644 index 675a919b3d..0000000000 --- a/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/js/qpid/management/store/pool/none/edit.js +++ /dev/null @@ -1,26 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -define([], - function () - { - return {show: function(data) {}}; - } -); diff --git a/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/js/qpid/management/store/pool/none/show.js b/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/js/qpid/management/store/pool/none/show.js deleted file mode 100644 index 39cb2bf507..0000000000 --- a/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/js/qpid/management/store/pool/none/show.js +++ /dev/null @@ -1,33 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -define([], - function () - { - function NonePool(data) - { - } - - NonePool.prototype.update=function(data) - { - }; - - return NonePool; -}); diff --git a/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/js/qpid/management/virtualhost/jdbc/add.js b/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/js/qpid/management/virtualhost/jdbc/add.js deleted file mode 100644 index 8de6206373..0000000000 --- a/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/js/qpid/management/virtualhost/jdbc/add.js +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -define(["dojo/_base/xhr", - "dojo/_base/array", - "dojo/parser", - "dojo/dom", - "dojo/dom-construct", - "dojo/json", - "dojo/string", - "dojo/store/Memory", - "dijit/registry", - "dojo/text!virtualhost/jdbc/add.html", - "dojo/text!service/helper?action=pluginList&plugin=JDBCConnectionProviderFactory", - "qpid/common/util", - "dijit/form/ValidationTextBox", - "dijit/form/CheckBox", - "dojo/domReady!"], - function (xhr, array, parser, dom, domConstruct, json, string, Memory, registry, template, poolTypeJsonString, util) - { - return { - show: function (data) - { - var that = this; - this.containerNode = domConstruct.create("div", {innerHTML: template}, data.containerNode); - parser.parse(this.containerNode).then(function(instances) - { - that._postParse(data); - }); - }, - _postParse: function (data) - { - var that = this; - registry.byId("addVirtualHost.connectionUrl").set("regExpGen", util.jdbcUrlOrContextVarRegexp); - registry.byId("addVirtualHost.username").set("regExpGen", util.nameOrContextVarRegexp); - var poolTypes = json.parse(poolTypeJsonString); - var poolTypesData = []; - for (var i =0 ; i < poolTypes.length; i++) - { - poolTypesData[i]= {id: poolTypes[i], name: poolTypes[i]}; - } - var poolTypesStore = new Memory({ data: poolTypesData }); - var poolTypeControl = registry.byId("addVirtualHost.connectionPoolType"); - poolTypeControl.set("store", poolTypesStore); - poolTypeControl.set("value", "NONE"); - - var poolTypeFieldsDiv = dom.byId("addVirtualHost.poolSpecificDiv"); - poolTypeControl.on("change", - function(type) - { - if(type && string.trim(type) != "") - { - var widgets = registry.findWidgets(poolTypeFieldsDiv); - array.forEach(widgets, function(item) { item.destroyRecursive();}); - domConstruct.empty(poolTypeFieldsDiv); - require(["qpid/management/store/pool/"+type.toLowerCase()+"/add"], - function(poolType) - { - poolType.show({containerNode:poolTypeFieldsDiv, context: data.parent.virtualHostContext}); - }); - } - } - ); - } - }; - } -); diff --git a/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/js/qpid/management/virtualhost/jdbc/edit.js b/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/js/qpid/management/virtualhost/jdbc/edit.js deleted file mode 100644 index 4a2a3763bd..0000000000 --- a/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/js/qpid/management/virtualhost/jdbc/edit.js +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -define(["qpid/common/util", - "dojo/text!service/helper?action=pluginList&plugin=JDBCConnectionProviderFactory", - "dojo/_base/array", - "dojo/json", - "dojo/string", - "dojo/store/Memory", - "dojo/dom", - "dojo/dom-construct", - "dijit/registry", - "dojo/domReady!"], - function (util, poolTypeJsonString, array, json, string, Memory, dom, domConstruct, registry) - { - - return { - show: function(data) - { - var that = this; - util.parseHtmlIntoDiv(data.containerNode, "virtualhost/jdbc/edit.html", - function(){that._postParse(data)}); - }, - _postParse: function(data) - { - registry.byId("editVirtualHost.connectionUrl").set("regExpGen", util.jdbcUrlOrContextVarRegexp); - registry.byId("editVirtualHost.username").set("regExpGen", util.nameOrContextVarRegexp); - - var poolTypes = json.parse(poolTypeJsonString); - var poolTypesData = []; - for (var i =0 ; i < poolTypes.length; i++) - { - poolTypesData[i]= {id: poolTypes[i], name: poolTypes[i]}; - } - var poolTypesStore = new Memory({ data: poolTypesData }); - var poolTypeControl = registry.byId("editVirtualHost.connectionPoolType"); - poolTypeControl.set("store", poolTypesStore); - poolTypeControl.set("value", data.data.connectionPoolType); - - var passwordControl = registry.byId("editVirtualHost.password"); - if (data.data.password) - { - passwordControl.set("placeHolder", "*******"); - } - - var poolTypeFieldsDiv = dom.byId("editVirtualHost.poolSpecificDiv"); - poolTypeControl.on("change", - function(type) - { - if(type && string.trim(type) != "") - { - var widgets = registry.findWidgets(poolTypeFieldsDiv); - array.forEach(widgets, function(item) { item.destroyRecursive();}); - domConstruct.empty(poolTypeFieldsDiv); - - require(["qpid/management/store/pool/"+type.toLowerCase()+"/edit"], - function(poolType) - { - poolType.show({containerNode:poolTypeFieldsDiv, data: data.data, context: data.parent.context}) - }); - } - } - ); - } - }; - } -); diff --git a/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/js/qpid/management/virtualhost/jdbc/show.js b/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/js/qpid/management/virtualhost/jdbc/show.js deleted file mode 100644 index b717f2091d..0000000000 --- a/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/js/qpid/management/virtualhost/jdbc/show.js +++ /dev/null @@ -1,64 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -define(["qpid/common/util", "dojo/query", "dojo/_base/array", "dojo/dom-construct", "dijit/registry", "dojo/domReady!"], - function (util, query, array, domConstruct, registry) - { - var fieldNames = ["connectionUrl", "username", "connectionPoolType"]; - - function JDBC(data) - { - var that = this; - util.buildUI(data.containerNode, data.parent, "virtualhostnode/jdbc/show.html", fieldNames, this, function() - { - that.usernameAttributeContainer=query(".usernameAttributeContainer", data.containerNode)[0]; - that.connectionPoolTypeAttributeContainer=query(".connectionPoolTypeAttributeContainer", data.containerNode)[0]; - }); - } - - JDBC.prototype.update = function(data) - { - var previousConnectionPoolType = this.connectionPoolType ? this.connectionPoolType.innerHTML : null; - util.updateUI(data, fieldNames, this); - this.usernameAttributeContainer.style.display = data.username ? "block" : "none"; - if (data.connectionPoolType && (!this.poolDetails || previousConnectionPoolType != data.connectionPoolType)) - { - var that = this; - require(["qpid/management/store/pool/" + data.connectionPoolType.toLowerCase() + "/show"], - function(PoolDetails) - { - var widgets = registry.findWidgets(that.connectionPoolTypeAttributeContainer); - array.forEach(widgets, function(item) { item.destroyRecursive();}); - domConstruct.empty(that.connectionPoolTypeAttributeContainer); - - that.poolDetails = new PoolDetails({containerNode:that.connectionPoolTypeAttributeContainer, parent: that}); - that.poolDetails.update(data); - } - ); - } - else - { - this.poolDetails.update(data); - } - } - - return JDBC; - } -); diff --git a/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/js/qpid/management/virtualhostnode/jdbc/add.js b/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/js/qpid/management/virtualhostnode/jdbc/add.js deleted file mode 100644 index 071c0c8b23..0000000000 --- a/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/js/qpid/management/virtualhostnode/jdbc/add.js +++ /dev/null @@ -1,85 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -define(["dojo/_base/xhr", - "dojo/_base/array", - "dojo/parser", - "dojo/dom", - "dojo/dom-construct", - "dojo/json", - "dojo/string", - "dojo/store/Memory", - "dijit/registry", - "dojo/text!virtualhostnode/jdbc/add.html", - "dojo/text!service/helper?action=pluginList&plugin=JDBCConnectionProviderFactory", - "qpid/common/util", - "dijit/form/ValidationTextBox", - "dijit/form/CheckBox", - "dojo/domReady!"], - function (xhr, array, parser, dom, domConstruct, json, string, Memory, registry, template, poolTypeJsonString, util) - { - return { - show: function (data) - { - var that = this; - this.containerNode = domConstruct.create("div", {innerHTML: template}, data.containerNode); - parser.parse(this.containerNode).then(function(instances) - { - that._postParse(data); - }); - }, - _postParse: function(data) - { - var that = this; - registry.byId("addVirtualHostNode.connectionUrl").set("regExpGen", util.jdbcUrlOrContextVarRegexp); - registry.byId("addVirtualHostNode.username").set("regExpGen", util.nameOrContextVarRegexp); - - var poolTypes = json.parse(poolTypeJsonString); - var poolTypesData = []; - for (var i =0 ; i < poolTypes.length; i++) - { - poolTypesData[i]= {id: poolTypes[i], name: poolTypes[i]}; - } - var poolTypesStore = new Memory({ data: poolTypesData }); - var poolTypeControl = registry.byId("addVirtualHostNode.connectionPoolType"); - poolTypeControl.set("store", poolTypesStore); - poolTypeControl.set("value", "NONE"); - - var poolTypeFieldsDiv = dom.byId("addVirtualHostNode.poolSpecificDiv"); - poolTypeControl.on("change", - function(type) - { - if(type && string.trim(type) != "") - { - var widgets = registry.findWidgets(poolTypeFieldsDiv); - array.forEach(widgets, function(item) { item.destroyRecursive();}); - domConstruct.empty(poolTypeFieldsDiv); - require(["qpid/management/store/pool/"+type.toLowerCase()+"/add"], - function(poolType) - { - poolType.show({containerNode:poolTypeFieldsDiv, context: data.parent.virtualHostNodeContext}); - }); - } - } - ); - } - }; - } -); diff --git a/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/js/qpid/management/virtualhostnode/jdbc/edit.js b/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/js/qpid/management/virtualhostnode/jdbc/edit.js deleted file mode 100644 index cccfa95d4c..0000000000 --- a/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/js/qpid/management/virtualhostnode/jdbc/edit.js +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -define(["qpid/common/util", - "dojo/text!service/helper?action=pluginList&plugin=JDBCConnectionProviderFactory", - "dojo/_base/array", - "dojo/json", - "dojo/string", - "dojo/store/Memory", - "dojo/dom", - "dojo/dom-construct", - "dijit/registry", - "dojo/domReady!"], - function (util, poolTypeJsonString, array, json, string, Memory, dom, domConstruct, registry) - { - return { - show: function(data) - { - var that = this; - util.parseHtmlIntoDiv(data.containerNode, "virtualhostnode/jdbc/edit.html", function(){ that._postParse(data);}); - }, - _postParse: function(data) - { - registry.byId("editVirtualHostNode.connectionUrl").set("regExpGen", util.jdbcUrlOrContextVarRegexp); - registry.byId("editVirtualHostNode.username").set("regExpGen", util.nameOrContextVarRegexp); - - var poolTypes = json.parse(poolTypeJsonString); - var poolTypesData = []; - for (var i =0 ; i < poolTypes.length; i++) - { - poolTypesData[i]= {id: poolTypes[i], name: poolTypes[i]}; - } - var poolTypesStore = new Memory({ data: poolTypesData }); - var poolTypeControl = registry.byId("editVirtualHostNode.connectionPoolType"); - poolTypeControl.set("store", poolTypesStore); - poolTypeControl.set("value", data.data.connectionPoolType); - - var passwordControl = registry.byId("editVirtualHostNode.password"); - if (data.data.password) - { - passwordControl.set("placeHolder", "*******"); - } - - var poolTypeFieldsDiv = dom.byId("editVirtualHostNode.poolSpecificDiv"); - poolTypeControl.on("change", - function(type) - { - if(type && string.trim(type) != "") - { - var widgets = registry.findWidgets(poolTypeFieldsDiv); - array.forEach(widgets, function(item) { item.destroyRecursive();}); - domConstruct.empty(poolTypeFieldsDiv); - - require(["qpid/management/store/pool/"+type.toLowerCase()+"/edit"], - function(poolType) - { - poolType.show({containerNode:poolTypeFieldsDiv, data: data.data, context: data.parent.context}) - - if (!(data.data.state == "STOPPED" || data.data.state == "ERRORED")) - { - var widgets = registry.findWidgets(poolTypeFieldsDiv); - array.forEach(widgets, function(item) { item.set("disabled", true);}); - } - }); - } - } - ); - } - }; - } -); diff --git a/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/js/qpid/management/virtualhostnode/jdbc/show.js b/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/js/qpid/management/virtualhostnode/jdbc/show.js deleted file mode 100644 index 019962fc64..0000000000 --- a/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/js/qpid/management/virtualhostnode/jdbc/show.js +++ /dev/null @@ -1,68 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -define(["qpid/common/util", "dojo/query", "dojo/_base/array", "dojo/dom-construct", "dijit/registry", "dojo/domReady!"], - function (util, query, array, domConstruct, registry) - { - var fieldNames = ["connectionUrl", "username", "connectionPoolType"]; - - function Jdbc(data) - { - this.parent = data.parent; - var that = this; - util.buildUI(data.containerNode, data.parent, "virtualhostnode/jdbc/show.html", fieldNames, this, - function() - { - that.usernameAttributeContainer=query(".usernameAttributeContainer", data.containerNode)[0]; - that.connectionPoolTypeAttributeContainer=query(".connectionPoolTypeAttributeContainer", data.containerNode)[0]; - }); - } - - Jdbc.prototype.update=function(data) - { - var previousConnectionPoolType = this.connectionPoolType ? this.connectionPoolType.innerHTML : null; - this.parent.editNodeButton.set("disabled", !(data.state == "STOPPED" || data.state == "ERRORED")); - util.updateUI(data, fieldNames, this); - - this.usernameAttributeContainer.style.display = data.username ? "block" : "none"; - if (data.connectionPoolType && (!this.poolDetails || previousConnectionPoolType != data.connectionPoolType)) - { - var that = this; - require(["qpid/management/store/pool/" + data.connectionPoolType.toLowerCase() + "/show"], - function(PoolDetails) - { - var widgets = registry.findWidgets(that.connectionPoolTypeAttributeContainer); - array.forEach(widgets, function(item) { item.destroyRecursive();}); - domConstruct.empty(that.connectionPoolTypeAttributeContainer); - - that.poolDetails = new PoolDetails({containerNode:that.connectionPoolTypeAttributeContainer, parent: that}); - that.poolDetails.update(data); - } - ); - } - else - { - this.poolDetails.update(data); - } - }; - - return Jdbc; -}); diff --git a/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/virtualhost/jdbc/add.html b/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/virtualhost/jdbc/add.html deleted file mode 100644 index 7fc7f17565..0000000000 --- a/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/virtualhost/jdbc/add.html +++ /dev/null @@ -1,76 +0,0 @@ -<!-- - ~ Licensed to the Apache Software Foundation (ASF) under one - ~ or more contributor license agreements. See the NOTICE file - ~ distributed with this work for additional information - ~ regarding copyright ownership. The ASF licenses this file - ~ to you under the Apache License, Version 2.0 (the - ~ "License"); you may not use this file except in compliance - ~ with the License. You may obtain a copy of the License at - ~ - ~ http://www.apache.org/licenses/LICENSE-2.0 - ~ - ~ Unless required by applicable law or agreed to in writing, - ~ software distributed under the License is distributed on an - ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - ~ KIND, either express or implied. See the License for the - ~ specific language governing permissions and limitations - ~ under the License. - --> -<div> - <div class="clear"> - <div class="formLabel-labelCell tableContainer-labelCell">JDBC Url*:</div> - <div class="formLabel-controlCell tableContainer-valueCell"> - <input type="text" id="addVirtualHost.connectionUrl" - data-dojo-type="dijit/form/ValidationTextBox" - data-dojo-props=" - name: 'connectionUrl', - placeHolder: 'jdbc:provider:info', - required: true, - missingMessage: 'JDBC URL must be supplied', - title: 'Enter JDBC URL'"/> - </div> - </div> - <div class="clear"> - <div class="formLabel-labelCell tableContainer-labelCell">Username*:</div> - <div class="formLabel-controlCell tableContainer-valueCell"> - <input type="text" id="addVirtualHost.username" - data-dojo-type="dijit/form/ValidationTextBox" - data-dojo-props=" - name: 'username', - placeHolder: 'username', - required: true, - missingMessage: 'Username must be supplied', - title: 'Enter username'" /> - </div> - </div> - <div class="clear"> - <div class="formLabel-labelCell tableContainer-labelCell">Password*:</div> - <div class="formLabel-controlCell tableContainer-valueCell"> - <input type="password" id="addVirtualHost.password" - data-dojo-type="dijit/form/ValidationTextBox" - data-dojo-props=" - name: 'password', - placeHolder: 'password', - required: true, - missingMessage: 'Password must be supplied', - title: 'Enter password'" /> - </div> - </div> - <div class="clear"> - <div class="formLabel-labelCell tableContainer-labelCell">Connection Pool*:</div> - <div class="formLabel-controlCell tableContainer-valueCell"> - <input type="text" id="addVirtualHost.connectionPoolType" - data-dojo-type="dijit/form/FilteringSelect" - data-dojo-props=" - name: 'connectionPoolType', - required: true, - missingMessage: 'Connection Pool type must be supplied', - title: 'Select Connection Pool', - placeHolder: 'Select pool type'" /> - </div> - </div> - - <div class="clear"></div> - <div id="addVirtualHost.poolSpecificDiv"></div> - <div class="infoMessage">The virtual host will have the same name as the node.</div> -</div> diff --git a/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/virtualhost/jdbc/edit.html b/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/virtualhost/jdbc/edit.html deleted file mode 100644 index 10212079eb..0000000000 --- a/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/virtualhost/jdbc/edit.html +++ /dev/null @@ -1,78 +0,0 @@ -<!-- - ~ Licensed to the Apache Software Foundation (ASF) under one - ~ or more contributor license agreements. See the NOTICE file - ~ distributed with this work for additional information - ~ regarding copyright ownership. The ASF licenses this file - ~ to you under the Apache License, Version 2.0 (the - ~ "License"); you may not use this file except in compliance - ~ with the License. You may obtain a copy of the License at - ~ - ~ http://www.apache.org/licenses/LICENSE-2.0 - ~ - ~ Unless required by applicable law or agreed to in writing, - ~ software distributed under the License is distributed on an - ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - ~ KIND, either express or implied. See the License for the - ~ specific language governing permissions and limitations - ~ under the License. - --> - -<div> - <div class="clear"> - <div class="formLabel-labelCell tableContainer-labelCell">JDBC Url*:</div> - <div class="formLabel-controlCell tableContainer-valueCell"> - <input type="text" id="editVirtualHost.connectionUrl" - data-dojo-type="dijit/form/ValidationTextBox" - data-dojo-props=" - name: 'connectionUrl', - placeHolder: 'jdbc:provider:info', - required: true, - missingMessage: 'JDBC URL must be supplied', - title: 'Enter JDBC URL'"/> - </div> - </div> - <div class="clear"> - <div class="formLabel-labelCell tableContainer-labelCell">Username*:</div> - <div class="formLabel-controlCell tableContainer-valueCell"> - <input type="text" id="editVirtualHost.username" - data-dojo-type="dijit/form/ValidationTextBox" - data-dojo-props=" - name: 'username', - placeHolder: 'username', - required: true, - missingMessage: 'Username must be supplied', - title: 'Enter username'" /> - </div> - </div> - <div class="clear"> - <div class="formLabel-labelCell tableContainer-labelCell">Password*:</div> - <div class="formLabel-controlCell tableContainer-valueCell"> - <input type="password" id="editVirtualHost.password" - data-dojo-type="dijit/form/ValidationTextBox" - data-dojo-props=" - name: 'password', - placeHolder: 'password', - type: 'password', - required: false, - missingMessage: 'Password must be supplied', - title: 'Enter password'" /> - </div> - </div> - <div class="clear"> - <div class="formLabel-labelCell tableContainer-labelCell">Connection Pool*:</div> - <div class="formLabel-controlCell tableContainer-valueCell"> - <input type="text" id="editVirtualHost.connectionPoolType" - data-dojo-type="dijit/form/FilteringSelect" - data-dojo-props=" - name: 'connectionPoolType', - required: true, - missingMessage: 'Connection Pool type must be supplied', - title: 'Select Connection Pool', - placeHolder: 'Select pool type'" /> - </div> - </div> - - <div class="clear"></div> - <div id="editVirtualHost.poolSpecificDiv"></div> - -</div> diff --git a/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/virtualhost/store/pool/none/add.html b/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/virtualhost/store/pool/none/add.html deleted file mode 100644 index 2666129a1f..0000000000 --- a/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/virtualhost/store/pool/none/add.html +++ /dev/null @@ -1,17 +0,0 @@ -<!-- - ~ Licensed to the Apache Software Foundation (ASF) under one or more - ~ contributor license agreements. See the NOTICE file distributed with - ~ this work for additional information regarding copyright ownership. - ~ The ASF licenses this file to You under the Apache License, Version 2.0 - ~ (the "License"); you may not use this file except in compliance with - ~ the License. You may obtain a copy of the License at - ~ - ~ http://www.apache.org/licenses/LICENSE-2.0 - ~ - ~ Unless required by applicable law or agreed to in writing, software - ~ distributed under the License is distributed on an "AS IS" BASIS, - ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - ~ See the License for the specific language governing permissions and - ~ limitations under the License. - --> - diff --git a/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/virtualhostnode/jdbc/add.html b/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/virtualhostnode/jdbc/add.html deleted file mode 100644 index f9561d4c51..0000000000 --- a/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/virtualhostnode/jdbc/add.html +++ /dev/null @@ -1,77 +0,0 @@ -<!-- - - - - Licensed to the Apache Software Foundation (ASF) under one - - or more contributor license agreements. See the NOTICE file - - distributed with this work for additional information - - regarding copyright ownership. The ASF licenses this file - - to you under the Apache License, Version 2.0 (the - - "License"); you may not use this file except in compliance - - with the License. You may obtain a copy of the License at - - - - http://www.apache.org/licenses/LICENSE-2.0 - - - - Unless required by applicable law or agreed to in writing, - - software distributed under the License is distributed on an - - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - - KIND, either express or implied. See the License for the - - specific language governing permissions and limitations - - under the License. - - - --> -<div> - <div class="clear"> - <div class="formLabel-labelCell tableContainer-labelCell">JDBC Url*:</div> - <div class="formLabel-controlCell tableContainer-valueCell"> - <input type="text" id="addVirtualHostNode.connectionUrl" - data-dojo-type="dijit/form/ValidationTextBox" - data-dojo-props=" - name: 'connectionUrl', - placeHolder: 'jdbc:provider:info', - required: true, - promptMessage: 'JDBC URL specifying the connection to the database', - title: 'Enter JDBC URL'"/> - </div> - </div> - <div class="clear"> - <div class="formLabel-labelCell tableContainer-labelCell">Username*:</div> - <div class="formLabel-controlCell tableContainer-valueCell"> - <input type="text" id="addVirtualHostNode.username" - data-dojo-type="dijit/form/ValidationTextBox" - data-dojo-props=" - name: 'username', - placeHolder: 'username', - required: true, - promptMessage: 'Database user name', - title: 'Enter username'" /> - </div> - </div> - <div class="clear"> - <div class="formLabel-labelCell tableContainer-labelCell">Password*:</div> - <div class="formLabel-controlCell tableContainer-valueCell"> - <input type="password" id="addVirtualHostNode.password" - data-dojo-type="dijit/form/ValidationTextBox" - data-dojo-props=" - name: 'password', - placeHolder: 'password', - required: true, - promptMessage: 'Database password', - title: 'Enter password'" /> - </div> - </div> - <div class="clear"> - <div class="formLabel-labelCell tableContainer-labelCell">Connection Pool*:</div> - <div class="formLabel-controlCell tableContainer-valueCell"> - <input type="text" id="addVirtualHostNode.connectionPoolType" - data-dojo-type="dijit/form/FilteringSelect" - data-dojo-props=" - name: 'connectionPoolType', - required: true, - promptMessage: 'Connection pool type to use when connecting to the database', - title: 'Select the connection pool type', - placeHolder: 'Select pool type'" /> - </div> - </div> - - <div class="clear"></div> - <div id="addVirtualHostNode.poolSpecificDiv"></div> -</div> diff --git a/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/virtualhostnode/jdbc/edit.html b/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/virtualhostnode/jdbc/edit.html deleted file mode 100644 index c8cc56d1cb..0000000000 --- a/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/virtualhostnode/jdbc/edit.html +++ /dev/null @@ -1,77 +0,0 @@ -<!-- - - - - Licensed to the Apache Software Foundation (ASF) under one - - or more contributor license agreements. See the NOTICE file - - distributed with this work for additional information - - regarding copyright ownership. The ASF licenses this file - - to you under the Apache License, Version 2.0 (the - - "License"); you may not use this file except in compliance - - with the License. You may obtain a copy of the License at - - - - http://www.apache.org/licenses/LICENSE-2.0 - - - - Unless required by applicable law or agreed to in writing, - - software distributed under the License is distributed on an - - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - - KIND, either express or implied. See the License for the - - specific language governing permissions and limitations - - under the License. - - - --> -<div> - <div class="clear"> - <div class="formLabel-labelCell tableContainer-labelCell">JDBC Url*:</div> - <div class="formLabel-controlCell tableContainer-valueCell"> - <input type="text" id="editVirtualHostNode.connectionUrl" - data-dojo-type="dijit/form/ValidationTextBox" - data-dojo-props=" - name: 'connectionUrl', - placeHolder: 'jdbc:provider:info', - required: true, - missingMessage: 'JDBC URL must be supplied', - title: 'Enter JDBC URL'"/> - </div> - </div> - <div class="clear"> - <div class="formLabel-labelCell tableContainer-labelCell">Username*:</div> - <div class="formLabel-controlCell tableContainer-valueCell"> - <input type="text" id="editVirtualHostNode.username" - data-dojo-type="dijit/form/ValidationTextBox" - data-dojo-props=" - name: 'username', - placeHolder: 'username', - required: true, - missingMessage: 'Username must be supplied', - title: 'Enter username'" /> - </div> - </div> - <div class="clear"> - <div class="formLabel-labelCell tableContainer-labelCell">Password*:</div> - <div class="formLabel-controlCell tableContainer-valueCell"> - <input type="password" id="editVirtualHostNode.password" - data-dojo-type="dijit/form/ValidationTextBox" - data-dojo-props=" - name: 'password', - placeHolder: 'password', - required: false, - missingMessage: 'Password must be supplied', - title: 'Enter password'" /> - </div> - </div> - <div class="clear"> - <div class="formLabel-labelCell tableContainer-labelCell">Connection Pool*:</div> - <div class="formLabel-controlCell tableContainer-valueCell"> - <input type="text" id="editVirtualHostNode.connectionPoolType" - data-dojo-type="dijit/form/FilteringSelect" - data-dojo-props=" - name: 'connectionPoolType', - required: true, - missingMessage: 'Connection Pool type must be supplied', - title: 'Select Connection Pool', - placeHolder: 'Select pool type'" /> - </div> - </div> - - <div class="clear"></div> - <div id="editVirtualHostNode.poolSpecificDiv"></div> -</div> diff --git a/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/virtualhostnode/jdbc/show.html b/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/virtualhostnode/jdbc/show.html deleted file mode 100644 index b6145f59b6..0000000000 --- a/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/virtualhostnode/jdbc/show.html +++ /dev/null @@ -1,34 +0,0 @@ -<!-- - ~ Licensed to the Apache Software Foundation (ASF) under one or more - ~ contributor license agreements. See the NOTICE file distributed with - ~ this work for additional information regarding copyright ownership. - ~ The ASF licenses this file to You under the Apache License, Version 2.0 - ~ (the "License"); you may not use this file except in compliance with - ~ the License. You may obtain a copy of the License at - ~ - ~ http://www.apache.org/licenses/LICENSE-2.0 - ~ - ~ Unless required by applicable law or agreed to in writing, software - ~ distributed under the License is distributed on an "AS IS" BASIS, - ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - ~ See the License for the specific language governing permissions and - ~ limitations under the License. - --> -<div> - <div class="clear"> - <div class="formLabel-labelCell">Connection URL:</div> - <div class="connectionUrl"></div> - </div> - <div class="clear usernameAttributeContainer"> - <div class="formLabel-labelCell">Username:</div> - <div class="username"></div> - </div> - <div class="clear"> - <div class="formLabel-labelCell">Connection Pool Type:</div> - <div class="connectionPoolType"></div> - </div> - <div class="clear connectionPoolTypeAttributeContainer"/> - - <div class="clear"></div> -</div> - diff --git a/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/virtualhostnode/store/pool/none/add.html b/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/virtualhostnode/store/pool/none/add.html deleted file mode 100644 index 2666129a1f..0000000000 --- a/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/virtualhostnode/store/pool/none/add.html +++ /dev/null @@ -1,17 +0,0 @@ -<!-- - ~ Licensed to the Apache Software Foundation (ASF) under one or more - ~ contributor license agreements. See the NOTICE file distributed with - ~ this work for additional information regarding copyright ownership. - ~ The ASF licenses this file to You under the Apache License, Version 2.0 - ~ (the "License"); you may not use this file except in compliance with - ~ the License. You may obtain a copy of the License at - ~ - ~ http://www.apache.org/licenses/LICENSE-2.0 - ~ - ~ Unless required by applicable law or agreed to in writing, software - ~ distributed under the License is distributed on an "AS IS" BASIS, - ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - ~ See the License for the specific language governing permissions and - ~ limitations under the License. - --> - diff --git a/qpid/java/broker-plugins/jdbc-store/src/test/java/org/apache/qpid/server/store/jdbc/JDBCDetailsTest.java b/qpid/java/broker-plugins/jdbc-store/src/test/java/org/apache/qpid/server/store/jdbc/JDBCDetailsTest.java deleted file mode 100644 index 67e9960ca7..0000000000 --- a/qpid/java/broker-plugins/jdbc-store/src/test/java/org/apache/qpid/server/store/jdbc/JDBCDetailsTest.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.qpid.server.store.jdbc; - -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -import junit.framework.TestCase; - -public class JDBCDetailsTest extends TestCase -{ - public void testDerby() - { - JDBCDetails derbyDetails = JDBCDetails.getDetailsForJdbcUrl("jdbc:derby:sample", - Collections.<String, String>emptyMap()); - assertEquals("derby", derbyDetails.getVendor()); - assertEquals("varchar(%d) for bit data", derbyDetails.getVarBinaryType()); - assertEquals("bigint", derbyDetails.getBigintType()); - assertEquals("blob", derbyDetails.getBlobType()); - assertFalse(derbyDetails.isUseBytesMethodsForBlob()); - - assertTrue(derbyDetails.isKnownVendor()); - assertFalse(derbyDetails.isOverridden()); - } - - public void testUnknownVendor_UsesFallbackDetails() - { - JDBCDetails details = JDBCDetails.getDetailsForJdbcUrl("jdbc:homedb:", Collections.<String, String>emptyMap()); - assertEquals("fallback", details.getVendor()); - assertEquals("varchar(%d) for bit data", details.getVarBinaryType()); - assertEquals("bigint", details.getBigintType()); - assertEquals("blob", details.getBlobType()); - assertEquals(false, details.isUseBytesMethodsForBlob()); - assertFalse(details.isOverridden()); - assertFalse(details.isKnownVendor()); - } - - public void testDerbyWithOverride() - { - - Map<String, String> contextMap = new HashMap<>(); - contextMap.put(JDBCDetails.CONTEXT_JDBCSTORE_VARBINARYTYPE, "myvarbin"); - - JDBCDetails derbyDetails = JDBCDetails.getDetailsForJdbcUrl("jdbc:derby:sample", contextMap); - assertEquals("derby", derbyDetails.getVendor()); - assertEquals("myvarbin", derbyDetails.getVarBinaryType()); - assertEquals("bigint", derbyDetails.getBigintType()); - assertEquals("blob", derbyDetails.getBlobType()); - assertFalse(derbyDetails.isUseBytesMethodsForBlob()); - - assertTrue(derbyDetails.isKnownVendor()); - assertTrue(derbyDetails.isOverridden()); - } - - - - - public void testRecognisedDriver_AllDetailsProvidedByContext() - { - Map<String, String> contextMap = new HashMap<>(); - contextMap.put(JDBCDetails.CONTEXT_JDBCSTORE_VARBINARYTYPE, "myvarbin"); - contextMap.put(JDBCDetails.CONTEXT_JDBCSTORE_BIGINTTYPE, "mybigint"); - contextMap.put(JDBCDetails.CONTEXT_JDBCSTORE_BLOBTYPE, "myblob"); - contextMap.put(JDBCDetails.CONTEXT_JDBCSTORE_USEBYTESFORBLOB, "true"); - - JDBCDetails details = JDBCDetails.getDetailsForJdbcUrl("jdbc:sybase:", contextMap); - assertEquals("sybase", details.getVendor()); - assertEquals("myvarbin", details.getVarBinaryType()); - assertEquals("mybigint", details.getBigintType()); - assertEquals("myblob", details.getBlobType()); - assertEquals(true, details.isUseBytesMethodsForBlob()); - assertTrue(details.isKnownVendor()); - assertTrue(details.isOverridden()); - } - -}
\ No newline at end of file diff --git a/qpid/java/broker-plugins/jdbc-store/src/test/java/org/apache/qpid/server/store/jdbc/JDBCMessageStoreTest.java b/qpid/java/broker-plugins/jdbc-store/src/test/java/org/apache/qpid/server/store/jdbc/JDBCMessageStoreTest.java deleted file mode 100644 index 3a85ae3257..0000000000 --- a/qpid/java/broker-plugins/jdbc-store/src/test/java/org/apache/qpid/server/store/jdbc/JDBCMessageStoreTest.java +++ /dev/null @@ -1,158 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.server.store.jdbc; - -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import java.sql.Connection; -import java.sql.DatabaseMetaData; -import java.sql.DriverManager; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.HashSet; -import java.util.Set; - -import org.apache.qpid.server.model.VirtualHost; -import org.apache.qpid.server.store.MessageStore; -import org.apache.qpid.server.store.MessageStoreTestCase; -import org.apache.qpid.server.virtualhost.jdbc.JDBCVirtualHost; - -public class JDBCMessageStoreTest extends MessageStoreTestCase -{ - private String _connectionURL; - - @Override - public void tearDown() throws Exception - { - try - { - shutdownDerby(); - } - finally - { - super.tearDown(); - } - } - - public void testOnDelete() throws Exception - { - Set<String> expectedTables = GenericJDBCMessageStore.MESSAGE_STORE_TABLE_NAMES; - assertTablesExist(expectedTables, true); - getStore().closeMessageStore(); - assertTablesExist(expectedTables, true); - getStore().onDelete(mock(JDBCVirtualHost.class)); - assertTablesExist(expectedTables, false); - } - - @Override - protected VirtualHost createVirtualHost() - { - _connectionURL = "jdbc:derby:memory:/" + getTestName() + ";create=true"; - - final JDBCVirtualHost jdbcVirtualHost = mock(JDBCVirtualHost.class); - when(jdbcVirtualHost.getConnectionUrl()).thenReturn(_connectionURL); - when(jdbcVirtualHost.getUsername()).thenReturn("test"); - when(jdbcVirtualHost.getPassword()).thenReturn("pass"); - return jdbcVirtualHost; - } - - - @Override - protected MessageStore createMessageStore() - { - return new GenericJDBCMessageStore(); - } - - private void assertTablesExist(Set<String> expectedTables, boolean exists) throws SQLException - { - Set<String> existingTables = getTableNames(); - for (String tableName : expectedTables) - { - assertEquals("Table " + tableName + (exists ? " is not found" : " actually exist"), exists, - existingTables.contains(tableName)); - } - } - - private Set<String> getTableNames() throws SQLException - { - Set<String> tableNames = new HashSet<String>(); - Connection conn = null; - try - { - conn = openConnection(); - DatabaseMetaData metaData = conn.getMetaData(); - ResultSet tables = metaData.getTables(null, null, null, new String[] { "TABLE" }); - try - { - while (tables.next()) - { - tableNames.add(tables.getString("TABLE_NAME")); - } - } - finally - { - tables.close(); - } - } - finally - { - if (conn != null) - { - conn.close(); - } - } - return tableNames; - } - - private Connection openConnection() throws SQLException - { - return DriverManager.getConnection(_connectionURL); - } - - - private void shutdownDerby() throws SQLException - { - Connection connection = null; - try - { - connection = DriverManager.getConnection("jdbc:derby:memory:/" + getTestName() + ";shutdown=true"); - } - catch(SQLException e) - { - if (e.getSQLState().equalsIgnoreCase("08006")) - { - //expected and represents a clean shutdown of this database only, do nothing. - } - else - { - throw e; - } - } - finally - { - if (connection != null) - { - connection.close(); - } - } - } -} |
