use of org.jboss.jca.common.api.metadata.resourceadapter.Activation in project wildfly by wildfly.
the class AdminObjectAdd method performRuntime.
@Override
protected void performRuntime(OperationContext context, ModelNode operation, final Resource resource) throws OperationFailedException {
final ModelNode address = operation.require(OP_ADDR);
PathAddress path = PathAddress.pathAddress(address);
final String raName = context.getCurrentAddress().getParent().getLastElement().getValue();
final String archiveOrModuleName;
ModelNode raModel = context.readResourceFromRoot(path.subAddress(0, path.size() - 1)).getModel();
final boolean statsEnabled = STATISTICS_ENABLED.resolveModelAttribute(context, raModel).asBoolean();
if (!raModel.hasDefined(ARCHIVE.getName()) && !raModel.hasDefined(MODULE.getName())) {
throw ConnectorLogger.ROOT_LOGGER.archiveOrModuleRequired();
}
if (raModel.get(ARCHIVE.getName()).isDefined()) {
archiveOrModuleName = ARCHIVE.resolveModelAttribute(context, raModel).asString();
} else {
archiveOrModuleName = MODULE.resolveModelAttribute(context, raModel).asString();
}
final String poolName = PathAddress.pathAddress(address).getLastElement().getValue();
final ModifiableAdminObject adminObjectValue;
try {
adminObjectValue = RaOperationUtil.buildAdminObjects(context, operation, poolName);
} catch (ValidateException e) {
throw new OperationFailedException(e, new ModelNode().set(ConnectorLogger.ROOT_LOGGER.failedToCreate("AdminObject", operation, e.getLocalizedMessage())));
}
ServiceName serviceName = ServiceName.of(ConnectorServices.RA_SERVICE, raName, poolName);
ServiceName raServiceName = ServiceName.of(ConnectorServices.RA_SERVICE, raName);
final ServiceTarget serviceTarget = context.getServiceTarget();
final AdminObjectService service = new AdminObjectService(adminObjectValue);
serviceTarget.addService(serviceName, service).setInitialMode(ServiceController.Mode.ACTIVE).addDependency(raServiceName, ModifiableResourceAdapter.class, service.getRaInjector()).install();
ServiceRegistry registry = context.getServiceRegistry(true);
final ServiceController<?> RaxmlController = registry.getService(ServiceName.of(ConnectorServices.RA_SERVICE, raName));
Activation raxml = (Activation) RaxmlController.getValue();
ServiceName deploymentServiceName = ConnectorServices.getDeploymentServiceName(archiveOrModuleName, raName);
String bootStrapCtxName = DEFAULT_NAME;
if (raxml.getBootstrapContext() != null && !raxml.getBootstrapContext().equals("undefined")) {
bootStrapCtxName = raxml.getBootstrapContext();
}
AdminObjectStatisticsService adminObjectStatisticsService = new AdminObjectStatisticsService(context.getResourceRegistrationForUpdate(), poolName, statsEnabled);
ServiceBuilder statsServiceBuilder = serviceTarget.addService(serviceName.append(ConnectorServices.STATISTICS_SUFFIX), adminObjectStatisticsService);
statsServiceBuilder.addDependency(ConnectorServices.BOOTSTRAP_CONTEXT_SERVICE.append(bootStrapCtxName), adminObjectStatisticsService.getBootstrapContextInjector()).addDependency(deploymentServiceName, adminObjectStatisticsService.getResourceAdapterDeploymentInjector()).setInitialMode(ServiceController.Mode.PASSIVE).install();
PathElement peAO = PathElement.pathElement(Constants.STATISTICS_NAME, "extended");
final Resource aoResource = new IronJacamarResource.IronJacamarRuntimeResource();
resource.registerChild(peAO, aoResource);
}
use of org.jboss.jca.common.api.metadata.resourceadapter.Activation in project wildfly by wildfly.
the class IronJacamarDeploymentParsingProcessor method process.
public static IronJacamarXmlDescriptor process(VirtualFile deploymentRoot, boolean resolveProperties) throws DeploymentUnitProcessingException {
IronJacamarXmlDescriptor xmlDescriptor = null;
if (deploymentRoot == null || !deploymentRoot.exists())
return null;
final String deploymentRootName = deploymentRoot.getName().toLowerCase(Locale.ENGLISH);
VirtualFile serviceXmlFile = null;
if (deploymentRootName.endsWith(".rar")) {
serviceXmlFile = deploymentRoot.getChild("/META-INF/ironjacamar.xml");
}
if (serviceXmlFile == null || !serviceXmlFile.exists())
return null;
InputStream xmlStream = null;
Activation result = null;
try {
xmlStream = serviceXmlFile.openStream();
IronJacamarParser ironJacamarParser = new IronJacamarParser();
ironJacamarParser.setSystemPropertiesResolved(resolveProperties);
result = ironJacamarParser.parse(xmlStream);
if (result != null) {
xmlDescriptor = new IronJacamarXmlDescriptor(result);
} else
throw ConnectorLogger.ROOT_LOGGER.failedToParseServiceXml(serviceXmlFile);
} catch (Exception e) {
throw ConnectorLogger.ROOT_LOGGER.failedToParseServiceXml(e, serviceXmlFile);
} finally {
VFSUtils.safeClose(xmlStream);
}
return xmlDescriptor;
}
use of org.jboss.jca.common.api.metadata.resourceadapter.Activation in project wildfly by wildfly.
the class ParsedRaDeploymentProcessor method process.
public static ServiceBuilder<ResourceAdapterDeployment> process(final ConnectorXmlDescriptor connectorXmlDescriptor, final IronJacamarXmlDescriptor ironJacamarXmlDescriptor, final ClassLoader classLoader, final ServiceTarget serviceTarget, final Map<ResourceRoot, Index> annotationIndexes, final ServiceName duServiceName, final ManagementResourceRegistration registration, Resource deploymentResource) throws DeploymentUnitProcessingException {
Connector cmd = connectorXmlDescriptor != null ? connectorXmlDescriptor.getConnector() : null;
final Activation activation = ironJacamarXmlDescriptor != null ? ironJacamarXmlDescriptor.getIronJacamar() : null;
try {
// Annotation merging
Annotations annotator = new Annotations();
if (annotationIndexes != null && annotationIndexes.size() > 0) {
DEPLOYMENT_CONNECTOR_LOGGER.debugf("ParsedRaDeploymentProcessor: Found %d annotationIndexes", annotationIndexes.size());
for (Index index : annotationIndexes.values()) {
// Don't apply any empty indexes, as IronJacamar doesn't like that atm.
if (index.getKnownClasses() != null && index.getKnownClasses().size() > 0) {
AnnotationRepository repository = new JandexAnnotationRepositoryImpl(index, classLoader);
cmd = annotator.merge(cmd, repository, classLoader);
DEPLOYMENT_CONNECTOR_LOGGER.debugf("ParsedRaDeploymentProcessor: CMD=%s", cmd);
}
}
}
if (annotationIndexes == null || annotationIndexes.size() == 0)
DEPLOYMENT_CONNECTOR_LOGGER.debugf("ParsedRaDeploymentProcessor: Found 0 annotationIndexes");
// FIXME: when the connector is null the Iron Jacamar data is ignored
if (cmd != null) {
// Validate metadata
cmd.validate();
// Merge metadata
cmd = (new Merger()).mergeConnectorWithCommonIronJacamar(activation, cmd);
}
TransactionSupportEnum transactionSupport = TransactionSupportEnum.NoTransaction;
if (cmd != null && cmd.getResourceadapter() != null && cmd.getResourceadapter().getOutboundResourceadapter() != null) {
transactionSupport = cmd.getResourceadapter().getOutboundResourceadapter().getTransactionSupport();
}
if (activation != null && activation.getTransactionSupport() != null) {
transactionSupport = activation.getTransactionSupport();
}
final ServiceName deployerServiceName = ConnectorServices.RESOURCE_ADAPTER_DEPLOYER_SERVICE_PREFIX.append(connectorXmlDescriptor.getDeploymentName());
final ResourceAdapterDeploymentService raDeploymentService = new ResourceAdapterDeploymentService(connectorXmlDescriptor, cmd, activation, classLoader, deployerServiceName, duServiceName, registration, deploymentResource);
// Create the service
ServiceBuilder<ResourceAdapterDeployment> builder = Services.addServerExecutorDependency(serviceTarget.addService(deployerServiceName, raDeploymentService), raDeploymentService.getExecutorServiceInjector(), false).addDependency(ConnectorServices.IRONJACAMAR_MDR, AS7MetadataRepository.class, raDeploymentService.getMdrInjector()).addDependency(ConnectorServices.RA_REPOSITORY_SERVICE, ResourceAdapterRepository.class, raDeploymentService.getRaRepositoryInjector()).addDependency(ConnectorServices.MANAGEMENT_REPOSITORY_SERVICE, ManagementRepository.class, raDeploymentService.getManagementRepositoryInjector()).addDependency(ConnectorServices.RESOURCE_ADAPTER_REGISTRY_SERVICE, ResourceAdapterDeploymentRegistry.class, raDeploymentService.getRegistryInjector()).addDependency(ConnectorServices.TRANSACTION_INTEGRATION_SERVICE, TransactionIntegration.class, raDeploymentService.getTxIntegrationInjector()).addDependency(ConnectorServices.CONNECTOR_CONFIG_SERVICE, JcaSubsystemConfiguration.class, raDeploymentService.getConfigInjector()).addDependency(ConnectorServices.IDLE_REMOVER_SERVICE).addDependency(ConnectorServices.CONNECTION_VALIDATOR_SERVICE).addDependency(NamingService.SERVICE_NAME);
if (transactionSupport == null || transactionSupport.equals(TransactionSupportEnum.NoTransaction)) {
builder.addDependency(ConnectorServices.NON_TX_CCM_SERVICE, CachedConnectionManager.class, raDeploymentService.getCcmInjector());
} else {
builder.addDependency(ConnectorServices.CCM_SERVICE, CachedConnectionManager.class, raDeploymentService.getCcmInjector());
}
if (activation != null && ActivationSecurityUtil.isLegacySecurityRequired(activation)) {
builder.addDependency(SubjectFactoryService.SERVICE_NAME, SubjectFactory.class, raDeploymentService.getSubjectFactoryInjector()).addDependency(SimpleSecurityManagerService.SERVICE_NAME, ServerSecurityManager.class, raDeploymentService.getServerSecurityManager());
}
return builder;
} catch (Throwable t) {
throw new DeploymentUnitProcessingException(t);
}
}
use of org.jboss.jca.common.api.metadata.resourceadapter.Activation in project wildfly by wildfly.
the class DirectAdminObjectActivatorService method start.
@Override
public void start(StartContext context) throws StartException {
ROOT_LOGGER.debugf("started DirectConnectionFactoryActivatorService %s", context.getController().getName());
String aoClass = null;
try {
Connector cmd = mdr.getValue().getResourceAdapter(raId);
if (cmd.getVersion() == Connector.Version.V_10) {
throw ConnectorLogger.ROOT_LOGGER.adminObjectForJCA10(resourceAdapter, jndiName);
} else {
ResourceAdapter ra1516 = (ResourceAdapter) cmd.getResourceadapter();
if (ra1516.getAdminObjects() != null) {
for (AdminObject ao : ra1516.getAdminObjects()) {
if (ao.getAdminobjectClass().getValue().equals(className))
aoClass = ao.getAdminobjectClass().getValue();
}
}
}
if (aoClass == null || !aoClass.equals(className)) {
throw ConnectorLogger.ROOT_LOGGER.invalidAdminObject(aoClass, resourceAdapter, jndiName);
}
Map<String, String> raConfigProperties = new HashMap<String, String>();
Map<String, String> aoConfigProperties = new HashMap<String, String>();
if (properties != null) {
for (Map.Entry<String, String> prop : properties.entrySet()) {
String key = prop.getKey();
String value = prop.getValue();
if (key.startsWith("ra.")) {
raConfigProperties.put(key.substring(3), value);
} else if (key.startsWith("ao.")) {
aoConfigProperties.put(key.substring(3), value);
} else {
aoConfigProperties.put(key, value);
}
}
}
org.jboss.jca.common.api.metadata.resourceadapter.AdminObject ao = new AdminObjectImpl(aoConfigProperties, aoClass, jndiName, poolName(aoClass, className), Boolean.TRUE, Boolean.TRUE);
Activation activation = new ActivationImpl(null, null, TransactionSupportEnum.LocalTransaction, Collections.<ConnectionDefinition>emptyList(), Collections.singletonList(ao), null, Collections.<String>emptyList(), null, null);
String serviceName = jndiName;
serviceName = serviceName.replace(':', '_');
serviceName = serviceName.replace('/', '_');
ResourceAdapterActivatorService activator = new ResourceAdapterActivatorService(cmd, activation, module.getClassLoader(), serviceName);
activator.setCreateBinderService(false);
activator.setBindInfo(bindInfo);
ServiceTarget serviceTarget = context.getChildTarget();
ServiceBuilder adminObjectServiceBuilder = serviceTarget.addService(ConnectorServices.RESOURCE_ADAPTER_ACTIVATOR_SERVICE.append(serviceName), activator).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"));
adminObjectServiceBuilder.setInitialMode(ServiceController.Mode.ACTIVE).install();
} catch (Exception e) {
throw new StartException(e);
}
}
use of org.jboss.jca.common.api.metadata.resourceadapter.Activation in project wildfly by wildfly.
the class DirectConnectionFactoryActivatorService method start.
@Override
public void start(org.jboss.msc.service.StartContext context) throws org.jboss.msc.service.StartException {
ROOT_LOGGER.debugf("started DirectConnectionFactoryActivatorService %s", context.getController().getName());
String cfInterface = null;
try {
Connector cmd = mdr.getValue().getResourceAdapter(raId);
ResourceAdapter ra = cmd.getResourceadapter();
if (ra.getOutboundResourceadapter() != null) {
for (ConnectionDefinition cd : ra.getOutboundResourceadapter().getConnectionDefinitions()) {
if (cd.getConnectionFactoryInterface().getValue().equals(interfaceName))
cfInterface = cd.getConnectionFactoryInterface().getValue();
}
}
if (cfInterface == null || !cfInterface.equals(interfaceName)) {
throw ConnectorLogger.ROOT_LOGGER.invalidConnectionFactory(cfInterface, resourceAdapter, jndiName);
}
Map<String, String> raConfigProperties = new HashMap<String, String>();
Map<String, String> mcfConfigProperties = new HashMap<String, String>();
String securitySetting = null;
String securitySettingDomain = null;
boolean elytronEnabled = false;
if (properties != null) {
for (Map.Entry<String, String> prop : properties.entrySet()) {
String key = prop.getKey();
String value = prop.getValue();
if (key.equals("ironjacamar.security")) {
securitySetting = value;
} else if (key.equals("ironjacamar.security.elytron") && value.equals("true")) {
elytronEnabled = true;
} else if (key.equals("ironjacamar.security.elytron-authentication-context")) {
securitySettingDomain = value;
elytronEnabled = true;
} else if (key.equals("ironjacamar.security.domain")) {
securitySettingDomain = value;
} else {
if (key.startsWith("ra.")) {
raConfigProperties.put(key.substring(3), value);
} else if (key.startsWith("mcf.")) {
mcfConfigProperties.put(key.substring(4), value);
} else {
mcfConfigProperties.put(key, value);
}
}
}
}
String mcfClass = null;
if (ra.getOutboundResourceadapter() != null) {
for (ConnectionDefinition cd : ra.getOutboundResourceadapter().getConnectionDefinitions()) {
if (cd.getConnectionFactoryInterface().getValue().equals(cfInterface))
mcfClass = cd.getManagedConnectionFactoryClass().getValue();
}
}
Security security = null;
if (securitySetting != null) {
if ("".equals(securitySetting)) {
security = new SecurityImpl(null, null, false, false);
} else if ("application".equals(securitySetting)) {
security = new SecurityImpl(null, null, true, false);
} else if ("domain".equals(securitySetting) && securitySettingDomain != null) {
security = new SecurityImpl(securitySettingDomain, null, false, elytronEnabled);
} else if ("domain-and-application".equals(securitySetting) && securitySettingDomain != null) {
security = new SecurityImpl(null, securitySettingDomain, false, elytronEnabled);
}
}
if (security == null) {
SUBSYSTEM_RA_LOGGER.noSecurityDefined(jndiName);
}
Pool pool = null;
Boolean isXA = Boolean.FALSE;
if (transactionSupport == TransactionSupport.TransactionSupportLevel.XATransaction) {
pool = new XaPoolImpl(minPoolSize < 0 ? Defaults.MIN_POOL_SIZE : minPoolSize, Defaults.INITIAL_POOL_SIZE, maxPoolSize < 0 ? Defaults.MAX_POOL_SIZE : maxPoolSize, Defaults.PREFILL, Defaults.USE_STRICT_MIN, Defaults.FLUSH_STRATEGY, null, Defaults.FAIR, Defaults.IS_SAME_RM_OVERRIDE, Defaults.INTERLEAVING, Defaults.PAD_XID, Defaults.WRAP_XA_RESOURCE, Defaults.NO_TX_SEPARATE_POOL);
isXA = Boolean.TRUE;
} else {
pool = new PoolImpl(minPoolSize < 0 ? Defaults.MIN_POOL_SIZE : minPoolSize, Defaults.INITIAL_POOL_SIZE, maxPoolSize < 0 ? Defaults.MAX_POOL_SIZE : maxPoolSize, Defaults.PREFILL, Defaults.USE_STRICT_MIN, Defaults.FLUSH_STRATEGY, null, Defaults.FAIR);
}
TransactionSupportEnum transactionSupportValue = TransactionSupportEnum.NoTransaction;
if (transactionSupport == TransactionSupport.TransactionSupportLevel.XATransaction) {
transactionSupportValue = TransactionSupportEnum.XATransaction;
} else if (transactionSupport == TransactionSupport.TransactionSupportLevel.LocalTransaction) {
transactionSupportValue = TransactionSupportEnum.LocalTransaction;
}
org.jboss.jca.common.api.metadata.resourceadapter.ConnectionDefinition cd = new org.jboss.jca.common.metadata.resourceadapter.ConnectionDefinitionImpl(mcfConfigProperties, mcfClass, jndiName, poolName(cfInterface), Boolean.TRUE, Boolean.TRUE, Boolean.TRUE, Boolean.TRUE, Boolean.TRUE, Defaults.CONNECTABLE, Defaults.TRACKING, Defaults.MCP, Defaults.ENLISTMENT_TRACE, pool, null, null, security, null, isXA);
Activation activation = new ActivationImpl(null, null, transactionSupportValue, Collections.singletonList(cd), Collections.<AdminObject>emptyList(), raConfigProperties, Collections.<String>emptyList(), null, null);
String serviceName = jndiName;
serviceName = serviceName.replace(':', '_');
serviceName = serviceName.replace('/', '_');
ResourceAdapterActivatorService activator = new ResourceAdapterActivatorService(cmd, activation, module.getClassLoader(), serviceName);
activator.setCreateBinderService(false);
activator.setBindInfo(bindInfo);
org.jboss.msc.service.ServiceTarget serviceTarget = context.getChildTarget();
org.jboss.msc.service.ServiceName activatorServiceName = ConnectorServices.RESOURCE_ADAPTER_ACTIVATOR_SERVICE.append(serviceName);
org.jboss.msc.service.ServiceBuilder connectionFactoryServiceBuilder = serviceTarget.addService(activatorServiceName, activator).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.CONNECTOR_CONFIG_SERVICE, JcaSubsystemConfiguration.class, activator.getConfigInjector()).addDependency(ConnectorServices.CCM_SERVICE, CachedConnectionManager.class, activator.getCcmInjector()).addDependency(NamingService.SERVICE_NAME).addDependency(ConnectorServices.TRANSACTION_INTEGRATION_SERVICE, TransactionIntegration.class, activator.getTxIntegrationInjector()).addDependency(TxnServices.JBOSS_TXN_TRANSACTION_MANAGER).addDependency(ConnectorServices.BOOTSTRAP_CONTEXT_SERVICE.append("default"));
if (ActivationSecurityUtil.isLegacySecurityRequired(security)) {
connectionFactoryServiceBuilder.addDependency(SubjectFactoryService.SERVICE_NAME, SubjectFactory.class, activator.getSubjectFactoryInjector()).addDependency(SimpleSecurityManagerService.SERVICE_NAME, ServerSecurityManager.class, activator.getServerSecurityManager());
}
connectionFactoryServiceBuilder.setInitialMode(org.jboss.msc.service.ServiceController.Mode.ACTIVE).install();
} catch (Exception e) {
throw new org.jboss.msc.service.StartException(e);
}
}
Aggregations