use of org.apache.struts.tiles.DefinitionsFactoryException in project sonar-java by SonarSource.
the class InitDefinitionsTag method doStartTag.
/**
* Do start tag.
*/
public int doStartTag() throws JspException {
DefinitionsFactory factory = TilesUtil.getDefinitionsFactory(pageContext.getRequest(), pageContext.getServletContext());
if (factory != null)
return SKIP_BODY;
DefinitionsFactoryConfig factoryConfig = new DefinitionsFactoryConfig();
factoryConfig.setFactoryClassname(classname);
factoryConfig.setDefinitionConfigFiles(filename);
try {
factory = TilesUtil.createDefinitionsFactory(pageContext.getServletContext(), factoryConfig);
} catch (DefinitionsFactoryException ex) {
ex.printStackTrace();
throw new JspException(ex);
}
return SKIP_BODY;
}
use of org.apache.struts.tiles.DefinitionsFactoryException in project sonar-java by SonarSource.
the class RedeployableActionServlet method getRequestProcessor.
protected synchronized RequestProcessor getRequestProcessor(ModuleConfig config) throws ServletException {
if (tileProcessor != null) {
TilesRequestProcessor processor = (TilesRequestProcessor) super.getRequestProcessor(config);
return processor;
}
// reset the request processor
String requestProcessorKey = Globals.REQUEST_PROCESSOR_KEY + config.getPrefix();
getServletContext().removeAttribute(requestProcessorKey);
// create a new request processor instance
TilesRequestProcessor processor = (TilesRequestProcessor) super.getRequestProcessor(config);
tileProcessor = processor;
try {
// reload Tiles defs
DefinitionsFactory factory = processor.getDefinitionsFactory();
factory.init(factory.getConfig(), getServletContext());
// System.out.println("reloaded tiles-definitions");
} catch (DefinitionsFactoryException e) {
e.printStackTrace();
}
return processor;
}
use of org.apache.struts.tiles.DefinitionsFactoryException in project jaffa-framework by jaffa-projects.
the class JaffaI18nFactorySet method parseXmlFile.
/**
* Parse specified xml file and find definitions from with in classpath by searching all jars
* and add definition to specified definitions set.
* This method is used to load several description files in one instances list.
* If filename exists and definition set is <code>null</code>, create a new set. Otherwise, return
* passed definition set (can be <code>null</code>).
* @param servletContext Current servlet context. Used to open file.
* @param xmlDefinitions Definitions set to which definitions will be added. If null, a definitions
* set is created on request.
* @return XmlDefinitionsSet The definitions set created or passed as parameter.
* @throws DefinitionsFactoryException On errors parsing file.
*/
protected XmlDefinitionsSet parseXmlFile(ServletContext servletContext, XmlDefinitionsSet xmlDefinitions) throws DefinitionsFactoryException {
if (log.isDebugEnabled()) {
log.debug("Parsing tiles definition files from classpath");
}
try {
List<Resource> resourceList = new ArrayList<>();
for (String filename : filenames) {
PathMatchingResourcePatternResolver resolver = OrderedPathMatchingResourcePatternResolver.getInstance();
resourceList.addAll(Arrays.asList(resolver.getResources(filename)));
}
// if( xmlParser == null )
if (true) {
xmlParser = new XmlParser();
xmlParser.setValidating(isValidatingParser);
}
// Check if definition set already exist.
if (xmlDefinitions == null) {
xmlDefinitions = new XmlDefinitionsSet();
}
if (resourceList != null && resourceList.size() > 0) {
for (Resource resource : resourceList) {
if (log.isDebugEnabled()) {
log.debug("Parsing tiles definition: " + resource.getFilename());
}
xmlParser.parse(resource.getInputStream(), xmlDefinitions);
}
} else {
if (log.isDebugEnabled()) {
log.debug("Can't open files '" + filenames + "'");
}
return xmlDefinitions;
}
} catch (SAXException | IOException ex) {
if (log.isDebugEnabled()) {
log.debug("Error while parsing files '" + filenames + "'.");
ex.printStackTrace();
}
throw new DefinitionsFactoryException("Error while parsing files '" + filenames + "'. " + ex.getMessage(), ex);
}
return xmlDefinitions;
}
Aggregations