Esempio n. 1
0
 private void initializeEmbedder() throws Exception {
   InputStream in =
       mainSite.getClass().getClassLoader().getResourceAsStream("showcaseEmbedder.html");
   if (in != null) {
     variables.put("embedder", new String(FileServiceHelper.convertStream(in), "UTF-8"));
   }
 }
Esempio n. 2
0
 private void apply(KevScriptEngine kengine, int tries) {
   if (tries < 5) {
     try {
       mainSite.getModelService().unregisterModelListener(this);
       kengine.atomicInterpretDeploy();
       mainSite.getModelService().registerModelListener(this);
       buildCache();
       String pattern = mainSite.getDictionary().get("urlpattern").toString();
       if (pattern.endsWith("**")) {
         pattern = pattern.replace("**", "");
       }
       if (!pattern.endsWith("/")) {
         pattern = pattern + "/";
       }
       mainSite.invalidateCacheResponse(pattern + "talks");
     } catch (Exception ignored) {
       org.kevoree.log.Log.debug("Unable to define talks.", ignored);
     }
   } else {
     org.kevoree.log.Log.warn("Unable to define talks (see debug logs for more info");
   }
 }
Esempio n. 3
0
 @Override
 public void modelUpdated() {
   final ContainerRoot model = mainSite.getModelService().getLastModel();
   final ModelListener modelListener = this;
   threadPool.execute(
       new Runnable() {
         @Override
         public void run() {
           slidesList.clear();
           // look for all components that have a super type equals to KevoreeSlidePage
           KevScriptEngine kengine = mainSite.getKevScriptEngineFactory().createKevScriptEngine();
           kengine.addVariable("nodeName", mainSite.getNodeName());
           kengine.addVariable("webSocketUrl", webSocketUrl);
           boolean forwardChannelIsAdded = false;
           for (TypeDefinition typeDefinition : model.getTypeDefinitions()) {
             boolean isSlideShow = "KevoreeSlidePage".equals(typeDefinition.getName());
             boolean isSlideShowDev = "KevoreeSlidePageDev".equals(typeDefinition.getName());
             if (!isSlideShow && !isSlideShowDev) {
               isSlideShow = false;
               isSlideShowDev = false;
               for (TypeDefinition superTypeDefinition : typeDefinition.getSuperTypes()) {
                 if ("KevoreeSlidePage".equals(superTypeDefinition.getName())) {
                   isSlideShow = true;
                 } else if ("KevoreeSlidePageDev".equals(superTypeDefinition.getName())) {
                   isSlideShowDev = true;
                 }
               }
             } else {
               isSlideShow = false;
               isSlideShowDev = false;
             }
             org.kevoree.log.Log.debug(
                 "{} is slideShow: {}", typeDefinition.getName(), isSlideShow);
             org.kevoree.log.Log.debug(
                 "{} is slideShowDev: {}", typeDefinition.getName(), isSlideShowDev);
             if (isSlideShow && !isSlideShowDev) {
               kengine.addVariable("instanceName", typeDefinition.getName());
               kengine.addVariable("typeDefinitionName", typeDefinition.getName());
               kengine.append(
                   "addComponent {instanceName}@{nodeName} : {typeDefinitionName} {urlpattern='/talks/{instanceName}/', wsurl='{webSocketUrl}'}");
               // find webserver
               String webServer[] = getWebServerName(model);
               if (webServer != null) {
                 // find channels
                 String channelRequestName;
                 if (mainSite.isPortBinded("forward")) {
                   channelRequestName =
                       findChannel(model, mainSite.getName(), "forward", mainSite.getNodeName());
                 } else {
                   channelRequestName = "forwardChannel";
                   if (!forwardChannelIsAdded) {
                     forwardChannelIsAdded = true;
                     kengine.addVariable("mainSiteName", mainSite.getName());
                     kengine.addVariable("mainSiteNodeName", mainSite.getNodeName());
                     kengine.append("addChannel forwardChannel : defMSG");
                     kengine.append(
                         "bind {mainSiteName}.forward@{mainSiteNodeName} => forwardChannel");
                   }
                 }
                 String channelResponseName =
                     findChannel(model, webServer[0], "response", webServer[1]);
                 if (channelRequestName != null && channelResponseName != null) {
                   // add bindings
                   kengine.addVariable("channelRequestName", channelRequestName);
                   kengine.addVariable("channelResponseName", channelResponseName);
                   kengine.append(
                       "bind {instanceName}.request@{nodeName} => {channelRequestName}");
                   kengine.append(
                       "bind {instanceName}.content@{nodeName} => {channelResponseName}");
                 } else {
                   org.kevoree.log.Log.warn("Unable to find channels to connect slide component");
                 }
                 slidesList.put(
                     typeDefinition.getName(),
                     new String[] {
                       "{urlsite}{urlpattern}talks/" + typeDefinition.getName() + "/",
                       getPaperURL(typeDefinition)
                     });
               } else {
                 org.kevoree.log.Log.warn("Unable to find webserver to connect slide component");
               }
             } else {
               org.kevoree.log.Log.debug("{} is not a slideshow", typeDefinition.getName());
             }
           }
           /*try {
               mainSite.getModelService().unregisterModelListener(modelListener);
               kengine.atomicInterpretDeploy();
               mainSite.getModelService().registerModelListener(modelListener);
               buildCache();
               String pattern = mainSite.getDictionary().get("urlpattern").toString();
               if (pattern.endsWith("**")) {
                   pattern = pattern.replace("**", "");
               }
               if (!pattern.endsWith("/")) {
                   pattern = pattern + "/";
               }
               mainSite.invalidateCacheResponse(pattern + "talks");
           } catch (Exception ignored) {
               logger.debug("Unable to define talks.", ignored);
           }*/
           SlideListPage.this.apply(kengine, 0);
         }
       });
 }