You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@guacamole.apache.org by mj...@apache.org on 2016/03/20 03:22:12 UTC
[32/50] incubator-guacamole-client git commit: GUAC-1378: Read HTML
patch resources from extensions into service.
GUAC-1378: Read HTML patch resources from extensions into service.
Project: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/commit/ec4f3703
Tree: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/tree/ec4f3703
Diff: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/diff/ec4f3703
Branch: refs/heads/master
Commit: ec4f37032b54c9b55471f18e120ba5120bf4f29b
Parents: 29a0715
Author: Michael Jumper <mi...@guac-dev.org>
Authored: Fri Feb 19 00:20:02 2016 -0800
Committer: Michael Jumper <mi...@guac-dev.org>
Committed: Fri Feb 19 00:20:02 2016 -0800
----------------------------------------------------------------------
.../net/basic/extension/ExtensionModule.java | 16 +++-
.../basic/extension/PatchResourceService.java | 84 ++++++++++++++++++++
2 files changed, 97 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/ec4f3703/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/extension/ExtensionModule.java
----------------------------------------------------------------------
diff --git a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/extension/ExtensionModule.java b/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/extension/ExtensionModule.java
index 6296ea5..deca3c8 100644
--- a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/extension/ExtensionModule.java
+++ b/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/extension/ExtensionModule.java
@@ -101,6 +101,11 @@ public class ExtensionModule extends ServletModule {
* Service for adding and retrieving language resources.
*/
private final LanguageResourceService languageResourceService;
+
+ /**
+ * Service for adding and retrieving HTML patch resources.
+ */
+ private final PatchResourceService patchResourceService;
/**
* Returns the classloader that should be used as the parent classloader
@@ -140,6 +145,7 @@ public class ExtensionModule extends ServletModule {
public ExtensionModule(Environment environment) {
this.environment = environment;
this.languageResourceService = new LanguageResourceService(environment);
+ this.patchResourceService = new PatchResourceService();
}
/**
@@ -307,7 +313,7 @@ public class ExtensionModule extends ServletModule {
* A modifiable collection of static JavaScript resources which may
* receive new JavaScript resources from extensions.
*
- * @param cssResources
+ * @param cssResources
* A modifiable collection of static CSS resources which may receive
* new CSS resources from extensions.
*/
@@ -366,6 +372,9 @@ public class ExtensionModule extends ServletModule {
// Add any translation resources
serveLanguageResources(extension.getTranslationResources());
+ // Add all HTML patch resources
+ patchResourceService.addPatchResources(extension.getHTMLResources().values());
+
// Add all static resources under namespace-derived prefix
String staticResourcePrefix = "/app/ext/" + extension.getNamespace() + "/";
serveStaticResources(staticResourcePrefix, extension.getStaticResources());
@@ -394,12 +403,13 @@ public class ExtensionModule extends ServletModule {
@Override
protected void configureServlets() {
- // Bind language resource service
+ // Bind resource services
bind(LanguageResourceService.class).toInstance(languageResourceService);
+ bind(PatchResourceService.class).toInstance(patchResourceService);
// Load initial language resources from servlet context
languageResourceService.addLanguageResources(getServletContext());
-
+
// Load authentication provider from guacamole.properties for sake of backwards compatibility
Class<AuthenticationProvider> authProviderProperty = getAuthProviderProperty();
if (authProviderProperty != null)
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/ec4f3703/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/extension/PatchResourceService.java
----------------------------------------------------------------------
diff --git a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/extension/PatchResourceService.java b/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/extension/PatchResourceService.java
new file mode 100644
index 0000000..7c88292
--- /dev/null
+++ b/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/extension/PatchResourceService.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2016 Glyptodon LLC
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+package org.glyptodon.guacamole.net.basic.extension;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import org.glyptodon.guacamole.net.basic.resource.Resource;
+
+/**
+ * Service which provides access to all HTML patches as resources, and allows
+ * other patch resources to be added.
+ *
+ * @author Michael Jumper
+ */
+public class PatchResourceService {
+
+ /**
+ * A list of all HTML patch resources currently defined, in the order they
+ * should be applied.
+ */
+ private final List<Resource> resources = new ArrayList<Resource>();
+
+ /**
+ * Adds the given HTML patch resource such that it will apply to the
+ * Guacamole UI. The patch will be applied by the JavaScript side of the
+ * web application in the order that addPatchResource() is invoked.
+ *
+ * @param resource
+ * The HTML patch resource to add. This resource must have the mimetype
+ * "text/html".
+ */
+ public void addPatchResource(Resource resource) {
+ resources.add(resource);
+ }
+
+ /**
+ * Adds the given HTML patch resources such that they will apply to the
+ * Guacamole UI. The patches will be applied by the JavaScript side of the
+ * web application in the order provided.
+ *
+ * @param resources
+ * The HTML patch resources to add. Each resource must have the
+ * mimetype "text/html".
+ */
+ public void addPatchResources(Collection<Resource> resources) {
+ for (Resource resource : resources)
+ addPatchResource(resource);
+ }
+
+ /**
+ * Returns a list of all HTML patches currently associated with this
+ * service, in the order they should be applied. The returned list cannot
+ * be modified.
+ *
+ * @return
+ * A list of all HTML patches currently associated with this service.
+ */
+ public List<Resource> getPatchResources() {
+ return Collections.unmodifiableList(resources);
+ }
+
+}