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

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


                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

        }
        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

                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 (resource.isNativeAmd()) {
                    /* nothing to do for an AMD module */
                    // buffer.append("/* native AMD module */\n");
                } else if (isModule) {
                    Set<ResourceId> depResourceIds = resource.getDependencies();
                    int argCount = depResourceIds.size();
                    JSONArray deps = new JSONArray();

                    LinkedList<String> params = new LinkedList<String>();
                    List<String> argNames = new ArrayList<String>(argCount);
                    List<String> argValues = new ArrayList<String>(argCount);
                    for (ResourceId id : depResourceIds) {
                        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

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

            ScriptResource resource = scripts.addResource(desc.id, desc.fetchMode, desc.alias, desc.group, contextPath, desc.nativeAmd);
            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());
                }
            }
        }

        /* No exception was thrown, now we can at once assign these two local variables to service fields */
 
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

         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 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()))
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

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.