This repository has been archived by the owner on Feb 9, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
UF-317: Dynamic GWT plugin support (details below) (#464)
Enhance run-time plugin mechanism to support client-side plugin development using the GWT/Errai/UberFire programming model. This has been a long time coming with the lion's share of the work in Errai (IOC/CDI support for JS types) and GWT (JsInterop) respectively. UberFire enhancements: - Add minimal new API surface to mark perspectives, screens, and editors as dynamic - Refactor Activity class hierarchy and related types to allow sharing of these types across different scripts using JsInterop - Mark types as @jstypes were possible to export method names (need stable method names across different compilation units) - Add @JSignore to methods that can't be exported because they use parameter or return types that can't be used from JavaScript e.g. widgets - Provide and use alternative default methods usable from JS where possible - Disable managed beans on classpath that are not needed in plugins based on system property - Monitor the /plugins dir for .jar files, extract them and publish the contained JS files - Load plugins using Errai's ScriptRegistry and ScriptInjectionFilter to ensure all plugin scripts are executed before the actual app bootstraps (required to make sure all plugins and its managed beans can be discovered by the main application) - Enhance uberfire-showcase to demonstrate this new plugin functionality (see README.md in uberfire-showcase/ uberfire-dynamic-plugin for details) - Add test coverage for client-side dynamic activity generation, server-side plugin monitoring and processing
- Loading branch information
Showing
197 changed files
with
4,049 additions
and
598 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
uberfire-api/src/main/java/org/uberfire/mvp/impl/ExternalPathPlaceRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright 2016 Red Hat, Inc. and/or its affiliates. | ||
* | ||
* Licensed 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 org.uberfire.mvp.impl; | ||
|
||
import org.uberfire.backend.vfs.Path; | ||
|
||
import jsinterop.annotations.JsIgnore; | ||
import jsinterop.annotations.JsType; | ||
|
||
/** | ||
* A {@link PathPlaceRequest} originating from an external script. | ||
*/ | ||
@JsType | ||
public class ExternalPathPlaceRequest extends DefaultPlaceRequest { | ||
|
||
private Path path; | ||
|
||
public ExternalPathPlaceRequest(Path path) { | ||
this.path = path; | ||
} | ||
|
||
@Override | ||
public Path getPath() { | ||
return path; | ||
} | ||
|
||
@JsIgnore | ||
public static ExternalPathPlaceRequest create(PathPlaceRequest request) { | ||
return new ExternalPathPlaceRequest(request.getPath().getOriginal()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
97 changes: 97 additions & 0 deletions
97
uberfire-api/src/main/java/org/uberfire/plugin/PluginUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
/* | ||
* Copyright 2016 Red Hat, Inc. and/or its affiliates. | ||
* | ||
* Licensed 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 org.uberfire.plugin; | ||
|
||
import java.util.Arrays; | ||
import java.util.Collection; | ||
import java.util.Collections; | ||
import java.util.HashSet; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
import jsinterop.annotations.JsIgnore; | ||
import jsinterop.annotations.JsType; | ||
|
||
import static org.uberfire.commons.validation.PortablePreconditions.checkNotNull; | ||
|
||
/** | ||
* Utilities for working with external (GWT-compiled) plugins. | ||
*/ | ||
public class PluginUtil { | ||
|
||
private PluginUtil() { | ||
} | ||
|
||
/** | ||
* {@link List} is a {@link JsType} but {@link Collection#iterator()} is | ||
* {@link JsIgnore}d and therefore not exported to JavaScript. | ||
* | ||
* This method takes a list and converts it to a new list so it can be | ||
* iterated over in the current script (e.g. using enhanced for loops), even | ||
* if the instance was provided by an external (GWT-compiled) script. | ||
* | ||
* @param externalList | ||
* A list, possibly provided by an external script. Must not be null. | ||
* @return an immutable list containing the original elements of the | ||
* provided list | ||
*/ | ||
public static <T> List<T> ensureIterable( List<T> externalList ) { | ||
checkNotNull( "externalList", | ||
externalList ); | ||
|
||
// toArray(T[]) is @JsIgnored | ||
@SuppressWarnings("unchecked") | ||
final List<T> tmp = (List<T>) Arrays.asList( externalList.toArray() ); | ||
return Collections.unmodifiableList( tmp ); | ||
} | ||
|
||
/** | ||
* {@link Set} is a {@link JsType} but {@link Collection#iterator()} is | ||
* {@link JsIgnore}d and therefore not exported to JavaScript. | ||
* | ||
* This method takes a set and converts it to a new set so it can be | ||
* iterated over in the current script (e.g. using enhanced for loops), even | ||
* if the instance was provided by an external (GWT-compiled) script. | ||
* | ||
* @param externalSet | ||
* A set, possibly provided by an external script. Must not be null. | ||
* @return an immutable set containing the original elements of the provided | ||
* set | ||
*/ | ||
public static <T> Set<T> ensureIterable( Set<T> externalSet ) { | ||
checkNotNull( "externalSet", | ||
externalSet ); | ||
|
||
// toArray(T[]) is @JsIgnored | ||
@SuppressWarnings("unchecked") | ||
final List<T> tmp = (List<T>) Arrays.asList( externalSet.toArray() ); | ||
return Collections.unmodifiableSet( new HashSet<T>( tmp ) ); | ||
} | ||
|
||
/** | ||
* {@link Integer} is not a {@link JsType} and can't be shared across | ||
* scripts. | ||
* | ||
* This method converts a regular int to an {@link Integer} using -1 as a | ||
* placeholder for null. | ||
* | ||
* @param value | ||
* @return boxed {@link Integer}, null if provided value is -1. | ||
*/ | ||
public static Integer toInteger(int value) { | ||
return (value != -1) ? value : null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.