org.camunda.bpm.engine.spring.application.SpringProcessApplicationElResolver Maven / Gradle / Ivy
/*
* Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
* under one or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information regarding copyright
* ownership. Camunda licenses this file to you under the Apache License,
* Version 2.0; you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.camunda.bpm.engine.spring.application;
import java.util.logging.Level;
import java.util.logging.Logger;
import jakarta.servlet.ServletContext;
import org.camunda.bpm.application.AbstractProcessApplication;
import org.camunda.bpm.application.ProcessApplicationElResolver;
import org.camunda.bpm.application.impl.JakartaEjbProcessApplication;
import org.camunda.bpm.engine.spring.ApplicationContextElResolver;
import org.camunda.bpm.impl.juel.jakarta.el.ELResolver;
import org.springframework.util.ClassUtils;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
/**
* ProcessApplicationElResolver implementation providing support for the Spring Framework.
*
* This implementation supports the following environments:
*
* - Bootstrapping through {@link SpringProcessApplication}. In this case the spring application context
* is retrieved from the {@link SpringProcessApplication} class.
* - Bootstrapping through {@link org.camunda.bpm.application.impl.JakartaServletProcessApplication}. In this case we have access to the {@link ServletContext}
* which allows accessing the web application's application context through the WebApplicationContextUtils class.
*
*
*
*
* Limitation: The {@link EjbProcessApplication} is currently unsupported.
*
* @author Daniel Meyer
*
*/
public class SpringProcessApplicationElResolver implements ProcessApplicationElResolver {
private final static Logger LOGGER = Logger.getLogger(SpringProcessApplicationElResolver.class.getName());
@Override
public Integer getPrecedence() {
return ProcessApplicationElResolver.SPRING_RESOLVER;
}
@Override
public ELResolver getElResolver(AbstractProcessApplication processApplication) {
if (processApplication instanceof SpringProcessApplication) {
SpringProcessApplication springProcessApplication = (SpringProcessApplication) processApplication;
return new ApplicationContextElResolver(springProcessApplication.getApplicationContext());
} else if (processApplication instanceof org.camunda.bpm.application.impl.JakartaServletProcessApplication) {
// Using fully-qualified class name instead of import statement to allow for automatic transformation
org.camunda.bpm.application.impl.JakartaServletProcessApplication servletProcessApplication = (org.camunda.bpm.application.impl.JakartaServletProcessApplication) processApplication;
if(!ClassUtils.isPresent("org.springframework.web.context.support.WebApplicationContextUtils", processApplication.getProcessApplicationClassloader())) {
LOGGER.log(Level.FINE, "WebApplicationContextUtils must be present for SpringProcessApplicationElResolver to work");
return null;
}
ServletContext servletContext = servletProcessApplication.getServletContext();
WebApplicationContext applicationContext = WebApplicationContextUtils.getWebApplicationContext(servletContext);
if(applicationContext != null) {
return new ApplicationContextElResolver(applicationContext);
}
}
LOGGER.log(Level.FINE, "Process application class {0} unsupported by SpringProcessApplicationElResolver", processApplication);
return null;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy