use of org.openntf.nsfodp.commons.odp.XSPCompilationResult in project org.openntf.nsfodp by OpenNTF.
the class ODPCompiler method compileXSP.
// *******************************************************************************
// * Internal utility methods
// *******************************************************************************
private XSPCompilationResult compileXSP(XPage xpage, JavaSourceClassLoader classLoader) throws Exception {
try {
String javaSource;
try (InputStream xspSource = xpage.getSourceAsStream()) {
javaSource = dynamicXPageBean.translate(xpage.getJavaClassName(), xpage.getPageName(), xspSource, (FacesSharableRegistry) facesProject.getRegistry());
}
Class<?> compiled = classLoader.addClass(xpage.getJavaClassName(), javaSource);
return new XSPCompilationResult(javaSource, compiled);
} catch (Throwable e) {
throw new RuntimeException(MessageFormat.format(Messages.ODPCompiler_errorConvertingXSP, odp.getBaseDirectory().relativize(xpage.getDataFile())), e);
}
}
use of org.openntf.nsfodp.commons.odp.XSPCompilationResult in project org.openntf.nsfodp by OpenNTF.
the class ODPCompiler method compileCustomControls.
// *******************************************************************************
// * XSP compilation methods
// *******************************************************************************
private Map<CustomControl, XSPCompilationResult> compileCustomControls(JavaSourceClassLoader classLoader) throws Exception {
subTask(Messages.ODPCompiler_compilingCustomControls);
ConfigParser configParser = ConfigParserFactory.getParserInstance();
FacesClassLoader facesClassLoader = new DynamicFacesClassLoader(dynamicXPageBean, classLoader);
Map<CustomControl, XSPCompilationResult> result = new LinkedHashMap<>();
List<CustomControl> ccs = odp.getCustomControls();
for (CustomControl cc : ccs) {
Document xspConfig = cc.getXspConfig().get();
// $NON-NLS-1$
String namespace = StringUtil.trim(NSFODPDomUtil.node(xspConfig, "/faces-config/faces-config-extension/namespace-uri/text()").get().getTextContent());
Path fileName = odp.getBaseDirectory().relativize(cc.getXspConfigFile());
LibraryFragmentImpl fragment = (LibraryFragmentImpl) configParser.createFacesLibraryFragment(facesProject, facesClassLoader, fileName.toString(), xspConfig.getDocumentElement(), resourceBundleSource, iconUrlSource, namespace);
UpdatableLibrary library = getLibrary(namespace);
library.addLibraryFragment(fragment);
// Load the definition to refresh its parent ref
CompositeComponentDefinitionImpl def = (CompositeComponentDefinitionImpl) library.getDefinition(cc.getControlName());
def.refreshReferences();
}
// Now that they're all defined, try to compile them in a queue
for (CustomControl cc : ccs) {
XSPCompilationResult compilationResult = compileXSP(cc, classLoader);
result.put(cc, compilationResult);
}
return result;
}
use of org.openntf.nsfodp.commons.odp.XSPCompilationResult in project org.openntf.nsfodp by OpenNTF.
the class ODPCompiler method compileXPages.
private Map<XPage, XSPCompilationResult> compileXPages(JavaSourceClassLoader classLoader) throws Exception {
subTask(Messages.ODPCompiler_compilingXPages);
Map<XPage, XSPCompilationResult> result = new LinkedHashMap<>();
for (XPage xpage : odp.getXPages()) {
XSPCompilationResult compilationResult = compileXSP(xpage, classLoader);
result.put(xpage, compilationResult);
}
return result;
}
Aggregations