use of org.jboss.metadata.javaee.spec.ParamValueMetaData in project wildfly by wildfly.
the class WebMetaDataHelper method newParamValue.
/**
* Creates new parameter meta data and associates it with parameters meta data.
*
* @param key parameter key
* @param value parameter value
* @param paramsMD parameters meta data
* @return new parameter meta data
*/
public static ParamValueMetaData newParamValue(final String key, final String value, final List<ParamValueMetaData> paramsMD) {
final ParamValueMetaData paramValueMD = WebMetaDataHelper.newParamValue(key, value);
paramsMD.add(paramValueMD);
return paramValueMD;
}
use of org.jboss.metadata.javaee.spec.ParamValueMetaData in project wildfly by wildfly.
the class WebMetaDataModifier method configureEndpoints.
/**
* Configures transport servlet class for every found webservice endpoint.
*
* @param dep webservice deployment
* @param jbossWebMD web meta data
*/
private void configureEndpoints(final Deployment dep, final JBossWebMetaData jbossWebMD) {
final String transportClassName = this.getTransportClassName(dep);
WSLogger.ROOT_LOGGER.trace("Modifying servlets");
// get a list of the endpoint bean class names
final Set<String> epNames = new HashSet<String>();
for (Endpoint ep : dep.getService().getEndpoints()) {
epNames.add(ep.getTargetBeanName());
}
// fix servlet class names for endpoints
for (final ServletMetaData servletMD : jbossWebMD.getServlets()) {
final String endpointClassName = ASHelper.getEndpointClassName(servletMD);
if (endpointClassName != null && endpointClassName.length() > 0) {
// exclude JSP
if (epNames.contains(endpointClassName)) {
// set transport servlet
servletMD.setServletClass(WSFServlet.class.getName());
WSLogger.ROOT_LOGGER.tracef("Setting transport class: %s for endpoint: %s", transportClassName, endpointClassName);
final List<ParamValueMetaData> initParams = WebMetaDataHelper.getServletInitParams(servletMD);
// configure transport class name
WebMetaDataHelper.newParamValue(WSFServlet.STACK_SERVLET_DELEGATE_CLASS, transportClassName, initParams);
// configure webservice endpoint
WebMetaDataHelper.newParamValue(Endpoint.SEPID_DOMAIN_ENDPOINT, endpointClassName, initParams);
} else if (endpointClassName.startsWith("org.apache.cxf")) {
throw WSLogger.ROOT_LOGGER.invalidWSServlet(endpointClassName);
}
}
}
}
use of org.jboss.metadata.javaee.spec.ParamValueMetaData in project wildfly by wildfly.
the class EndpointPublisherImpl method addServlets.
private static void addServlets(JBossWebMetaData jbwebMD, WebDeploymentBuilder deployment) {
for (JBossServletMetaData smd : jbwebMD.getServlets()) {
final String sc = smd.getServletClass();
if (sc.equals(WSFServlet.class.getName())) {
ServletBuilder servletBuilder = new ServletBuilder();
final String servletName = smd.getServletName();
List<ParamValueMetaData> params = smd.getInitParam();
List<String> urlPatterns = null;
for (ServletMappingMetaData smmd : jbwebMD.getServletMappings()) {
if (smmd.getServletName().equals(servletName)) {
urlPatterns = smmd.getUrlPatterns();
servletBuilder.addUrlMappings(urlPatterns);
break;
}
}
WSFServlet wsfs = new WSFServlet();
servletBuilder.setServletName(servletName);
servletBuilder.setServlet(wsfs);
servletBuilder.setServletClass(WSFServlet.class);
for (ParamValueMetaData param : params) {
servletBuilder.addInitParam(param.getParamName(), param.getParamValue());
}
deployment.addServlet(servletBuilder);
}
}
}
use of org.jboss.metadata.javaee.spec.ParamValueMetaData in project wildfly by wildfly.
the class WebIntegrationProcessor method deploy.
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
final EEModuleDescription module = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
final EEApplicationClasses applicationClasses = deploymentUnit.getAttachment(Attachments.EE_APPLICATION_CLASSES_DESCRIPTION);
if (!DeploymentTypeMarker.isType(DeploymentType.WAR, deploymentUnit)) {
// Skip non web deployments
return;
}
WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
if (warMetaData == null) {
WeldLogger.DEPLOYMENT_LOGGER.debug("Not installing Weld web tier integration as no war metadata found");
return;
}
JBossWebMetaData webMetaData = warMetaData.getMergedJBossWebMetaData();
if (webMetaData == null) {
WeldLogger.DEPLOYMENT_LOGGER.debug("Not installing Weld web tier integration as no merged web metadata found");
return;
}
if (!WeldDeploymentMarker.isWeldDeployment(deploymentUnit)) {
if (WeldDeploymentMarker.isPartOfWeldDeployment(deploymentUnit)) {
createDependency(deploymentUnit, warMetaData);
}
return;
}
createDependency(deploymentUnit, warMetaData);
List<ListenerMetaData> listeners = webMetaData.getListeners();
if (listeners == null) {
listeners = new ArrayList<ListenerMetaData>();
webMetaData.setListeners(listeners);
} else {
//if the weld servlet listener is present remove it
//this should allow wars to be portable between AS7 and servlet containers
final ListIterator<ListenerMetaData> iterator = listeners.listIterator();
while (iterator.hasNext()) {
final ListenerMetaData listener = iterator.next();
if (listener.getListenerClass().trim().equals(WELD_SERVLET_LISTENER)) {
WeldLogger.DEPLOYMENT_LOGGER.debugf("Removing weld servlet listener %s from web config, as it is not needed in EE6 environments", WELD_SERVLET_LISTENER);
iterator.remove();
break;
}
}
}
listeners.add(0, INITIAL_LISTENER_METADATA);
listeners.add(TERMINAL_LISTENER_MEDATADA);
//These listeners use resource injection, so they need to be components
registerAsComponent(WELD_INITIAL_LISTENER, deploymentUnit);
registerAsComponent(WELD_TERMINAL_LISTENER, deploymentUnit);
deploymentUnit.addToAttachmentList(ExpressionFactoryWrapper.ATTACHMENT_KEY, WeldJspExpressionFactoryWrapper.INSTANCE);
if (webMetaData.getContextParams() == null) {
webMetaData.setContextParams(new ArrayList<ParamValueMetaData>());
}
final List<ParamValueMetaData> contextParams = webMetaData.getContextParams();
setupWeldContextIgnores(contextParams, InitParameters.CONTEXT_IGNORE_FORWARD);
setupWeldContextIgnores(contextParams, InitParameters.CONTEXT_IGNORE_INCLUDE);
if (webMetaData.getFilterMappings() != null) {
// register ConversationFilter
boolean filterMappingFound = false;
for (FilterMappingMetaData mapping : webMetaData.getFilterMappings()) {
if (CONVERSATION_FILTER_NAME.equals(mapping.getFilterName())) {
filterMappingFound = true;
break;
}
}
if (filterMappingFound) {
// otherwise WeldListener will take care of conversation context activation
boolean filterFound = false;
// register ConversationFilter
if (webMetaData.getFilters() == null) {
webMetaData.setFilters(new FiltersMetaData());
}
for (FilterMetaData filter : webMetaData.getFilters()) {
if (CONVERSATION_FILTER_CLASS.equals(filter.getFilterClass())) {
filterFound = true;
break;
}
}
if (!filterFound) {
webMetaData.getFilters().add(conversationFilterMetadata);
registerAsComponent(CONVERSATION_FILTER_CLASS, deploymentUnit);
webMetaData.getContextParams().add(CONVERSATION_FILTER_INITIALIZED);
}
}
}
}
use of org.jboss.metadata.javaee.spec.ParamValueMetaData in project wildfly by wildfly.
the class JaxrsSpringProcessor method deploy.
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
if (deploymentUnit.getParent() != null) {
return;
}
final List<DeploymentUnit> deploymentUnits = new ArrayList<DeploymentUnit>();
deploymentUnits.add(deploymentUnit);
deploymentUnits.addAll(deploymentUnit.getAttachmentList(Attachments.SUB_DEPLOYMENTS));
boolean found = false;
for (DeploymentUnit unit : deploymentUnits) {
WarMetaData warMetaData = unit.getAttachment(WarMetaData.ATTACHMENT_KEY);
if (warMetaData == null) {
continue;
}
JBossWebMetaData md = warMetaData.getMergedJBossWebMetaData();
if (md == null) {
continue;
}
if (md.getContextParams() != null) {
boolean skip = false;
for (ParamValueMetaData prop : md.getContextParams()) {
if (prop.getParamName().equals(ENABLE_PROPERTY)) {
boolean explicitEnable = Boolean.parseBoolean(prop.getParamValue());
if (explicitEnable) {
found = true;
} else {
skip = true;
}
break;
} else if (prop.getParamName().equals(DISABLE_PROPERTY) && "true".equals(prop.getParamValue())) {
skip = true;
JaxrsLogger.JAXRS_LOGGER.disablePropertyDeprecated();
break;
}
}
if (skip) {
continue;
}
}
if (md.getListeners() != null) {
for (ListenerMetaData listener : md.getListeners()) {
if (SPRING_LISTENER.equals(listener.getListenerClass())) {
found = true;
break;
}
}
}
if (md.getServlets() != null) {
for (JBossServletMetaData servlet : md.getServlets()) {
if (SPRING_SERVLET.equals(servlet.getServletClass())) {
found = true;
break;
}
}
}
if (found) {
try {
// actual close is done by the MSC service above
MountHandle mh = new MountHandle(null);
ResourceRoot resourceRoot = new ResourceRoot(getResteasySpringVirtualFile(), mh);
ModuleRootMarker.mark(resourceRoot);
deploymentUnit.addToAttachmentList(Attachments.RESOURCE_ROOTS, resourceRoot);
} catch (Exception e) {
throw new DeploymentUnitProcessingException(e);
}
return;
}
}
}
Aggregations