use of com.sun.faces.config.WebConfiguration in project mojarra by eclipse-ee4j.
the class SerializationProviderFactory method findProviderClass.
/**
* Tries to find a provider class in a web context parameter. If not present it tries to find it as a System property.
* If still not found returns null.
*
* @param extContext The ExternalContext for this request
* @return The provider class name specified in the container configuration, or <code>null</code> if not found.
*/
private static String findProviderClass(ExternalContext extContext) {
WebConfiguration webConfig = WebConfiguration.getInstance(extContext);
String provider = webConfig.getOptionValue(WebContextInitParameter.SerializationProviderClass);
if (provider != null) {
return provider;
} else {
return System.getProperty(SERIALIZATION_PROVIDER_PROPERTY);
}
}
use of com.sun.faces.config.WebConfiguration in project mojarra by eclipse-ee4j.
the class SAXCompiler method writeXmlDecl.
protected static void writeXmlDecl(InputStream is, String encoding, CompilationManager mngr) throws IOException {
is.mark(128);
try {
byte[] b = new byte[128];
if (is.read(b) > 0) {
String r = new String(b, encoding);
Matcher m = XmlDeclaration.matcher(r);
if (m.find()) {
WebConfiguration config = mngr.getWebConfiguration();
FaceletsConfiguration faceletsConfig = config.getFaceletsConfiguration();
boolean currentModeIsXhtml = faceletsConfig.isProcessCurrentDocumentAsFaceletsXhtml(mngr.getAlias());
// with the value of XHTML
if (currentModeIsXhtml) {
Util.saveXMLDECLToFacesContextAttributes(m.group(0) + "\n");
}
}
}
} finally {
is.reset();
}
}
use of com.sun.faces.config.WebConfiguration in project mojarra by eclipse-ee4j.
the class DefaultFaceletFactory method init.
public final void init(FacesContext facesContext, Compiler compiler, DefaultResourceResolver resolver, long refreshPeriod, FaceletCache cache) {
notNull("compiler", compiler);
notNull("resolver", resolver);
ExternalContext externalContext = facesContext.getExternalContext();
WebConfiguration config = WebConfiguration.getInstance(externalContext);
this.compiler = compiler;
cachePerContract = new ConcurrentHashMap<>();
this.resolver = resolver;
baseUrl = resolver.resolveUrl("/");
this.idMappers = config.isOptionEnabled(UseFaceletsID) ? null : new Cache<>(new IdMapperFactory());
refreshPeriod = refreshPeriod >= 0 ? refreshPeriod * 1000 : -1;
this.refreshPeriod = refreshPeriod;
if (log.isLoggable(Level.FINE)) {
log.log(Level.FINE, "Using ResourceResolver: {0}", resolver);
log.log(Level.FINE, "Using Refresh Period: {0}", refreshPeriod);
}
// We can cast to the FaceletCache<DefaultFacelet> here because we know
// that the Generics information is only used at compile time, and all cache
// implementations will be using instance factories provided by us and returning DefaultFacelet
this.cache = initCache(cache);
}
use of com.sun.faces.config.WebConfiguration in project mojarra by eclipse-ee4j.
the class FaceletCacheFactoryImpl method getFaceletCache.
@Override
public FaceletCache getFaceletCache() {
WebConfiguration webConfig = WebConfiguration.getInstance();
String refreshPeriod = webConfig.getOptionValue(WebConfiguration.WebContextInitParameter.FaceletsDefaultRefreshPeriod);
long period = Long.parseLong(refreshPeriod) * 1000;
FaceletCache<DefaultFacelet> result = new DefaultFaceletCache(period);
return result;
}
use of com.sun.faces.config.WebConfiguration in project mojarra by eclipse-ee4j.
the class ProtectedViewsConfigProcessor method processProtectedViews.
// --------------------------------------------------------- Private Methods
private void processProtectedViews(FacesContext context, NodeList protectedViews, String namespace, DocumentInfo info) {
WebConfiguration config = null;
ViewHandler viewHandler = null;
for (int i = 0, size = protectedViews.getLength(); i < size; i++) {
Node urlPatterns = protectedViews.item(i);
NodeList children = ((Element) urlPatterns).getElementsByTagNameNS(namespace, "*");
for (int c = 0, csize = children.getLength(); c < csize; c++) {
Node n = children.item(c);
String urlPattern = null;
if (URL_PATTERN.equals(n.getLocalName())) {
urlPattern = getNodeText(n);
} else {
if (LOGGER.isLoggable(Level.WARNING)) {
LOGGER.log(Level.WARNING, MessageFormat.format("Processing protected-views elements for document: ''{0}'', encountered unexpected configuration ''{1}'', ignoring and continuing", info.getSourceURI(), getNodeText(n)));
}
}
if (urlPattern != null) {
if (config == null) {
config = WebConfiguration.getInstance();
}
if (viewHandler == null) {
viewHandler = context.getApplication().getViewHandler();
}
viewHandler.addProtectedView(urlPattern);
} else {
if (LOGGER.isLoggable(WARNING)) {
LOGGER.log(WARNING, format("Processing protected-views elements for document: ''{0}'', encountered <url-pattern> element without expected children", info.getSourceURI()));
}
}
}
}
}
Aggregations