use of org.jboss.as.server.deployment.DeploymentUnitProcessingException in project wildfly by wildfly.
the class SingletonComponentDescription method createConfiguration.
@Override
public ComponentConfiguration createConfiguration(final ClassReflectionIndex classIndex, final ClassLoader moduleClassLoader, final ModuleLoader moduleLoader) {
ComponentConfiguration singletonComponentConfiguration = new ComponentConfiguration(this, classIndex, moduleClassLoader, moduleLoader);
// setup the component create service
singletonComponentConfiguration.setComponentCreateServiceFactory(new SingletonComponentCreateServiceFactory(this.isInitOnStartup(), dependsOn));
if (isExplicitSecurityDomainConfigured()) {
getConfigurators().add(new ComponentConfigurator() {
@Override
public void configure(final DeploymentPhaseContext context, final ComponentDescription description, final ComponentConfiguration configuration) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = context.getDeploymentUnit();
String contextID = deploymentUnit.getName();
if (deploymentUnit.getParent() != null) {
contextID = deploymentUnit.getParent().getName() + "!" + contextID;
}
EJBComponentDescription ejbComponentDescription = (EJBComponentDescription) description;
if (isSecurityDomainKnown()) {
final HashMap<Integer, InterceptorFactory> elytronInterceptorFactories = getElytronInterceptorFactories(contextID, ejbComponentDescription.isEnableJacc());
elytronInterceptorFactories.forEach((priority, elytronInterceptorFactory) -> configuration.addPostConstructInterceptor(elytronInterceptorFactory, priority));
} else {
configuration.addPostConstructInterceptor(new SecurityContextInterceptorFactory(isExplicitSecurityDomainConfigured(), false, contextID), InterceptorOrder.View.SECURITY_CONTEXT);
}
}
});
}
getConfigurators().add(new ComponentConfigurator() {
@Override
public void configure(DeploymentPhaseContext context, ComponentDescription description, ComponentConfiguration configuration) throws DeploymentUnitProcessingException {
if (isInitOnStartup()) {
final StartupCountdown startupCountdown = context.getDeploymentUnit().getAttachment(Attachments.STARTUP_COUNTDOWN);
configuration.addPostConstructInterceptor(new ImmediateInterceptorFactory(new StartupCountDownInterceptor(startupCountdown)), InterceptorOrder.ComponentPostConstruct.STARTUP_COUNTDOWN_INTERCEPTOR);
}
}
});
if (getTransactionManagementType().equals(TransactionManagementType.CONTAINER)) {
//we need to add the transaction interceptor to the lifecycle methods
getConfigurators().add(new ComponentConfigurator() {
@Override
public void configure(final DeploymentPhaseContext context, final ComponentDescription description, final ComponentConfiguration configuration) throws DeploymentUnitProcessingException {
final EEApplicationClasses applicationClasses = context.getDeploymentUnit().getAttachment(Attachments.EE_APPLICATION_CLASSES_DESCRIPTION);
InterceptorClassDescription interceptorConfig = ComponentDescription.mergeInterceptorConfig(configuration.getComponentClass(), applicationClasses.getClassByName(description.getComponentClassName()), description, MetadataCompleteMarker.isMetadataComplete(context.getDeploymentUnit()));
if (interceptorConfig.getPostConstruct() != null) {
configuration.addPostConstructInterceptor(new LifecycleCMTTxInterceptor.Factory(interceptorConfig.getPostConstruct(), true), InterceptorOrder.ComponentPostConstruct.TRANSACTION_INTERCEPTOR);
}
configuration.addPreDestroyInterceptor(new LifecycleCMTTxInterceptor.Factory(interceptorConfig.getPreDestroy(), true), InterceptorOrder.ComponentPreDestroy.TRANSACTION_INTERCEPTOR);
configuration.addTimeoutViewInterceptor(TimerCMTTxInterceptor.FACTORY, InterceptorOrder.View.CMT_TRANSACTION_INTERCEPTOR);
}
});
} else {
// add the bmt interceptor
getConfigurators().add(new ComponentConfigurator() {
@Override
public void configure(final DeploymentPhaseContext context, final ComponentDescription description, final ComponentConfiguration configuration) throws DeploymentUnitProcessingException {
configuration.addPostConstructInterceptor(EjbBMTInterceptor.FACTORY, InterceptorOrder.ComponentPostConstruct.TRANSACTION_INTERCEPTOR);
configuration.addPreDestroyInterceptor(EjbBMTInterceptor.FACTORY, InterceptorOrder.ComponentPreDestroy.TRANSACTION_INTERCEPTOR);
// add the bmt interceptor factory
configuration.addComponentInterceptor(EjbBMTInterceptor.FACTORY, InterceptorOrder.Component.BMT_TRANSACTION_INTERCEPTOR, false);
}
});
}
return singletonComponentConfiguration;
}
use of org.jboss.as.server.deployment.DeploymentUnitProcessingException in project wildfly by wildfly.
the class SingletonComponentDescription method addViewSerializationInterceptor.
private void addViewSerializationInterceptor(final ViewDescription view) {
view.setSerializable(true);
view.setUseWriteReplace(true);
view.getConfigurators().add(new ViewConfigurator() {
@Override
public void configure(final DeploymentPhaseContext context, final ComponentConfiguration componentConfiguration, final ViewDescription description, final ViewConfiguration configuration) throws DeploymentUnitProcessingException {
final DeploymentReflectionIndex index = context.getDeploymentUnit().getAttachment(org.jboss.as.server.deployment.Attachments.REFLECTION_INDEX);
ClassReflectionIndex classIndex = index.getClassIndex(WriteReplaceInterface.class);
for (Method method : classIndex.getMethods()) {
configuration.addClientInterceptor(method, StatelessWriteReplaceInterceptor.factory(configuration.getViewServiceName().getCanonicalName()), InterceptorOrder.Client.WRITE_REPLACE);
}
}
});
}
use of org.jboss.as.server.deployment.DeploymentUnitProcessingException in project wildfly by wildfly.
the class StatefulComponentDescription method addViewSerializationInterceptor.
private void addViewSerializationInterceptor(final ViewDescription view) {
view.setSerializable(true);
view.setUseWriteReplace(true);
view.getConfigurators().add(new ViewConfigurator() {
@Override
public void configure(final DeploymentPhaseContext context, final ComponentConfiguration componentConfiguration, final ViewDescription description, final ViewConfiguration configuration) throws DeploymentUnitProcessingException {
final DeploymentReflectionIndex index = context.getDeploymentUnit().getAttachment(org.jboss.as.server.deployment.Attachments.REFLECTION_INDEX);
ClassReflectionIndex classIndex = index.getClassIndex(WriteReplaceInterface.class);
for (Method method : (Collection<Method>) classIndex.getMethods()) {
configuration.addClientInterceptor(method, new StatefulWriteReplaceInterceptor.Factory(configuration.getViewServiceName().getCanonicalName()), InterceptorOrder.Client.WRITE_REPLACE);
}
}
});
}
use of org.jboss.as.server.deployment.DeploymentUnitProcessingException in project wildfly by wildfly.
the class WSIntegrationProcessorJAXWS_JMS method deploy.
@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit unit = phaseContext.getDeploymentUnit();
if (DeploymentTypeMarker.isType(DeploymentType.EAR, unit)) {
return;
}
final List<AnnotationInstance> webServiceAnnotations = getAnnotations(unit, WEB_SERVICE_ANNOTATION);
// TODO: how about @WebServiceProvider JMS based endpoints?
//group @WebService annotations in the deployment by wsdl contract location
Map<String, List<AnnotationInstance>> map = new HashMap<String, List<AnnotationInstance>>();
for (AnnotationInstance webServiceAnnotation : webServiceAnnotations) {
final AnnotationValue wsdlLocation = webServiceAnnotation.value(WSDL_LOCATION);
final AnnotationValue port = webServiceAnnotation.value(PORT_NAME);
final AnnotationValue service = webServiceAnnotation.value(SERVICE_NAME);
//support for contract-first development only: pick-up @WebService annotations referencing a provided wsdl contract only
if (wsdlLocation != null && port != null && service != null) {
String key = wsdlLocation.asString();
List<AnnotationInstance> annotations = map.get(key);
if (annotations == null) {
annotations = new LinkedList<AnnotationInstance>();
map.put(key, annotations);
}
annotations.add(webServiceAnnotation);
}
}
//extract SOAP-over-JMS 1.0 bindings
List<JMSEndpointMetaData> list = new LinkedList<JMSEndpointMetaData>();
if (!map.isEmpty()) {
for (String wsdlLocation : map.keySet()) {
try {
final ResourceRoot resourceRoot = getWsdlResourceRoot(unit, wsdlLocation);
if (resourceRoot == null)
continue;
final VirtualFile wsdlLocationFile = resourceRoot.getRoot().getChild(wsdlLocation);
final URL url = wsdlLocationFile.toURL();
SOAPAddressWSDLParser parser = new SOAPAddressWSDLParser(url);
for (AnnotationInstance ai : map.get(wsdlLocation)) {
String port = ai.value(PORT_NAME).asString();
String service = ai.value(SERVICE_NAME).asString();
AnnotationValue targetNS = ai.value(TARGET_NAMESPACE);
String tns = targetNS != null ? targetNS.asString() : null;
QName serviceName = new QName(tns, service);
QName portName = new QName(tns, port);
String soapAddress = parser.filterSoapAddress(serviceName, portName, SOAPAddressWSDLParser.SOAP_OVER_JMS_NS);
if (soapAddress != null) {
ClassInfo webServiceClassInfo = (ClassInfo) ai.target();
String beanClassName = webServiceClassInfo.name().toString();
//service name ?
list.add(new JMSEndpointMetaData(beanClassName, port, beanClassName, wsdlLocation, soapAddress));
}
}
} catch (Exception ignore) {
WSLogger.ROOT_LOGGER.cannotReadWsdl(wsdlLocation);
}
}
}
unit.putAttachment(JMS_ENDPOINT_METADATA_KEY, new JMSEndpointsMetaData(list));
}
use of org.jboss.as.server.deployment.DeploymentUnitProcessingException in project wildfly by wildfly.
the class MessagingXmlParsingDeploymentUnitProcessor method deploy.
@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
final Set<VirtualFile> files = messageDestinations(deploymentUnit);
final XMLMapper mapper = XMLMapper.Factory.create();
final MessagingDeploymentParser_1_0 messagingDeploymentParser_1_0 = new MessagingDeploymentParser_1_0(JBossDescriptorPropertyReplacement.propertyReplacer(deploymentUnit));
mapper.registerRootElement(ROOT_1_0, messagingDeploymentParser_1_0);
mapper.registerRootElement(ROOT_NO_NAMESPACE, messagingDeploymentParser_1_0);
for (final VirtualFile file : files) {
InputStream xmlStream = null;
try {
final File f = file.getPhysicalFile();
xmlStream = new FileInputStream(f);
try {
final XMLInputFactory inputFactory = INPUT_FACTORY;
setIfSupported(inputFactory, XMLInputFactory.IS_VALIDATING, Boolean.FALSE);
setIfSupported(inputFactory, XMLInputFactory.SUPPORT_DTD, Boolean.FALSE);
final XMLStreamReader streamReader = inputFactory.createXMLStreamReader(xmlStream);
final ParseResult result = new ParseResult();
try {
mapper.parseDocument(result, streamReader);
deploymentUnit.addToAttachmentList(MessagingAttachments.PARSE_RESULT, result);
} finally {
safeClose(streamReader, f.getAbsolutePath());
}
} catch (XMLStreamException e) {
throw MessagingLogger.ROOT_LOGGER.couldNotParseDeployment(f.getPath(), e);
}
} catch (Exception e) {
throw new DeploymentUnitProcessingException(e.getMessage(), e);
} finally {
VFSUtils.safeClose(xmlStream);
}
}
}
Aggregations