use of org.jboss.jca.common.api.metadata.resourceadapter.Activation in project wildfly by wildfly.
the class PooledConnectionFactoryService method createService.
private void createService(ServiceTarget serviceTarget, ServiceContainer container) throws Exception {
InputStream is = null;
InputStream isIj = null;
List<ConfigProperty> properties = new ArrayList<ConfigProperty>();
try {
StringBuilder connectorClassname = new StringBuilder();
StringBuilder connectorParams = new StringBuilder();
// pick the first connector available if pickAnyConnectors is true
if (discoveryGroupName == null && connectors.isEmpty() && pickAnyConnectors) {
Set<String> connectorNames = activeMQServer.getValue().getConfiguration().getConnectorConfigurations().keySet();
if (connectorNames.size() > 0) {
String connectorName = connectorNames.iterator().next();
MessagingLogger.ROOT_LOGGER.connectorForPooledConnectionFactory(name, connectorName);
connectors.add(connectorName);
}
}
for (String connector : connectors) {
TransportConfiguration tc = activeMQServer.getValue().getConfiguration().getConnectorConfigurations().get(connector);
if (tc == null) {
throw MessagingLogger.ROOT_LOGGER.connectorNotDefined(connector);
}
if (connectorClassname.length() > 0) {
connectorClassname.append(",");
connectorParams.append(",");
}
connectorClassname.append(tc.getFactoryClassName());
Map<String, Object> params = tc.getParams();
boolean multiple = false;
for (Map.Entry<String, Object> entry : params.entrySet()) {
if (multiple) {
connectorParams.append(";");
}
connectorParams.append(entry.getKey()).append("=").append(entry.getValue());
multiple = true;
}
}
if (connectorClassname.length() > 0) {
properties.add(simpleProperty15(CONNECTOR_CLASSNAME, STRING_TYPE, connectorClassname.toString()));
}
if (connectorParams.length() > 0) {
properties.add(simpleProperty15(CONNECTION_PARAMETERS, STRING_TYPE, connectorParams.toString()));
}
if (discoveryGroupName != null) {
DiscoveryGroupConfiguration discoveryGroupConfiguration = activeMQServer.getValue().getConfiguration().getDiscoveryGroupConfigurations().get(discoveryGroupName);
BroadcastEndpointFactory bgCfg = discoveryGroupConfiguration.getBroadcastEndpointFactory();
if (bgCfg instanceof UDPBroadcastEndpointFactory) {
UDPBroadcastEndpointFactory udpCfg = (UDPBroadcastEndpointFactory) bgCfg;
properties.add(simpleProperty15(GROUP_ADDRESS, STRING_TYPE, udpCfg.getGroupAddress()));
properties.add(simpleProperty15(GROUP_PORT, INTEGER_TYPE, "" + udpCfg.getGroupPort()));
properties.add(simpleProperty15(DISCOVERY_LOCAL_BIND_ADDRESS, STRING_TYPE, "" + udpCfg.getLocalBindAddress()));
} else if (bgCfg instanceof ChannelBroadcastEndpointFactory) {
properties.add(simpleProperty15(JGROUPS_CHANNEL_LOCATOR_CLASS, STRING_TYPE, JGroupsChannelLocator.class.getName()));
properties.add(simpleProperty15(JGROUPS_CHANNEL_NAME, STRING_TYPE, jgroupsChannelName));
properties.add(simpleProperty15(JGROUPS_CHANNEL_REF_NAME, STRING_TYPE, serverName + '/' + jgroupsChannelName));
}
properties.add(simpleProperty15(DISCOVERY_INITIAL_WAIT_TIMEOUT, LONG_TYPE, "" + discoveryGroupConfiguration.getDiscoveryInitialWaitTimeout()));
properties.add(simpleProperty15(REFRESH_TIMEOUT, LONG_TYPE, "" + discoveryGroupConfiguration.getRefreshTimeout()));
}
boolean hasReconnect = false;
final List<ConfigProperty> inboundProperties = new ArrayList<>();
final String reconnectName = ConnectionFactoryAttributes.Pooled.RECONNECT_ATTEMPTS_PROP_NAME;
for (PooledConnectionFactoryConfigProperties adapterParam : adapterParams) {
hasReconnect |= reconnectName.equals(adapterParam.getName());
ConfigProperty p = simpleProperty15(adapterParam.getName(), adapterParam.getType(), adapterParam.getValue());
if (adapterParam.getName().equals(REBALANCE_CONNECTIONS_PROP_NAME)) {
boolean rebalanceConnections = Boolean.parseBoolean(adapterParam.getValue());
if (rebalanceConnections) {
inboundProperties.add(p);
}
} else {
properties.add(p);
}
}
// The default -1, which will hang forever until a server appears
if (!hasReconnect) {
properties.add(simpleProperty15(reconnectName, Integer.class.getName(), DEFAULT_MAX_RECONNECTS));
}
WildFlyRecoveryRegistry.container = container;
OutboundResourceAdapter outbound = createOutbound();
InboundResourceAdapter inbound = createInbound(inboundProperties);
ResourceAdapter ra = createResourceAdapter15(properties, outbound, inbound);
Connector cmd = createConnector15(ra);
TransactionSupportEnum transactionSupport = getTransactionSupport(txSupport);
ConnectionDefinition common = createConnDef(transactionSupport, bindInfo.getBindName(), minPoolSize, maxPoolSize, managedConnectionPoolClassName, enlistmentTrace);
Activation activation = createActivation(common, transactionSupport);
ResourceAdapterActivatorService activator = new ResourceAdapterActivatorService(cmd, activation, PooledConnectionFactoryService.class.getClassLoader(), name);
activator.setBindInfo(bindInfo);
activator.setCreateBinderService(createBinderService);
ServiceController<ResourceAdapterDeployment> controller = Services.addServerExecutorDependency(serviceTarget.addService(getResourceAdapterActivatorsServiceName(name), activator), activator.getExecutorServiceInjector(), false).addDependency(ActiveMQActivationService.getServiceName(getActiveMQServiceName(serverName))).addDependency(ConnectorServices.IRONJACAMAR_MDR, AS7MetadataRepository.class, activator.getMdrInjector()).addDependency(ConnectorServices.RA_REPOSITORY_SERVICE, ResourceAdapterRepository.class, activator.getRaRepositoryInjector()).addDependency(ConnectorServices.MANAGEMENT_REPOSITORY_SERVICE, ManagementRepository.class, activator.getManagementRepositoryInjector()).addDependency(ConnectorServices.RESOURCE_ADAPTER_REGISTRY_SERVICE, ResourceAdapterDeploymentRegistry.class, activator.getRegistryInjector()).addDependency(ConnectorServices.TRANSACTION_INTEGRATION_SERVICE, TransactionIntegration.class, activator.getTxIntegrationInjector()).addDependency(ConnectorServices.CONNECTOR_CONFIG_SERVICE, JcaSubsystemConfiguration.class, activator.getConfigInjector()).addDependency(ConnectorServices.CCM_SERVICE, CachedConnectionManager.class, activator.getCcmInjector()).addDependency(NamingService.SERVICE_NAME).addDependency(TxnServices.JBOSS_TXN_TRANSACTION_MANAGER).addDependency(ConnectorServices.BOOTSTRAP_CONTEXT_SERVICE.append("default")).setInitialMode(ServiceController.Mode.PASSIVE).install();
createJNDIAliases(bindInfo, jndiAliases, controller);
// Mock the deployment service to allow it to start
serviceTarget.addService(ConnectorServices.RESOURCE_ADAPTER_DEPLOYER_SERVICE_PREFIX.append(name), Service.NULL).install();
} finally {
if (is != null)
is.close();
if (isIj != null)
isIj.close();
}
}
use of org.jboss.jca.common.api.metadata.resourceadapter.Activation in project wildfly by wildfly.
the class RaOperationUtil method activate.
public static void activate(OperationContext context, String raName, String archiveName) throws OperationFailedException {
ServiceRegistry registry = context.getServiceRegistry(true);
ServiceController<?> inactiveRaController = registry.getService(ConnectorServices.INACTIVE_RESOURCE_ADAPTER_SERVICE.append(archiveName));
if (inactiveRaController == null) {
inactiveRaController = registry.getService(ConnectorServices.INACTIVE_RESOURCE_ADAPTER_SERVICE.append(raName));
if (inactiveRaController == null) {
throw ConnectorLogger.ROOT_LOGGER.RARNotYetDeployed(raName);
}
}
InactiveResourceAdapterDeploymentService.InactiveResourceAdapterDeployment inactive = (InactiveResourceAdapterDeploymentService.InactiveResourceAdapterDeployment) inactiveRaController.getValue();
final ServiceController<?> RaxmlController = registry.getService(ServiceName.of(ConnectorServices.RA_SERVICE, raName));
Activation raxml = (Activation) RaxmlController.getValue();
RaServicesFactory.createDeploymentService(inactive.getRegistration(), inactive.getConnectorXmlDescriptor(), inactive.getModule(), inactive.getServiceTarget(), archiveName, inactive.getDeploymentUnitServiceName(), inactive.getDeployment(), raxml, inactive.getResource(), registry);
}
use of org.jboss.jca.common.api.metadata.resourceadapter.Activation in project wildfly by wildfly.
the class RaOperationUtil method restartIfPresent.
public static ServiceName restartIfPresent(OperationContext context, final String raName, final String id) throws OperationFailedException {
final ServiceName raDeploymentServiceName = ConnectorServices.getDeploymentServiceName(raName, id);
final ServiceRegistry registry = context.getServiceRegistry(true);
ServiceController raServiceController = registry.getService(raDeploymentServiceName);
if (raServiceController != null) {
final org.jboss.msc.service.ServiceController.Mode originalMode = raServiceController.getMode();
raServiceController.addListener(new AbstractServiceListener() {
@Override
public void transition(ServiceController controller, ServiceController.Transition transition) {
switch(transition) {
case STOPPING_to_DOWN:
try {
final ServiceController<?> RaxmlController = registry.getService(ServiceName.of(ConnectorServices.RA_SERVICE, id));
Activation raxml = (Activation) RaxmlController.getValue();
((ResourceAdapterXmlDeploymentService) controller.getService()).setRaxml(raxml);
controller.compareAndSetMode(ServiceController.Mode.NEVER, originalMode);
} finally {
controller.removeListener(this);
}
}
}
@Override
public void listenerAdded(ServiceController controller) {
controller.setMode(ServiceController.Mode.NEVER);
}
});
return raDeploymentServiceName;
} else {
return null;
}
}
Aggregations