/** create an instance **/ public ManagementRepositoryService() { super(); this.value = new ManagementRepository(); }
public List<Pool> match(String jndiName, ManagementRepository repository) { ArrayList<Pool> result = new ArrayList<Pool>(repository.getConnectors().size()); if (repository.getConnectors() != null) { for (Connector c : repository.getConnectors()) { if (c.getConnectionFactories() == null || c.getConnectionFactories().size() == 0) continue; for (ConnectionFactory cf : c.getConnectionFactories()) { if (cf != null && cf.getPool() != null && jndiName.equalsIgnoreCase(cf.getJndiName())) { result.add(cf.getPool()); } } } } return result; } }
public List<Pool> match(String jndiName, ManagementRepository repository) { ArrayList<org.jboss.jca.core.api.connectionmanager.pool.Pool> result = new ArrayList<Pool>(repository .getDataSources().size()); if (repository.getDataSources() != null) { for (DataSource ds : repository.getDataSources()) { if (jndiName.equalsIgnoreCase(ds.getJndiName()) && ds.getPool() != null) { result.add(ds.getPool()); } } } result.trimToSize(); return result; } }
if (connector != null && connector.getResourceAdapter() != null) { StatisticsPlugin raStats = connector.getResourceAdapter().getStatistics(); if (raStats != null) { raStats.setEnabled(statsEnabled); List<ConnectionFactory> connectionFactories = connector.getConnectionFactories(); if (connectionFactories != null) { for (ConnectionFactory cf : connectionFactories) { ManagedConnectionFactory mcf = cf.getManagedConnectionFactory(); StatisticsPlugin extendStats = mcf == null ? null : mcf.getStatistics(); if (extendStats != null) { extendStats.setEnabled(statsEnabled); cdRegistration.registerOverrideModel(cf.getJndiName(), OD_PROVIDER); if (overrideCdRegistration.getSubModel(EXTENDED_STATS_ADDR) == null) { overrideCdRegistration.registerSubModel(new StatisticsResourceDefinition(EXTENDED_STATS, CommonAttributes.RESOURCE_NAME, extendStats)); List<AdminObject> adminObjects = connector.getAdminObjects(); if (adminObjects != null) { PathAddress AO_ADDR = PathAddress.EMPTY_ADDRESS.append(Constants.ADMIN_OBJECTS_NAME); for (AdminObject ao : adminObjects) { StatisticsPlugin extendStats = ao.getStatistics(); if (extendStats != null) { extendStats.setEnabled(statsEnabled); cdRegistration.registerOverrideModel(ao.getJndiName(), OD_PROVIDER); if (overrideCdRegistration.getSubModel(EXTENDED_STATS_ADDR) == null) { overrideCdRegistration.registerSubModel(new StatisticsResourceDefinition(EXTENDED_STATS, CommonAttributes.RESOURCE_NAME, extendStats));
protected List<PoolConfiguration> getMatchingPoolConfigs(String poolName, ManagementRepository repository) { ArrayList<PoolConfiguration> result = new ArrayList<PoolConfiguration>(repository.getConnectors().size()); if (repository.getConnectors() != null) { for (Connector conn : repository.getConnectors()) { if (conn.getConnectionFactories() == null || conn.getConnectionFactories().get(0) == null || conn.getConnectionFactories().get(0).getPool() == null) continue; ConnectionFactory connectionFactory = conn.getConnectionFactories().get(0); if (poolName.equals(connectionFactory.getPool().getName())) { PoolConfiguration pc = conn.getConnectionFactories().get(0).getPoolConfiguration(); result.add(pc); } } } result.trimToSize(); return result; }
if (connector != null && connector.getResourceAdapter() != null) { ManagementResourceRegistration cdefReg = raReg.getSubModel(PathAddress.pathAddress(PathElement.pathElement(Constants.CONNECTIONDEFINITIONS_NAME))); List<ConnectionFactory> connectionFactories = connector.getConnectionFactories(); if (connectionFactories != null) { // code reads that it won't be null but it's not documented, so... for (ConnectionFactory cf : connectionFactories) { cdefReg.unregisterOverrideModel(cf.getJndiName()); List<AdminObject> adminObjects = connector.getAdminObjects(); if (adminObjects != null) { // code reads that it won't be null but it's not documented, so... ManagementResourceRegistration aoReg = raReg.getSubModel(PathAddress.pathAddress(PathElement.pathElement(Constants.ADMIN_OBJECTS_NAME))); aoReg.unregisterOverrideModel(ao.getJndiName());
protected List<PoolConfiguration> getMatchingPoolConfigs(String poolName, ManagementRepository repository) { ArrayList<PoolConfiguration> result = new ArrayList<PoolConfiguration>(repository.getDataSources().size()); if (repository.getDataSources() != null) { for (DataSource ds : repository.getDataSources()) { if (poolName.equalsIgnoreCase(ds.getPool().getName())) { result.add(ds.getPoolConfiguration()); } } } result.trimToSize(); return result; }
PathElement peExtendedStats = PathElement.pathElement(Constants.STATISTICS_NAME, "extended"); if (deploymentMD.getConnector() != null && deploymentMD.getConnector().getConnectionFactories() != null) { for (ConnectionFactory cf : deploymentMD.getConnector().getConnectionFactories()) { if (cf.getManagedConnectionFactory() != null && cf.getManagedConnectionFactory().getStatistics() != null) { StatisticsPlugin extendStats = cf.getManagedConnectionFactory().getStatistics(); extendStats.setEnabled(statsEnabled); if (extendStats.getNames().size() != 0) {
@Override protected boolean applyUpdateToRuntime(final OperationContext context, final ModelNode operation, final String parameterName, final ModelNode newValue, final ModelNode currentValue, final HandbackHolder<List<DataSource>> handbackHolder) throws OperationFailedException { final String jndiName = context.readResource(PathAddress.EMPTY_ADDRESS).getModel().get(Constants.JNDI_NAME.getName()).asString(); final ServiceController<?> managementRepoService = context.getServiceRegistry(false).getService( ConnectorServices.MANAGEMENT_REPOSITORY_SERVICE); Boolean boolValue = Constants.ENLISTMENT_TRACE.resolveValue(context, newValue).asBoolean(); try { final ManagementRepository repository = (ManagementRepository) managementRepoService.getValue(); if (repository.getDataSources() != null) { for (DataSource dataSource : repository.getDataSources()) { if (jndiName.equalsIgnoreCase(dataSource.getJndiName())) { dataSource.setEnlistmentTrace(boolValue); } } List<DataSource> list = new ArrayList<>(); for (DataSource ds : repository.getDataSources()) { if (jndiName.equalsIgnoreCase(ds.getJndiName())) { list.add(ds); } } handbackHolder.setHandback(list); } } catch (Exception e) { throw new OperationFailedException(ConnectorLogger.ROOT_LOGGER.failedToSetAttribute(e.getLocalizedMessage())); } return false; }
@Override protected boolean applyUpdateToRuntime(final OperationContext context, final ModelNode operation, final String parameterName, final ModelNode newValue, final ModelNode currentValue, final HandbackHolder<List<ConnectionManager>> handbackHolder) throws OperationFailedException { final String jndiName = context.readResource(PathAddress.EMPTY_ADDRESS).getModel().get(Constants.JNDINAME.getName()).asString(); final ServiceController<?> managementRepoService = context.getServiceRegistry(false).getService( ConnectorServices.MANAGEMENT_REPOSITORY_SERVICE); Boolean boolValue = Constants.ENLISTMENT_TRACE.resolveValue(context, newValue).asBoolean(); try { final ManagementRepository repository = (ManagementRepository) managementRepoService.getValue(); if (repository.getConnectors() != null) { List<ConnectionManager> handback = new LinkedList<>(); for (Connector connector : repository.getConnectors()) { for (ConnectionManager cm : connector.getConnectionManagers()) { if (jndiName.equalsIgnoreCase(cm.getUniqueId())) { cm.setEnlistmentTrace(boolValue); handback.add(cm); } } } handbackHolder.setHandback(handback); } } catch (Exception e) { throw new OperationFailedException(ConnectorLogger.ROOT_LOGGER.failedToSetAttribute(e.getLocalizedMessage())); } return false; }
StatisticsPlugin jdbcStats = deploymentMD.getDataSources()[0].getStatistics(); StatisticsPlugin poolStats = deploymentMD.getDataSources()[0].getPool().getStatistics(); jdbcStats.setEnabled(statsEnabled); poolStats.setEnabled(statsEnabled);
value = new ResourceAdapterDeployment(deploymentMD, raName, raServiceName); registry.getValue().registerResourceAdapterDeployment(value); managementRepository.getValue().getConnectors().add(value.getDeployment().getConnector());
@Override public void start(StartContext context) throws StartException { ROOT_LOGGER.debugf("Starting ResourceAdapterStatusicService"); synchronized (this) { PathElement peExtendedStats = PathElement.pathElement(Constants.STATISTICS_NAME, "extended"); final CommonDeployment deploymentMD = deployment.getValue().getDeployment(); if (deploymentMD.getConnector() != null && deploymentMD.getConnector().getResourceAdapter() != null && deploymentMD.getConnector().getResourceAdapter().getStatistics() != null) { StatisticsPlugin raStats = deploymentMD.getConnector().getResourceAdapter().getStatistics(); raStats.setEnabled(statsEnabled); overrideRegistration.registerSubModel(new StatisticsResourceDefinition(peExtendedStats, CommonAttributes.RESOURCE_NAME, raStats)); } } }
@Override public void start(StartContext context) throws StartException { ROOT_LOGGER.debugf("Starting ResourceAdapterStatusicService"); synchronized (this) { final CommonDeployment deploymentMD = deployment.getValue().getDeployment(); PathElement peExtendedStats = PathElement.pathElement(Constants.STATISTICS_NAME, "extended"); if (deploymentMD.getConnector() != null && deploymentMD.getConnector().getAdminObjects() != null) { for (AdminObject ao : deploymentMD.getConnector().getAdminObjects()) { if (ao.getStatistics() != null) { StatisticsPlugin extendStats = ao.getStatistics(); extendStats.setEnabled(statsEnabled); if (extendStats.getNames().size() != 0) { if (extendStats.getNames().size() != 0 && overrideRegistration.getSubModel(PathAddress.pathAddress(peExtendedStats)) == null) { overrideRegistration.registerSubModel(new StatisticsResourceDefinition(peExtendedStats, CommonAttributes.RESOURCE_NAME, extendStats)); } } } } } } }
managementRepositoryValue.getValue().getDataSources().remove(mgtDs);
@Override protected void revertUpdateToRuntime(OperationContext context, ModelNode operation, String parameterName, ModelNode valueToRestore, ModelNode valueToRevert, List<DataSource> handback) throws OperationFailedException { Boolean value = Constants.ENLISTMENT_TRACE.resolveValue(context, valueToRestore).asBoolean(); if (handback != null) { for (DataSource ds : handback) { ds.setEnlistmentTrace(value); } } }
@Override protected void revertUpdateToRuntime(OperationContext context, ModelNode operation, String parameterName, ModelNode valueToRestore, ModelNode valueToRevert, List<ConnectionManager> handback) throws OperationFailedException { Boolean value = Constants.ENLISTMENT_TRACE.resolveValue(context, valueToRestore).asBoolean(); if (handback != null) { for (ConnectionManager ds : handback) { ds.setEnlistmentTrace(value); } } }
ServiceName raServiceName = ConnectorServices.getResourceAdapterServiceName(deploymentName); value = new ResourceAdapterDeployment(raDeployment, deploymentName, raServiceName); managementRepository.getValue().getConnectors().add(value.getDeployment().getConnector()); registry.getValue().registerResourceAdapterDeployment(value); ServiceTarget serviceTarget = context.getChildTarget();
managementRepository.getValue().getConnectors().add(value.getDeployment().getConnector()); registry.getValue().registerResourceAdapterDeployment(value); final ServiceBuilder raServiceSB = context.getChildTarget()
managementRepository.getValue().getConnectors().remove(value.getDeployment().getConnector());