Package org.gatein.portal.controller.resource.script

Examples of org.gatein.portal.controller.resource.script.ScriptResource


   public void execute(JavascriptConfigService service, ServletContext scontext)
   {
      for (ScriptResourceDescriptor desc : descriptors)
      {
         ScriptResource resource = service.scripts.addResource(desc.id, desc.fetchMode, desc.alias);
         if (resource != null)
         {
            for (Javascript module : desc.modules)
            {
               module.addModuleTo(resource);
            }
            for (Locale locale : desc.getSupportedLocales())
            {
               resource.addSupportedLocale(locale);
            }
            for (DependencyDescriptor dependency : desc.dependencies)
            {
               resource.addDependency(dependency.getResourceId(), dependency.getAlias());
            }           
         }
      }
   }
View Full Code Here


      return paths;
   }

   public Reader getScript(ResourceId id, String name, Locale locale)
   {
      ScriptResource script = getResource(id);
      if (script != null && !"merged".equals(name))
      {
         return getJavascript(script, name, locale);
      }
      else
View Full Code Here

      }
   }
  
   public Reader getScript(ResourceId resourceId, Locale locale)
   {
      ScriptResource resource = getResource(resourceId);
     
      if (resource != null)
      {
         List<Module> modules = new ArrayList<Module>(resource.getModules());
         Collections.sort(modules, MODULE_COMPARATOR);
         ArrayList<Reader> readers = new ArrayList<Reader>(modules.size() * 2);
        
         //
         StringBuilder buffer = new StringBuilder();
         boolean isModule = FetchMode.ON_LOAD.equals(resource.getFetchMode());
         if (isModule)
         {
            buffer.append("define('").append(resourceId).append("', ");
            buffer.append(new JSONArray(resource.getDependencies()));           
            buffer.append(", function(");
            for (ResourceId resId : resource.getDependencies())
            {              
               String alias = resource.getDependencyAlias(resId);
               ScriptResource dep = getResource(resId);
               if (dep != null)
               {
                  buffer.append(alias == null ? dep.getAlias() : alias).append(",");                 
               }
            }
            if (buffer.charAt(buffer.length() - 1) == ',')
            {
               buffer.deleteCharAt(buffer.length() - 1);
View Full Code Here

      URIWriter writer = new URIWriter(buffer);

      //
      if (ids.size() > 0)
      {
         ScriptResource resource = getResource(ids.keySet().iterator().next());
               
         //
         if (resource != null)
         {
            FetchMode mode = resource.getFetchMode();
            List<Module> modules = resource.getModules();
            if (modules.size() > 0 && modules.get(0) instanceof Module.Remote)
            {
               urls.put(((Module.Remote)modules.get(0)).getURI(), mode);
            }
            else
            {
               controllerContext.renderURL(resource.getParameters(minified, locale), writer);
               urls.put(buffer.toString(), mode);
               buffer.setLength(0);
               writer.reset(buffer);
            }           
         }
View Full Code Here

         throw new IllegalArgumentException("name can't be null");
      }
      ResourceId id = new ResourceId(scope, name);
      ExoContainer container = ExoContainerContext.getCurrentContainer();
      JavascriptConfigService service = (JavascriptConfigService)container.getComponentInstanceOfType(JavascriptConfigService.class);
      ScriptResource resource = service.getResource(id);
      if (resource != null)
      {
         if (FetchMode.IMMEDIATE.equals(resource.getFetchMode()))
         {
            resourceIds.add(id, null);        
         }
         else
         {
View Full Code Here

        }
        ResourceId id = new ResourceId(scope, name);
        ExoContainer container = ExoContainerContext.getCurrentContainer();
        JavascriptConfigService service = (JavascriptConfigService) container
                .getComponentInstanceOfType(JavascriptConfigService.class);
        ScriptResource resource = service.getResource(id);
        if (resource != null) {
            if (FetchMode.IMMEDIATE.equals(resource.getFetchMode())) {
                resourceIds.add(id, null);
            } else {
                Map<ResourceId, FetchMode> tmp = new HashMap<ResourceId, FetchMode>();
                tmp.put(id, null);
                for (ScriptResource res : service.resolveIds(tmp).keySet()) {
View Full Code Here

            String contextPath = null;
            if (desc.modules.size() > 0) {
                contextPath = desc.modules.get(0).getContextPath();
            }

            ScriptResource resource = service.scripts.addResource(desc.id, desc.fetchMode, desc.alias, desc.group, contextPath);
            if (resource != null) {
                for (Javascript module : desc.modules) {
                    module.addModuleTo(resource);
                }
                for (Locale locale : desc.getSupportedLocales()) {
                    resource.addSupportedLocale(locale);
                }
                for (DependencyDescriptor dependency : desc.dependencies) {
                    resource.addDependency(dependency.getResourceId(), dependency.getAlias(), dependency.getPluginResource());
                }
            }
        }
    }
View Full Code Here

                return new CompositeReader(readers);
            } else {
                return null;
            }
        } else {
            ScriptResource resource = getResource(resourceId);

            if (resource != null) {
                List<Module> modules = new ArrayList<Module>(resource.getModules());

                Collections.sort(modules, MODULE_COMPARATOR);
                ArrayList<Reader> readers = new ArrayList<Reader>(modules.size() * 2);
                StringBuilder buffer = new StringBuilder();

                //
                boolean isModule = FetchMode.ON_LOAD.equals(resource.getFetchMode());

                if (isModule) {
                    JSONArray deps = new JSONArray();
                    LinkedList<String> params = new LinkedList<String>();
                    List<String> argNames = new LinkedList<String>();
                    List<String> argValues = new LinkedList<String>(params);
                    for (ResourceId id : resource.getDependencies()) {
                        ScriptResource dep = getResource(id);
                        if (dep != null) {
                            Set<DepInfo> depInfos = resource.getDepInfo(id);
                            for (DepInfo info : depInfos) {
                                String pluginRS = info.getPluginRS();
                                String alias = info.getAlias();
                                if (alias == null) {
                                    alias = dep.getAlias();
                                }

                                deps.put(parsePluginRS(dep.getId().toString(), pluginRS));
                                params.add(encode(params, alias));
                                argNames.add(parsePluginRS(alias, pluginRS));
                            }
                        } else if (RESERVED_MODULE.contains(id.getName())) {
                            String reserved = id.getName();
View Full Code Here

        }

        //
        if (resource != null) {
            if (resource instanceof ScriptResource) {
                ScriptResource rs = (ScriptResource) resource;

                List<Module> modules = rs.getModules();
                if (modules.size() > 0 && modules.get(0) instanceof Module.Remote) {
                    return ((Module.Remote) modules.get(0)).getURI();
                }
            }
View Full Code Here

                return new CompositeReader(readers);
            } else {
                return null;
            }
        } else {
            ScriptResource resource = getResource(resourceId);

            if (resource != null) {
                List<Module> modules = new ArrayList<Module>(resource.getModules());

                Collections.sort(modules, MODULE_COMPARATOR);
                ArrayList<Reader> readers = new ArrayList<Reader>(modules.size() * 2);
                StringBuilder buffer = new StringBuilder();

                //
                boolean isModule = FetchMode.ON_LOAD.equals(resource.getFetchMode());

                if (isModule) {
                    JSONArray deps = new JSONArray();
                    LinkedList<String> params = new LinkedList<String>();
                    List<String> argNames = new LinkedList<String>();
                    List<String> argValues = new LinkedList<String>(params);
                    for (ResourceId id : resource.getDependencies()) {
                        ScriptResource dep = getResource(id);
                        if (dep != null) {
                            Set<DepInfo> depInfos = resource.getDepInfo(id);
                            for (DepInfo info : depInfos) {
                                String pluginRS = info.getPluginRS();
                                String alias = info.getAlias();
                                if (alias == null) {
                                    alias = dep.getAlias();
                                }

                                deps.put(parsePluginRS(dep.getId().toString(), pluginRS));
                                params.add(encode(params, alias));
                                argNames.add(parsePluginRS(alias, pluginRS));
                            }
                        } else if (RESERVED_MODULE.contains(id.getName())) {
                            String reserved = id.getName();
View Full Code Here

TOP

Related Classes of org.gatein.portal.controller.resource.script.ScriptResource

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.