You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by ah...@apache.org on 2019/09/25 14:40:14 UTC

[isis] branch v2 updated: ISIS-2158: DemoApp: preload JRuby stuff for AsciiDoc

This is an automated email from the ASF dual-hosted git repository.

ahuber pushed a commit to branch v2
in repository https://gitbox.apache.org/repos/asf/isis.git


The following commit(s) were added to refs/heads/v2 by this push:
     new 37259aa  ISIS-2158: DemoApp: preload JRuby stuff for AsciiDoc
37259aa is described below

commit 37259aa2f5af87f9b8d0baf4ab1a444dbfc79e38
Author: Andi Huber <ah...@apache.org>
AuthorDate: Wed Sep 25 16:40:04 2019 +0200

    ISIS-2158: DemoApp: preload JRuby stuff for AsciiDoc
    
    - this takes ~4 sec, we don't want to wait this long on first request
---
 .../domainapp/application/DemoAppManifest.java     |  5 ++-
 .../domainapp/utils/LibraryPreloadingService.java  | 41 ++++++++++++++++++++++
 2 files changed, 45 insertions(+), 1 deletion(-)

diff --git a/examples/apps/demo/src/main/java/domainapp/application/DemoAppManifest.java b/examples/apps/demo/src/main/java/domainapp/application/DemoAppManifest.java
index c4078b8..4d59df0 100644
--- a/examples/apps/demo/src/main/java/domainapp/application/DemoAppManifest.java
+++ b/examples/apps/demo/src/main/java/domainapp/application/DemoAppManifest.java
@@ -47,6 +47,7 @@ import org.apache.isis.security.shiro.IsisBootSecurityShiro;
 import org.apache.isis.viewer.wicket.viewer.IsisBootWebWicket;
 
 import domainapp.dom.DemoModule;
+import domainapp.utils.LibraryPreloadingService;
 
 /**
  * Makes the integral parts of the 'demo' web application.
@@ -69,7 +70,9 @@ import domainapp.dom.DemoModule;
     IsisBootSecmanPersistenceJdo.class,
     IsisBootSecmanEncryptionJbcrypt.class,
 
-    IsisBootFixtures.class
+    IsisBootFixtures.class,
+    
+    LibraryPreloadingService.class // just a performance enhancement
 
 })
 @ComponentScan(
diff --git a/examples/apps/demo/src/main/java/domainapp/utils/LibraryPreloadingService.java b/examples/apps/demo/src/main/java/domainapp/utils/LibraryPreloadingService.java
new file mode 100644
index 0000000..859e62d
--- /dev/null
+++ b/examples/apps/demo/src/main/java/domainapp/utils/LibraryPreloadingService.java
@@ -0,0 +1,41 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package domainapp.utils;
+
+import javax.annotation.PostConstruct;
+import javax.inject.Singleton;
+
+import org.apache.isis.commons.internal.concurrent._ConcurrentContext;
+import org.apache.isis.commons.internal.concurrent._ConcurrentTaskList;
+import org.apache.isis.extensions.asciidoc.AsciiDoc;
+
+import lombok.val;
+
+@Singleton
+public class LibraryPreloadingService {
+
+    @PostConstruct
+    public void preloadLibraries() {
+        val tasks = _ConcurrentTaskList.named("LibraryPreloading")
+        .addRunnable("Preload JRuby for AsciiDoc", ()->AsciiDoc.valueOfAdoc("Dummy"));
+        
+        tasks.submit(_ConcurrentContext.forkJoin());
+    }
+    
+}