Package org.apache.myfaces.trinidad.share.io

Examples of org.apache.myfaces.trinidad.share.io.NameResolver


    ParseContext context,
    String       sourceName,
    Class<?>     expectedType) throws IOException, SAXException
  {
    // Step 1. Find the name resolver.
    NameResolver resolver = getResolver(context);
    if (resolver == null)
    {
      _log(context, "Internal error: couldn't find NameResolver");
      return null;
    }

    // Step 2. Find an InputStreamProvider.  Mark a dependency on the base
    // provider (if necessary)
    InputStreamProvider provider = resolver.getProvider(sourceName);
    InputStreamProvider baseProvider = getInputStreamProvider(context);
    if (baseProvider instanceof CachingInputStreamProvider)
    {
      ((CachingInputStreamProvider) baseProvider).addCacheDependency(provider);
    }

    // Step 3. Detect if this will be a circular include.
    ArrayList<Object> list =
      (ArrayList<Object>) context.getProperty(_SHARE_NAMESPACE, "_includeStack");
    Object identifier = provider.getIdentifier();

    if ((list != null) && (list.contains(identifier)))
    {
      // =-=AEW Just logging an error isn't really enough - the include
      // will fail, but parsing continues.  So, instead, we throw
      // an exception...
      throw new SAXParseException(_LOG.getMessage(
        "CIRCULAR_INCLUDE_DETECTED", sourceName), context.getLocator());
    }

    // Step 4. Try to get a cached version
    Object cached = provider.getCachedResult();
    if ((cached != null) && expectedType.isInstance(cached))
      return cached;


    // Step 5. Set up the new context;  first, clone the original
    ParseContext newContext = (ParseContext) context.clone();

    // Add the current identifer to the stack (used for detecting
    // circular includes) placed on the ParseContext
    if (list == null)
      list = new ArrayList<Object>();
    else
      list = (ArrayList<Object>) list.clone();
    list.add(identifier);
    newContext.setProperty(_SHARE_NAMESPACE, "_includeStack", list);


    ParserManager parserManager =context.getParserManager();
    TreeBuilder builder = new TreeBuilder(parserManager,
                                          expectedType);
    InputStream stream = provider.openInputStream();

    try
    {
      InputSource source = new InputSource(stream);
      source.setSystemId(sourceName);

      setResolver(newContext, resolver.getResolver(sourceName));
      setInputStreamProvider(newContext, provider);

      // Step 6. Parse!
      Object value = builder.parse(context.getXMLProvider(),
                                   source,
View Full Code Here


  /**
   * Gets the NameResolver stored on the ParseContext.
   */
  static public NameResolver getResolver(ParseContext context)
  {
    NameResolver source = (NameResolver)
      context.getProperty(_SHARE_NAMESPACE, "_nameResolver");
    if (source == null)
      source = new DefaultNameResolver(null, null);

    return source;
View Full Code Here

   * resolver that can only support absolute names.
   * @param name the name of the target
   */
  final public NameResolver getRootResolver(String name)
  {
    NameResolver resolver = getResolver(name);
    if (resolver instanceof DefaultNameResolver)
    {
      ((DefaultNameResolver) resolver).__setRootResolver(null);
    }

View Full Code Here

   * resolver that can only support absolute names.
   * @param name the name of the target
   */
  public NameResolver getResolver(String name)
  {
    NameResolver resolver = _base.getResolver(name);
    return new CachingNameResolver(resolver,
                                   _cachedFiles,
                                   _msBetweenChecks);
  }
View Full Code Here

    // Get the index of the icon name in the _ICONS list
    String source = null;
    boolean isDirectionIndependent = false;
    boolean isCoreColor = false;
    Class<LookAndFeel> lookAndFeel = null;
    NameResolver resolver = null;

    if ( icon != null )
    {
      source = icon.getName();
      isDirectionIndependent = icon.isSymmetric();
View Full Code Here

    Object objContext = fContext.getExternalContext().getContext();
    if (objContext instanceof ServletContext)
    {
      ServletContext servletContext = (ServletContext) objContext;

      NameResolver resolver = new ServletNameResolver( _request,
                                                       servletContext);
      InputStreamProvider provider = resolveSourceIcon(context,
                                                       getSource(),
                                                       resolver);
View Full Code Here

    )
  {
    // In order to create the StyleSheetEntry, we need to locate and
    // parse the style sheet file.  We use a NameResolver to use to
    // find the style sheet.
    NameResolver resolver = _getNameResolver(context, styleSheetName);
    if (resolver == null)
      return null;

    // a private static inner class to store the document, icon, and skin properties
    // =-=jmw @todo Should I just create a StyleSheetEntry directly,
View Full Code Here

    if ((localStylesDir == null))
    {
      _LOG.warning(_STYLES_DIR_ERROR);
      return null;
    }
    NameResolver resolver = null;

    try
    {
      resolver =
          _getNameResolverForStyleSheetFile(context, localStylesDir, styleSheetName);
View Full Code Here

    if (provider != null)
      return StyleSheetNameResolver.createResolver(context, localStylesDir, provider);

    // If we still can't locate the file at this point, then look for a custom
    // NameResolver specified as a META-INF\services.
    NameResolver servicesNameResolver = _loadNameResolverFromServices(filename);
    if (servicesNameResolver != null)
    {
      if (_LOG.isFine())
      {
        _LOG.fine("Using the InputStreamProvider from META-INF\\services");
View Full Code Here

    // We don't want to check services every time, so instead store it on the applicationMap.
    FacesContext context = FacesContext.getCurrentInstance();
    Map<String, Object> appMap = context.getExternalContext().getApplicationMap();

    // Is it stored on the application map already? If so, use it.
    NameResolver savedResolver = (NameResolver)appMap.get(_SERVICES_RESOLVER_KEY);
    if (savedResolver != null)
      return savedResolver;

    List<NameResolver> resolvers = ClassLoaderUtils.getServices(
                                      _NAME_RESOLVER_CLASS_NAME);
View Full Code Here

TOP

Related Classes of org.apache.myfaces.trinidad.share.io.NameResolver

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.