use of org.jboss.as.connector.metadata.xmldescriptors.IronJacamarXmlDescriptor in project wildfly by wildfly.
the class IronJacamarDeploymentParsingProcessor method deploy.
/**
* Process a deployment for iron-jacamar.xml files. Will parse the xml file
* and attach metadata discovered during processing.
*
* @param phaseContext the deployment unit context
* @throws DeploymentUnitProcessingException
*/
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
final ResourceRoot resourceRoot = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT);
final VirtualFile deploymentRoot = resourceRoot.getRoot();
final boolean resolveProperties = Util.shouldResolveJBoss(deploymentUnit);
IronJacamarXmlDescriptor xmlDescriptor = process(deploymentRoot, resolveProperties);
if (xmlDescriptor != null) {
deploymentUnit.putAttachment(IronJacamarXmlDescriptor.ATTACHMENT_KEY, xmlDescriptor);
}
}
use of org.jboss.as.connector.metadata.xmldescriptors.IronJacamarXmlDescriptor in project wildfly by wildfly.
the class ParsedRaDeploymentProcessor method deploy.
/**
* Process a deployment for a Connector. Will install a {@Code
* JBossService} for this ResourceAdapter.
*
* @param phaseContext the deployment unit context
* @throws DeploymentUnitProcessingException
*
*/
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final ConnectorXmlDescriptor connectorXmlDescriptor = phaseContext.getDeploymentUnit().getAttachment(ConnectorXmlDescriptor.ATTACHMENT_KEY);
final ManagementResourceRegistration registration;
final ManagementResourceRegistration baseRegistration = phaseContext.getDeploymentUnit().getAttachment(DeploymentModelUtils.MUTABLE_REGISTRATION_ATTACHMENT);
final Resource deploymentResource = phaseContext.getDeploymentUnit().getAttachment(DeploymentModelUtils.DEPLOYMENT_RESOURCE);
if (connectorXmlDescriptor == null) {
return;
}
final ServiceTarget serviceTarget = phaseContext.getServiceTarget();
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
if (deploymentUnit.getParent() != null) {
registration = baseRegistration.getSubModel(PathAddress.pathAddress(PathElement.pathElement("subdeployment")));
} else {
registration = baseRegistration;
}
final IronJacamarXmlDescriptor ironJacamarXmlDescriptor = deploymentUnit.getAttachment(IronJacamarXmlDescriptor.ATTACHMENT_KEY);
final Module module = deploymentUnit.getAttachment(Attachments.MODULE);
if (module == null)
throw ConnectorLogger.ROOT_LOGGER.failedToGetModuleAttachment(phaseContext.getDeploymentUnit());
DEPLOYMENT_CONNECTOR_LOGGER.debugf("ParsedRaDeploymentProcessor: Processing=%s", deploymentUnit);
final ClassLoader classLoader = module.getClassLoader();
Map<ResourceRoot, Index> annotationIndexes = AnnotationIndexUtils.getAnnotationIndexes(deploymentUnit);
ServiceBuilder builder = process(connectorXmlDescriptor, ironJacamarXmlDescriptor, classLoader, serviceTarget, annotationIndexes, deploymentUnit.getServiceName(), registration, deploymentResource);
if (builder != null) {
String bootstrapCtx = null;
if (ironJacamarXmlDescriptor != null && ironJacamarXmlDescriptor.getIronJacamar() != null && ironJacamarXmlDescriptor.getIronJacamar().getBootstrapContext() != null)
bootstrapCtx = ironJacamarXmlDescriptor.getIronJacamar().getBootstrapContext();
if (bootstrapCtx == null)
bootstrapCtx = "default";
//Register an empty override model regardless of we're enabled or not - the statistics listener will add the relevant childresources
if (registration.isAllowsOverride() && registration.getOverrideModel(deploymentUnit.getName()) == null) {
registration.registerOverrideModel(deploymentUnit.getName(), new OverrideDescriptionProvider() {
@Override
public Map<String, ModelNode> getAttributeOverrideDescriptions(Locale locale) {
return Collections.emptyMap();
}
@Override
public Map<String, ModelNode> getChildTypeOverrideDescriptions(Locale locale) {
return Collections.emptyMap();
}
});
}
builder.setInitialMode(Mode.ACTIVE).install();
}
}
use of org.jboss.as.connector.metadata.xmldescriptors.IronJacamarXmlDescriptor in project wildfly by wildfly.
the class RaOperationUtil method installRaServicesAndDeployFromModule.
public static void installRaServicesAndDeployFromModule(OperationContext context, String name, ModifiableResourceAdapter resourceAdapter, String fullModuleName, final List<ServiceController<?>> newControllers) throws OperationFailedException {
ServiceName raServiceName = installRaServices(context, name, resourceAdapter, newControllers);
final boolean resolveProperties = true;
final ServiceTarget serviceTarget = context.getServiceTarget();
final String moduleName;
//load module
String slot = "main";
if (fullModuleName.contains(":")) {
slot = fullModuleName.substring(fullModuleName.indexOf(":") + 1);
moduleName = fullModuleName.substring(0, fullModuleName.indexOf(":"));
} else {
moduleName = fullModuleName;
}
Module module;
try {
ModuleIdentifier moduleId = ModuleIdentifier.create(moduleName, slot);
module = Module.getCallerModuleLoader().loadModule(moduleId);
} catch (ModuleLoadException e) {
throw new OperationFailedException(ConnectorLogger.ROOT_LOGGER.failedToLoadModuleRA(moduleName), e);
}
URL path = module.getExportedResource("META-INF/ra.xml");
Closeable closable = null;
try {
VirtualFile child;
if (path.getPath().contains("!")) {
throw new OperationFailedException(ConnectorLogger.ROOT_LOGGER.compressedRarNotSupportedInModuleRA(moduleName));
} else {
child = VFS.getChild(path.getPath().split("META-INF")[0]);
closable = VFS.mountReal(new File(path.getPath().split("META-INF")[0]), child);
}
//final Closeable closable = VFS.mountZip((InputStream) new JarInputStream(new FileInputStream(path.getPath().split("!")[0].split(":")[1])), path.getPath().split("!")[0].split(":")[1], child, TempFileProviderService.provider());
final MountHandle mountHandle = new MountHandle(closable);
final ResourceRoot resourceRoot = new ResourceRoot(child, mountHandle);
final VirtualFile deploymentRoot = resourceRoot.getRoot();
if (deploymentRoot == null || !deploymentRoot.exists())
return;
ConnectorXmlDescriptor connectorXmlDescriptor = RaDeploymentParsingProcessor.process(resolveProperties, deploymentRoot, null, name);
IronJacamarXmlDescriptor ironJacamarXmlDescriptor = IronJacamarDeploymentParsingProcessor.process(deploymentRoot, resolveProperties);
RaNativeProcessor.process(deploymentRoot);
Map<ResourceRoot, Index> annotationIndexes = new HashMap<ResourceRoot, Index>();
ResourceRootIndexer.indexResourceRoot(resourceRoot);
Index index = resourceRoot.getAttachment(Attachments.ANNOTATION_INDEX);
if (index != null) {
annotationIndexes.put(resourceRoot, index);
}
if (ironJacamarXmlDescriptor != null) {
ConnectorLogger.SUBSYSTEM_RA_LOGGER.forceIJToNull();
ironJacamarXmlDescriptor = null;
}
final ServiceName deployerServiceName = ConnectorServices.RESOURCE_ADAPTER_DEPLOYER_SERVICE_PREFIX.append(connectorXmlDescriptor.getDeploymentName());
final ServiceController<?> deployerService = context.getServiceRegistry(true).getService(deployerServiceName);
if (deployerService == null) {
ServiceBuilder builder = ParsedRaDeploymentProcessor.process(connectorXmlDescriptor, ironJacamarXmlDescriptor, module.getClassLoader(), serviceTarget, annotationIndexes, RAR_MODULE.append(name), null, null);
newControllers.add(builder.addDependency(raServiceName).setInitialMode(ServiceController.Mode.ACTIVE).install());
}
String rarName = resourceAdapter.getArchive();
if (fullModuleName.equals(rarName)) {
ServiceName serviceName = ConnectorServices.INACTIVE_RESOURCE_ADAPTER_SERVICE.append(name);
InactiveResourceAdapterDeploymentService service = new InactiveResourceAdapterDeploymentService(connectorXmlDescriptor, module, name, name, RAR_MODULE.append(name), null, serviceTarget, null);
newControllers.add(serviceTarget.addService(serviceName, service).setInitialMode(ServiceController.Mode.ACTIVE).install());
}
} catch (Exception e) {
throw new OperationFailedException(ConnectorLogger.ROOT_LOGGER.failedToLoadModuleRA(moduleName), e);
} finally {
if (closable != null) {
try {
closable.close();
} catch (IOException e) {
}
}
}
}
use of org.jboss.as.connector.metadata.xmldescriptors.IronJacamarXmlDescriptor 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;
}
Aggregations