private ModifiableDataSource buildDataSource(DataSource ds) throws org.jboss.jca.common.api.validator.ValidateException { assert ds.getSecurity() == null || ds.getSecurity() instanceof DsSecurity; return new ModifiableDataSource(ds.getConnectionUrl(), ds.getDriverClass(), ds.getDataSourceClass(), ds.getDriver(), ds.getTransactionIsolation(), ds.getConnectionProperties(), ds.getTimeOut(), (DsSecurity) ds.getSecurity(), ds.getStatement(), ds.getValidation(), ds.getUrlDelimiter(), ds.getUrlSelectorStrategyClassName(), ds.getNewConnectionSql(), ds.isUseJavaContext(), ds.getPoolName(), ds.isEnabled(), ds.getJndiName(), ds.isSpy(), ds.isUseCcm(), ds.isJTA(), ds.isConnectable(), ds.isTracking(), ds.getMcp(), ds.isEnlistmentTrace(), ds.getPool()); }
private ModifiableXaDataSource buildXaDataSource(XaDataSource xads) throws org.jboss.jca.common.api.validator.ValidateException { final DsXaPool xaPool; if (xads.getXaPool() == null) { xaPool = new DsXaPoolImpl(Defaults.MIN_POOL_SIZE, Defaults.INITIAL_POOL_SIZE, Defaults.MAX_POOL_SIZE, Defaults.PREFILL, Defaults.USE_STRICT_MIN, Defaults.FLUSH_STRATEGY, Defaults.IS_SAME_RM_OVERRIDE, Defaults.INTERLEAVING, Defaults.PAD_XID, Defaults.WRAP_XA_RESOURCE, Defaults.NO_TX_SEPARATE_POOL, Defaults.ALLOW_MULTIPLE_USERS, null, Defaults.FAIR, null); } else { final DsXaPool p = xads.getXaPool(); xaPool = new DsXaPoolImpl(getDef(p.getMinPoolSize(), Defaults.MIN_POOL_SIZE), getDef(p.getInitialPoolSize(), Defaults.INITIAL_POOL_SIZE), getDef(p.getMaxPoolSize(), Defaults.MAX_POOL_SIZE), getDef(p.isPrefill(), Defaults.PREFILL), getDef(p.isUseStrictMin(), Defaults.USE_STRICT_MIN), getDef(p.getFlushStrategy(), Defaults.FLUSH_STRATEGY), getDef(p.isSameRmOverride(), Defaults.IS_SAME_RM_OVERRIDE), getDef(p.isInterleaving(), Defaults.INTERLEAVING), getDef(p.isPadXid(), Defaults.PAD_XID) , getDef(p.isWrapXaResource(), Defaults.WRAP_XA_RESOURCE), getDef(p.isNoTxSeparatePool(), Defaults.NO_TX_SEPARATE_POOL), getDef(p.isAllowMultipleUsers(), Defaults.ALLOW_MULTIPLE_USERS), p.getCapacity(), getDef(p.isFair(), Defaults.FAIR), p.getConnectionListener()); } return new ModifiableXaDataSource(xads.getTransactionIsolation(), xads.getTimeOut(), xads.getSecurity(), xads.getStatement(), xads.getValidation(), xads.getUrlDelimiter(), xads.getUrlProperty(), xads.getUrlSelectorStrategyClassName(), xads.isUseJavaContext(), xads.getPoolName(), xads.isEnabled(), xads.getJndiName(), xads.isSpy(), xads.isUseCcm(), xads.isConnectable(), xads.isTracking(), xads.getMcp(), xads.isEnlistmentTrace(), xads.getXaDataSourceProperty(), xads.getXaDataSourceClass(), xads.getDriver(), xads.getNewConnectionSql(), xaPool, xads.getRecovery()); }
@Override protected ManagedConnectionFactory createMcf(XaDataSource arg0, String arg1, ClassLoader arg2) throws NotFoundException, DeployException { final XAManagedConnectionFactory xaManagedConnectionFactory = new XAManagedConnectionFactory(xaDataSourceConfig.getXaDataSourceProperty()); if (xaDataSourceConfig.getUrlDelimiter() != null) { xaManagedConnectionFactory.setURLDelimiter(xaDataSourceConfig.getUrlDelimiter()); } if (xaDataSourceConfig.getXaDataSourceClass() != null) { xaManagedConnectionFactory.setXADataSourceClass(xaDataSourceConfig.getXaDataSourceClass()); } if (xaDataSourceConfig.getUrlSelectorStrategyClassName() != null) { xaManagedConnectionFactory .setUrlSelectorStrategyClassName(xaDataSourceConfig.getUrlSelectorStrategyClassName()); } if (xaDataSourceConfig.getXaPool() != null && xaDataSourceConfig.getXaPool().isSameRmOverride() != null) { xaManagedConnectionFactory.setIsSameRMOverrideValue(xaDataSourceConfig.getXaPool().isSameRmOverride()); } if (xaDataSourceConfig.getNewConnectionSql() != null) { xaManagedConnectionFactory.setNewConnectionSQL(xaDataSourceConfig.getNewConnectionSql()); } if (xaDataSourceConfig.getUrlSelectorStrategyClassName() != null) { xaManagedConnectionFactory .setUrlSelectorStrategyClassName(xaDataSourceConfig.getUrlSelectorStrategyClassName()); } setMcfProperties(xaManagedConnectionFactory, xaDataSourceConfig, xaDataSourceConfig.getStatement()); return xaManagedConnectionFactory; }
if (dataSourceConfig.getTransactionIsolation() != null) { managedConnectionFactory.setTransactionIsolation(dataSourceConfig.getTransactionIsolation().name()); final DsSecurity security = dataSourceConfig.getSecurity(); if (security != null) { if (security.getUserName() != null) { managedConnectionFactory.setUserName(security.getUserName()); if (security.getPassword() != null) { managedConnectionFactory.setPassword(security.getPassword()); final TimeOut timeOut = dataSourceConfig.getTimeOut(); if (timeOut != null) { if (timeOut.getUseTryLock() != null) { managedConnectionFactory.setUseTryLock(timeOut.getUseTryLock().intValue()); if (timeOut.getQueryTimeout() != null) { managedConnectionFactory.setQueryTimeout(timeOut.getQueryTimeout().intValue()); if (timeOut.isSetTxQueryTimeout()) { managedConnectionFactory.setTransactionQueryTimeout(true); if (statement.getTrackStatements() != null) { managedConnectionFactory.setTrackStatements(statement.getTrackStatements().name()); if (statement.isSharePreparedStatements() != null) { managedConnectionFactory.setSharePreparedStatements(statement.isSharePreparedStatements()); if (statement.getPreparedStatementsCacheSize() != null) {
ClassLoader arg2) throws NotFoundException, DeployException { final LocalManagedConnectionFactory managedConnectionFactory = new LocalManagedConnectionFactory(); managedConnectionFactory.setDriverClass(dataSourceConfig.getDriverClass()); if (dataSourceConfig.getUrlDelimiter() != null) { try { managedConnectionFactory.setURLDelimiter(dataSourceConfig.getUrlDelimiter()); } catch (Exception e) { throw ConnectorLogger.ROOT_LOGGER.failedToGetUrlDelimiter(e); if (dataSourceConfig.getDataSourceClass() != null) { managedConnectionFactory.setDataSourceClass(dataSourceConfig.getDataSourceClass()); if (dataSourceConfig.getConnectionProperties() != null) { managedConnectionFactory.setConnectionProperties(buildConfigPropsString(dataSourceConfig .getConnectionProperties())); if (dataSourceConfig.getConnectionUrl() != null) { managedConnectionFactory.setConnectionURL(dataSourceConfig.getConnectionUrl()); if (dataSourceConfig.getNewConnectionSql() != null) { managedConnectionFactory.setNewConnectionSQL(dataSourceConfig.getNewConnectionSql()); if (dataSourceConfig.getUrlSelectorStrategyClassName() != null) { managedConnectionFactory.setUrlSelectorStrategyClassName(dataSourceConfig.getUrlSelectorStrategyClassName()); setMcfProperties(managedConnectionFactory, dataSourceConfig, dataSourceConfig.getStatement());
switch (reader.nextTag()) { case END_ELEMENT: { if (DataSource.Tag.forName(reader.getLocalName()) == DataSource.Tag.VALIDATION) { if (Validation.Tag.forName(reader.getLocalName()) == Validation.Tag.UNKNOWN) { throw new ParserException(bundle.unexpectedEndTag(reader.getLocalName())); Validation.Tag currTag = Validation.Tag.forName(reader.getLocalName()); switch (currTag) { case BACKGROUND_VALIDATION: { parseExtension(reader, currTag.getLocalName(), operation, EXCEPTION_SORTER_CLASSNAME, EXCEPTION_SORTER_PROPERTIES); break; parseExtension(reader, currTag.getLocalName(), operation, STALE_CONNECTION_CHECKER_CLASSNAME, STALE_CONNECTION_CHECKER_PROPERTIES); break; parseExtension(reader, currTag.getLocalName(), operation, VALID_CONNECTION_CHECKER_CLASSNAME, VALID_CONNECTION_CHECKER_PROPERTIES); break;
writer.writeStartElement(DataSources.Tag.DRIVERS.getLocalName()); ModelNode drivers = node.get(JDBC_DRIVER_NAME); for (String driverName : drivers.keys()) { ModelNode driver = drivers.get(driverName); writer.writeStartElement(DataSources.Tag.DRIVER.getLocalName()); writer.writeAttribute(Driver.Attribute.NAME.getLocalName(), driver.require(DRIVER_NAME.getName()).asString()); if (has(driver, DRIVER_MODULE_NAME.getName())) { String moduleName = driver.get(DRIVER_MODULE_NAME.getName()).asString(); moduleName = moduleName + ":" + driver.get(MODULE_SLOT.getName()).asString(); writer.writeAttribute(Driver.Attribute.MODULE.getLocalName(), moduleName); writeElementIfHas(writer, driver, Driver.Tag.DRIVER_CLASS.getLocalName(), DRIVER_CLASS_NAME.getName()); writeElementIfHas(writer, driver, Driver.Tag.XA_DATASOURCE_CLASS.getLocalName(), DRIVER_XA_DATASOURCE_CLASS_NAME.getName()); writeElementIfHas(writer, driver, Driver.Tag.DATASOURCE_CLASS.getLocalName(), DRIVER_DATASOURCE_CLASS_NAME.getName());
@Override public void undeploy(final DeploymentUnit deploymentUnit) { final List<DataSources> dataSourcesList = deploymentUnit.getAttachmentList(DsXmlDeploymentParsingProcessor.DATA_SOURCES_ATTACHMENT_KEY); for (final DataSources dataSources : dataSourcesList) { if (dataSources.getDataSource() != null) { for (int i = 0; i < dataSources.getDataSource().size(); i++) { DataSource ds = dataSources.getDataSource().get(i); undeployDataSource(ds, deploymentUnit); } } if (dataSources.getXaDataSource() != null) { for (int i = 0; i < dataSources.getXaDataSource().size(); i++) { XaDataSource xads = dataSources.getXaDataSource().get(i); undeployXaDataSource(xads, deploymentUnit); } } } deploymentUnit.removeAttachment(DsXmlDeploymentParsingProcessor.DATA_SOURCES_ATTACHMENT_KEY); }
switch (reader.nextTag()) { case END_ELEMENT: { if (DataSource.Tag.forName(reader.getLocalName()) == DataSource.Tag.STATEMENT) { if (Statement.Tag.forName(reader.getLocalName()) == Statement.Tag.UNKNOWN) { throw new ParserException(bundle.unexpectedEndTag(reader.getLocalName())); switch (Statement.Tag.forName(reader.getLocalName())) { case PREPARED_STATEMENT_CACHE_SIZE: { String value = rawElementText(reader);
switch (reader.nextTag()) { case END_ELEMENT: { if (DataSource.Tag.forName(reader.getLocalName()) == DataSource.Tag.TIMEOUT) { if (TimeOut.Tag.forName(reader.getLocalName()) == TimeOut.Tag.UNKNOWN) { throw new ParserException(bundle.unexpectedEndTag(reader.getLocalName())); switch (TimeOut.Tag.forName(reader.getLocalName())) { case ALLOCATION_RETRY: { String value = rawElementText(reader);
switch (reader.nextTag()) { case END_ELEMENT: { if (DataSource.Tag.forName(reader.getLocalName()) == DataSource.Tag.POOL) { return; if (DsPool.Tag.forName(reader.getLocalName()) == DsPool.Tag.UNKNOWN) { throw new ParserException(bundle.unexpectedEndTag(reader.getLocalName())); switch (DsPool.Tag.forName(reader.getLocalName())) { case MAX_POOL_SIZE: { String value = rawElementText(reader);
private void handlePropertyAttribute(final String attributeName, final OperationContext context, final XaDataSource dataSource, final String propName) { if (attributeName.equals(ModelDescriptionConstants.VALUE)) { setStringIfNotNull(context, dataSource.getXaDataSourceProperty().get(propName)); } else { throw ConnectorLogger.ROOT_LOGGER.unknownAttribute(attributeName); } }
private void handlePropertyAttribute(final String attributeName, final OperationContext context, final DataSource dataSource, final String propName) { if(attributeName.equals(ModelDescriptionConstants.VALUE)) { setStringIfNotNull(context, dataSource.getConnectionProperties().get(propName)); } else { throw ConnectorLogger.ROOT_LOGGER.unknownAttribute(attributeName); } }
private void writeAttributeIfHas(final XMLExtendedStreamWriter writer, final ModelNode node, final Driver.Attribute attr, final String identifier) throws XMLStreamException { if (has(node, identifier)) { writer.writeAttribute(attr.getLocalName(), node.get(identifier).asString()); } }
private void undeployXaDataSource(final XaDataSource ds, final DeploymentUnit deploymentUnit) { final PathAddress addr = getDataSourceAddress(ds.getJndiName(), deploymentUnit, true); XMLXaDataSourceRuntimeHandler.INSTANCE.unregisterDataSource(addr); }
private void undeployDataSource(final DataSource ds, final DeploymentUnit deploymentUnit) { final PathAddress addr = getDataSourceAddress(ds.getJndiName(), deploymentUnit, false); XMLDataSourceRuntimeHandler.INSTANCE.unregisterDataSource(addr); }
@Override public void validate() throws ValidateException { if ((this.xaDataSourceClass == null || this.xaDataSourceClass.trim().length() == 0) && (this.driver == null || this.driver.trim().length() == 0)) throw new ValidateException(bundle.requiredElementMissing(XaDataSource.Tag.XA_DATASOURCE_CLASS.getLocalName(), this.getClass().getCanonicalName())); }
@Override public void validate() throws ValidateException { if (this.driverClass != null && (this.connectionUrl == null || this.connectionUrl.trim().length() == 0)) throw new ValidateException(bundle.requiredElementMissing(Tag.CONNECTION_URL.getLocalName(), this.getClass().getCanonicalName())); if ((this.driverClass == null || this.driverClass.trim().length() == 0) && (this.dataSourceClass == null || this.dataSourceClass.trim().length() == 0) && (this.driver == null || this.driver.trim().length() == 0)) throw new ValidateException(bundle.requiredElementMissing(Tag.DRIVER_CLASS.getLocalName(), this.getClass().getCanonicalName())); }
private void installManagementModel(final XaDataSource ds, final DeploymentUnit deploymentUnit, final PathAddress addr) { XMLXaDataSourceRuntimeHandler.INSTANCE.registerDataSource(addr, ds); final DeploymentResourceSupport deploymentResourceSupport = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_RESOURCE_SUPPORT); deploymentResourceSupport.getDeploymentSubModel(DataSourcesExtension.SUBSYSTEM_NAME, addr.getLastElement()); if (ds.getXaDataSourceProperty() != null) { for (final Map.Entry<String, String> prop : ds.getXaDataSourceProperty().entrySet()) { PathAddress registration = PathAddress.pathAddress(addr.getLastElement(), PathElement.pathElement(XA_CONNECTION_PROPERTIES, prop.getKey())); deploymentResourceSupport.getDeploymentSubModel(DataSourcesExtension.SUBSYSTEM_NAME, registration); } } }
private void installManagementModel(final DataSource ds, final DeploymentUnit deploymentUnit, final PathAddress addr) { XMLDataSourceRuntimeHandler.INSTANCE.registerDataSource(addr, ds); final DeploymentResourceSupport deploymentResourceSupport = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_RESOURCE_SUPPORT); deploymentResourceSupport.getDeploymentSubModel(DataSourcesExtension.SUBSYSTEM_NAME, addr.getLastElement()); if (ds.getConnectionProperties() != null) { for (final Map.Entry<String, String> prop : ds.getConnectionProperties().entrySet()) { PathAddress registration = PathAddress.pathAddress(addr.getLastElement(), PathElement.pathElement(CONNECTION_PROPERTIES, prop.getKey())); deploymentResourceSupport.getDeploymentSubModel(DataSourcesExtension.SUBSYSTEM_NAME, registration); } } }